From 9fe01886396ef8ac9466d8f2f24eb6ddc3c2aaae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCri=20Valdmann?= Date: Tue, 24 Apr 2018 10:44:08 +0200 Subject: Fix invalid site instance when switching browser contexts All pages in a site instance should belong to the same browser context, an invariant which is violated by our WebContentsDelegateQt::OpenURLFromTab. Task-number: QTBUG-67900 Change-Id: I754180bb96de07448ee3058210391f7856f4caeb Reviewed-by: Allan Sandfeld Jensen --- src/core/web_contents_delegate_qt.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/core/web_contents_delegate_qt.cpp') diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp index 40fc0934d..e544760c7 100644 --- a/src/core/web_contents_delegate_qt.cpp +++ b/src/core/web_contents_delegate_qt.cpp @@ -44,6 +44,7 @@ #include "web_contents_delegate_qt.h" #include "browser_context_adapter.h" +#include "browser_context_qt.h" #include "color_chooser_qt.h" #include "color_chooser_controller.h" #include "favicon_manager.h" @@ -116,19 +117,25 @@ WebContentsDelegateQt::~WebContentsDelegateQt() content::WebContents *WebContentsDelegateQt::OpenURLFromTab(content::WebContents *source, const content::OpenURLParams ¶ms) { content::WebContents *target = source; + content::SiteInstance *target_site_instance = params.source_site_instance.get(); + content::Referrer referrer = params.referrer; if (params.disposition != WindowOpenDisposition::CURRENT_TAB) { QSharedPointer targetAdapter = createWindow(0, params.disposition, gfx::Rect(), params.user_gesture); if (targetAdapter) { + if (targetAdapter->browserContext() != source->GetBrowserContext()) { + target_site_instance = nullptr; + referrer = content::Referrer(); + } if (!targetAdapter->isInitialized()) - targetAdapter->initialize(params.source_site_instance.get()); + targetAdapter->initialize(target_site_instance); target = targetAdapter->webContents(); } } Q_ASSERT(target); content::NavigationController::LoadURLParams load_url_params(params.url); - load_url_params.source_site_instance = params.source_site_instance; - load_url_params.referrer = params.referrer; + load_url_params.source_site_instance = target_site_instance; + load_url_params.referrer = referrer; load_url_params.frame_tree_node_id = params.frame_tree_node_id; load_url_params.redirect_chain = params.redirect_chain; load_url_params.transition_type = params.transition; -- cgit v1.2.3 From bab4ababd097fd90b227a5a1bca63343b97af091 Mon Sep 17 00:00:00 2001 From: Peter Varga Date: Wed, 16 May 2018 09:36:24 +0200 Subject: Keep settings synchronized when RVH swaps There can be more than one RenderViewHost assigned to a single WebContents. This is the case when starting a page load results changing processes. When applying settings during the load it updates only the old RVH. This fix applies the settings to the new RVH too after the swap. Task-number: QTBUG-66656 Change-Id: I833415b2a34f58e2a9a18c209a025c82b73aa65a Reviewed-by: Allan Sandfeld Jensen --- src/core/web_contents_delegate_qt.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/core/web_contents_delegate_qt.cpp') diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp index aae7f4a43..7f3ced8aa 100644 --- a/src/core/web_contents_delegate_qt.cpp +++ b/src/core/web_contents_delegate_qt.cpp @@ -527,6 +527,17 @@ void WebContentsDelegateQt::ActivateContents(content::WebContents* contents) contents->Focus(); } +void WebContentsDelegateQt::RenderViewHostChanged(content::RenderViewHost *old_host, content::RenderViewHost *new_host) +{ + Q_ASSERT(new_host); + + // The old RVH can be nullptr if it was shut down. + if (!old_host) + return; + + new_host->UpdateWebkitPreferences(old_host->GetWebkitPreferences()); +} + void WebContentsDelegateQt::RequestToLockMouse(content::WebContents *web_contents, bool user_gesture, bool last_unlocked_by_target) { Q_UNUSED(user_gesture); -- cgit v1.2.3