summaryrefslogtreecommitdiffstats
path: root/src/core/web_contents_delegate_qt.cpp
diff options
context:
space:
mode:
authorTamas Zakor <ztamas@inf.u-szeged.hu>2020-10-14 14:56:47 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-11-10 11:02:57 +0100
commitbbf7226ace4d9bbcff4d68c063dc598c2d3f2ff0 (patch)
tree922e100467cc80f1dd6d794b07a35c12cf314bee /src/core/web_contents_delegate_qt.cpp
parentf93900ec2e5e4289f562b630821650f7c3f8f906 (diff)
Fix new view request handling
Ignore url loading if the request is not from a data url and the Q(Quick)WebEngineNewViewRequest.openIn() is not called on newViewRequested(). Set the missing Q(Quick)WebEngineNewViewRequest::requestedUrl property. Fixes: QTBUG-87378 Change-Id: Idddc9cf075db68dcf5825b3e746d16419d02cfa0 Reviewed-by: Tamas Zakor <ztamas@inf.u-szeged.hu> Reviewed-by: Peter Varga <pvarga@inf.u-szeged.hu> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/core/web_contents_delegate_qt.cpp')
-rw-r--r--src/core/web_contents_delegate_qt.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/core/web_contents_delegate_qt.cpp b/src/core/web_contents_delegate_qt.cpp
index d5a3934fe..36af1b025 100644
--- a/src/core/web_contents_delegate_qt.cpp
+++ b/src/core/web_contents_delegate_qt.cpp
@@ -128,7 +128,7 @@ content::WebContents *WebContentsDelegateQt::OpenURLFromTab(content::WebContents
content::SiteInstance *target_site_instance = params.source_site_instance.get();
content::Referrer referrer = params.referrer;
if (params.disposition != WindowOpenDisposition::CURRENT_TAB) {
- QSharedPointer<WebContentsAdapter> targetAdapter = createWindow(0, params.disposition, gfx::Rect(), params.user_gesture);
+ QSharedPointer<WebContentsAdapter> targetAdapter = createWindow(nullptr, params.disposition, gfx::Rect(), toQt(params.url), params.user_gesture);
if (targetAdapter) {
if (targetAdapter->profile() != source->GetBrowserContext()) {
target_site_instance = nullptr;
@@ -137,6 +137,8 @@ content::WebContents *WebContentsDelegateQt::OpenURLFromTab(content::WebContents
if (!targetAdapter->isInitialized())
targetAdapter->initialize(target_site_instance);
target = targetAdapter->webContents();
+ } else {
+ return target;
}
}
Q_ASSERT(target);
@@ -235,7 +237,7 @@ QUrl WebContentsDelegateQt::url(content::WebContents* source) const {
void WebContentsDelegateQt::AddNewContents(content::WebContents* source, std::unique_ptr<content::WebContents> new_contents, WindowOpenDisposition disposition, const gfx::Rect& initial_pos, bool user_gesture, bool* was_blocked)
{
Q_UNUSED(source)
- QSharedPointer<WebContentsAdapter> newAdapter = createWindow(std::move(new_contents), disposition, initial_pos, user_gesture);
+ QSharedPointer<WebContentsAdapter> newAdapter = createWindow(std::move(new_contents), disposition, initial_pos, m_initialTargetUrl, user_gesture);
// Chromium can forget to pass user-agent override settings to new windows (see QTBUG-61774 and QTBUG-76249),
// so set it here. Note the actual value doesn't really matter here. Only the second value does, but we try
// to give the correct user-agent anyway.
@@ -675,7 +677,7 @@ void WebContentsDelegateQt::overrideWebPreferences(content::WebContents *webCont
QSharedPointer<WebContentsAdapter>
WebContentsDelegateQt::createWindow(std::unique_ptr<content::WebContents> new_contents,
- WindowOpenDisposition disposition, const gfx::Rect &initial_pos,
+ WindowOpenDisposition disposition, const gfx::Rect &initial_pos, const QUrl &url,
bool user_gesture)
{
QSharedPointer<WebContentsAdapter> newAdapter = QSharedPointer<WebContentsAdapter>::create(std::move(new_contents));
@@ -683,7 +685,7 @@ WebContentsDelegateQt::createWindow(std::unique_ptr<content::WebContents> new_co
return m_viewClient->adoptNewWindow(
std::move(newAdapter),
static_cast<WebContentsAdapterClient::WindowOpenDisposition>(disposition), user_gesture,
- toQt(initial_pos), m_initialTargetUrl);
+ toQt(initial_pos), url);
}
void WebContentsDelegateQt::allowCertificateError(const QSharedPointer<CertificateErrorController> &errorController)