Make <webview> work with plugins turned off
This commit is contained in:
parent
db071f8d8e
commit
10a8f3c884
9 changed files with 44 additions and 23 deletions
|
@ -75,7 +75,7 @@ void AtomBrowserClient::OverrideWebkitPrefs(
|
|||
prefs->javascript_enabled = true;
|
||||
prefs->web_security_enabled = true;
|
||||
prefs->javascript_can_open_windows_automatically = true;
|
||||
prefs->plugins_enabled = false;
|
||||
prefs->plugins_enabled = true;
|
||||
prefs->dom_paste_enabled = true;
|
||||
prefs->java_enabled = false;
|
||||
prefs->allow_scripts_to_close_windows = true;
|
||||
|
|
|
@ -18,9 +18,6 @@ app.on('ready', function() {
|
|||
resizable: false,
|
||||
'auto-hide-menu-bar': true,
|
||||
'use-content-size': true,
|
||||
'web-preferences': {
|
||||
'plugins': true,
|
||||
},
|
||||
});
|
||||
mainWindow.loadUrl('file://' + __dirname + '/index.html');
|
||||
mainWindow.focus();
|
||||
|
|
|
@ -362,6 +362,10 @@ void NativeWindow::AppendExtraCommandLineSwitches(
|
|||
command_line->AppendSwitch(::switches::kDisableDirectWrite);
|
||||
#endif
|
||||
|
||||
// Check if plugins are enabled.
|
||||
if (web_preferences_.Get("plugins", &b) && b)
|
||||
command_line->AppendSwitch(switches::kEnablePlugins);
|
||||
|
||||
// This set of options are not availabe in WebPreferences, so we have to pass
|
||||
// them via command line and enable them in renderer procss.
|
||||
for (size_t i = 0; i < arraysize(kWebRuntimeFeatures); ++i) {
|
||||
|
@ -392,8 +396,6 @@ void NativeWindow::OverrideWebkitPrefs(const GURL& url,
|
|||
prefs->experimental_webgl_enabled = b;
|
||||
if (web_preferences_.Get("webaudio", &b))
|
||||
prefs->webaudio_enabled = b;
|
||||
if (web_preferences_.Get("plugins", &b))
|
||||
prefs->plugins_enabled = b;
|
||||
if (web_preferences_.Get("extra-plugin-dirs", &list))
|
||||
for (size_t i = 0; i < list.size(); ++i)
|
||||
content::PluginService::GetInstance()->AddExtraPluginDir(list[i]);
|
||||
|
|
|
@ -60,6 +60,9 @@ const char kDarkTheme[] = "dark-theme";
|
|||
// Enable DirectWrite on Windows.
|
||||
const char kDirectWrite[] = "direct-write";
|
||||
|
||||
// Enable plugins.
|
||||
const char kEnablePlugins[] = "enable-plugins";
|
||||
|
||||
// Web runtime features.
|
||||
const char kExperimentalFeatures[] = "experimental-features";
|
||||
const char kExperimentalCanvasFeatures[] = "experimental-canvas-features";
|
||||
|
|
|
@ -36,6 +36,7 @@ extern const char kAutoHideMenuBar[];
|
|||
extern const char kEnableLargerThanScreen[];
|
||||
extern const char kDarkTheme[];
|
||||
extern const char kDirectWrite[];
|
||||
extern const char kEnablePlugins[];
|
||||
|
||||
extern const char kExperimentalFeatures[];
|
||||
extern const char kExperimentalCanvasFeatures[];
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "atom/renderer/atom_render_view_observer.h"
|
||||
#include "chrome/renderer/printing/print_web_view_helper.h"
|
||||
#include "chrome/renderer/tts_dispatcher.h"
|
||||
#include "content/public/common/content_constants.h"
|
||||
#include "content/public/renderer/render_frame.h"
|
||||
#include "content/public/renderer/render_frame_observer.h"
|
||||
#include "content/public/renderer/render_thread.h"
|
||||
|
@ -20,6 +21,7 @@
|
|||
#include "native_mate/converter.h"
|
||||
#include "third_party/WebKit/public/web/WebCustomElement.h"
|
||||
#include "third_party/WebKit/public/web/WebFrame.h"
|
||||
#include "third_party/WebKit/public/web/WebPluginParams.h"
|
||||
#include "third_party/WebKit/public/web/WebKit.h"
|
||||
#include "third_party/WebKit/public/web/WebRuntimeFeatures.h"
|
||||
|
||||
|
@ -112,6 +114,20 @@ blink::WebSpeechSynthesizer* AtomRendererClient::OverrideSpeechSynthesizer(
|
|||
return new TtsDispatcher(client);
|
||||
}
|
||||
|
||||
bool AtomRendererClient::OverrideCreatePlugin(
|
||||
content::RenderFrame* render_frame,
|
||||
blink::WebLocalFrame* frame,
|
||||
const blink::WebPluginParams& params,
|
||||
blink::WebPlugin** plugin) {
|
||||
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
|
||||
if (params.mimeType.utf8() == content::kBrowserPluginMimeType ||
|
||||
command_line->HasSwitch(switches::kEnablePlugins))
|
||||
return false;
|
||||
|
||||
*plugin = nullptr;
|
||||
return true;
|
||||
}
|
||||
|
||||
void AtomRendererClient::DidCreateScriptContext(blink::WebFrame* frame,
|
||||
v8::Handle<v8::Context> context,
|
||||
int extension_group,
|
||||
|
|
|
@ -45,21 +45,25 @@ class AtomRendererClient : public content::ContentRendererClient,
|
|||
virtual void WebKitInitialized() OVERRIDE;
|
||||
|
||||
// content::ContentRendererClient:
|
||||
virtual void RenderThreadStarted() OVERRIDE;
|
||||
virtual void RenderFrameCreated(content::RenderFrame* render_frame) OVERRIDE;
|
||||
virtual void RenderViewCreated(content::RenderView*) OVERRIDE;
|
||||
virtual blink::WebSpeechSynthesizer* OverrideSpeechSynthesizer(
|
||||
blink::WebSpeechSynthesizerClient* client);
|
||||
virtual void DidCreateScriptContext(blink::WebFrame* frame,
|
||||
void RenderThreadStarted() override;
|
||||
void RenderFrameCreated(content::RenderFrame* render_frame) override;
|
||||
void RenderViewCreated(content::RenderView*) override;
|
||||
blink::WebSpeechSynthesizer* OverrideSpeechSynthesizer(
|
||||
blink::WebSpeechSynthesizerClient* client) override;
|
||||
bool OverrideCreatePlugin(content::RenderFrame* render_frame,
|
||||
blink::WebLocalFrame* frame,
|
||||
const blink::WebPluginParams& params,
|
||||
blink::WebPlugin** plugin) override;
|
||||
void DidCreateScriptContext(blink::WebFrame* frame,
|
||||
v8::Handle<v8::Context> context,
|
||||
int extension_group,
|
||||
int world_id) OVERRIDE;
|
||||
virtual bool ShouldFork(blink::WebFrame* frame,
|
||||
int world_id) override;
|
||||
bool ShouldFork(blink::WebFrame* frame,
|
||||
const GURL& url,
|
||||
const std::string& http_method,
|
||||
bool is_initial_navigation,
|
||||
bool is_server_redirect,
|
||||
bool* send_referrer) OVERRIDE;
|
||||
bool* send_referrer) override;
|
||||
|
||||
void EnableWebRuntimeFeatures();
|
||||
|
||||
|
|
|
@ -387,7 +387,6 @@ describe 'asar package', ->
|
|||
w = new BrowserWindow(show: false, width: 400, height: 400)
|
||||
p = path.resolve fixtures, 'asar', 'web.asar', 'index.html'
|
||||
u = url.format protocol: 'asar', slashed: false, pathname: p
|
||||
console.log u
|
||||
w.loadUrl u
|
||||
ipc.on 'dirname', (event, dirname) ->
|
||||
assert.equal dirname, path.dirname(p)
|
||||
|
|
|
@ -141,7 +141,6 @@ app.on('ready', function() {
|
|||
width: 800,
|
||||
height: 600,
|
||||
'web-preferences': {
|
||||
plugins: true, // Required by <webview>.
|
||||
javascript: true // Test whether web-preferences crashes.
|
||||
},
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue