Rely on content switches for implementing experimental features

This commit is contained in:
Cheng Zhao 2016-01-07 12:49:00 +08:00
parent 16d23bbda5
commit bd20b3f32a
5 changed files with 7 additions and 45 deletions

View file

@ -10,6 +10,7 @@
#include "atom/common/options_switches.h"
#include "base/command_line.h"
#include "base/strings/string_number_conversions.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/web_preferences.h"
#include "native_mate/dictionary.h"
#include "net/base/filename_util.h"
@ -22,22 +23,6 @@ DEFINE_WEB_CONTENTS_USER_DATA_KEY(atom::WebContentsPreferences);
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(
content::WebContents* web_contents,
const mate::Dictionary& web_preferences) {
@ -79,13 +64,12 @@ void WebContentsPreferences::AppendExtraCommandLineSwitches(
if (web_preferences.GetBoolean("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) {
const auto& feature = kWebRuntimeFeatures[i];
if (web_preferences.GetBoolean(feature.name, &b))
command_line->AppendSwitchASCII(feature.cmd, b ? "true" : "false");
}
// Experimental flags.
if (web_preferences.GetBoolean(options::kExperimentalFeatures, &b) && b)
command_line->AppendSwitch(
::switches::kEnableExperimentalWebPlatformFeatures);
if (web_preferences.GetBoolean(options::kExperimentalCanvasFeatures, &b) && b)
command_line->AppendSwitch(::switches::kEnableExperimentalCanvasFeatures);
// Check if we have node integration specified.
bool node_integration = true;

View file

@ -136,8 +136,6 @@ const char kPreloadScript[] = "preload";
const char kPreloadURL[] = "preload-url";
const char kNodeIntegration[] = "node-integration";
const char kGuestInstanceID[] = "guest-instance-id";
const char kExperimentalFeatures[] = "experimental-features";
const char kExperimentalCanvasFeatures[] = "experimental-canvas-features";
const char kOpenerID[] = "opener-id";
// Widevine options

View file

@ -74,8 +74,6 @@ extern const char kPreloadScript[];
extern const char kPreloadURL[];
extern const char kNodeIntegration[];
extern const char kGuestInstanceID[];
extern const char kExperimentalFeatures[];
extern const char kExperimentalCanvasFeatures[];
extern const char kOpenerID[];
extern const char kWidevineCdmPath[];

View file

@ -41,11 +41,6 @@ namespace atom {
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.
class AtomRenderFrameObserver : public content::RenderFrameObserver {
public:
@ -95,8 +90,6 @@ AtomRendererClient::~AtomRendererClient() {
}
void AtomRendererClient::WebKitInitialized() {
EnableWebRuntimeFeatures();
blink::WebCustomElement::addEmbedderCustomElementName("webview");
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(
std::vector<media::KeySystemInfo>* key_systems) {
AddChromeKeySystems(key_systems);

View file

@ -58,8 +58,6 @@ class AtomRendererClient : public content::ContentRendererClient,
const GURL& original_url) override;
void AddKeySystems(std::vector<media::KeySystemInfo>* key_systems) override;
void EnableWebRuntimeFeatures();
scoped_ptr<NodeBindings> node_bindings_;
scoped_ptr<AtomBindings> atom_bindings_;