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(
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"))) {
......
......@@ -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",
......
......@@ -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) {
......
......@@ -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,
......
......@@ -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();
}
......
......@@ -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()) {
......
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