Launcher.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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/ByteString.h>
  8. #include <AK/Forward.h>
  9. #include <AK/HashMap.h>
  10. #include <AK/RefCounted.h>
  11. #include <LibURL/Forward.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. ByteString name;
  23. ByteString executable;
  24. LauncherType launcher_type { LauncherType::Default };
  25. static NonnullRefPtr<Details> from_details_str(ByteString const&);
  26. };
  27. static void ensure_connection();
  28. static ErrorOr<void> add_allowed_url(URL::URL const&);
  29. static ErrorOr<void> add_allowed_handler_with_any_url(ByteString const& handler);
  30. static ErrorOr<void> add_allowed_handler_with_only_specific_urls(ByteString const& handler, Vector<URL::URL> const&);
  31. static ErrorOr<void> seal_allowlist();
  32. static bool open(const URL::URL&, ByteString const& handler_name = {});
  33. static bool open(const URL::URL&, Details const& details);
  34. static Vector<ByteString> get_handlers_for_url(const URL::URL&);
  35. static Vector<NonnullRefPtr<Details>> get_handlers_with_details_for_url(const URL::URL&);
  36. };
  37. }