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

Unified 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: fix compile 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 side-by-side diff with in-line comments
Download patch
Index: android_webview/browser/command_line_helper.cc
diff --git a/android_webview/browser/command_line_helper.cc b/android_webview/browser/command_line_helper.cc
new file mode 100644
index 0000000000000000000000000000000000000000..6cd85a2859b421c65c0f92ffead8ea399d1d63b4
--- /dev/null
+++ b/android_webview/browser/command_line_helper.cc
@@ -0,0 +1,42 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "android_webview/browser/command_line_helper.h"
+
+#include <vector>
+
+#include "base/command_line.h"
+#include "base/feature_list.h"
+#include "base/stl_util.h"
+#include "base/strings/string_util.h"
+#include "content/public/common/content_switches.h"
+
+using std::string;
+using std::vector;
+
+// static
+void CommandLineHelper::AddEnabledFeature(base::CommandLine& command_line,
+ const string& feature_name) {
+ const string enabled_features_list =
+ command_line.GetSwitchValueASCII(switches::kEnableFeatures);
+ const string disabled_features_list =
+ command_line.GetSwitchValueASCII(switches::kDisableFeatures);
+
+ if (enabled_features_list.empty() && disabled_features_list.empty()) {
+ command_line.AppendSwitchASCII(switches::kEnableFeatures, feature_name);
+ return;
+ }
+
+ vector<string> enabled_features =
+ base::FeatureList::SplitFeatureListString(enabled_features_list);
+ vector<string> disabled_features =
+ base::FeatureList::SplitFeatureListString(disabled_features_list);
+
+ if (!base::ContainsValue(enabled_features, feature_name) &&
+ !base::ContainsValue(disabled_features, feature_name)) {
+ enabled_features.push_back(feature_name);
+ command_line.AppendSwitchASCII(switches::kEnableFeatures,
+ base::JoinString(enabled_features, ","));
+ }
+}
« 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