summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/prefs/session_startup_pref.cc30
-rw-r--r--chrome/browser/prefs/session_startup_pref.h4
2 files changed, 24 insertions, 10 deletions
diff --git a/chrome/browser/prefs/session_startup_pref.cc b/chrome/browser/prefs/session_startup_pref.cc
index d63767d..bbe96c9 100644
--- a/chrome/browser/prefs/session_startup_pref.cc
+++ b/chrome/browser/prefs/session_startup_pref.cc
@@ -7,6 +7,7 @@
#include <string>
#include "base/values.h"
+#include "base/version.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"
@@ -72,18 +73,10 @@ void SessionStartupPref::RegisterUserPrefs(PrefService* prefs) {
// static
SessionStartupPref::Type SessionStartupPref::GetDefaultStartupType() {
#if defined(OS_CHROMEOS)
- SessionStartupPref::Type type = SessionStartupPref::LAST;
+ return SessionStartupPref::LAST;
#else
- SessionStartupPref::Type type = SessionStartupPref::DEFAULT;
+ return SessionStartupPref::DEFAULT;
#endif
-
-#if defined(OS_MACOSX)
- // Use Lion's system preference, if it is set.
- if (restore_utils::IsWindowRestoreEnabled())
- type = SessionStartupPref::LAST;
-#endif
-
- return type;
}
// static
@@ -129,6 +122,11 @@ SessionStartupPref SessionStartupPref::GetStartupPref(PrefService* prefs) {
MigrateIfNecessary(prefs);
+#if defined(OS_MACOSX)
+ if (restore_utils::IsWindowRestoreEnabled())
+ MigrateMacDefaultPrefIfNecessary(prefs);
+#endif
+
SessionStartupPref pref(
PrefValueToType(prefs->GetInteger(prefs::kRestoreOnStartup)));
@@ -189,6 +187,18 @@ void SessionStartupPref::MigrateIfNecessary(PrefService* prefs) {
}
// static
+void SessionStartupPref::MigrateMacDefaultPrefIfNecessary(PrefService* prefs) {
+ DCHECK(prefs);
+ // The default startup pref used to be LAST, now it is DEFAULT. Don't change
+ // the setting for existing profiles (even if the user has never changed it),
+ // but make new profiles default to DEFAULT.
+ bool old_profile_version = Version(prefs->GetString(
+ prefs::kProfileCreatedByVersion)).IsOlderThan("21.0.1180.0");
+ if (old_profile_version && TypeIsDefault(prefs))
+ prefs->SetInteger(prefs::kRestoreOnStartup, kPrefValueLast);
+}
+
+// static
bool SessionStartupPref::TypeIsManaged(PrefService* prefs) {
DCHECK(prefs);
const PrefService::Preference* pref_restore =
diff --git a/chrome/browser/prefs/session_startup_pref.h b/chrome/browser/prefs/session_startup_pref.h
index e1885aa..48e2e114 100644
--- a/chrome/browser/prefs/session_startup_pref.h
+++ b/chrome/browser/prefs/session_startup_pref.h
@@ -58,6 +58,10 @@ struct SessionStartupPref {
// the same effect.
static void MigrateIfNecessary(PrefService* prefs);
+ // The default startup pref for Mac used to be LAST, now it's DEFAULT. This
+ // migrates old users by writing out the preference explicitly.
+ static void MigrateMacDefaultPrefIfNecessary(PrefService* prefs);
+
// Whether the startup type and URLs are managed via policy.
static bool TypeIsManaged(PrefService* prefs);
static bool URLsAreManaged(PrefService* prefs);