Pass web runtime features by command line.
This commit is contained in:
parent
81241b38eb
commit
8de90db429
3 changed files with 50 additions and 0 deletions
|
@ -325,6 +325,21 @@ void NativeWindow::AppendExtraCommandLineSwitches(
|
||||||
if (zoom_factor_ != 1.0)
|
if (zoom_factor_ != 1.0)
|
||||||
command_line->AppendSwitchASCII(switches::kZoomFactor,
|
command_line->AppendSwitchASCII(switches::kZoomFactor,
|
||||||
base::DoubleToString(zoom_factor_));
|
base::DoubleToString(zoom_factor_));
|
||||||
|
|
||||||
|
if (web_preferences_.IsEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
// This set of options are not availabe in WebPreferences, so we have to pass
|
||||||
|
// them via command line and enable them in renderer procss.
|
||||||
|
bool b;
|
||||||
|
std::string web_runtime_features;
|
||||||
|
mate::Dictionary web_preferences(web_preferences_.isolate(),
|
||||||
|
web_preferences_.NewHandle());
|
||||||
|
for (int i = 0; i < switches::kWebRuntimeFeaturesFlagsSize; ++i) {
|
||||||
|
const char* feature_flag = switches::kWebRuntimeFeaturesFlags[i];
|
||||||
|
if (web_preferences.Get(feature_flag, &b))
|
||||||
|
command_line->AppendSwitchASCII(feature_flag, b ? "true" : "false");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindow::OverrideWebkitPrefs(const GURL& url, WebPreferences* prefs) {
|
void NativeWindow::OverrideWebkitPrefs(const GURL& url, WebPreferences* prefs) {
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include "third_party/WebKit/public/web/WebDocument.h"
|
#include "third_party/WebKit/public/web/WebDocument.h"
|
||||||
#include "third_party/WebKit/public/web/WebFrame.h"
|
#include "third_party/WebKit/public/web/WebFrame.h"
|
||||||
#include "third_party/WebKit/public/web/WebKit.h"
|
#include "third_party/WebKit/public/web/WebKit.h"
|
||||||
|
#include "third_party/WebKit/public/web/WebRuntimeFeatures.h"
|
||||||
|
|
||||||
#include "atom/common/node_includes.h"
|
#include "atom/common/node_includes.h"
|
||||||
|
|
||||||
|
@ -34,6 +35,19 @@ const char* kSecurityManualEnableIframe = "manual-enable-iframe";
|
||||||
const char* kSecurityDisable = "disable";
|
const char* kSecurityDisable = "disable";
|
||||||
const char* kSecurityEnableNodeIntegration = "enable-node-integration";
|
const char* kSecurityEnableNodeIntegration = "enable-node-integration";
|
||||||
|
|
||||||
|
bool IsSwitchEnabled(base::CommandLine* command_line,
|
||||||
|
const char* switch_string,
|
||||||
|
bool* enabled) {
|
||||||
|
std::string value = command_line->GetSwitchValueASCII(switch_string);
|
||||||
|
if (value == "true")
|
||||||
|
*enabled = true;
|
||||||
|
else if (value == "false")
|
||||||
|
*enabled = false;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// Helper class to forward the WillReleaseScriptContext message to the client.
|
// Helper class to forward the WillReleaseScriptContext message to the client.
|
||||||
class AtomRenderFrameObserver : public content::RenderFrameObserver {
|
class AtomRenderFrameObserver : public content::RenderFrameObserver {
|
||||||
public:
|
public:
|
||||||
|
@ -86,6 +100,8 @@ AtomRendererClient::~AtomRendererClient() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AtomRendererClient::WebKitInitialized() {
|
void AtomRendererClient::WebKitInitialized() {
|
||||||
|
EnableWebRuntimeFeatures();
|
||||||
|
|
||||||
if (!IsNodeBindingEnabled())
|
if (!IsNodeBindingEnabled())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -220,4 +236,21 @@ bool AtomRendererClient::IsNodeBindingEnabled(blink::WebFrame* frame) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AtomRendererClient::EnableWebRuntimeFeatures() {
|
||||||
|
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
|
||||||
|
bool b;
|
||||||
|
if (IsSwitchEnabled(command_line, switches::kExperimentalFeatures, &b))
|
||||||
|
blink::WebRuntimeFeatures::enableExperimentalFeatures(b);
|
||||||
|
if (IsSwitchEnabled(command_line, switches::kExperimentalCanvasFeatures, &b))
|
||||||
|
blink::WebRuntimeFeatures::enableExperimentalCanvasFeatures(b);
|
||||||
|
if (IsSwitchEnabled(command_line, switches::kSubpixelFontScaling, &b))
|
||||||
|
blink::WebRuntimeFeatures::enableSubpixelFontScaling(b);
|
||||||
|
if (IsSwitchEnabled(command_line, switches::kOverlayScrollbars, &b))
|
||||||
|
blink::WebRuntimeFeatures::enableOverlayScrollbars(b);
|
||||||
|
if (IsSwitchEnabled(command_line, switches::kOverlayFullscreenVideo, &b))
|
||||||
|
blink::WebRuntimeFeatures::enableOverlayFullscreenVideo(b);
|
||||||
|
if (IsSwitchEnabled(command_line, switches::kSharedWorker, &b))
|
||||||
|
blink::WebRuntimeFeatures::enableSharedWorker(b);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|
|
@ -61,6 +61,8 @@ class AtomRendererClient : public content::ContentRendererClient,
|
||||||
bool is_server_redirect,
|
bool is_server_redirect,
|
||||||
bool* send_referrer) OVERRIDE;
|
bool* send_referrer) OVERRIDE;
|
||||||
|
|
||||||
|
void EnableWebRuntimeFeatures();
|
||||||
|
|
||||||
std::vector<node::Environment*> web_page_envs_;
|
std::vector<node::Environment*> web_page_envs_;
|
||||||
|
|
||||||
scoped_ptr<NodeBindings> node_bindings_;
|
scoped_ptr<NodeBindings> node_bindings_;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue