summaryrefslogtreecommitdiffstats
path: root/components/enhanced_bookmarks/enhanced_bookmark_features.cc
diff options
context:
space:
mode:
authorsdefresne <sdefresne@chromium.org>2015-07-27 12:18:00 -0700
committerCommit bot <commit-bot@chromium.org>2015-07-27 19:18:57 +0000
commit0f2ef35a2de53103f42a7ab62ccc07aa34481e41 (patch)
tree7e6b89bd5a67371f5ba652948ce7886782970412 /components/enhanced_bookmarks/enhanced_bookmark_features.cc
parentf7701e71c321e821163217db2336241d240c563b (diff)
downloadchromium_src-0f2ef35a2de53103f42a7ab62ccc07aa34481e41.zip
chromium_src-0f2ef35a2de53103f42a7ab62ccc07aa34481e41.tar.gz
chromium_src-0f2ef35a2de53103f42a7ab62ccc07aa34481e41.tar.bz2
Componentize enhanced_bookmark_features.{h,cc}.
Enhanced bookmarks and the DOM distiller are (or will be) used on iOS and android. Move the function checking whether the features are enabled into the respective component to allow sharing the code. Move IsEnhancedBookmarksEnabled() function to the enhanced_bookmarks component with supporting switches. Move IsEnableDomDistillerSet() and IsEnableSyncArticlesSet() functions to the dom_distiller component with supporting switches. BUG=359565 Review URL: https://codereview.chromium.org/1253953002 Cr-Commit-Position: refs/heads/master@{#340526}
Diffstat (limited to 'components/enhanced_bookmarks/enhanced_bookmark_features.cc')
-rw-r--r--components/enhanced_bookmarks/enhanced_bookmark_features.cc40
1 files changed, 40 insertions, 0 deletions
diff --git a/components/enhanced_bookmarks/enhanced_bookmark_features.cc b/components/enhanced_bookmarks/enhanced_bookmark_features.cc
new file mode 100644
index 0000000..4ec07123
--- /dev/null
+++ b/components/enhanced_bookmarks/enhanced_bookmark_features.cc
@@ -0,0 +1,40 @@
+// Copyright 2015 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 "components/enhanced_bookmarks/enhanced_bookmark_features.h"
+
+#include <string>
+
+#include "base/command_line.h"
+#include "components/enhanced_bookmarks/enhanced_bookmark_switches.h"
+#include "components/variations/variations_associated_data.h"
+
+#if defined(OS_IOS) || defined(OS_ANDROID)
+
+namespace enhanced_bookmarks {
+namespace {
+const char kFieldTrialName[] = "EnhancedBookmarks";
+} // namespace
+
+bool IsEnhancedBookmarksEnabled() {
+ // kEnhancedBookmarksExperiment flag could have values "", "1" and "0". "" -
+ // default, "0" - user opted out, "1" - user opted in. Tests also use the
+ // command line flag to force enhanced bookmark to be on.
+ std::string switch_value =
+ base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
+ switches::kEnhancedBookmarksExperiment);
+ if (switch_value == "1")
+ return true;
+ if (switch_value == "0")
+ return false;
+
+ // Check that the "id" param is present. This is a legacy of the desktop
+ // implementation providing the extension id via param. This probably should
+ // be replaced with code that checks the experiment name instead.
+ return !variations::GetVariationParamValue(kFieldTrialName, "id").empty();
+}
+
+} // namespace enhanced_bookmarks
+
+#endif