2020-04-18 21:56:28 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-04-18 21:56:28 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2022-12-04 18:02:33 +00:00
|
|
|
#include <AK/DeprecatedString.h>
|
2020-04-18 21:56:28 +02:00
|
|
|
#include <AK/Forward.h>
|
2020-07-13 18:55:09 -06:00
|
|
|
#include <AK/HashMap.h>
|
|
|
|
#include <AK/RefCounted.h>
|
2020-04-18 21:56:28 +02:00
|
|
|
|
2020-04-26 20:30:01 +01:00
|
|
|
namespace Desktop {
|
2020-04-18 21:56:28 +02:00
|
|
|
|
2020-04-26 20:30:01 +01:00
|
|
|
class Launcher {
|
2020-04-18 21:56:28 +02:00
|
|
|
public:
|
2020-07-13 18:55:09 -06:00
|
|
|
enum class LauncherType {
|
|
|
|
Default = 0,
|
2020-07-14 09:36:00 -06:00
|
|
|
Application,
|
2020-07-13 18:55:09 -06:00
|
|
|
UserPreferred,
|
|
|
|
UserDefault
|
|
|
|
};
|
|
|
|
|
2020-09-18 09:49:51 +02:00
|
|
|
struct Details : public RefCounted<Details> {
|
2022-12-04 18:02:33 +00:00
|
|
|
DeprecatedString name;
|
|
|
|
DeprecatedString executable;
|
2020-07-13 18:55:09 -06:00
|
|
|
LauncherType launcher_type { LauncherType::Default };
|
|
|
|
|
2022-12-04 18:02:33 +00:00
|
|
|
static NonnullRefPtr<Details> from_details_str(DeprecatedString const&);
|
2020-07-13 18:55:09 -06:00
|
|
|
};
|
|
|
|
|
2021-12-29 17:23:43 +01:00
|
|
|
static void ensure_connection();
|
2021-11-24 00:23:00 +01:00
|
|
|
static ErrorOr<void> add_allowed_url(URL const&);
|
2022-12-04 18:02:33 +00:00
|
|
|
static ErrorOr<void> add_allowed_handler_with_any_url(DeprecatedString const& handler);
|
|
|
|
static ErrorOr<void> add_allowed_handler_with_only_specific_urls(DeprecatedString const& handler, Vector<URL> const&);
|
2021-11-24 00:23:00 +01:00
|
|
|
static ErrorOr<void> seal_allowlist();
|
2022-12-04 18:02:33 +00:00
|
|
|
static bool open(const URL&, DeprecatedString const& handler_name = {});
|
2022-04-01 20:58:27 +03:00
|
|
|
static bool open(const URL&, Details const& details);
|
2022-12-04 18:02:33 +00:00
|
|
|
static Vector<DeprecatedString> get_handlers_for_url(const URL&);
|
2023-03-06 14:17:01 +01:00
|
|
|
static Vector<NonnullRefPtr<Details>> get_handlers_with_details_for_url(const URL&);
|
2020-04-18 21:56:28 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|