OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "android_webview/browser/command_line_helper.h" |
| 6 |
| 7 #include <vector> |
| 8 |
| 9 #include "base/command_line.h" |
| 10 #include "base/feature_list.h" |
| 11 #include "base/stl_util.h" |
| 12 #include "base/strings/string_util.h" |
| 13 #include "content/public/common/content_switches.h" |
| 14 |
| 15 using std::string; |
| 16 using std::vector; |
| 17 |
| 18 // static |
| 19 void CommandLineHelper::AddEnabledFeature(base::CommandLine& command_line, |
| 20 const string& feature_name) { |
| 21 const string enabled_features_list = |
| 22 command_line.GetSwitchValueASCII(switches::kEnableFeatures); |
| 23 const string disabled_features_list = |
| 24 command_line.GetSwitchValueASCII(switches::kDisableFeatures); |
| 25 |
| 26 if (enabled_features_list.empty() && disabled_features_list.empty()) { |
| 27 command_line.AppendSwitchASCII(switches::kEnableFeatures, feature_name); |
| 28 return; |
| 29 } |
| 30 |
| 31 vector<string> enabled_features = |
| 32 base::FeatureList::SplitFeatureListString(enabled_features_list); |
| 33 vector<string> disabled_features = |
| 34 base::FeatureList::SplitFeatureListString(disabled_features_list); |
| 35 |
| 36 if (!base::ContainsValue(enabled_features, feature_name) && |
| 37 !base::ContainsValue(disabled_features, feature_name)) { |
| 38 enabled_features.push_back(feature_name); |
| 39 command_line.AppendSwitchASCII(switches::kEnableFeatures, |
| 40 base::JoinString(enabled_features, ",")); |
| 41 } |
| 42 } |
OLD | NEW |