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

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

Issue 10173007: Revert 133740 - Fix homepage migration for users who never changed their settings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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
« 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
===================================================================
--- 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 =
« 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