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

Unified Diff: android_webview/browser/command_line_helper.cc

Issue 2520053002: [Merge M-55] Disable Web Payments in WebView (Closed)
Patch Set: Created 4 years, 1 month 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
index 6cd85a2859b421c65c0f92ffead8ea399d1d63b4..29afae050050ed8f6fd0f7bd6cb6b2ab0f50a816 100644
--- a/android_webview/browser/command_line_helper.cc
+++ b/android_webview/browser/command_line_helper.cc
@@ -15,28 +15,50 @@
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);
+namespace {
+
+// Adds |feature_name| to the list of features in |feature_list_name|, but only
+// if the |feature_name| is absent from the list of features in both
+// |feature_list_name| and |other_feature_list_name|.
+void AddFeatureToList(base::CommandLine& command_line,
+ const string& feature_name,
+ const char* feature_list_name,
+ const char* other_feature_list_name) {
+ const string features_list =
+ command_line.GetSwitchValueASCII(feature_list_name);
+ const string other_features_list =
+ command_line.GetSwitchValueASCII(other_feature_list_name);
- if (enabled_features_list.empty() && disabled_features_list.empty()) {
- command_line.AppendSwitchASCII(switches::kEnableFeatures, feature_name);
+ if (features_list.empty() && other_features_list.empty()) {
+ command_line.AppendSwitchASCII(feature_list_name, feature_name);
return;
}
- vector<string> enabled_features =
- base::FeatureList::SplitFeatureListString(enabled_features_list);
- vector<string> disabled_features =
- base::FeatureList::SplitFeatureListString(disabled_features_list);
+ vector<string> features =
+ base::FeatureList::SplitFeatureListString(features_list);
+ vector<string> other_features =
+ base::FeatureList::SplitFeatureListString(other_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, ","));
+ if (!base::ContainsValue(features, feature_name) &&
+ !base::ContainsValue(other_features, feature_name)) {
+ features.push_back(feature_name);
+ command_line.AppendSwitchASCII(feature_list_name,
+ base::JoinString(features, ","));
}
}
+
+} // namespace
+
+// static
+void CommandLineHelper::AddEnabledFeature(base::CommandLine& command_line,
+ const string& feature_name) {
+ AddFeatureToList(command_line, feature_name, switches::kEnableFeatures,
+ switches::kDisableFeatures);
+}
+
+// static
+void CommandLineHelper::AddDisabledFeature(base::CommandLine& command_line,
+ const string& feature_name) {
+ AddFeatureToList(command_line, feature_name, switches::kDisableFeatures,
+ switches::kEnableFeatures);
+}
« 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