Route Download bubble file open to OnOpenURLFromTab (fixes #3750)

Some downloaded file types [1] default to opening in a Browser. Open
requests for these file types originating from the Download bubble UI
should route to the source Browser (call OnOpenURLFromTab). If
OnOpenURLFromTab is unhandled proceed with the default Chrome behavior
of opening the URL in a new default Browser.

[1] PDF, html, etc. For the complete list of file types see
ChromeDownloadManagerDelegate::IsOpenInBrowserPreferredForFile.
This commit is contained in:
Marshall Greenblatt
2024-08-08 16:34:44 -04:00
parent 87f49de296
commit a5544b6fb1
6 changed files with 80 additions and 42 deletions

View File

@@ -164,13 +164,14 @@ class BrowserDelegate : public content::WebContentsDelegate {
virtual bool HasViewsHostedOpener() const { return false; }
// Same as OpenURLFromTab but only taking |navigation_handle_callback|
// if the return value is non-nullptr.
virtual content::WebContents* OpenURLFromTabEx(
// if the return value is false. Return false to cancel the navigation
// or true to proceed with default chrome handling.
virtual bool OpenURLFromTabEx(
content::WebContents* source,
const content::OpenURLParams& params,
base::OnceCallback<void(content::NavigationHandle&)>&
navigation_handle_callback) {
return nullptr;
return true;
}
};