Chromium Code Reviews| 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 <algorithm> | |
| 8 #include <vector> | |
| 9 | |
| 10 #include "base/command_line.h" | |
| 11 #include "base/feature_list.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 namespace { | |
| 19 | |
| 20 bool contains(const vector<string>& features, const string& feature_name) { | |
|
Tobias Sargeant
2016/10/05 13:56:15
This is base::ContainsValue in base/stl_util.h
timvolodine
2016/10/06 11:58:42
yes thanks, I thought there should be something in
| |
| 21 return std::find(features.begin(), features.end(), feature_name) != | |
| 22 features.end(); | |
| 23 } | |
| 24 | |
| 25 } // namespace | |
| 26 | |
| 27 // static | |
| 28 void CommandLineHelper::AddEnabledFeature(base::CommandLine& command_line, | |
| 29 const string& feature_name) { | |
| 30 string enabled_features_list = | |
| 31 command_line.GetSwitchValueASCII(switches::kEnableFeatures); | |
| 32 string disabled_features_list = | |
| 33 command_line.GetSwitchValueASCII(switches::kDisableFeatures); | |
| 34 | |
| 35 if (enabled_features_list.empty() && disabled_features_list.empty()) { | |
| 36 command_line.AppendSwitchASCII(switches::kEnableFeatures, feature_name); | |
| 37 return; | |
| 38 } | |
| 39 | |
| 40 vector<string> enabled_features = | |
| 41 base::FeatureList::SplitFeatureListString(enabled_features_list); | |
| 42 vector<string> disabled_features = | |
| 43 base::FeatureList::SplitFeatureListString(disabled_features_list); | |
| 44 | |
| 45 if (!contains(enabled_features, feature_name) && | |
| 46 !contains(disabled_features, feature_name)) { | |
| 47 enabled_features.push_back(feature_name); | |
| 48 command_line.AppendSwitchASCII(switches::kEnableFeatures, | |
| 49 base::JoinString(enabled_features, ",")); | |
| 50 } | |
| 51 } | |
| OLD | NEW |