diff options
author | kkimlabs <kkimlabs@chromium.org> | 2014-09-09 02:06:42 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-09-09 09:09:27 +0000 |
commit | 948ce92d41501beacc70936f6b9104d51844ecca (patch) | |
tree | 25e31dcd1bb70be76cd116944b81a696c63c51cf | |
parent | 5092c26c486dbb29c83d58a4f33afde90ef3f96b (diff) | |
download | chromium_src-948ce92d41501beacc70936f6b9104d51844ecca.zip chromium_src-948ce92d41501beacc70936f6b9104d51844ecca.tar.gz chromium_src-948ce92d41501beacc70936f6b9104d51844ecca.tar.bz2 |
[Android] Add enhanced bookmark opt-in flag.
On Android, we provide opt-in flag for enhanced bookmark.
This is consistent with ios.
BUG=386785
Review URL: https://codereview.chromium.org/517713002
Cr-Commit-Position: refs/heads/master@{#293900}
-rw-r--r-- | chrome/browser/about_flags.cc | 6 | ||||
-rw-r--r-- | chrome/browser/bookmarks/DEPS | 2 | ||||
-rw-r--r-- | chrome/browser/bookmarks/enhanced_bookmarks_features.cc | 22 | ||||
-rw-r--r-- | chrome/browser/bookmarks/enhanced_bookmarks_features.h | 11 | ||||
-rw-r--r-- | chrome/browser/chrome_browser_main_android.cc | 8 | ||||
-rw-r--r-- | chrome/browser/extensions/external_component_loader.cc | 16 |
6 files changed, 48 insertions, 17 deletions
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc index 51672bc..9736f1a 100644 --- a/chrome/browser/about_flags.cc +++ b/chrome/browser/about_flags.cc @@ -2011,6 +2011,10 @@ void GetSanitizedEnabledFlags( bool SkipConditionalExperiment(const Experiment& experiment) { if (experiment.internal_name == std::string("enhanced-bookmarks-experiment")) { +#if defined(OS_ANDROID) + // On Android, user can opt in. + return false; +#else CommandLine* command_line = CommandLine::ForCurrentProcess(); // Dont't skip experiment if it has non default value. // It means user selected it. @@ -2018,7 +2022,9 @@ bool SkipConditionalExperiment(const Experiment& experiment) { return false; return !IsEnhancedBookmarksExperimentEnabled(); +#endif } + if ((experiment.internal_name == std::string("manual-enhanced-bookmarks")) || (experiment.internal_name == std::string("manual-enhanced-bookmarks-optout"))) { diff --git a/chrome/browser/bookmarks/DEPS b/chrome/browser/bookmarks/DEPS index 620ea19..a9233d06 100644 --- a/chrome/browser/bookmarks/DEPS +++ b/chrome/browser/bookmarks/DEPS @@ -5,6 +5,7 @@ include_rules = [ # exceptions! "-chrome/browser", "+chrome/browser/bookmarks", + "+chrome/browser/browser_process.h", "+chrome/browser/favicon", "+chrome/browser/chrome_notification_types.h", "+chrome/browser/policy/profile_policy_connector.h", @@ -13,6 +14,7 @@ include_rules = [ "+chrome/browser/profiles/profile.h", "+chrome/browser/profiles/startup_task_runner_service.h", "+chrome/browser/profiles/startup_task_runner_service_factory.h", + "+chrome/browser/signin/signin_manager_factory.h", "+chrome/browser/undo/bookmark_undo_service.h", "+chrome/browser/undo/bookmark_undo_service_factory.h", diff --git a/chrome/browser/bookmarks/enhanced_bookmarks_features.cc b/chrome/browser/bookmarks/enhanced_bookmarks_features.cc index 6f4b36b..b123763 100644 --- a/chrome/browser/bookmarks/enhanced_bookmarks_features.cc +++ b/chrome/browser/bookmarks/enhanced_bookmarks_features.cc @@ -10,8 +10,12 @@ #include "base/prefs/scoped_user_pref_update.h" #include "base/sha1.h" #include "base/strings/string_number_conversions.h" +#include "chrome/browser/browser_process.h" +#include "chrome/browser/profiles/profile.h" +#include "chrome/browser/signin/signin_manager_factory.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" +#include "components/signin/core/browser/signin_manager.h" #include "components/sync_driver/pref_names.h" #include "components/variations/variations_associated_data.h" #include "extensions/common/features/feature.h" @@ -129,6 +133,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); @@ -139,6 +151,16 @@ void UpdateBookmarksExperimentState( bookmarks_experiment_new_state); } +void InitBookmarksExperimentState(Profile* profile) { + SigninManagerBase* signin = SigninManagerFactory::GetForProfile(profile); + bool is_signed_in = signin && !signin->IsAuthenticated(); + UpdateBookmarksExperimentState( + profile->GetPrefs(), + g_browser_process->local_state(), + is_signed_in, + BOOKMARKS_EXPERIMENT_ENABLED_FROM_SYNC_UNKNOWN); +} + void ForceFinchBookmarkExperimentIfNeeded( PrefService* flags_storage, BookmarksExperimentState bookmarks_experiment_state) { diff --git a/chrome/browser/bookmarks/enhanced_bookmarks_features.h b/chrome/browser/bookmarks/enhanced_bookmarks_features.h index a8ee358..b85b342 100644 --- a/chrome/browser/bookmarks/enhanced_bookmarks_features.h +++ b/chrome/browser/bookmarks/enhanced_bookmarks_features.h @@ -10,6 +10,7 @@ #include "extensions/common/extension.h" class PrefService; +class Profile; // States for bookmark experiment. They are set by Chrome sync into // sync_driver::prefs::kEnhancedBookmarksExperimentEnabled user preference and @@ -30,14 +31,20 @@ enum BookmarksExperimentState { bool GetBookmarksExperimentExtensionID(const PrefService* user_prefs, std::string* extension_id); -// Updates bookmark experiment state based on information from Chrome sync -// and Finch experiments. +// Updates bookmark experiment state based on information from Chrome sync, +// Finch experiments, and command line flag. void UpdateBookmarksExperimentState( PrefService* user_prefs, PrefService* local_state, bool user_signed_in, BookmarksExperimentState experiment_enabled_from_sync); +// Same as UpdateBookmarksExperimentState, but the last argument with +// BOOKMARKS_EXPERIMENT_ENABLED_FROM_SYNC_UNKNOWN. +// Intended for performing initial configuration of bookmarks experiments +// when the browser is first initialized. +void InitBookmarksExperimentState(Profile* profile); + // Sets flag to opt-in user into Finch experiment. void ForceFinchBookmarkExperimentIfNeeded( PrefService* local_state, diff --git a/chrome/browser/chrome_browser_main_android.cc b/chrome/browser/chrome_browser_main_android.cc index fd20dba..a39f51f 100644 --- a/chrome/browser/chrome_browser_main_android.cc +++ b/chrome/browser/chrome_browser_main_android.cc @@ -7,11 +7,14 @@ #include "base/command_line.h" #include "base/debug/trace_event.h" #include "base/path_service.h" +#include "chrome/browser/bookmarks/enhanced_bookmarks_features.h" #include "chrome/browser/google/google_search_counter_android.h" +#include "chrome/browser/signin/signin_manager_factory.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_switches.h" #include "components/crash/app/breakpad_linux.h" #include "components/crash/browser/crash_dump_manager_android.h" +#include "components/signin/core/browser/signin_manager.h" #include "content/public/browser/android/compositor.h" #include "content/public/common/main_function_params.h" #include "net/android/network_change_notifier_factory_android.h" @@ -52,7 +55,10 @@ void ChromeBrowserMainPartsAndroid::PreProfileInit() { } void ChromeBrowserMainPartsAndroid::PostProfileInit() { - search_counter_.reset(new GoogleSearchCounterAndroid(profile())); + Profile* main_profile = profile(); + search_counter_.reset(new GoogleSearchCounterAndroid(main_profile)); + InitBookmarksExperimentState(main_profile); + ChromeBrowserMainParts::PostProfileInit(); } diff --git a/chrome/browser/extensions/external_component_loader.cc b/chrome/browser/extensions/external_component_loader.cc index 88d9260..d7d8a29 100644 --- a/chrome/browser/extensions/external_component_loader.cc +++ b/chrome/browser/extensions/external_component_loader.cc @@ -15,15 +15,6 @@ #include "chrome/common/extensions/extension_constants.h" #include "components/signin/core/browser/signin_manager.h" -namespace { - -bool IsUserSignedin(Profile* profile) { - SigninManagerBase* signin = SigninManagerFactory::GetForProfile(profile); - return signin && signin->IsAuthenticated(); -} - -} // namespace - namespace extensions { ExternalComponentLoader::ExternalComponentLoader(Profile* profile) @@ -66,11 +57,8 @@ void ExternalComponentLoader::StartLoading() { } } - UpdateBookmarksExperimentState( - profile_->GetPrefs(), - g_browser_process->local_state(), - IsUserSignedin(profile_), - BOOKMARKS_EXPERIMENT_ENABLED_FROM_SYNC_UNKNOWN); + InitBookmarksExperimentState(profile_); + std::string ext_id; if (GetBookmarksExperimentExtensionID(profile_->GetPrefs(), &ext_id) && !ext_id.empty()) { |