diff --git a/atom/browser/atom_resource_dispatcher_host_delegate.cc b/atom/browser/atom_resource_dispatcher_host_delegate.cc index abd2fb53f1e2..d54021859703 100644 --- a/atom/browser/atom_resource_dispatcher_host_delegate.cc +++ b/atom/browser/atom_resource_dispatcher_host_delegate.cc @@ -6,6 +6,7 @@ #include "atom/browser/login_handler.h" #include "atom/browser/web_contents_permission_helper.h" +#include "atom/browser/web_contents_preferences.h" #include "atom/common/atom_constants.h" #include "atom/common/platform_util.h" #include "base/strings/stringprintf.h" @@ -124,7 +125,9 @@ bool AtomResourceDispatcherHostDelegate::ShouldInterceptResourceAsStream( std::string* payload) { const content::ResourceRequestInfo* info = content::ResourceRequestInfo::ForRequest(request); - if (mime_type == "application/pdf" && info->IsMainFrame()) { + content::WebContents* web_contents = info->GetWebContentsGetterForRequest().Run(); + if (mime_type == "application/pdf" && info->IsMainFrame() && + WebContentsPreferences::IsPluginsEnabled(web_contents)) { *origin = GURL(kPdfViewerUIOrigin); content::BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, diff --git a/atom/browser/web_contents_preferences.cc b/atom/browser/web_contents_preferences.cc index 2bd0900311a8..7d99dd7ed5fb 100644 --- a/atom/browser/web_contents_preferences.cc +++ b/atom/browser/web_contents_preferences.cc @@ -237,6 +237,21 @@ bool WebContentsPreferences::UsesNativeWindowOpen( return use; } +bool WebContentsPreferences::IsPluginsEnabled(content::WebContents* web_contents) { + WebContentsPreferences* self; + if (!web_contents) + return false; + + self = FromWebContents(web_contents); + if (!self) + return false; + + base::DictionaryValue& web_preferences = self->web_preferences_; + bool plugins = false; + web_preferences.GetBoolean("plugins", &plugins); + return plugins; +} + // static void WebContentsPreferences::OverrideWebkitPrefs( content::WebContents* web_contents, content::WebPreferences* prefs) { diff --git a/atom/browser/web_contents_preferences.h b/atom/browser/web_contents_preferences.h index f046cdfc99ac..aa3dc36287b7 100644 --- a/atom/browser/web_contents_preferences.h +++ b/atom/browser/web_contents_preferences.h @@ -39,6 +39,7 @@ class WebContentsPreferences static bool IsSandboxed(content::WebContents* web_contents); static bool UsesNativeWindowOpen(content::WebContents* web_contents); + static bool IsPluginsEnabled(content::WebContents* web_contents); // Modify the WebPreferences according to |web_contents|'s preferences. static void OverrideWebkitPrefs(