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(NULL, FeatureSwitch::DEFAULT_DISABLED), |
21 NULL, | 21 force_dev_mode_highlighting(switches::kForceDevModeHighlighting, |
22 FeatureSwitch::DEFAULT_DISABLED), | 22 FeatureSwitch::DEFAULT_DISABLED), |
23 force_dev_mode_highlighting( | 23 prompt_for_external_extensions(NULL, |
24 switches::kForceDevModeHighlighting, | |
25 FeatureSwitch::DEFAULT_DISABLED), | |
26 prompt_for_external_extensions( | |
27 NULL, | |
28 #if defined(OS_WIN) | 24 #if defined(OS_WIN) |
29 FeatureSwitch::DEFAULT_ENABLED), | 25 FeatureSwitch::DEFAULT_ENABLED), |
30 #else | 26 #else |
31 FeatureSwitch::DEFAULT_DISABLED), | 27 FeatureSwitch::DEFAULT_DISABLED), |
32 #endif | 28 #endif |
33 error_console( | 29 error_console(switches::kErrorConsole, FeatureSwitch::DEFAULT_DISABLED), |
34 switches::kErrorConsole, | 30 enable_override_bookmarks_ui(switches::kEnableOverrideBookmarksUI, |
35 FeatureSwitch::DEFAULT_DISABLED), | 31 FeatureSwitch::DEFAULT_DISABLED), |
36 enable_override_bookmarks_ui( | 32 extension_action_redesign(switches::kExtensionActionRedesign, |
37 switches::kEnableOverrideBookmarksUI, | 33 FeatureSwitch::DEFAULT_DISABLED), |
38 FeatureSwitch::DEFAULT_DISABLED), | |
39 extension_action_redesign( | |
40 switches::kExtensionActionRedesign, | |
41 FeatureSwitch::DEFAULT_DISABLED), | |
42 scripts_require_action(switches::kScriptsRequireAction, | 34 scripts_require_action(switches::kScriptsRequireAction, |
43 FeatureSwitch::DEFAULT_DISABLED), | 35 FeatureSwitch::DEFAULT_DISABLED), |
44 embedded_extension_options( | 36 embedded_extension_options(switches::kEmbeddedExtensionOptions, |
45 switches::kEmbeddedExtensionOptions, | 37 FeatureSwitch::DEFAULT_DISABLED), |
46 FeatureSwitch::DEFAULT_DISABLED), | |
47 mime_handler_view(switches::kMimeHandlerView, | 38 mime_handler_view(switches::kMimeHandlerView, |
48 FeatureSwitch::DEFAULT_DISABLED) {} | 39 FeatureSwitch::DEFAULT_DISABLED), |
| 40 trace_app_source(switches::kTraceAppSource, |
| 41 FeatureSwitch::DEFAULT_DISABLED) { |
| 42 } |
49 | 43 |
50 // Enables extensions to be easily installed from sites other than the web | 44 // Enables extensions to be easily installed from sites other than the web |
51 // store. | 45 // store. |
52 FeatureSwitch easy_off_store_install; | 46 FeatureSwitch easy_off_store_install; |
53 | 47 |
54 FeatureSwitch force_dev_mode_highlighting; | 48 FeatureSwitch force_dev_mode_highlighting; |
55 | 49 |
56 // Should we prompt the user before allowing external extensions to install? | 50 // Should we prompt the user before allowing external extensions to install? |
57 // Default is yes. | 51 // Default is yes. |
58 FeatureSwitch prompt_for_external_extensions; | 52 FeatureSwitch prompt_for_external_extensions; |
59 | 53 |
60 FeatureSwitch error_console; | 54 FeatureSwitch error_console; |
61 FeatureSwitch enable_override_bookmarks_ui; | 55 FeatureSwitch enable_override_bookmarks_ui; |
62 FeatureSwitch extension_action_redesign; | 56 FeatureSwitch extension_action_redesign; |
63 FeatureSwitch scripts_require_action; | 57 FeatureSwitch scripts_require_action; |
64 FeatureSwitch embedded_extension_options; | 58 FeatureSwitch embedded_extension_options; |
65 FeatureSwitch mime_handler_view; | 59 FeatureSwitch mime_handler_view; |
| 60 FeatureSwitch trace_app_source; |
66 }; | 61 }; |
67 | 62 |
68 base::LazyInstance<CommonSwitches> g_common_switches = | 63 base::LazyInstance<CommonSwitches> g_common_switches = |
69 LAZY_INSTANCE_INITIALIZER; | 64 LAZY_INSTANCE_INITIALIZER; |
70 | 65 |
71 } // namespace | 66 } // namespace |
72 | 67 |
73 FeatureSwitch* FeatureSwitch::force_dev_mode_highlighting() { | 68 FeatureSwitch* FeatureSwitch::force_dev_mode_highlighting() { |
74 return &g_common_switches.Get().force_dev_mode_highlighting; | 69 return &g_common_switches.Get().force_dev_mode_highlighting; |
75 } | 70 } |
(...skipping 14 matching lines...) Expand all Loading... |
90 } | 85 } |
91 FeatureSwitch* FeatureSwitch::scripts_require_action() { | 86 FeatureSwitch* FeatureSwitch::scripts_require_action() { |
92 return &g_common_switches.Get().scripts_require_action; | 87 return &g_common_switches.Get().scripts_require_action; |
93 } | 88 } |
94 FeatureSwitch* FeatureSwitch::embedded_extension_options() { | 89 FeatureSwitch* FeatureSwitch::embedded_extension_options() { |
95 return &g_common_switches.Get().embedded_extension_options; | 90 return &g_common_switches.Get().embedded_extension_options; |
96 } | 91 } |
97 FeatureSwitch* FeatureSwitch::mime_handler_view() { | 92 FeatureSwitch* FeatureSwitch::mime_handler_view() { |
98 return &g_common_switches.Get().mime_handler_view; | 93 return &g_common_switches.Get().mime_handler_view; |
99 } | 94 } |
| 95 FeatureSwitch* FeatureSwitch::trace_app_source() { |
| 96 return &g_common_switches.Get().trace_app_source; |
| 97 } |
100 | 98 |
101 FeatureSwitch::ScopedOverride::ScopedOverride(FeatureSwitch* feature, | 99 FeatureSwitch::ScopedOverride::ScopedOverride(FeatureSwitch* feature, |
102 bool override_value) | 100 bool override_value) |
103 : feature_(feature), | 101 : feature_(feature), |
104 previous_value_(feature->GetOverrideValue()) { | 102 previous_value_(feature->GetOverrideValue()) { |
105 feature_->SetOverrideValue( | 103 feature_->SetOverrideValue( |
106 override_value ? OVERRIDE_ENABLED : OVERRIDE_DISABLED); | 104 override_value ? OVERRIDE_ENABLED : OVERRIDE_DISABLED); |
107 } | 105 } |
108 | 106 |
109 FeatureSwitch::ScopedOverride::~ScopedOverride() { | 107 FeatureSwitch::ScopedOverride::~ScopedOverride() { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 | 166 |
169 void FeatureSwitch::SetOverrideValue(OverrideValue override_value) { | 167 void FeatureSwitch::SetOverrideValue(OverrideValue override_value) { |
170 override_value_ = override_value; | 168 override_value_ = override_value; |
171 } | 169 } |
172 | 170 |
173 FeatureSwitch::OverrideValue FeatureSwitch::GetOverrideValue() const { | 171 FeatureSwitch::OverrideValue FeatureSwitch::GetOverrideValue() const { |
174 return override_value_; | 172 return override_value_; |
175 } | 173 } |
176 | 174 |
177 } // namespace extensions | 175 } // namespace extensions |
OLD | NEW |