ladybird/Userland/Libraries/LibDesktop/Launcher.h
Shannon Booth e800605ad3 AK+LibURL: Move AK::URL into a new URL library
This URL library ends up being a relatively fundamental base library of
the system, as LibCore depends on LibURL.

This change has two main benefits:
 * Moving AK back more towards being an agnostic library that can
   be used between the kernel and userspace. URL has never really fit
   that description - and is not used in the kernel.
 * URL _should_ depend on LibUnicode, as it needs punnycode support.
   However, it's not really possible to do this inside of AK as it can't
   depend on any external library. This change brings us a little closer
   to being able to do that, but unfortunately we aren't there quite
   yet, as the code generators depend on LibCore.
2024-03-18 14:06:28 -04:00

45 lines
1.3 KiB
C++

/*
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/ByteString.h>
#include <AK/Forward.h>
#include <AK/HashMap.h>
#include <AK/RefCounted.h>
#include <LibURL/Forward.h>
namespace Desktop {
class Launcher {
public:
enum class LauncherType {
Default = 0,
Application,
UserPreferred,
UserDefault
};
struct Details : public RefCounted<Details> {
ByteString name;
ByteString executable;
LauncherType launcher_type { LauncherType::Default };
static NonnullRefPtr<Details> from_details_str(ByteString const&);
};
static void ensure_connection();
static ErrorOr<void> add_allowed_url(URL::URL const&);
static ErrorOr<void> add_allowed_handler_with_any_url(ByteString const& handler);
static ErrorOr<void> add_allowed_handler_with_only_specific_urls(ByteString const& handler, Vector<URL::URL> const&);
static ErrorOr<void> seal_allowlist();
static bool open(const URL::URL&, ByteString const& handler_name = {});
static bool open(const URL::URL&, Details const& details);
static Vector<ByteString> get_handlers_for_url(const URL::URL&);
static Vector<NonnullRefPtr<Details>> get_handlers_with_details_for_url(const URL::URL&);
};
}