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 1084194595050f1070453fa59fdc6729aed786d7..31777bc5f01bfc30c56d9b63f3522c57a38569b8 100644 |
--- a/chrome/browser/prefs/session_startup_pref.cc |
+++ b/chrome/browser/prefs/session_startup_pref.cc |
@@ -6,6 +6,7 @@ |
#include <string> |
+#include "base/values.h" |
#include "chrome/browser/net/url_fixer_upper.h" |
#include "chrome/browser/prefs/pref_service.h" |
#include "chrome/browser/prefs/scoped_user_pref_update.h" |
@@ -20,7 +21,7 @@ namespace { |
// For historical reasons the enum and value registered in the prefs don't line |
// up. These are the values registered in prefs. |
-const int kPrefValueHomePage = 0; |
+const int kPrefValueHomePage = 0; // Deprecated |
const int kPrefValueLast = 1; |
const int kPrefValueURLs = 4; |
const int kPrefValueNewTab = 5; |
@@ -28,13 +29,19 @@ const int kPrefValueNewTab = 5; |
// Converts a SessionStartupPref::Type to an integer written to prefs. |
int TypeToPrefValue(SessionStartupPref::Type type) { |
switch (type) { |
- case SessionStartupPref::HOMEPAGE: return kPrefValueHomePage; |
case SessionStartupPref::LAST: return kPrefValueLast; |
case SessionStartupPref::URLS: return kPrefValueURLs; |
default: return kPrefValueNewTab; |
} |
} |
+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); |
+} |
+ |
} // namespace |
// static |
@@ -101,6 +108,16 @@ 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) { |
Dan Beam
2012/03/02 22:18:08
how does one ever delete this code?
Tyler Breisacher (Chromium)
2012/03/02 22:35:54
If all users have upgraded to a version that has t
|
+ 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_pref_list = prefs->GetList( |