| 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" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 switches::kEasyOffStoreExtensionInstall, | 23 switches::kEasyOffStoreExtensionInstall, |
| 24 FeatureSwitch::DEFAULT_DISABLED), | 24 FeatureSwitch::DEFAULT_DISABLED), |
| 25 extensions_in_action_box( | 25 extensions_in_action_box( |
| 26 switches::kExtensionsInActionBox, | 26 switches::kExtensionsInActionBox, |
| 27 FeatureSwitch::DEFAULT_DISABLED), | 27 FeatureSwitch::DEFAULT_DISABLED), |
| 28 script_badges( | 28 script_badges( |
| 29 switches::kScriptBadges, | 29 switches::kScriptBadges, |
| 30 FeatureSwitch::DEFAULT_DISABLED), | 30 FeatureSwitch::DEFAULT_DISABLED), |
| 31 script_bubble( | 31 script_bubble( |
| 32 switches::kScriptBubble, | 32 switches::kScriptBubble, |
| 33 FeatureSwitch::DEFAULT_DISABLED) { | 33 FeatureSwitch::DEFAULT_DISABLED), |
| 34 prompt_for_external_extensions( |
| 35 switches::kPromptForExternalExtensions, |
| 36 FeatureSwitch::DEFAULT_ENABLED) |
| 37 { |
| 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 prompt_for_external_extensions; |
| 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::prompt_for_external_extensions() { |
| 80 return &g_common_switches.Get().prompt_for_external_extensions; |
| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 | 146 |
| 139 void FeatureSwitch::SetOverrideValue(OverrideValue override_value) { | 147 void FeatureSwitch::SetOverrideValue(OverrideValue override_value) { |
| 140 override_value_ = override_value; | 148 override_value_ = override_value; |
| 141 } | 149 } |
| 142 | 150 |
| 143 FeatureSwitch::OverrideValue FeatureSwitch::GetOverrideValue() const { | 151 FeatureSwitch::OverrideValue FeatureSwitch::GetOverrideValue() const { |
| 144 return override_value_; | 152 return override_value_; |
| 145 } | 153 } |
| 146 | 154 |
| 147 } // namespace extensions | 155 } // namespace extensions |
| OLD | NEW |