Launcher.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/Forward.h>
  8. #include <AK/HashMap.h>
  9. #include <AK/NonnullRefPtrVector.h>
  10. #include <AK/RefCounted.h>
  11. #include <AK/String.h>
  12. namespace Desktop {
  13. class Launcher {
  14. public:
  15. enum class LauncherType {
  16. Default = 0,
  17. Application,
  18. UserPreferred,
  19. UserDefault
  20. };
  21. struct Details : public RefCounted<Details> {
  22. String name;
  23. String executable;
  24. LauncherType launcher_type { LauncherType::Default };
  25. static NonnullRefPtr<Details> from_details_str(const String&);
  26. };
  27. [[nodiscard]] static bool add_allowed_url(const URL&);
  28. [[nodiscard]] static bool add_allowed_handler_with_any_url(const String& handler);
  29. [[nodiscard]] static bool add_allowed_handler_with_only_specific_urls(const String& handler, const Vector<URL>&);
  30. [[nodiscard]] static bool seal_allowlist();
  31. static bool open(const URL&, const String& handler_name = {});
  32. static bool open(const URL&, const Details& details);
  33. static Vector<String> get_handlers_for_url(const URL&);
  34. static NonnullRefPtrVector<Details> get_handlers_with_details_for_url(const URL&);
  35. };
  36. }