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

Unified Diff: chrome/browser/prefs/session_startup_pref.cc

Issue 10049005: Fix homepage migration for users who never changed their settings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: simpler approach (+ rebase) Created 8 years, 8 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
Index: chrome/browser/prefs/session_startup_pref.cc
diff --git a/chrome/browser/prefs/session_startup_pref.cc b/chrome/browser/prefs/session_startup_pref.cc
index 447df6523efc57b16e18fcdbf7e666bb4dc04e77..131ece4227ce802d75c24691940e6fab0bc7c0a9 100644
--- a/chrome/browser/prefs/session_startup_pref.cc
+++ b/chrome/browser/prefs/session_startup_pref.cc
@@ -70,6 +70,9 @@ void SessionStartupPref::RegisterUserPrefs(PrefService* prefs) {
PrefService::SYNCABLE_PREF);
prefs->RegisterListPref(prefs::kURLsToRestoreOnStartup,
PrefService::SYNCABLE_PREF);
+ prefs->RegisterBooleanPref(prefs::kRestoreOnStartupMigrated,
+ false,
+ PrefService::UNSYNCABLE_PREF);
}
// static
@@ -132,14 +135,26 @@ SessionStartupPref SessionStartupPref::GetStartupPref(PrefService* prefs) {
SessionStartupPref pref(
PrefValueToType(prefs->GetInteger(prefs::kRestoreOnStartup)));
- // Migrate from "Open the home page" to "Open the following URLs". If the user
- // had the "Open the homepage" option selected, then we need to switch them to
- // "Open the following URLs" and set the list of URLs to a list containing
- // just the user's homepage.
- if (pref.type == SessionStartupPref::HOMEPAGE) {
- prefs->SetInteger(prefs::kRestoreOnStartup, kPrefValueURLs);
- pref.type = SessionStartupPref::URLS;
- SetNewURLList(prefs);
+ if (!prefs->GetBoolean(prefs::kRestoreOnStartupMigrated)) {
Ivan Korotkov 2012/04/17 09:27:51 Could you move the migration to a separate functio
Tyler Breisacher (Chromium) 2012/04/17 19:54:33 Done.
+ // Migrate from "Open the home page" to "Open the following URLs". If the
+ // user had the "Open the home page" option selected, switch them to "Open
+ // the following URLs" and set the list of URLs to a one-item list
+ // containing their homepage.
+ if (pref.type == SessionStartupPref::HOMEPAGE ||
+ (!prefs->HasPrefPath(prefs::kRestoreOnStartup) &&
+ !prefs->GetBoolean(prefs::kHomePageIsNewTabPage))) {
+
+ if (prefs->GetBoolean(prefs::kHomePageIsNewTabPage)) {
Mattias Nissler (ping if slow) 2012/04/17 09:54:48 These values may still come from policy, in which
Tyler Breisacher (Chromium) 2012/04/17 19:54:33 Done.
+ prefs->SetInteger(prefs::kRestoreOnStartup, kPrefValueNewTab);
+ pref.type = SessionStartupPref::DEFAULT;
+ } else {
+ prefs->SetInteger(prefs::kRestoreOnStartup, kPrefValueURLs);
+ pref.type = SessionStartupPref::URLS;
+ SetNewURLList(prefs);
+ }
+ }
+
+ prefs->SetBoolean(prefs::kRestoreOnStartupMigrated, true);
}
// Always load the urls, even if the pref type isn't URLS. This way the
« no previous file with comments | « no previous file | chrome/browser/prefs/session_startup_pref_unittest.cc » ('j') | chrome/test/functional/protector.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698