Commit 948ce92d authored by kkimlabs's avatar kkimlabs Committed by Commit bot

[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}
parent 5092c26c
...@@ -2011,6 +2011,10 @@ void GetSanitizedEnabledFlags( ...@@ -2011,6 +2011,10 @@ void GetSanitizedEnabledFlags(
bool SkipConditionalExperiment(const Experiment& experiment) { bool SkipConditionalExperiment(const Experiment& experiment) {
if (experiment.internal_name == if (experiment.internal_name ==
std::string("enhanced-bookmarks-experiment")) { std::string("enhanced-bookmarks-experiment")) {
#if defined(OS_ANDROID)
// On Android, user can opt in.
return false;
#else
CommandLine* command_line = CommandLine::ForCurrentProcess(); CommandLine* command_line = CommandLine::ForCurrentProcess();
// Dont't skip experiment if it has non default value. // Dont't skip experiment if it has non default value.
// It means user selected it. // It means user selected it.
...@@ -2018,7 +2022,9 @@ bool SkipConditionalExperiment(const Experiment& experiment) { ...@@ -2018,7 +2022,9 @@ bool SkipConditionalExperiment(const Experiment& experiment) {
return false; return false;
return !IsEnhancedBookmarksExperimentEnabled(); return !IsEnhancedBookmarksExperimentEnabled();
#endif
} }
if ((experiment.internal_name == std::string("manual-enhanced-bookmarks")) || if ((experiment.internal_name == std::string("manual-enhanced-bookmarks")) ||
(experiment.internal_name == (experiment.internal_name ==
std::string("manual-enhanced-bookmarks-optout"))) { std::string("manual-enhanced-bookmarks-optout"))) {
......
...@@ -5,6 +5,7 @@ include_rules = [ ...@@ -5,6 +5,7 @@ include_rules = [
# exceptions! # exceptions!
"-chrome/browser", "-chrome/browser",
"+chrome/browser/bookmarks", "+chrome/browser/bookmarks",
"+chrome/browser/browser_process.h",
"+chrome/browser/favicon", "+chrome/browser/favicon",
"+chrome/browser/chrome_notification_types.h", "+chrome/browser/chrome_notification_types.h",
"+chrome/browser/policy/profile_policy_connector.h", "+chrome/browser/policy/profile_policy_connector.h",
...@@ -13,6 +14,7 @@ include_rules = [ ...@@ -13,6 +14,7 @@ include_rules = [
"+chrome/browser/profiles/profile.h", "+chrome/browser/profiles/profile.h",
"+chrome/browser/profiles/startup_task_runner_service.h", "+chrome/browser/profiles/startup_task_runner_service.h",
"+chrome/browser/profiles/startup_task_runner_service_factory.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.h",
"+chrome/browser/undo/bookmark_undo_service_factory.h", "+chrome/browser/undo/bookmark_undo_service_factory.h",
......
...@@ -10,8 +10,12 @@ ...@@ -10,8 +10,12 @@
#include "base/prefs/scoped_user_pref_update.h" #include "base/prefs/scoped_user_pref_update.h"
#include "base/sha1.h" #include "base/sha1.h"
#include "base/strings/string_number_conversions.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/chrome_switches.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
#include "components/signin/core/browser/signin_manager.h"
#include "components/sync_driver/pref_names.h" #include "components/sync_driver/pref_names.h"
#include "components/variations/variations_associated_data.h" #include "components/variations/variations_associated_data.h"
#include "extensions/common/features/feature.h" #include "extensions/common/features/feature.h"
...@@ -129,6 +133,14 @@ void UpdateBookmarksExperimentState( ...@@ -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", UMA_HISTOGRAM_ENUMERATION("EnhancedBookmarks.SyncExperimentState",
bookmarks_experiment_new_state, bookmarks_experiment_new_state,
BOOKMARKS_EXPERIMENT_ENUM_SIZE); BOOKMARKS_EXPERIMENT_ENUM_SIZE);
...@@ -139,6 +151,16 @@ void UpdateBookmarksExperimentState( ...@@ -139,6 +151,16 @@ void UpdateBookmarksExperimentState(
bookmarks_experiment_new_state); 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( void ForceFinchBookmarkExperimentIfNeeded(
PrefService* flags_storage, PrefService* flags_storage,
BookmarksExperimentState bookmarks_experiment_state) { BookmarksExperimentState bookmarks_experiment_state) {
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "extensions/common/extension.h" #include "extensions/common/extension.h"
class PrefService; class PrefService;
class Profile;
// States for bookmark experiment. They are set by Chrome sync into // States for bookmark experiment. They are set by Chrome sync into
// sync_driver::prefs::kEnhancedBookmarksExperimentEnabled user preference and // sync_driver::prefs::kEnhancedBookmarksExperimentEnabled user preference and
...@@ -30,14 +31,20 @@ enum BookmarksExperimentState { ...@@ -30,14 +31,20 @@ enum BookmarksExperimentState {
bool GetBookmarksExperimentExtensionID(const PrefService* user_prefs, bool GetBookmarksExperimentExtensionID(const PrefService* user_prefs,
std::string* extension_id); std::string* extension_id);
// Updates bookmark experiment state based on information from Chrome sync // Updates bookmark experiment state based on information from Chrome sync,
// and Finch experiments. // Finch experiments, and command line flag.
void UpdateBookmarksExperimentState( void UpdateBookmarksExperimentState(
PrefService* user_prefs, PrefService* user_prefs,
PrefService* local_state, PrefService* local_state,
bool user_signed_in, bool user_signed_in,
BookmarksExperimentState experiment_enabled_from_sync); 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. // Sets flag to opt-in user into Finch experiment.
void ForceFinchBookmarkExperimentIfNeeded( void ForceFinchBookmarkExperimentIfNeeded(
PrefService* local_state, PrefService* local_state,
......
...@@ -7,11 +7,14 @@ ...@@ -7,11 +7,14 @@
#include "base/command_line.h" #include "base/command_line.h"
#include "base/debug/trace_event.h" #include "base/debug/trace_event.h"
#include "base/path_service.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/google/google_search_counter_android.h"
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
#include "components/crash/app/breakpad_linux.h" #include "components/crash/app/breakpad_linux.h"
#include "components/crash/browser/crash_dump_manager_android.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/browser/android/compositor.h"
#include "content/public/common/main_function_params.h" #include "content/public/common/main_function_params.h"
#include "net/android/network_change_notifier_factory_android.h" #include "net/android/network_change_notifier_factory_android.h"
...@@ -52,7 +55,10 @@ void ChromeBrowserMainPartsAndroid::PreProfileInit() { ...@@ -52,7 +55,10 @@ void ChromeBrowserMainPartsAndroid::PreProfileInit() {
} }
void ChromeBrowserMainPartsAndroid::PostProfileInit() { 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(); ChromeBrowserMainParts::PostProfileInit();
} }
......
...@@ -15,15 +15,6 @@ ...@@ -15,15 +15,6 @@
#include "chrome/common/extensions/extension_constants.h" #include "chrome/common/extensions/extension_constants.h"
#include "components/signin/core/browser/signin_manager.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 { namespace extensions {
ExternalComponentLoader::ExternalComponentLoader(Profile* profile) ExternalComponentLoader::ExternalComponentLoader(Profile* profile)
...@@ -66,11 +57,8 @@ void ExternalComponentLoader::StartLoading() { ...@@ -66,11 +57,8 @@ void ExternalComponentLoader::StartLoading() {
} }
} }
UpdateBookmarksExperimentState( InitBookmarksExperimentState(profile_);
profile_->GetPrefs(),
g_browser_process->local_state(),
IsUserSignedin(profile_),
BOOKMARKS_EXPERIMENT_ENABLED_FROM_SYNC_UNKNOWN);
std::string ext_id; std::string ext_id;
if (GetBookmarksExperimentExtensionID(profile_->GetPrefs(), &ext_id) && if (GetBookmarksExperimentExtensionID(profile_->GetPrefs(), &ext_id) &&
!ext_id.empty()) { !ext_id.empty()) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment