mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 13:36:13 +03:00
UI/Qt: Add --allow-popups
option to disable popup blocking by default
This commit is contained in:
parent
3225e6fad2
commit
577a7610fb
Notes:
sideshowbarker
2024-07-17 01:53:23 +09:00
Author: https://github.com/tcl3 Commit: https://github.com/LadybirdBrowser/ladybird/commit/577a7610fb Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/187 Reviewed-by: https://github.com/kalenikaliaksandr
@ -62,9 +62,9 @@ void Application::close_task_manager_window()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BrowserWindow& Application::new_window(Vector<URL::URL> const& initial_urls, WebView::CookieJar& cookie_jar, WebContentOptions const& web_content_options, StringView webdriver_content_ipc_path, Tab* parent_tab, Optional<u64> page_index)
|
BrowserWindow& Application::new_window(Vector<URL::URL> const& initial_urls, WebView::CookieJar& cookie_jar, WebContentOptions const& web_content_options, StringView webdriver_content_ipc_path, bool allow_popups, Tab* parent_tab, Optional<u64> page_index)
|
||||||
{
|
{
|
||||||
auto* window = new BrowserWindow(initial_urls, cookie_jar, web_content_options, webdriver_content_ipc_path, parent_tab, move(page_index));
|
auto* window = new BrowserWindow(initial_urls, cookie_jar, web_content_options, webdriver_content_ipc_path, allow_popups, parent_tab, move(page_index));
|
||||||
set_active_window(*window);
|
set_active_window(*window);
|
||||||
window->show();
|
window->show();
|
||||||
window->activateWindow();
|
window->activateWindow();
|
||||||
|
@ -27,7 +27,7 @@ public:
|
|||||||
Function<void(URL::URL)> on_open_file;
|
Function<void(URL::URL)> on_open_file;
|
||||||
RefPtr<Protocol::RequestClient> request_server_client;
|
RefPtr<Protocol::RequestClient> request_server_client;
|
||||||
|
|
||||||
BrowserWindow& new_window(Vector<URL::URL> const& initial_urls, WebView::CookieJar&, WebContentOptions const&, StringView webdriver_content_ipc_path, Tab* parent_tab = nullptr, Optional<u64> page_index = {});
|
BrowserWindow& new_window(Vector<URL::URL> const& initial_urls, WebView::CookieJar&, WebContentOptions const&, StringView webdriver_content_ipc_path, bool allow_popups, Tab* parent_tab = nullptr, Optional<u64> page_index = {});
|
||||||
|
|
||||||
void show_task_manager_window();
|
void show_task_manager_window();
|
||||||
void close_task_manager_window();
|
void close_task_manager_window();
|
||||||
|
@ -69,11 +69,12 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
BrowserWindow::BrowserWindow(Vector<URL::URL> const& initial_urls, WebView::CookieJar& cookie_jar, WebContentOptions const& web_content_options, StringView webdriver_content_ipc_path, Tab* parent_tab, Optional<u64> page_index)
|
BrowserWindow::BrowserWindow(Vector<URL::URL> const& initial_urls, WebView::CookieJar& cookie_jar, WebContentOptions const& web_content_options, StringView webdriver_content_ipc_path, bool allow_popups, Tab* parent_tab, Optional<u64> page_index)
|
||||||
: m_tabs_container(new TabWidget(this))
|
: m_tabs_container(new TabWidget(this))
|
||||||
, m_cookie_jar(cookie_jar)
|
, m_cookie_jar(cookie_jar)
|
||||||
, m_web_content_options(web_content_options)
|
, m_web_content_options(web_content_options)
|
||||||
, m_webdriver_content_ipc_path(webdriver_content_ipc_path)
|
, m_webdriver_content_ipc_path(webdriver_content_ipc_path)
|
||||||
|
, m_allow_popups(allow_popups)
|
||||||
{
|
{
|
||||||
setWindowIcon(app_icon());
|
setWindowIcon(app_icon());
|
||||||
|
|
||||||
@ -480,7 +481,7 @@ BrowserWindow::BrowserWindow(Vector<URL::URL> const& initial_urls, WebView::Cook
|
|||||||
|
|
||||||
m_block_pop_ups_action = new QAction("Block Pop-ups", this);
|
m_block_pop_ups_action = new QAction("Block Pop-ups", this);
|
||||||
m_block_pop_ups_action->setCheckable(true);
|
m_block_pop_ups_action->setCheckable(true);
|
||||||
m_block_pop_ups_action->setChecked(true);
|
m_block_pop_ups_action->setChecked(!allow_popups);
|
||||||
debug_menu->addAction(m_block_pop_ups_action);
|
debug_menu->addAction(m_block_pop_ups_action);
|
||||||
QObject::connect(m_block_pop_ups_action, &QAction::triggered, this, [this] {
|
QObject::connect(m_block_pop_ups_action, &QAction::triggered, this, [this] {
|
||||||
bool state = m_block_pop_ups_action->isChecked();
|
bool state = m_block_pop_ups_action->isChecked();
|
||||||
@ -522,7 +523,7 @@ BrowserWindow::BrowserWindow(Vector<URL::URL> const& initial_urls, WebView::Cook
|
|||||||
});
|
});
|
||||||
QObject::connect(m_new_window_action, &QAction::triggered, this, [this] {
|
QObject::connect(m_new_window_action, &QAction::triggered, this, [this] {
|
||||||
auto initial_urls = Vector<URL::URL> { ak_url_from_qstring(Settings::the()->new_tab_page()) };
|
auto initial_urls = Vector<URL::URL> { ak_url_from_qstring(Settings::the()->new_tab_page()) };
|
||||||
(void)static_cast<Ladybird::Application*>(QApplication::instance())->new_window(initial_urls, m_cookie_jar, m_web_content_options, m_webdriver_content_ipc_path);
|
(void)static_cast<Ladybird::Application*>(QApplication::instance())->new_window(initial_urls, m_cookie_jar, m_web_content_options, m_webdriver_content_ipc_path, m_allow_popups);
|
||||||
});
|
});
|
||||||
QObject::connect(open_file_action, &QAction::triggered, this, &BrowserWindow::open_file);
|
QObject::connect(open_file_action, &QAction::triggered, this, &BrowserWindow::open_file);
|
||||||
QObject::connect(settings_action, &QAction::triggered, this, [this] {
|
QObject::connect(settings_action, &QAction::triggered, this, [this] {
|
||||||
@ -686,7 +687,7 @@ void BrowserWindow::initialize_tab(Tab* tab)
|
|||||||
|
|
||||||
tab->view().on_new_web_view = [this, tab](auto activate_tab, Web::HTML::WebViewHints hints, Optional<u64> page_index) {
|
tab->view().on_new_web_view = [this, tab](auto activate_tab, Web::HTML::WebViewHints hints, Optional<u64> page_index) {
|
||||||
if (hints.popup) {
|
if (hints.popup) {
|
||||||
auto& window = static_cast<Ladybird::Application*>(QApplication::instance())->new_window({}, m_cookie_jar, m_web_content_options, m_webdriver_content_ipc_path, tab, AK::move(page_index));
|
auto& window = static_cast<Ladybird::Application*>(QApplication::instance())->new_window({}, m_cookie_jar, m_web_content_options, m_webdriver_content_ipc_path, m_allow_popups, tab, AK::move(page_index));
|
||||||
window.set_window_rect(hints.screen_x, hints.screen_y, hints.width, hints.height);
|
window.set_window_rect(hints.screen_x, hints.screen_y, hints.width, hints.height);
|
||||||
return window.current_tab()->view().handle();
|
return window.current_tab()->view().handle();
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ class BrowserWindow : public QMainWindow {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BrowserWindow(Vector<URL::URL> const& initial_urls, WebView::CookieJar&, WebContentOptions const&, StringView webdriver_content_ipc_path, Tab* parent_tab = nullptr, Optional<u64> page_index = {});
|
BrowserWindow(Vector<URL::URL> const& initial_urls, WebView::CookieJar&, WebContentOptions const&, StringView webdriver_content_ipc_path, bool allow_popups, Tab* parent_tab = nullptr, Optional<u64> page_index = {});
|
||||||
|
|
||||||
WebContentView& view() const { return m_current_tab->view(); }
|
WebContentView& view() const { return m_current_tab->view(); }
|
||||||
|
|
||||||
@ -204,6 +204,8 @@ private:
|
|||||||
|
|
||||||
WebContentOptions m_web_content_options;
|
WebContentOptions m_web_content_options;
|
||||||
StringView m_webdriver_content_ipc_path;
|
StringView m_webdriver_content_ipc_path;
|
||||||
|
|
||||||
|
bool m_allow_popups { false };
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -102,6 +102,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||||||
bool enable_idl_tracing = false;
|
bool enable_idl_tracing = false;
|
||||||
bool new_window = false;
|
bool new_window = false;
|
||||||
bool force_new_process = false;
|
bool force_new_process = false;
|
||||||
|
bool allow_popups = false;
|
||||||
|
|
||||||
Core::ArgsParser args_parser;
|
Core::ArgsParser args_parser;
|
||||||
args_parser.set_general_help("The Ladybird web browser :^)");
|
args_parser.set_general_help("The Ladybird web browser :^)");
|
||||||
@ -119,6 +120,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||||||
args_parser.add_option(expose_internals_object, "Expose internals object", "expose-internals-object");
|
args_parser.add_option(expose_internals_object, "Expose internals object", "expose-internals-object");
|
||||||
args_parser.add_option(new_window, "Force opening in a new window", "new-window", 'n');
|
args_parser.add_option(new_window, "Force opening in a new window", "new-window", 'n');
|
||||||
args_parser.add_option(force_new_process, "Force creation of new browser/chrome process", "force-new-process");
|
args_parser.add_option(force_new_process, "Force creation of new browser/chrome process", "force-new-process");
|
||||||
|
args_parser.add_option(allow_popups, "Disable popup blocking by default", "allow-popups");
|
||||||
args_parser.parse(arguments);
|
args_parser.parse(arguments);
|
||||||
|
|
||||||
WebView::ChromeProcess chrome_process;
|
WebView::ChromeProcess chrome_process;
|
||||||
@ -181,10 +183,10 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||||||
};
|
};
|
||||||
|
|
||||||
chrome_process.on_new_window = [&](auto const& urls) {
|
chrome_process.on_new_window = [&](auto const& urls) {
|
||||||
app.new_window(sanitize_urls(urls), *cookie_jar, web_content_options, webdriver_content_ipc_path);
|
app.new_window(sanitize_urls(urls), *cookie_jar, web_content_options, webdriver_content_ipc_path, allow_popups);
|
||||||
};
|
};
|
||||||
|
|
||||||
auto& window = app.new_window(sanitize_urls(raw_urls), *cookie_jar, web_content_options, webdriver_content_ipc_path);
|
auto& window = app.new_window(sanitize_urls(raw_urls), *cookie_jar, web_content_options, webdriver_content_ipc_path, allow_popups);
|
||||||
window.setWindowTitle("Ladybird");
|
window.setWindowTitle("Ladybird");
|
||||||
|
|
||||||
if (Ladybird::Settings::the()->is_maximized()) {
|
if (Ladybird::Settings::the()->is_maximized()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user