Suppress pdf plugin dispatch if plugins are disabled
This commit is contained in:
parent
337f61af98
commit
1b75e45a62
3 changed files with 20 additions and 1 deletions
|
@ -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,
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Reference in a new issue