From bb9e92a5d90628a4c5b5f8a97f837b2a8d343931 Mon Sep 17 00:00:00 2001 From: Milan Burda Date: Tue, 23 Apr 2019 18:14:18 +0200 Subject: [PATCH] refactor: add missing constants for options (#17897) --- atom/browser/web_contents_preferences.cc | 19 ++++++++++--------- atom/common/options_switches.cc | 16 ++++++++++++++++ atom/common/options_switches.h | 5 +++++ 3 files changed, 31 insertions(+), 9 deletions(-) diff --git a/atom/browser/web_contents_preferences.cc b/atom/browser/web_contents_preferences.cc index 637ee1762b1b..b4399263d909 100644 --- a/atom/browser/web_contents_preferences.cc +++ b/atom/browser/web_contents_preferences.cc @@ -128,10 +128,10 @@ WebContentsPreferences::WebContentsPreferences( SetDefaultBoolIfUndefined(options::kNativeWindowOpen, false); SetDefaultBoolIfUndefined(options::kEnableRemoteModule, true); SetDefaultBoolIfUndefined(options::kContextIsolation, false); - SetDefaultBoolIfUndefined("javascript", true); - SetDefaultBoolIfUndefined("images", true); - SetDefaultBoolIfUndefined("textAreasAreResizable", true); - SetDefaultBoolIfUndefined("webgl", true); + SetDefaultBoolIfUndefined(options::kJavaScript, true); + SetDefaultBoolIfUndefined(options::kImages, true); + SetDefaultBoolIfUndefined(options::kTextAreasAreResizable, true); + SetDefaultBoolIfUndefined(options::kWebGL, true); bool webSecurity = true; SetDefaultBoolIfUndefined(options::kWebSecurity, webSecurity); // If webSecurity was explicity set to false, let's inherit that into @@ -405,19 +405,20 @@ void WebContentsPreferences::AppendCommandLineSwitches( void WebContentsPreferences::OverrideWebkitPrefs( content::WebPreferences* prefs) { - prefs->javascript_enabled = IsEnabled("javascript", true /* default_value */); - prefs->images_enabled = IsEnabled("images", true /* default_value */); + prefs->javascript_enabled = + IsEnabled(options::kJavaScript, true /* default_value */); + prefs->images_enabled = IsEnabled(options::kImages, true /* default_value */); prefs->text_areas_are_resizable = - IsEnabled("textAreasAreResizable", true /* default_value */); + IsEnabled(options::kTextAreasAreResizable, true /* default_value */); prefs->navigate_on_drag_drop = - IsEnabled("navigateOnDragDrop", false /* default_value */); + IsEnabled(options::kNavigateOnDragDrop, false /* default_value */); if (!GetAsAutoplayPolicy(&preference_, "autoplayPolicy", &prefs->autoplay_policy)) { prefs->autoplay_policy = content::AutoplayPolicy::kNoUserGestureRequired; } // Check if webgl should be enabled. - bool is_webgl_enabled = IsEnabled("webgl", true /* default_value */); + bool is_webgl_enabled = IsEnabled(options::kWebGL, true /* default_value */); prefs->webgl1_enabled = is_webgl_enabled; prefs->webgl2_enabled = is_webgl_enabled; diff --git a/atom/common/options_switches.cc b/atom/common/options_switches.cc index b22631651d87..d7cbf532ea8d 100644 --- a/atom/common/options_switches.cc +++ b/atom/common/options_switches.cc @@ -160,6 +160,22 @@ const char kNodeIntegrationInSubFrames[] = "nodeIntegrationInSubFrames"; const char kDisableHtmlFullscreenWindowResize[] = "disableHtmlFullscreenWindowResize"; +// Enables JavaScript support. +const char kJavaScript[] = "javascript"; + +// Enables image support. +const char kImages[] = "images"; + +// Make TextArea elements resizable. +const char kTextAreasAreResizable[] = "textAreasAreResizable"; + +// Enables WebGL support. +const char kWebGL[] = "webgl"; + +// Whether dragging and dropping a file or link onto the page causes a +// navigation. +const char kNavigateOnDragDrop[] = "navigateOnDragDrop"; + } // namespace options namespace switches { diff --git a/atom/common/options_switches.h b/atom/common/options_switches.h index 3b999faa8e8b..346fbcfc0cc9 100644 --- a/atom/common/options_switches.h +++ b/atom/common/options_switches.h @@ -77,6 +77,11 @@ extern const char kAllowRunningInsecureContent[]; extern const char kOffscreen[]; extern const char kNodeIntegrationInSubFrames[]; extern const char kDisableHtmlFullscreenWindowResize[]; +extern const char kJavaScript[]; +extern const char kImages[]; +extern const char kTextAreasAreResizable[]; +extern const char kWebGL[]; +extern const char kNavigateOnDragDrop[]; } // namespace options