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

Unified Diff: chrome/browser/ui/browser_instant_controller.cc

Issue 12315116: Add ability to change default pref values, and use in BrowserInstantController. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge LKGR and address review nit. Created 7 years, 10 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/ui/browser_instant_controller.h ('k') | chrome/test/base/testing_profile.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/browser_instant_controller.cc
diff --git a/chrome/browser/ui/browser_instant_controller.cc b/chrome/browser/ui/browser_instant_controller.cc
index 8d5bc2775a88805ccbe9af21a07a2bb98dac865e..445e75c72f01abb1d4efca1c5b4a93aed9e967a9 100644
--- a/chrome/browser/ui/browser_instant_controller.cc
+++ b/chrome/browser/ui/browser_instant_controller.cc
@@ -47,7 +47,40 @@ BrowserInstantController::BrowserInstantController(Browser* browser)
chrome::search::IsInstantExtendedAPIEnabled(profile())),
instant_unload_handler_(browser),
initialized_theme_info_(false) {
- profile_pref_registrar_.Init(profile()->GetPrefs());
+ PrefService* prefs = profile()->GetPrefs();
+
+ // The kInstantExtendedEnabled and kInstantEnabled preferences are
+ // separate, as the way opt-in is done is a bit different, and
+ // because the experiment that controls the behavior of
+ // kInstantExtendedEnabled (value retrieved via
+ // search::GetInstantExtendedDefaultSetting) may take different
+ // settings on different Chrome set-ups for the same user.
+ //
+ // In one mode of the experiment, however, the
+ // kInstantExtendedEnabled preference's default value is set to the
+ // existing value of kInstantEnabled.
+ //
+ // Because this requires reading the value of the kInstantEnabled
+ // value, we reset the default for kInstantExtendedEnabled here,
+ // instead of fully determining the default in RegisterUserPrefs,
+ // below.
+ bool instant_extended_default = true;
+ switch (search::GetInstantExtendedDefaultSetting()) {
+ case search::INSTANT_DEFAULT_ON:
+ instant_extended_default = true;
+ break;
+ case search::INSTANT_USE_EXISTING:
+ instant_extended_default = prefs->GetBoolean(prefs::kInstantEnabled);
+ case search::INSTANT_DEFAULT_OFF:
+ instant_extended_default = false;
+ break;
+ }
+
+ prefs->SetDefaultPrefValue(
+ prefs::kInstantExtendedEnabled,
+ Value::CreateBooleanValue(instant_extended_default));
+
+ profile_pref_registrar_.Init(prefs);
profile_pref_registrar_.Add(
GetInstantPrefName(profile()),
base::Bind(&BrowserInstantController::ResetInstant,
@@ -77,29 +110,16 @@ bool BrowserInstantController::IsInstantEnabled(Profile* profile) {
}
void BrowserInstantController::RegisterUserPrefs(
- PrefService* prefs,
PrefRegistrySyncable* registry) {
- // TODO(joi): Get rid of the need for PrefService param above.
registry->RegisterBooleanPref(prefs::kInstantConfirmDialogShown, false,
PrefRegistrySyncable::SYNCABLE_PREF);
registry->RegisterBooleanPref(prefs::kInstantEnabled, false,
PrefRegistrySyncable::SYNCABLE_PREF);
- bool instant_extended_default = true;
- switch (search::GetInstantExtendedDefaultSetting()) {
- case search::INSTANT_DEFAULT_ON:
- instant_extended_default = true;
- break;
- case search::INSTANT_USE_EXISTING:
- instant_extended_default = prefs->GetBoolean(prefs::kInstantEnabled);
- break;
- case search::INSTANT_DEFAULT_OFF:
- instant_extended_default = false;
- break;
- }
-
+ // Note that the default for this pref gets reset in the
+ // BrowserInstantController constructor.
registry->RegisterBooleanPref(prefs::kInstantExtendedEnabled,
- instant_extended_default,
+ false,
PrefRegistrySyncable::SYNCABLE_PREF);
}
« no previous file with comments | « chrome/browser/ui/browser_instant_controller.h ('k') | chrome/test/base/testing_profile.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698