Index: chrome/browser/prefs/session_startup_pref.cc |
=================================================================== |
--- chrome/browser/prefs/session_startup_pref.cc (revision 133745) |
+++ chrome/browser/prefs/session_startup_pref.cc (working copy) |
@@ -35,13 +35,10 @@ |
} |
void SetNewURLList(PrefService* prefs) { |
- if (prefs->IsUserModifiablePreference(prefs::kURLsToRestoreOnStartup)) { |
- base::ListValue new_url_pref_list; |
- base::StringValue* home_page = |
- new base::StringValue(prefs->GetString(prefs::kHomePage)); |
- new_url_pref_list.Append(home_page); |
- prefs->Set(prefs::kURLsToRestoreOnStartup, new_url_pref_list); |
- } |
+ 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) { |
@@ -64,9 +61,6 @@ |
PrefService::SYNCABLE_PREF); |
prefs->RegisterListPref(prefs::kURLsToRestoreOnStartup, |
PrefService::SYNCABLE_PREF); |
- prefs->RegisterBooleanPref(prefs::kRestoreOnStartupMigrated, |
- false, |
- PrefService::UNSYNCABLE_PREF); |
} |
// static |
@@ -126,12 +120,19 @@ |
// 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); |
+ } |
+ |
// Always load the urls, even if the pref type isn't URLS. This way the |
// preferences panels can show the user their last choice. |
const ListValue* url_list = prefs->GetList(prefs::kURLsToRestoreOnStartup); |
@@ -141,48 +142,6 @@ |
} |
// static |
-void SessionStartupPref::MigrateIfNecessary(PrefService* prefs) { |
- DCHECK(prefs); |
- |
- if (!prefs->GetBoolean(prefs::kRestoreOnStartupMigrated)) { |
- // Read existing values |
- const base::Value* homepage_is_new_tab_page_value = |
- prefs->GetUserPrefValue(prefs::kHomePageIsNewTabPage); |
- bool homepage_is_new_tab_page = true; |
- if (homepage_is_new_tab_page_value) |
- homepage_is_new_tab_page_value->GetAsBoolean(&homepage_is_new_tab_page); |
- |
- const base::Value* restore_on_startup_value = |
- prefs->GetUserPrefValue(prefs::kRestoreOnStartup); |
- int restore_on_startup = -1; |
- if (restore_on_startup_value) |
- restore_on_startup_value->GetAsInteger(&restore_on_startup); |
- |
- // If restore_on_startup has the deprecated value kPrefValueHomePage, |
- // migrate it to open the homepage on startup. If 'homepage is NTP' is set, |
- // that means just opening the NTP. If not, it means opening a one-item URL |
- // list containing the homepage. |
- if (restore_on_startup == kPrefValueHomePage) { |
- if (homepage_is_new_tab_page) { |
- prefs->SetInteger(prefs::kRestoreOnStartup, kPrefValueNewTab); |
- } else { |
- prefs->SetInteger(prefs::kRestoreOnStartup, kPrefValueURLs); |
- SetNewURLList(prefs); |
- } |
- } else if (!restore_on_startup_value && !homepage_is_new_tab_page) { |
- // kRestoreOnStartup was never set by the user, but the homepage was set. |
- // Migrate to the list of URLs. (If restore_on_startup was never set, |
- // and homepage_is_new_tab_page is true, no action is needed. The new |
- // default value is "open the new tab page" which is what we want.) |
- 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 = |