OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "extensions/common/feature_switch.h" | 5 #include "extensions/common/feature_switch.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
11 #include "extensions/common/switches.h" | 11 #include "extensions/common/switches.h" |
12 | 12 |
13 namespace extensions { | 13 namespace extensions { |
14 | 14 |
15 namespace { | 15 namespace { |
16 | 16 |
17 const char kEnableMediaRouterExperiment[] = "EnableMediaRouter"; | |
17 const char kExtensionActionRedesignExperiment[] = "ExtensionActionRedesign"; | 18 const char kExtensionActionRedesignExperiment[] = "ExtensionActionRedesign"; |
18 | 19 |
19 class CommonSwitches { | 20 class CommonSwitches { |
20 public: | 21 public: |
21 CommonSwitches() | 22 CommonSwitches() |
22 : easy_off_store_install(nullptr, FeatureSwitch::DEFAULT_DISABLED), | 23 : easy_off_store_install(nullptr, FeatureSwitch::DEFAULT_DISABLED), |
23 force_dev_mode_highlighting(switches::kForceDevModeHighlighting, | 24 force_dev_mode_highlighting(switches::kForceDevModeHighlighting, |
24 FeatureSwitch::DEFAULT_DISABLED), | 25 FeatureSwitch::DEFAULT_DISABLED), |
25 prompt_for_external_extensions( | 26 prompt_for_external_extensions( |
26 #if defined(CHROMIUM_BUILD) | 27 #if defined(CHROMIUM_BUILD) |
(...skipping 11 matching lines...) Expand all Loading... | |
38 FeatureSwitch::DEFAULT_DISABLED), | 39 FeatureSwitch::DEFAULT_DISABLED), |
39 extension_action_redesign(switches::kExtensionActionRedesign, | 40 extension_action_redesign(switches::kExtensionActionRedesign, |
40 kExtensionActionRedesignExperiment, | 41 kExtensionActionRedesignExperiment, |
41 FeatureSwitch::DEFAULT_DISABLED), | 42 FeatureSwitch::DEFAULT_DISABLED), |
42 extension_action_redesign_override(switches::kExtensionActionRedesign, | 43 extension_action_redesign_override(switches::kExtensionActionRedesign, |
43 FeatureSwitch::DEFAULT_ENABLED), | 44 FeatureSwitch::DEFAULT_ENABLED), |
44 scripts_require_action(switches::kScriptsRequireAction, | 45 scripts_require_action(switches::kScriptsRequireAction, |
45 FeatureSwitch::DEFAULT_DISABLED), | 46 FeatureSwitch::DEFAULT_DISABLED), |
46 embedded_extension_options(switches::kEmbeddedExtensionOptions, | 47 embedded_extension_options(switches::kEmbeddedExtensionOptions, |
47 FeatureSwitch::DEFAULT_DISABLED), | 48 FeatureSwitch::DEFAULT_DISABLED), |
49 #if defined(ENABLE_MEDIA_ROUTER) | |
50 // The switch enable-media-router is defined in | |
msw
2015/10/23 20:18:43
If media_router::MediaRouterEnabled simply does:
imcheng
2015/10/23 21:39:27
The flag's presence will be checked in FeatureSwit
msw
2015/10/23 22:30:49
Acknowledged.
| |
51 // chrome/common/chrome_switches.cc, but we can't depend on chrome here. | |
52 media_router("media-router", | |
53 kEnableMediaRouterExperiment, | |
54 FeatureSwitch::DEFAULT_DISABLED), | |
55 #endif // defined(ENABLE_MEDIA_ROUTER) | |
48 trace_app_source(switches::kTraceAppSource, | 56 trace_app_source(switches::kTraceAppSource, |
49 FeatureSwitch::DEFAULT_ENABLED) { | 57 FeatureSwitch::DEFAULT_ENABLED) { |
50 } | 58 } |
51 | 59 |
52 // Enables extensions to be easily installed from sites other than the web | 60 // Enables extensions to be easily installed from sites other than the web |
53 // store. | 61 // store. |
54 FeatureSwitch easy_off_store_install; | 62 FeatureSwitch easy_off_store_install; |
55 | 63 |
56 FeatureSwitch force_dev_mode_highlighting; | 64 FeatureSwitch force_dev_mode_highlighting; |
57 | 65 |
58 // Should we prompt the user before allowing external extensions to install? | 66 // Should we prompt the user before allowing external extensions to install? |
59 // Default is yes. | 67 // Default is yes. |
60 FeatureSwitch prompt_for_external_extensions; | 68 FeatureSwitch prompt_for_external_extensions; |
61 | 69 |
62 FeatureSwitch error_console; | 70 FeatureSwitch error_console; |
63 FeatureSwitch enable_override_bookmarks_ui; | 71 FeatureSwitch enable_override_bookmarks_ui; |
64 FeatureSwitch extension_action_redesign; | 72 FeatureSwitch extension_action_redesign; |
65 FeatureSwitch extension_action_redesign_override; | 73 FeatureSwitch extension_action_redesign_override; |
66 FeatureSwitch scripts_require_action; | 74 FeatureSwitch scripts_require_action; |
67 FeatureSwitch embedded_extension_options; | 75 FeatureSwitch embedded_extension_options; |
76 #if defined(ENABLE_MEDIA_ROUTER) | |
77 FeatureSwitch media_router; | |
78 #endif | |
68 FeatureSwitch trace_app_source; | 79 FeatureSwitch trace_app_source; |
69 }; | 80 }; |
70 | 81 |
71 base::LazyInstance<CommonSwitches> g_common_switches = | 82 base::LazyInstance<CommonSwitches> g_common_switches = |
72 LAZY_INSTANCE_INITIALIZER; | 83 LAZY_INSTANCE_INITIALIZER; |
73 | 84 |
74 } // namespace | 85 } // namespace |
75 | 86 |
76 FeatureSwitch* FeatureSwitch::force_dev_mode_highlighting() { | 87 FeatureSwitch* FeatureSwitch::force_dev_mode_highlighting() { |
77 return &g_common_switches.Get().force_dev_mode_highlighting; | 88 return &g_common_switches.Get().force_dev_mode_highlighting; |
78 } | 89 } |
79 FeatureSwitch* FeatureSwitch::easy_off_store_install() { | 90 FeatureSwitch* FeatureSwitch::easy_off_store_install() { |
80 return &g_common_switches.Get().easy_off_store_install; | 91 return &g_common_switches.Get().easy_off_store_install; |
81 } | 92 } |
82 FeatureSwitch* FeatureSwitch::prompt_for_external_extensions() { | 93 FeatureSwitch* FeatureSwitch::prompt_for_external_extensions() { |
83 return &g_common_switches.Get().prompt_for_external_extensions; | 94 return &g_common_switches.Get().prompt_for_external_extensions; |
84 } | 95 } |
85 FeatureSwitch* FeatureSwitch::error_console() { | 96 FeatureSwitch* FeatureSwitch::error_console() { |
86 return &g_common_switches.Get().error_console; | 97 return &g_common_switches.Get().error_console; |
87 } | 98 } |
88 FeatureSwitch* FeatureSwitch::enable_override_bookmarks_ui() { | 99 FeatureSwitch* FeatureSwitch::enable_override_bookmarks_ui() { |
89 return &g_common_switches.Get().enable_override_bookmarks_ui; | 100 return &g_common_switches.Get().enable_override_bookmarks_ui; |
90 } | 101 } |
91 FeatureSwitch* FeatureSwitch::extension_action_redesign() { | 102 FeatureSwitch* FeatureSwitch::extension_action_redesign() { |
92 #if defined(ENABLE_MEDIA_ROUTER) | 103 #if defined(ENABLE_MEDIA_ROUTER) |
93 // Force-enable the redesigned extension action toolbar when the Media Router | 104 // Force-enable the redesigned extension action toolbar when the Media Router |
94 // is enabled. Should be removed when the toolbar redesign is used by default. | 105 // is enabled. Should be removed when the toolbar redesign is used by default. |
95 // See crbug.com/514694 | 106 // See crbug.com/514694 |
96 // TODO(kmarshall): Remove this override. | 107 // TODO(kmarshall): Remove this override. |
97 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 108 if (media_router()->IsEnabled()) { |
98 "enable-media-router")) { | |
99 return &g_common_switches.Get().extension_action_redesign_override; | 109 return &g_common_switches.Get().extension_action_redesign_override; |
100 } | 110 } |
101 #endif // defined(ENABLE_MEDIA_ROUTER) | 111 #endif // defined(ENABLE_MEDIA_ROUTER) |
102 return &g_common_switches.Get().extension_action_redesign; | 112 return &g_common_switches.Get().extension_action_redesign; |
103 } | 113 } |
104 FeatureSwitch* FeatureSwitch::scripts_require_action() { | 114 FeatureSwitch* FeatureSwitch::scripts_require_action() { |
105 return &g_common_switches.Get().scripts_require_action; | 115 return &g_common_switches.Get().scripts_require_action; |
106 } | 116 } |
107 FeatureSwitch* FeatureSwitch::embedded_extension_options() { | 117 FeatureSwitch* FeatureSwitch::embedded_extension_options() { |
108 return &g_common_switches.Get().embedded_extension_options; | 118 return &g_common_switches.Get().embedded_extension_options; |
109 } | 119 } |
110 FeatureSwitch* FeatureSwitch::trace_app_source() { | 120 FeatureSwitch* FeatureSwitch::trace_app_source() { |
111 return &g_common_switches.Get().trace_app_source; | 121 return &g_common_switches.Get().trace_app_source; |
112 } | 122 } |
123 #if defined(ENABLE_MEDIA_ROUTER) | |
124 FeatureSwitch* FeatureSwitch::media_router() { | |
125 return &g_common_switches.Get().media_router; | |
126 } | |
127 #endif | |
113 | 128 |
114 FeatureSwitch::ScopedOverride::ScopedOverride(FeatureSwitch* feature, | 129 FeatureSwitch::ScopedOverride::ScopedOverride(FeatureSwitch* feature, |
115 bool override_value) | 130 bool override_value) |
116 : feature_(feature), | 131 : feature_(feature), |
117 previous_value_(feature->GetOverrideValue()) { | 132 previous_value_(feature->GetOverrideValue()) { |
118 feature_->SetOverrideValue( | 133 feature_->SetOverrideValue( |
119 override_value ? OVERRIDE_ENABLED : OVERRIDE_DISABLED); | 134 override_value ? OVERRIDE_ENABLED : OVERRIDE_DISABLED); |
120 } | 135 } |
121 | 136 |
122 FeatureSwitch::ScopedOverride::~ScopedOverride() { | 137 FeatureSwitch::ScopedOverride::~ScopedOverride() { |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
199 | 214 |
200 void FeatureSwitch::SetOverrideValue(OverrideValue override_value) { | 215 void FeatureSwitch::SetOverrideValue(OverrideValue override_value) { |
201 override_value_ = override_value; | 216 override_value_ = override_value; |
202 } | 217 } |
203 | 218 |
204 FeatureSwitch::OverrideValue FeatureSwitch::GetOverrideValue() const { | 219 FeatureSwitch::OverrideValue FeatureSwitch::GetOverrideValue() const { |
205 return override_value_; | 220 return override_value_; |
206 } | 221 } |
207 | 222 |
208 } // namespace extensions | 223 } // namespace extensions |
OLD | NEW |