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

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

Issue 9559002: Bug 111139: Deprecate HOMEPAGE option, remove the UI for it, migrate users away from it (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 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/prefs/session_startup_pref.h ('k') | chrome/browser/prefs/session_startup_pref_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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(
« no previous file with comments | « chrome/browser/prefs/session_startup_pref.h ('k') | chrome/browser/prefs/session_startup_pref_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698