summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael BrĂ¼ning <michael.bruning@qt.io>2023-09-25 14:37:56 +0200
committerMichael BrĂ¼ning <michael.bruning@qt.io>2023-09-26 11:27:16 +0200
commit33fb26ef7e30f1fe29f2fb77406ab4a65b4f4949 (patch)
tree40e963f594e1dc58877fee8fb76adb2054f30787
parent9289004de25e4745d39eab8ddb2276d98dd51294 (diff)
Fix handling of external URLs in PDFs
The code assumed that the guest view web contents would have a delegate of type WebContentsDelegateQt (as it does in later versions after some refactoring) and, due to the lack of RTTI, called a method that does not exist in GuestViewBase. Fix this for this branch by using the top level web contents' delegate in this case. Fixes: QTBUG-117453 Change-Id: I9d32f145bf83ab68f8ee83a5fefa81c800896536 Reviewed-by: Szabolcs David <davidsz@inf.u-szeged.hu>
-rw-r--r--src/core/content_browser_client_qt.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp
index 0a444a277..e15bd05f3 100644
--- a/src/core/content_browser_client_qt.cpp
+++ b/src/core/content_browser_client_qt.cpp
@@ -763,6 +763,15 @@ static void LaunchURL(const GURL& url,
protocolHandlerRegistry->IsHandledProtocol(url.scheme()))
return;
+#if BUILDFLAG(ENABLE_EXTENSIONS)
+ if (guest_view::GuestViewBase::IsGuest(webContents)) {
+ // Use parent / top level contents delegate for launching URLs from guest views.
+ webContents = guest_view::GuestViewBase::GetTopLevelWebContents(webContents);
+ if (!webContents)
+ return;
+ }
+#endif //BUILDFLAG(ENABLE_EXTENSIONS)
+
WebContentsDelegateQt *contentsDelegate = static_cast<WebContentsDelegateQt*>(webContents->GetDelegate());
contentsDelegate->launchExternalURL(toQt(url), page_transition, is_main_frame, has_user_gesture);
}