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

Unified Diff: chrome/browser/bookmarks/enhanced_bookmarks_features.cc

Issue 497563002: [Android] Use correct enhanced bookmarks enabling logic. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: indent fix Created 6 years, 4 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
« no previous file with comments | « chrome/browser/bookmarks/enhanced_bookmarks_features.h ('k') | chrome/browser/chrome_browser_main.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/bookmarks/enhanced_bookmarks_features.cc
diff --git a/chrome/browser/bookmarks/enhanced_bookmarks_features.cc b/chrome/browser/bookmarks/enhanced_bookmarks_features.cc
index aad3817e1bcacbf3786729c87ccb50b76c88132b..8111dc7e8815d0484cd971921d8c8b3ba550b370 100644
--- a/chrome/browser/bookmarks/enhanced_bookmarks_features.cc
+++ b/chrome/browser/bookmarks/enhanced_bookmarks_features.cc
@@ -39,6 +39,16 @@ bool IsEnhancedBookmarksExperimentEnabledFromFinch() {
#endif
}
+PrefService* GetFlagsStorage(PrefService* user_prefs,
+ PrefService* local_state) {
+#if defined(OS_CHROMEOS)
+ // Chrome OS is using user prefs for flags storage.
+ return user_prefs;
+#else
+ return local_state;
+#endif
+}
+
}; // namespace
bool GetBookmarksExperimentExtensionID(const PrefService* user_prefs,
@@ -64,11 +74,7 @@ void UpdateBookmarksExperimentState(
PrefService* local_state,
bool user_signed_in,
BookmarksExperimentState experiment_enabled_from_sync) {
- PrefService* flags_storage = local_state;
-#if defined(OS_CHROMEOS)
- // Chrome OS is using user prefs for flags storage.
- flags_storage = user_prefs;
-#endif
+ PrefService* flags_storage = GetFlagsStorage(user_prefs, local_state);
BookmarksExperimentState bookmarks_experiment_state_before =
static_cast<BookmarksExperimentState>(user_prefs->GetInteger(
@@ -129,6 +135,14 @@ void UpdateBookmarksExperimentState(
}
}
+#if defined(OS_ANDROID)
+ bool opt_in = !opt_out
+ && CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
+ switches::kEnhancedBookmarksExperiment) == "1";
+ if (opt_in && bookmarks_experiment_new_state == BOOKMARKS_EXPERIMENT_NONE)
+ bookmarks_experiment_new_state = BOOKMARKS_EXPERIMENT_ENABLED;
+#endif
+
UMA_HISTOGRAM_ENUMERATION("EnhancedBookmarks.SyncExperimentState",
bookmarks_experiment_new_state,
BOOKMARKS_EXPERIMENT_ENUM_SIZE);
@@ -168,19 +182,11 @@ void ForceFinchBookmarkExperimentIfNeeded(
}
}
-bool IsEnhancedBookmarksExperimentEnabled() {
- CommandLine* command_line = CommandLine::ForCurrentProcess();
- if (command_line->HasSwitch(switches::kManualEnhancedBookmarks) ||
- command_line->HasSwitch(switches::kManualEnhancedBookmarksOptout)) {
- return true;
- }
-
- return IsEnhancedBookmarksExperimentEnabledFromFinch();
-}
-
#if defined(OS_ANDROID)
-bool IsEnhancedBookmarkImageFetchingEnabled() {
- if (IsEnhancedBookmarksExperimentEnabled())
+
+bool IsEnhancedBookmarkImageFetchingEnabled(PrefService* user_prefs,
+ PrefService* local_state) {
+ if (IsEnhancedBookmarksExperimentEnabled(user_prefs, local_state))
return true;
// Salient images are collected from visited bookmarked pages even if the
@@ -192,6 +198,40 @@ bool IsEnhancedBookmarkImageFetchingEnabled() {
kFieldTrialName, "DisableImagesFetching");
return disable_fetching.empty();
}
+
+bool IsEnhancedBookmarksExperimentEnabled(PrefService* user_prefs,
+ PrefService* local_state) {
+ PrefService* flags_storage = GetFlagsStorage(user_prefs, local_state);
+
+ const base::ListValue* experiments_list = flags_storage->GetList(
+ prefs::kEnabledLabsExperiments);
+
+ if (flags_storage) {
+ if (experiments_list->Find(
+ base::StringValue(switches::kManualEnhancedBookmarks))
Yaron 2014/08/28 00:17:40 I don't understand the distinction here. Either ex
Kibeom Kim (inactive) 2014/08/28 18:31:00 Done.
+ != experiments_list->end()) {
+ return true;
+ } else if (experiments_list->Find(
+ base::StringValue(switches::kManualEnhancedBookmarksOptout))
+ != experiments_list->end()) {
+ return false;
+ }
+ }
+
+ return IsEnhancedBookmarksExperimentEnabledFromFinch();
+}
+
+#else
+
+bool IsEnhancedBookmarksExperimentEnabled() {
+ CommandLine* command_line = CommandLine::ForCurrentProcess();
+ if (command_line->HasSwitch(switches::kManualEnhancedBookmarks) ||
+ command_line->HasSwitch(switches::kManualEnhancedBookmarksOptout)) {
+ return true;
+ }
+ return IsEnhancedBookmarksExperimentEnabledFromFinch();
+}
+
#endif
bool IsEnableDomDistillerSet() {
« no previous file with comments | « chrome/browser/bookmarks/enhanced_bookmarks_features.h ('k') | chrome/browser/chrome_browser_main.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698