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/ByteString.h>
  8. #include <AK/Forward.h>
  9. #include <AK/HashMap.h>
  10. #include <AK/RefCounted.h>
  11. namespace Desktop {
  12. class Launcher {
  13. public:
  14. enum class LauncherType {
  15. Default = 0,
  16. Application,
  17. UserPreferred,
  18. UserDefault
  19. };
  20. struct Details : public RefCounted<Details> {
  21. ByteString name;
  22. ByteString executable;
  23. LauncherType launcher_type { LauncherType::Default };
  24. static NonnullRefPtr<Details> from_details_str(ByteString const&);
  25. };
  26. static void ensure_connection();
  27. static ErrorOr<void> add_allowed_url(URL const&);
  28. static ErrorOr<void> add_allowed_handler_with_any_url(ByteString const& handler);
  29. static ErrorOr<void> add_allowed_handler_with_only_specific_urls(ByteString const& handler, Vector<URL> const&);
  30. static ErrorOr<void> seal_allowlist();
  31. static bool open(const URL&, ByteString const& handler_name = {});
  32. static bool open(const URL&, Details const& details);
  33. static Vector<ByteString> get_handlers_for_url(const URL&);
  34. static Vector<NonnullRefPtr<Details>> get_handlers_with_details_for_url(const URL&);
  35. };
  36. }