Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Side by Side Diff: android_webview/browser/command_line_helper.cc

Issue 2396803002: [Android WebView] Add functionality to enable features and enable the spellcheck feature. (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 }
OLDNEW
« no previous file with comments | « android_webview/browser/command_line_helper.h ('k') | android_webview/browser/command_line_helper_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698