Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Unified Diff: chrome/browser/plugins/plugin_observer.cc

Issue 2972123002: Click to Open PDF: Open PDF once View PDF is clicked. (Closed)
Patch Set: Change comment; return if URL is invalid Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/plugins/plugin_observer.cc
diff --git a/chrome/browser/plugins/plugin_observer.cc b/chrome/browser/plugins/plugin_observer.cc
index 6f939ac790ca9b8ad9b3fabee2019b5bf5470162..a7c310f9b6ba914171edae7543a13045639c19bb 100644
--- a/chrome/browser/plugins/plugin_observer.cc
+++ b/chrome/browser/plugins/plugin_observer.cc
@@ -267,6 +267,7 @@ bool PluginObserver::OnMessageReceived(
OnShowFlashPermissionBubble)
IPC_MESSAGE_HANDLER(ChromeViewHostMsg_CouldNotLoadPlugin,
OnCouldNotLoadPlugin)
+ IPC_MESSAGE_HANDLER(ChromeViewHostMsg_OpenPDF, OnOpenPDF)
IPC_MESSAGE_UNHANDLED(return false)
IPC_END_MESSAGE_MAP()
@@ -335,3 +336,16 @@ void PluginObserver::OnCouldNotLoadPlugin(const base::FilePath& plugin_path) {
plugin_name),
true);
}
+
+void PluginObserver::OnOpenPDF(const GURL& url) {
+ if (!url.SchemeIsHTTPOrHTTPS())
Lei Zhang 2017/07/12 22:57:30 What about ftp://, or file:// ? The latter works f
dcheng 2017/07/12 23:04:22 I think we should be using ChildProcessSecurityPol
tommycli 2017/07/12 23:05:15 Awesome thank dcheng, i did not know about that me
amberwon 2017/07/13 20:33:54 Done.
+ return;
+
+ web_contents()->OpenURL(content::OpenURLParams(
+ url,
+ content::Referrer::SanitizeForRequest(
+ url, content::Referrer(web_contents()->GetURL(),
+ blink::kWebReferrerPolicyDefault)),
+ WindowOpenDisposition::NEW_FOREGROUND_TAB,
+ ui::PAGE_TRANSITION_AUTO_BOOKMARK, false));
+}

Powered by Google App Engine
This is Rietveld 408576698