| 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/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 "chrome/common/chrome_switches.h" | 11 #include "chrome/common/chrome_switches.h" |
| 12 #include "extensions/common/switches.h" |
| 12 | 13 |
| 13 namespace extensions { | 14 namespace extensions { |
| 14 | 15 |
| 15 namespace { | 16 namespace { |
| 16 | 17 |
| 17 class CommonSwitches { | 18 class CommonSwitches { |
| 18 public: | 19 public: |
| 19 CommonSwitches() | 20 CommonSwitches() |
| 20 : easy_off_store_install( | 21 : easy_off_store_install( |
| 21 switches::kEasyOffStoreExtensionInstall, | 22 ::switches::kEasyOffStoreExtensionInstall, |
| 22 FeatureSwitch::DEFAULT_DISABLED), | 23 FeatureSwitch::DEFAULT_DISABLED), |
| 23 script_badges( | 24 script_badges( |
| 24 switches::kScriptBadges, | 25 ::switches::kScriptBadges, |
| 25 FeatureSwitch::DEFAULT_DISABLED), | 26 FeatureSwitch::DEFAULT_DISABLED), |
| 26 script_bubble( | 27 script_bubble( |
| 27 switches::kScriptBubble, | 28 ::switches::kScriptBubble, |
| 28 FeatureSwitch::DEFAULT_DISABLED), | 29 FeatureSwitch::DEFAULT_DISABLED), |
| 29 prompt_for_external_extensions( | 30 prompt_for_external_extensions( |
| 30 switches::kPromptForExternalExtensions, | 31 ::switches::kPromptForExternalExtensions, |
| 31 #if defined(OS_WIN) | 32 #if defined(OS_WIN) |
| 32 FeatureSwitch::DEFAULT_ENABLED) {} | 33 FeatureSwitch::DEFAULT_ENABLED), |
| 33 #else | 34 #else |
| 35 FeatureSwitch::DEFAULT_DISABLED), |
| 36 #endif |
| 37 error_console( |
| 38 switches::kErrorConsole, |
| 34 FeatureSwitch::DEFAULT_DISABLED) {} | 39 FeatureSwitch::DEFAULT_DISABLED) {} |
| 35 #endif | |
| 36 | 40 |
| 37 FeatureSwitch easy_off_store_install; | 41 FeatureSwitch easy_off_store_install; |
| 38 FeatureSwitch script_badges; | 42 FeatureSwitch script_badges; |
| 39 FeatureSwitch script_bubble; | 43 FeatureSwitch script_bubble; |
| 40 FeatureSwitch prompt_for_external_extensions; | 44 FeatureSwitch prompt_for_external_extensions; |
| 45 FeatureSwitch error_console; |
| 41 }; | 46 }; |
| 42 | 47 |
| 43 base::LazyInstance<CommonSwitches> g_common_switches = | 48 base::LazyInstance<CommonSwitches> g_common_switches = |
| 44 LAZY_INSTANCE_INITIALIZER; | 49 LAZY_INSTANCE_INITIALIZER; |
| 45 | 50 |
| 46 } // namespace | 51 } // namespace |
| 47 | 52 |
| 48 FeatureSwitch* FeatureSwitch::easy_off_store_install() { | 53 FeatureSwitch* FeatureSwitch::easy_off_store_install() { |
| 49 return &g_common_switches.Get().easy_off_store_install; | 54 return &g_common_switches.Get().easy_off_store_install; |
| 50 } | 55 } |
| 51 FeatureSwitch* FeatureSwitch::script_badges() { | 56 FeatureSwitch* FeatureSwitch::script_badges() { |
| 52 return &g_common_switches.Get().script_badges; | 57 return &g_common_switches.Get().script_badges; |
| 53 } | 58 } |
| 54 FeatureSwitch* FeatureSwitch::script_bubble() { | 59 FeatureSwitch* FeatureSwitch::script_bubble() { |
| 55 return &g_common_switches.Get().script_bubble; | 60 return &g_common_switches.Get().script_bubble; |
| 56 } | 61 } |
| 57 FeatureSwitch* FeatureSwitch::prompt_for_external_extensions() { | 62 FeatureSwitch* FeatureSwitch::prompt_for_external_extensions() { |
| 58 return &g_common_switches.Get().prompt_for_external_extensions; | 63 return &g_common_switches.Get().prompt_for_external_extensions; |
| 59 } | 64 } |
| 65 FeatureSwitch* FeatureSwitch::error_console() { |
| 66 return &g_common_switches.Get().error_console; |
| 67 } |
| 60 | 68 |
| 61 FeatureSwitch::ScopedOverride::ScopedOverride(FeatureSwitch* feature, | 69 FeatureSwitch::ScopedOverride::ScopedOverride(FeatureSwitch* feature, |
| 62 bool override_value) | 70 bool override_value) |
| 63 : feature_(feature), | 71 : feature_(feature), |
| 64 previous_value_(feature->GetOverrideValue()) { | 72 previous_value_(feature->GetOverrideValue()) { |
| 65 feature_->SetOverrideValue( | 73 feature_->SetOverrideValue( |
| 66 override_value ? OVERRIDE_ENABLED : OVERRIDE_DISABLED); | 74 override_value ? OVERRIDE_ENABLED : OVERRIDE_DISABLED); |
| 67 } | 75 } |
| 68 | 76 |
| 69 FeatureSwitch::ScopedOverride::~ScopedOverride() { | 77 FeatureSwitch::ScopedOverride::~ScopedOverride() { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 | 131 |
| 124 void FeatureSwitch::SetOverrideValue(OverrideValue override_value) { | 132 void FeatureSwitch::SetOverrideValue(OverrideValue override_value) { |
| 125 override_value_ = override_value; | 133 override_value_ = override_value; |
| 126 } | 134 } |
| 127 | 135 |
| 128 FeatureSwitch::OverrideValue FeatureSwitch::GetOverrideValue() const { | 136 FeatureSwitch::OverrideValue FeatureSwitch::GetOverrideValue() const { |
| 129 return override_value_; | 137 return override_value_; |
| 130 } | 138 } |
| 131 | 139 |
| 132 } // namespace extensions | 140 } // namespace extensions |
| OLD | NEW |