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 class CommonSwitches { | 17 class CommonSwitches { |
18 public: | 18 public: |
19 CommonSwitches() | 19 CommonSwitches() |
20 : easy_off_store_install( | 20 : easy_off_store_install( |
21 NULL, | 21 NULL, |
22 FeatureSwitch::DEFAULT_DISABLED), | 22 FeatureSwitch::DEFAULT_DISABLED), |
23 force_dev_mode_highlighting( | 23 force_dev_mode_highlighting( |
24 switches::kForceDevModeHighlighting, | 24 switches::kForceDevModeHighlighting, |
25 FeatureSwitch::DEFAULT_DISABLED), | 25 FeatureSwitch::DEFAULT_DISABLED), |
26 global_commands( | |
27 switches::kGlobalCommands, | |
28 #if defined(OS_CHROMEOS) | |
29 FeatureSwitch::DEFAULT_DISABLED), | |
30 #else | |
31 FeatureSwitch::DEFAULT_ENABLED), | |
32 #endif | |
33 prompt_for_external_extensions( | 26 prompt_for_external_extensions( |
34 NULL, | 27 NULL, |
35 #if defined(OS_WIN) | 28 #if defined(OS_WIN) |
36 FeatureSwitch::DEFAULT_ENABLED), | 29 FeatureSwitch::DEFAULT_ENABLED), |
37 #else | 30 #else |
38 FeatureSwitch::DEFAULT_DISABLED), | 31 FeatureSwitch::DEFAULT_DISABLED), |
39 #endif | 32 #endif |
40 error_console( | 33 error_console( |
41 switches::kErrorConsole, | 34 switches::kErrorConsole, |
42 FeatureSwitch::DEFAULT_DISABLED), | 35 FeatureSwitch::DEFAULT_DISABLED), |
43 enable_override_bookmarks_ui( | 36 enable_override_bookmarks_ui( |
44 switches::kEnableOverrideBookmarksUI, | 37 switches::kEnableOverrideBookmarksUI, |
45 FeatureSwitch::DEFAULT_DISABLED), | 38 FeatureSwitch::DEFAULT_DISABLED), |
46 extension_action_redesign( | 39 extension_action_redesign( |
47 switches::kExtensionActionRedesign, | 40 switches::kExtensionActionRedesign, |
48 FeatureSwitch::DEFAULT_DISABLED), | 41 FeatureSwitch::DEFAULT_DISABLED), |
49 scripts_require_action(switches::kScriptsRequireAction, | 42 scripts_require_action(switches::kScriptsRequireAction, |
50 FeatureSwitch::DEFAULT_DISABLED), | 43 FeatureSwitch::DEFAULT_DISABLED), |
51 embedded_extension_options( | 44 embedded_extension_options( |
52 switches::kEmbeddedExtensionOptions, | 45 switches::kEmbeddedExtensionOptions, |
53 FeatureSwitch::DEFAULT_DISABLED) {} | 46 FeatureSwitch::DEFAULT_DISABLED) {} |
54 | 47 |
55 // Enables extensions to be easily installed from sites other than the web | 48 // Enables extensions to be easily installed from sites other than the web |
56 // store. | 49 // store. |
57 FeatureSwitch easy_off_store_install; | 50 FeatureSwitch easy_off_store_install; |
58 | 51 |
59 FeatureSwitch force_dev_mode_highlighting; | 52 FeatureSwitch force_dev_mode_highlighting; |
60 FeatureSwitch global_commands; | |
61 | 53 |
62 // Should we prompt the user before allowing external extensions to install? | 54 // Should we prompt the user before allowing external extensions to install? |
63 // Default is yes. | 55 // Default is yes. |
64 FeatureSwitch prompt_for_external_extensions; | 56 FeatureSwitch prompt_for_external_extensions; |
65 | 57 |
66 FeatureSwitch error_console; | 58 FeatureSwitch error_console; |
67 FeatureSwitch enable_override_bookmarks_ui; | 59 FeatureSwitch enable_override_bookmarks_ui; |
68 FeatureSwitch extension_action_redesign; | 60 FeatureSwitch extension_action_redesign; |
69 FeatureSwitch scripts_require_action; | 61 FeatureSwitch scripts_require_action; |
70 FeatureSwitch embedded_extension_options; | 62 FeatureSwitch embedded_extension_options; |
71 }; | 63 }; |
72 | 64 |
73 base::LazyInstance<CommonSwitches> g_common_switches = | 65 base::LazyInstance<CommonSwitches> g_common_switches = |
74 LAZY_INSTANCE_INITIALIZER; | 66 LAZY_INSTANCE_INITIALIZER; |
75 | 67 |
76 } // namespace | 68 } // namespace |
77 | 69 |
78 FeatureSwitch* FeatureSwitch::force_dev_mode_highlighting() { | 70 FeatureSwitch* FeatureSwitch::force_dev_mode_highlighting() { |
79 return &g_common_switches.Get().force_dev_mode_highlighting; | 71 return &g_common_switches.Get().force_dev_mode_highlighting; |
80 } | 72 } |
81 FeatureSwitch* FeatureSwitch::easy_off_store_install() { | 73 FeatureSwitch* FeatureSwitch::easy_off_store_install() { |
82 return &g_common_switches.Get().easy_off_store_install; | 74 return &g_common_switches.Get().easy_off_store_install; |
83 } | 75 } |
84 FeatureSwitch* FeatureSwitch::global_commands() { | |
85 return &g_common_switches.Get().global_commands; | |
86 } | |
87 FeatureSwitch* FeatureSwitch::prompt_for_external_extensions() { | 76 FeatureSwitch* FeatureSwitch::prompt_for_external_extensions() { |
88 return &g_common_switches.Get().prompt_for_external_extensions; | 77 return &g_common_switches.Get().prompt_for_external_extensions; |
89 } | 78 } |
90 FeatureSwitch* FeatureSwitch::error_console() { | 79 FeatureSwitch* FeatureSwitch::error_console() { |
91 return &g_common_switches.Get().error_console; | 80 return &g_common_switches.Get().error_console; |
92 } | 81 } |
93 FeatureSwitch* FeatureSwitch::enable_override_bookmarks_ui() { | 82 FeatureSwitch* FeatureSwitch::enable_override_bookmarks_ui() { |
94 return &g_common_switches.Get().enable_override_bookmarks_ui; | 83 return &g_common_switches.Get().enable_override_bookmarks_ui; |
95 } | 84 } |
96 FeatureSwitch* FeatureSwitch::extension_action_redesign() { | 85 FeatureSwitch* FeatureSwitch::extension_action_redesign() { |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 | 162 |
174 void FeatureSwitch::SetOverrideValue(OverrideValue override_value) { | 163 void FeatureSwitch::SetOverrideValue(OverrideValue override_value) { |
175 override_value_ = override_value; | 164 override_value_ = override_value; |
176 } | 165 } |
177 | 166 |
178 FeatureSwitch::OverrideValue FeatureSwitch::GetOverrideValue() const { | 167 FeatureSwitch::OverrideValue FeatureSwitch::GetOverrideValue() const { |
179 return override_value_; | 168 return override_value_; |
180 } | 169 } |
181 | 170 |
182 } // namespace extensions | 171 } // namespace extensions |
OLD | NEW |