LibWebView+UI: Centralize option to treat file:// URLs as non-opaque
This commit is contained in:
parent
9d2dd7b95b
commit
ef4ff5d490
7 changed files with 15 additions and 31 deletions
|
|
@ -161,6 +161,7 @@ ErrorOr<void> Application::initialize(Main::Arguments const& arguments)
|
|||
bool force_fontconfig = false;
|
||||
bool collect_garbage_on_every_allocation = false;
|
||||
bool disable_scrollbar_painting = false;
|
||||
bool file_scheme_urls_have_tuple_origins = false;
|
||||
|
||||
Core::ArgsParser args_parser;
|
||||
args_parser.set_general_help("The Ladybird web browser :^)");
|
||||
|
|
@ -196,6 +197,7 @@ ErrorOr<void> Application::initialize(Main::Arguments const& arguments)
|
|||
args_parser.add_option(allow_popups, "Disable popup blocking by default", "allow-popups");
|
||||
args_parser.add_option(disable_scripting, "Disable scripting by default", "disable-scripting");
|
||||
args_parser.add_option(disable_sql_database, "Disable SQL database", "disable-sql-database");
|
||||
args_parser.add_option(file_scheme_urls_have_tuple_origins, "Treat file:// URLs as having tuple origins", "tuple-file-origins");
|
||||
args_parser.add_option(debug_process, "Wait for a debugger to attach to the given process name (WebContent, RequestServer, etc.)", "debug-process", 0, "process-name");
|
||||
args_parser.add_option(profile_process, "Enable callgrind profiling of the given process name (WebContent, RequestServer, etc.)", "profile-process", 0, "process-name");
|
||||
#if defined(AK_OS_MACOS)
|
||||
|
|
@ -329,6 +331,7 @@ ErrorOr<void> Application::initialize(Main::Arguments const& arguments)
|
|||
.enable_autoplay = enable_autoplay ? EnableAutoplay::Yes : EnableAutoplay::No,
|
||||
.collect_garbage_on_every_allocation = collect_garbage_on_every_allocation ? CollectGarbageOnEveryAllocation::Yes : CollectGarbageOnEveryAllocation::No,
|
||||
.paint_viewport_scrollbars = disable_scrollbar_painting ? PaintViewportScrollbars::No : PaintViewportScrollbars::Yes,
|
||||
.file_scheme_urls_have_tuple_origins = file_scheme_urls_have_tuple_origins ? FileSchemeUrlsHaveTupleOrigins::Yes : FileSchemeUrlsHaveTupleOrigins::No,
|
||||
.default_time_zone = default_time_zone,
|
||||
};
|
||||
|
||||
|
|
@ -341,6 +344,9 @@ ErrorOr<void> Application::initialize(Main::Arguments const& arguments)
|
|||
m_web_content_options.force_cpu_painting = ForceCPUPainting::Yes;
|
||||
}
|
||||
|
||||
if (m_web_content_options.file_scheme_urls_have_tuple_origins == FileSchemeUrlsHaveTupleOrigins::Yes)
|
||||
URL::set_file_scheme_urls_have_tuple_origins();
|
||||
|
||||
initialize_actions();
|
||||
|
||||
m_event_loop = create_platform_event_loop();
|
||||
|
|
|
|||
|
|
@ -123,9 +123,7 @@ static ErrorOr<NonnullRefPtr<WebView::WebContentClient>> launch_web_content_proc
|
|||
arguments.append("--collect-garbage-on-every-allocation"sv);
|
||||
if (web_content_options.paint_viewport_scrollbars == PaintViewportScrollbars::No)
|
||||
arguments.append("--disable-scrollbar-painting"sv);
|
||||
|
||||
// Propogate this process-wide setting to the child process also.
|
||||
if (URL::file_scheme_urls_have_tuple_origins())
|
||||
if (web_content_options.file_scheme_urls_have_tuple_origins == FileSchemeUrlsHaveTupleOrigins::Yes)
|
||||
arguments.append("--tuple-file-origins"sv);
|
||||
|
||||
if (auto const maybe_echo_server_port = web_content_options.echo_server_port; maybe_echo_server_port.has_value()) {
|
||||
|
|
@ -176,6 +174,8 @@ ErrorOr<NonnullRefPtr<Web::HTML::WebWorkerClient>> launch_web_worker_process(Web
|
|||
arguments.append("--expose-experimental-interfaces"sv);
|
||||
if (web_content_options.enable_http_memory_cache == WebView::EnableMemoryHTTPCache::Yes)
|
||||
arguments.append("--enable-http-memory-cache"sv);
|
||||
if (web_content_options.file_scheme_urls_have_tuple_origins == FileSchemeUrlsHaveTupleOrigins::Yes)
|
||||
arguments.append("--tuple-file-origins"sv);
|
||||
|
||||
arguments.append("--type"sv);
|
||||
switch (type) {
|
||||
|
|
@ -197,10 +197,6 @@ ErrorOr<NonnullRefPtr<Web::HTML::WebWorkerClient>> launch_web_worker_process(Web
|
|||
arguments.append(server.value());
|
||||
}
|
||||
|
||||
// Propogate this process-wide setting to the child process also.
|
||||
if (URL::file_scheme_urls_have_tuple_origins())
|
||||
arguments.append("--tuple-file-origins"sv);
|
||||
|
||||
return launch_server_process<Web::HTML::WebWorkerClient>("WebWorker"sv, move(arguments));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -161,6 +161,11 @@ enum class PaintViewportScrollbars {
|
|||
No,
|
||||
};
|
||||
|
||||
enum class FileSchemeUrlsHaveTupleOrigins {
|
||||
No,
|
||||
Yes,
|
||||
};
|
||||
|
||||
struct WebContentOptions {
|
||||
String command_line;
|
||||
String executable_path;
|
||||
|
|
@ -179,6 +184,7 @@ struct WebContentOptions {
|
|||
CollectGarbageOnEveryAllocation collect_garbage_on_every_allocation { CollectGarbageOnEveryAllocation::No };
|
||||
Optional<u16> echo_server_port {};
|
||||
PaintViewportScrollbars paint_viewport_scrollbars { PaintViewportScrollbars::Yes };
|
||||
FileSchemeUrlsHaveTupleOrigins file_scheme_urls_have_tuple_origins { FileSchemeUrlsHaveTupleOrigins::No };
|
||||
Optional<StringView> default_time_zone {};
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -18,8 +18,6 @@ class Application final : public WebView::Application {
|
|||
private:
|
||||
explicit Application();
|
||||
|
||||
virtual void create_platform_arguments(Core::ArgsParser&) override;
|
||||
virtual void create_platform_options(WebView::BrowserOptions&, WebView::RequestServerOptions&, WebView::WebContentOptions&) override;
|
||||
virtual NonnullOwnPtr<Core::EventLoop> create_platform_event_loop() override;
|
||||
|
||||
virtual Optional<WebView::ViewImplementation&> active_web_view() const override;
|
||||
|
|
@ -43,8 +41,6 @@ private:
|
|||
|
||||
virtual void on_devtools_enabled() const override;
|
||||
virtual void on_devtools_disabled() const override;
|
||||
|
||||
bool m_file_scheme_urls_have_tuple_origins { false };
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,17 +27,6 @@ namespace Ladybird {
|
|||
|
||||
Application::Application() = default;
|
||||
|
||||
void Application::create_platform_arguments(Core::ArgsParser& args_parser)
|
||||
{
|
||||
args_parser.add_option(m_file_scheme_urls_have_tuple_origins, "Treat file:// URLs as having tuple origins", "tuple-file-origins");
|
||||
}
|
||||
|
||||
void Application::create_platform_options(WebView::BrowserOptions&, WebView::RequestServerOptions&, WebView::WebContentOptions&)
|
||||
{
|
||||
if (m_file_scheme_urls_have_tuple_origins)
|
||||
URL::set_file_scheme_urls_have_tuple_origins();
|
||||
}
|
||||
|
||||
NonnullOwnPtr<Core::EventLoop> Application::create_platform_event_loop()
|
||||
{
|
||||
if (!browser_options().headless_mode.has_value()) {
|
||||
|
|
|
|||
|
|
@ -99,16 +99,9 @@ public:
|
|||
Application::Application() = default;
|
||||
Application::~Application() = default;
|
||||
|
||||
void Application::create_platform_arguments(Core::ArgsParser& args_parser)
|
||||
{
|
||||
args_parser.add_option(m_file_scheme_urls_have_tuple_origins, "Treat file:// URLs as having tuple origins", "tuple-file-origins");
|
||||
}
|
||||
|
||||
void Application::create_platform_options(WebView::BrowserOptions&, WebView::RequestServerOptions&, WebView::WebContentOptions& web_content_options)
|
||||
{
|
||||
web_content_options.config_path = Settings::the()->directory();
|
||||
if (m_file_scheme_urls_have_tuple_origins)
|
||||
URL::set_file_scheme_urls_have_tuple_origins();
|
||||
}
|
||||
|
||||
NonnullOwnPtr<Core::EventLoop> Application::create_platform_event_loop()
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ public:
|
|||
private:
|
||||
explicit Application();
|
||||
|
||||
virtual void create_platform_arguments(Core::ArgsParser&) override;
|
||||
virtual void create_platform_options(WebView::BrowserOptions&, WebView::RequestServerOptions&, WebView::WebContentOptions&) override;
|
||||
virtual NonnullOwnPtr<Core::EventLoop> create_platform_event_loop() override;
|
||||
|
||||
|
|
@ -61,7 +60,6 @@ private:
|
|||
|
||||
OwnPtr<QApplication> m_application;
|
||||
BrowserWindow* m_active_window { nullptr };
|
||||
bool m_file_scheme_urls_have_tuple_origins { false };
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue