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