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 scripts_require_action(switches::kScriptsRequireAction, | 39 scripts_require_action(switches::kScriptsRequireAction, |
47 FeatureSwitch::DEFAULT_DISABLED) {} | 40 FeatureSwitch::DEFAULT_DISABLED) {} |
48 | 41 |
49 // Enables extensions to be easily installed from sites other than the web | 42 // Enables extensions to be easily installed from sites other than the web |
50 // store. | 43 // store. |
51 FeatureSwitch easy_off_store_install; | 44 FeatureSwitch easy_off_store_install; |
52 | 45 |
53 FeatureSwitch force_dev_mode_highlighting; | 46 FeatureSwitch force_dev_mode_highlighting; |
54 FeatureSwitch global_commands; | |
55 | 47 |
56 // Should we prompt the user before allowing external extensions to install? | 48 // Should we prompt the user before allowing external extensions to install? |
57 // Default is yes. | 49 // Default is yes. |
58 FeatureSwitch prompt_for_external_extensions; | 50 FeatureSwitch prompt_for_external_extensions; |
59 | 51 |
60 FeatureSwitch error_console; | 52 FeatureSwitch error_console; |
61 FeatureSwitch enable_override_bookmarks_ui; | 53 FeatureSwitch enable_override_bookmarks_ui; |
62 FeatureSwitch scripts_require_action; | 54 FeatureSwitch scripts_require_action; |
63 }; | 55 }; |
64 | 56 |
65 base::LazyInstance<CommonSwitches> g_common_switches = | 57 base::LazyInstance<CommonSwitches> g_common_switches = |
66 LAZY_INSTANCE_INITIALIZER; | 58 LAZY_INSTANCE_INITIALIZER; |
67 | 59 |
68 } // namespace | 60 } // namespace |
69 | 61 |
70 FeatureSwitch* FeatureSwitch::force_dev_mode_highlighting() { | 62 FeatureSwitch* FeatureSwitch::force_dev_mode_highlighting() { |
71 return &g_common_switches.Get().force_dev_mode_highlighting; | 63 return &g_common_switches.Get().force_dev_mode_highlighting; |
72 } | 64 } |
73 FeatureSwitch* FeatureSwitch::easy_off_store_install() { | 65 FeatureSwitch* FeatureSwitch::easy_off_store_install() { |
74 return &g_common_switches.Get().easy_off_store_install; | 66 return &g_common_switches.Get().easy_off_store_install; |
75 } | 67 } |
76 FeatureSwitch* FeatureSwitch::global_commands() { | |
77 return &g_common_switches.Get().global_commands; | |
78 } | |
79 FeatureSwitch* FeatureSwitch::prompt_for_external_extensions() { | 68 FeatureSwitch* FeatureSwitch::prompt_for_external_extensions() { |
80 return &g_common_switches.Get().prompt_for_external_extensions; | 69 return &g_common_switches.Get().prompt_for_external_extensions; |
81 } | 70 } |
82 FeatureSwitch* FeatureSwitch::error_console() { | 71 FeatureSwitch* FeatureSwitch::error_console() { |
83 return &g_common_switches.Get().error_console; | 72 return &g_common_switches.Get().error_console; |
84 } | 73 } |
85 FeatureSwitch* FeatureSwitch::enable_override_bookmarks_ui() { | 74 FeatureSwitch* FeatureSwitch::enable_override_bookmarks_ui() { |
86 return &g_common_switches.Get().enable_override_bookmarks_ui; | 75 return &g_common_switches.Get().enable_override_bookmarks_ui; |
87 } | 76 } |
88 | 77 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 | 149 |
161 void FeatureSwitch::SetOverrideValue(OverrideValue override_value) { | 150 void FeatureSwitch::SetOverrideValue(OverrideValue override_value) { |
162 override_value_ = override_value; | 151 override_value_ = override_value; |
163 } | 152 } |
164 | 153 |
165 FeatureSwitch::OverrideValue FeatureSwitch::GetOverrideValue() const { | 154 FeatureSwitch::OverrideValue FeatureSwitch::GetOverrideValue() const { |
166 return override_value_; | 155 return override_value_; |
167 } | 156 } |
168 | 157 |
169 } // namespace extensions | 158 } // namespace extensions |
OLD | NEW |