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..1d4aad838ea420d625ee81ae94c8cf7d532c59ac 100644 |
--- a/chrome/browser/prefs/session_startup_pref.cc |
+++ b/chrome/browser/prefs/session_startup_pref.cc |
@@ -42,10 +42,13 @@ int TypeToPrefValue(SessionStartupPref::Type type) { |
} |
void SetNewURLList(PrefService* prefs) { |
- ListValue new_url_pref_list; |
- StringValue* home_page = new StringValue(prefs->GetString(prefs::kHomePage)); |
- new_url_pref_list.Append(home_page); |
- prefs->Set(prefs::kURLsToRestoreOnStartup, new_url_pref_list); |
+ if (prefs->IsUserModifiablePreference(prefs::kURLsToRestoreOnStartup)) { |
+ ListValue new_url_pref_list; |
+ StringValue* home_page = |
+ new StringValue(prefs->GetString(prefs::kHomePage)); |
+ new_url_pref_list.Append(home_page); |
+ prefs->Set(prefs::kURLsToRestoreOnStartup, new_url_pref_list); |
+ } |
} |
void URLListToPref(const base::ListValue* url_list, SessionStartupPref* pref) { |
@@ -70,6 +73,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 |
@@ -129,17 +135,17 @@ SessionStartupPref SessionStartupPref::GetStartupPref(Profile* profile) { |
// static |
SessionStartupPref SessionStartupPref::GetStartupPref(PrefService* prefs) { |
DCHECK(prefs); |
+ |
+ MigrateIfNecessary(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 (pref.type == HOMEPAGE) { |
+ // We've already migrated, so the only way this can happen is if |
+ // kRestoreOnStartup is controlled by a policy. In that case, act as though |
+ // URLS was selected. |
Mattias Nissler (ping if slow)
2012/04/18 11:40:54
We should change RestoreOnStartupPolicyHandler in
Tyler Breisacher (Chromium)
2012/04/18 18:26:03
http://crbug.com/124027
The patch I just uploaded
Mattias Nissler (ping if slow)
2012/04/19 13:23:17
Thanks for fixing the policy!
|
+ pref.type = URLS; |
} |
// Always load the urls, even if the pref type isn't URLS. This way the |
@@ -151,6 +157,30 @@ SessionStartupPref SessionStartupPref::GetStartupPref(PrefService* prefs) { |
} |
// static |
+void SessionStartupPref::MigrateIfNecessary(PrefService* prefs) { |
+ DCHECK(prefs); |
+ |
+ if (!prefs->GetBoolean(prefs::kRestoreOnStartupMigrated)) { |
+ |
+ if (prefs->GetInteger(prefs::kRestoreOnStartup) == kPrefValueHomePage || |
+ (!prefs->HasPrefPath(prefs::kRestoreOnStartup) && |
+ !prefs->GetBoolean(prefs::kHomePageIsNewTabPage))) { |
+ |
+ if (prefs->GetBoolean(prefs::kHomePageIsNewTabPage)) { |
Mattias Nissler (ping if slow)
2012/04/18 11:40:54
This still breaks if prefs::kHomePageIsNewTabPage
Tyler Breisacher (Chromium)
2012/04/18 18:26:03
I don't think we change the value of kHomePageIsNe
Mattias Nissler (ping if slow)
2012/04/19 13:23:17
What I meant was that the pref value you get in li
|
+ if (prefs->IsUserModifiablePreference(prefs::kRestoreOnStartup)) |
+ prefs->SetInteger(prefs::kRestoreOnStartup, kPrefValueNewTab); |
+ } else { |
+ if (prefs->IsUserModifiablePreference(prefs::kRestoreOnStartup)) |
+ prefs->SetInteger(prefs::kRestoreOnStartup, kPrefValueURLs); |
+ SetNewURLList(prefs); |
+ } |
+ } |
+ |
+ prefs->SetBoolean(prefs::kRestoreOnStartupMigrated, true); |
+ } |
+} |
+ |
+// static |
bool SessionStartupPref::TypeIsManaged(PrefService* prefs) { |
DCHECK(prefs); |
const PrefService::Preference* pref_restore = |