Rely on content switches for implementing experimental features
This commit is contained in:
parent
16d23bbda5
commit
bd20b3f32a
5 changed files with 7 additions and 45 deletions
|
@ -10,6 +10,7 @@
|
||||||
#include "atom/common/options_switches.h"
|
#include "atom/common/options_switches.h"
|
||||||
#include "base/command_line.h"
|
#include "base/command_line.h"
|
||||||
#include "base/strings/string_number_conversions.h"
|
#include "base/strings/string_number_conversions.h"
|
||||||
|
#include "content/public/common/content_switches.h"
|
||||||
#include "content/public/common/web_preferences.h"
|
#include "content/public/common/web_preferences.h"
|
||||||
#include "native_mate/dictionary.h"
|
#include "native_mate/dictionary.h"
|
||||||
#include "net/base/filename_util.h"
|
#include "net/base/filename_util.h"
|
||||||
|
@ -22,22 +23,6 @@ DEFINE_WEB_CONTENTS_USER_DATA_KEY(atom::WebContentsPreferences);
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
// Array of available web runtime features.
|
|
||||||
struct FeaturePair {
|
|
||||||
const char* name;
|
|
||||||
const char* cmd;
|
|
||||||
};
|
|
||||||
FeaturePair kWebRuntimeFeatures[] = {
|
|
||||||
{ options::kExperimentalFeatures,
|
|
||||||
switches::kExperimentalFeatures },
|
|
||||||
{ options::kExperimentalCanvasFeatures,
|
|
||||||
switches::kExperimentalCanvasFeatures },
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
WebContentsPreferences::WebContentsPreferences(
|
WebContentsPreferences::WebContentsPreferences(
|
||||||
content::WebContents* web_contents,
|
content::WebContents* web_contents,
|
||||||
const mate::Dictionary& web_preferences) {
|
const mate::Dictionary& web_preferences) {
|
||||||
|
@ -79,13 +64,12 @@ void WebContentsPreferences::AppendExtraCommandLineSwitches(
|
||||||
if (web_preferences.GetBoolean("plugins", &b) && b)
|
if (web_preferences.GetBoolean("plugins", &b) && b)
|
||||||
command_line->AppendSwitch(switches::kEnablePlugins);
|
command_line->AppendSwitch(switches::kEnablePlugins);
|
||||||
|
|
||||||
// This set of options are not availabe in WebPreferences, so we have to pass
|
// Experimental flags.
|
||||||
// them via command line and enable them in renderer procss.
|
if (web_preferences.GetBoolean(options::kExperimentalFeatures, &b) && b)
|
||||||
for (size_t i = 0; i < arraysize(kWebRuntimeFeatures); ++i) {
|
command_line->AppendSwitch(
|
||||||
const auto& feature = kWebRuntimeFeatures[i];
|
::switches::kEnableExperimentalWebPlatformFeatures);
|
||||||
if (web_preferences.GetBoolean(feature.name, &b))
|
if (web_preferences.GetBoolean(options::kExperimentalCanvasFeatures, &b) && b)
|
||||||
command_line->AppendSwitchASCII(feature.cmd, b ? "true" : "false");
|
command_line->AppendSwitch(::switches::kEnableExperimentalCanvasFeatures);
|
||||||
}
|
|
||||||
|
|
||||||
// Check if we have node integration specified.
|
// Check if we have node integration specified.
|
||||||
bool node_integration = true;
|
bool node_integration = true;
|
||||||
|
|
|
@ -136,8 +136,6 @@ const char kPreloadScript[] = "preload";
|
||||||
const char kPreloadURL[] = "preload-url";
|
const char kPreloadURL[] = "preload-url";
|
||||||
const char kNodeIntegration[] = "node-integration";
|
const char kNodeIntegration[] = "node-integration";
|
||||||
const char kGuestInstanceID[] = "guest-instance-id";
|
const char kGuestInstanceID[] = "guest-instance-id";
|
||||||
const char kExperimentalFeatures[] = "experimental-features";
|
|
||||||
const char kExperimentalCanvasFeatures[] = "experimental-canvas-features";
|
|
||||||
const char kOpenerID[] = "opener-id";
|
const char kOpenerID[] = "opener-id";
|
||||||
|
|
||||||
// Widevine options
|
// Widevine options
|
||||||
|
|
|
@ -74,8 +74,6 @@ extern const char kPreloadScript[];
|
||||||
extern const char kPreloadURL[];
|
extern const char kPreloadURL[];
|
||||||
extern const char kNodeIntegration[];
|
extern const char kNodeIntegration[];
|
||||||
extern const char kGuestInstanceID[];
|
extern const char kGuestInstanceID[];
|
||||||
extern const char kExperimentalFeatures[];
|
|
||||||
extern const char kExperimentalCanvasFeatures[];
|
|
||||||
extern const char kOpenerID[];
|
extern const char kOpenerID[];
|
||||||
|
|
||||||
extern const char kWidevineCdmPath[];
|
extern const char kWidevineCdmPath[];
|
||||||
|
|
|
@ -41,11 +41,6 @@ namespace atom {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
bool IsSwitchEnabled(base::CommandLine* command_line,
|
|
||||||
const char* switch_string) {
|
|
||||||
return command_line->GetSwitchValueASCII(switch_string) == "true";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Helper class to forward the messages to the client.
|
// Helper class to forward the messages to the client.
|
||||||
class AtomRenderFrameObserver : public content::RenderFrameObserver {
|
class AtomRenderFrameObserver : public content::RenderFrameObserver {
|
||||||
public:
|
public:
|
||||||
|
@ -95,8 +90,6 @@ AtomRendererClient::~AtomRendererClient() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AtomRendererClient::WebKitInitialized() {
|
void AtomRendererClient::WebKitInitialized() {
|
||||||
EnableWebRuntimeFeatures();
|
|
||||||
|
|
||||||
blink::WebCustomElement::addEmbedderCustomElementName("webview");
|
blink::WebCustomElement::addEmbedderCustomElementName("webview");
|
||||||
blink::WebCustomElement::addEmbedderCustomElementName("browserplugin");
|
blink::WebCustomElement::addEmbedderCustomElementName("browserplugin");
|
||||||
|
|
||||||
|
@ -210,15 +203,6 @@ content::BrowserPluginDelegate* AtomRendererClient::CreateBrowserPluginDelegate(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AtomRendererClient::EnableWebRuntimeFeatures() {
|
|
||||||
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
|
|
||||||
|
|
||||||
if (IsSwitchEnabled(command_line, switches::kExperimentalFeatures))
|
|
||||||
blink::WebRuntimeFeatures::enableExperimentalFeatures(true);
|
|
||||||
if (IsSwitchEnabled(command_line, switches::kExperimentalCanvasFeatures))
|
|
||||||
blink::WebRuntimeFeatures::enableExperimentalCanvasFeatures(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AtomRendererClient::AddKeySystems(
|
void AtomRendererClient::AddKeySystems(
|
||||||
std::vector<media::KeySystemInfo>* key_systems) {
|
std::vector<media::KeySystemInfo>* key_systems) {
|
||||||
AddChromeKeySystems(key_systems);
|
AddChromeKeySystems(key_systems);
|
||||||
|
|
|
@ -58,8 +58,6 @@ class AtomRendererClient : public content::ContentRendererClient,
|
||||||
const GURL& original_url) override;
|
const GURL& original_url) override;
|
||||||
void AddKeySystems(std::vector<media::KeySystemInfo>* key_systems) override;
|
void AddKeySystems(std::vector<media::KeySystemInfo>* key_systems) override;
|
||||||
|
|
||||||
void EnableWebRuntimeFeatures();
|
|
||||||
|
|
||||||
scoped_ptr<NodeBindings> node_bindings_;
|
scoped_ptr<NodeBindings> node_bindings_;
|
||||||
scoped_ptr<AtomBindings> atom_bindings_;
|
scoped_ptr<AtomBindings> atom_bindings_;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue