Make code more tidy.

This commit is contained in:
Cheng Zhao 2014-09-09 13:21:15 +08:00
parent f08c3f9134
commit 44d3e58ddb
3 changed files with 24 additions and 23 deletions

View file

@ -55,6 +55,20 @@ using content::NavigationEntry;
namespace atom {
namespace {
// Array of available web runtime features.
const char* kWebRuntimeFeatures[] = {
switches::kExperimentalFeatures,
switches::kExperimentalCanvasFeatures,
switches::kSubpixelFontScaling,
switches::kOverlayScrollbars,
switches::kOverlayFullscreenVideo,
switches::kSharedWorker,
};
} // namespace
NativeWindow::NativeWindow(content::WebContents* web_contents,
const mate::Dictionary& options)
: content::WebContentsObserver(web_contents),
@ -332,13 +346,12 @@ void NativeWindow::AppendExtraCommandLineSwitches(
// 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");
for (size_t i = 0; i < arraysize(kWebRuntimeFeatures); ++i) {
const char* feature = kWebRuntimeFeatures[i];
if (web_preferences.Get(feature, &b))
command_line->AppendSwitchASCII(feature, b ? "true" : "false");
}
}

View file

@ -57,23 +57,13 @@ const char kEnableLargerThanScreen[] = "enable-larger-than-screen";
// Forces to use dark theme on Linux.
const char kDarkTheme[] = "dark-theme";
// Array of availabe web runtime features.
const char kExperimentalFeatures[] = "experimental-features";
// Web runtime features.
const char kExperimentalFeatures[] = "experimental-features";
const char kExperimentalCanvasFeatures[] = "experimental-canvas-features";
const char kSubpixelFontScaling[] = "subpixel-font-scaling";
const char kOverlayScrollbars[] = "overlay-scrollbars";
const char kOverlayFullscreenVideo[] = "overlay-fullscreen-video";
const char kSharedWorker[] = "shared-worker";
const int kWebRuntimeFeaturesFlagsSize = 6;
const char* kWebRuntimeFeaturesFlags[kWebRuntimeFeaturesFlagsSize] = {
kExperimentalFeatures,
kExperimentalCanvasFeatures,
kSubpixelFontScaling,
kOverlayScrollbars,
kOverlayFullscreenVideo,
kSharedWorker,
};
const char kSubpixelFontScaling[] = "subpixel-font-scaling";
const char kOverlayScrollbars[] = "overlay-scrollbars";
const char kOverlayFullscreenVideo[] = "overlay-fullscreen-video";
const char kSharedWorker[] = "shared-worker";
} // namespace switches

View file

@ -42,8 +42,6 @@ extern const char kSubpixelFontScaling[];
extern const char kOverlayScrollbars[];
extern const char kOverlayFullscreenVideo[];
extern const char kSharedWorker[];
extern const int kWebRuntimeFeaturesFlagsSize;
extern const char* kWebRuntimeFeaturesFlags[];
} // namespace switches