OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/common/extensions/feature_switch.h" | 5 #include "chrome/common/extensions/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/string_util.h" | 9 #include "base/string_util.h" |
10 #include "chrome/common/chrome_switches.h" | 10 #include "chrome/common/chrome_switches.h" |
11 #include "content/public/common/content_switches.h" | |
11 | 12 |
12 namespace extensions { | 13 namespace extensions { |
13 | 14 |
14 namespace { | 15 namespace { |
15 | 16 |
16 class CommonSwitches { | 17 class CommonSwitches { |
17 public: | 18 public: |
18 CommonSwitches() | 19 CommonSwitches() |
19 : action_box( | 20 : action_box( |
20 switches::kActionBox, | 21 switches::kActionBox, |
21 FeatureSwitch::DEFAULT_ENABLED), | 22 FeatureSwitch::DEFAULT_ENABLED), |
22 easy_off_store_install( | 23 easy_off_store_install( |
23 switches::kEasyOffStoreExtensionInstall, | 24 switches::kEasyOffStoreExtensionInstall, |
24 FeatureSwitch::DEFAULT_DISABLED), | 25 FeatureSwitch::DEFAULT_DISABLED), |
25 extensions_in_action_box( | 26 extensions_in_action_box( |
26 switches::kExtensionsInActionBox, | 27 switches::kExtensionsInActionBox, |
27 FeatureSwitch::DEFAULT_DISABLED), | 28 FeatureSwitch::DEFAULT_DISABLED), |
28 script_badges( | 29 script_badges( |
29 switches::kScriptBadges, | 30 switches::kScriptBadges, |
30 FeatureSwitch::DEFAULT_DISABLED), | 31 FeatureSwitch::DEFAULT_DISABLED), |
31 script_bubble( | 32 script_bubble( |
32 switches::kScriptBubble, | 33 switches::kScriptBubble, |
34 FeatureSwitch::DEFAULT_DISABLED), | |
35 tab_capture( | |
36 switches::kEnableTabCapture, | |
33 FeatureSwitch::DEFAULT_DISABLED) { | 37 FeatureSwitch::DEFAULT_DISABLED) { |
34 // Disabling easy off-store installation is not yet implemented for Aura. Not | 38 // Disabling easy off-store installation is not yet implemented for Aura. Not |
35 // sure what the Aura equivalent for this UI is. | 39 // sure what the Aura equivalent for this UI is. |
36 #if defined(USE_AURA) | 40 #if defined(USE_AURA) |
37 easy_off_store_install.SetOverrideValue(FeatureSwitch::OVERRIDE_ENABLED); | 41 easy_off_store_install.SetOverrideValue(FeatureSwitch::OVERRIDE_ENABLED); |
38 #endif | 42 #endif |
39 | 43 |
40 if (!action_box.IsEnabled()){ | 44 if (!action_box.IsEnabled()){ |
41 extensions_in_action_box.SetOverrideValue( | 45 extensions_in_action_box.SetOverrideValue( |
42 FeatureSwitch::OVERRIDE_DISABLED); | 46 FeatureSwitch::OVERRIDE_DISABLED); |
43 } | 47 } |
44 } | 48 } |
45 | 49 |
46 FeatureSwitch action_box; | 50 FeatureSwitch action_box; |
47 FeatureSwitch easy_off_store_install; | 51 FeatureSwitch easy_off_store_install; |
48 FeatureSwitch extensions_in_action_box; | 52 FeatureSwitch extensions_in_action_box; |
49 FeatureSwitch script_badges; | 53 FeatureSwitch script_badges; |
50 FeatureSwitch script_bubble; | 54 FeatureSwitch script_bubble; |
55 FeatureSwitch tab_capture; | |
51 }; | 56 }; |
52 | 57 |
53 base::LazyInstance<CommonSwitches> g_common_switches = | 58 base::LazyInstance<CommonSwitches> g_common_switches = |
54 LAZY_INSTANCE_INITIALIZER; | 59 LAZY_INSTANCE_INITIALIZER; |
55 | 60 |
56 } // namespace | 61 } // namespace |
57 | 62 |
58 | 63 |
59 FeatureSwitch* FeatureSwitch::action_box() { | 64 FeatureSwitch* FeatureSwitch::action_box() { |
60 return &g_common_switches.Get().action_box; | 65 return &g_common_switches.Get().action_box; |
61 } | 66 } |
62 FeatureSwitch* FeatureSwitch::easy_off_store_install() { | 67 FeatureSwitch* FeatureSwitch::easy_off_store_install() { |
63 return &g_common_switches.Get().easy_off_store_install; | 68 return &g_common_switches.Get().easy_off_store_install; |
64 } | 69 } |
65 FeatureSwitch* FeatureSwitch::extensions_in_action_box() { | 70 FeatureSwitch* FeatureSwitch::extensions_in_action_box() { |
66 return &g_common_switches.Get().extensions_in_action_box; | 71 return &g_common_switches.Get().extensions_in_action_box; |
67 } | 72 } |
68 FeatureSwitch* FeatureSwitch::script_badges() { | 73 FeatureSwitch* FeatureSwitch::script_badges() { |
69 return &g_common_switches.Get().script_badges; | 74 return &g_common_switches.Get().script_badges; |
70 } | 75 } |
71 FeatureSwitch* FeatureSwitch::script_bubble() { | 76 FeatureSwitch* FeatureSwitch::script_bubble() { |
72 return &g_common_switches.Get().script_bubble; | 77 return &g_common_switches.Get().script_bubble; |
73 } | 78 } |
79 FeatureSwitch* FeatureSwitch::tab_capture() { | |
80 return &g_common_switches.Get().tab_capture; | |
81 } | |
74 | 82 |
75 | 83 |
76 FeatureSwitch::ScopedOverride::ScopedOverride(FeatureSwitch* feature, | 84 FeatureSwitch::ScopedOverride::ScopedOverride(FeatureSwitch* feature, |
77 bool override_value) | 85 bool override_value) |
78 : feature_(feature), | 86 : feature_(feature), |
79 previous_value_(feature->GetOverrideValue()) { | 87 previous_value_(feature->GetOverrideValue()) { |
80 feature_->SetOverrideValue( | 88 feature_->SetOverrideValue( |
81 override_value ? OVERRIDE_ENABLED : OVERRIDE_DISABLED); | 89 override_value ? OVERRIDE_ENABLED : OVERRIDE_DISABLED); |
82 } | 90 } |
83 | 91 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
118 | 126 |
119 if (switch_value == "0") | 127 if (switch_value == "0") |
120 return false; | 128 return false; |
121 | 129 |
122 if (!default_value_ && command_line_->HasSwitch(GetLegacyEnableFlag())) | 130 if (!default_value_ && command_line_->HasSwitch(GetLegacyEnableFlag())) |
123 return true; | 131 return true; |
124 | 132 |
125 if (default_value_ && command_line_->HasSwitch(GetLegacyDisableFlag())) | 133 if (default_value_ && command_line_->HasSwitch(GetLegacyDisableFlag())) |
126 return false; | 134 return false; |
127 | 135 |
136 if (command_line_->HasSwitch(switch_name_)) | |
Aaron Boodman
2012/10/17 20:28:14
Should not be necessary (GetLegacyEnableFlag() sho
justinlin
2012/10/17 23:41:48
The problem is the key is switches::kEnableTabCapt
Aaron Boodman
2012/10/18 22:51:35
So change kEnableTabCapture to "tab-capture" (prob
justinlin
2012/10/19 00:03:33
Done.
| |
137 return true; | |
138 | |
128 return default_value_; | 139 return default_value_; |
129 } | 140 } |
130 | 141 |
131 std::string FeatureSwitch::GetLegacyEnableFlag() const { | 142 std::string FeatureSwitch::GetLegacyEnableFlag() const { |
132 return std::string("enable-") + switch_name_; | 143 return std::string("enable-") + switch_name_; |
133 } | 144 } |
134 | 145 |
135 std::string FeatureSwitch::GetLegacyDisableFlag() const { | 146 std::string FeatureSwitch::GetLegacyDisableFlag() const { |
136 return std::string("disable-") + switch_name_; | 147 return std::string("disable-") + switch_name_; |
137 } | 148 } |
138 | 149 |
139 void FeatureSwitch::SetOverrideValue(OverrideValue override_value) { | 150 void FeatureSwitch::SetOverrideValue(OverrideValue override_value) { |
140 override_value_ = override_value; | 151 override_value_ = override_value; |
141 } | 152 } |
142 | 153 |
143 FeatureSwitch::OverrideValue FeatureSwitch::GetOverrideValue() const { | 154 FeatureSwitch::OverrideValue FeatureSwitch::GetOverrideValue() const { |
144 return override_value_; | 155 return override_value_; |
145 } | 156 } |
146 | 157 |
147 } // namespace extensions | 158 } // namespace extensions |
OLD | NEW |