From 44d3e58ddb17f7f34f2fff454a71cdbd8fc38cc8 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 9 Sep 2014 13:21:15 +0800 Subject: [PATCH] Make code more tidy. --- atom/browser/native_window.cc | 23 ++++++++++++++++++----- atom/common/options_switches.cc | 22 ++++++---------------- atom/common/options_switches.h | 2 -- 3 files changed, 24 insertions(+), 23 deletions(-) diff --git a/atom/browser/native_window.cc b/atom/browser/native_window.cc index 7b8e2ab29b..6cc0bc8fe0 100644 --- a/atom/browser/native_window.cc +++ b/atom/browser/native_window.cc @@ -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"); } } diff --git a/atom/common/options_switches.cc b/atom/common/options_switches.cc index 7c23c86416..806191750c 100644 --- a/atom/common/options_switches.cc +++ b/atom/common/options_switches.cc @@ -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 diff --git a/atom/common/options_switches.h b/atom/common/options_switches.h index 1e504ef161..8bdc3bcdda 100644 --- a/atom/common/options_switches.h +++ b/atom/common/options_switches.h @@ -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