| 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" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 feature_->SetOverrideValue( | 103 feature_->SetOverrideValue( |
| 104 override_value ? OVERRIDE_ENABLED : OVERRIDE_DISABLED); | 104 override_value ? OVERRIDE_ENABLED : OVERRIDE_DISABLED); |
| 105 } | 105 } |
| 106 | 106 |
| 107 FeatureSwitch::ScopedOverride::~ScopedOverride() { | 107 FeatureSwitch::ScopedOverride::~ScopedOverride() { |
| 108 feature_->SetOverrideValue(previous_value_); | 108 feature_->SetOverrideValue(previous_value_); |
| 109 } | 109 } |
| 110 | 110 |
| 111 FeatureSwitch::FeatureSwitch(const char* switch_name, | 111 FeatureSwitch::FeatureSwitch(const char* switch_name, |
| 112 DefaultValue default_value) { | 112 DefaultValue default_value) { |
| 113 Init(CommandLine::ForCurrentProcess(), switch_name, default_value); | 113 Init(base::CommandLine::ForCurrentProcess(), switch_name, default_value); |
| 114 } | 114 } |
| 115 | 115 |
| 116 FeatureSwitch::FeatureSwitch(const CommandLine* command_line, | 116 FeatureSwitch::FeatureSwitch(const base::CommandLine* command_line, |
| 117 const char* switch_name, | 117 const char* switch_name, |
| 118 DefaultValue default_value) { | 118 DefaultValue default_value) { |
| 119 Init(command_line, switch_name, default_value); | 119 Init(command_line, switch_name, default_value); |
| 120 } | 120 } |
| 121 | 121 |
| 122 void FeatureSwitch::Init(const CommandLine* command_line, | 122 void FeatureSwitch::Init(const base::CommandLine* command_line, |
| 123 const char* switch_name, | 123 const char* switch_name, |
| 124 DefaultValue default_value) { | 124 DefaultValue default_value) { |
| 125 command_line_ = command_line; | 125 command_line_ = command_line; |
| 126 switch_name_ = switch_name; | 126 switch_name_ = switch_name; |
| 127 default_value_ = default_value == DEFAULT_ENABLED; | 127 default_value_ = default_value == DEFAULT_ENABLED; |
| 128 override_value_ = OVERRIDE_NONE; | 128 override_value_ = OVERRIDE_NONE; |
| 129 } | 129 } |
| 130 | 130 |
| 131 bool FeatureSwitch::IsEnabled() const { | 131 bool FeatureSwitch::IsEnabled() const { |
| 132 if (override_value_ != OVERRIDE_NONE) | 132 if (override_value_ != OVERRIDE_NONE) |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 | 166 |
| 167 void FeatureSwitch::SetOverrideValue(OverrideValue override_value) { | 167 void FeatureSwitch::SetOverrideValue(OverrideValue override_value) { |
| 168 override_value_ = override_value; | 168 override_value_ = override_value; |
| 169 } | 169 } |
| 170 | 170 |
| 171 FeatureSwitch::OverrideValue FeatureSwitch::GetOverrideValue() const { | 171 FeatureSwitch::OverrideValue FeatureSwitch::GetOverrideValue() const { |
| 172 return override_value_; | 172 return override_value_; |
| 173 } | 173 } |
| 174 | 174 |
| 175 } // namespace extensions | 175 } // namespace extensions |
| OLD | NEW |