OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/prefs/session_startup_pref.h" | 5 #include "chrome/browser/prefs/session_startup_pref.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 // static | 240 // static |
241 void SessionStartupPref::MigrateMacDefaultPrefIfNecessary(PrefService* prefs) { | 241 void SessionStartupPref::MigrateMacDefaultPrefIfNecessary(PrefService* prefs) { |
242 #if defined(OS_MACOSX) | 242 #if defined(OS_MACOSX) |
243 DCHECK(prefs); | 243 DCHECK(prefs); |
244 if (!restore_utils::IsWindowRestoreEnabled()) | 244 if (!restore_utils::IsWindowRestoreEnabled()) |
245 return; | 245 return; |
246 // The default startup pref used to be LAST, now it is DEFAULT. Don't change | 246 // The default startup pref used to be LAST, now it is DEFAULT. Don't change |
247 // the setting for existing profiles (even if the user has never changed it), | 247 // the setting for existing profiles (even if the user has never changed it), |
248 // but make new profiles default to DEFAULT. | 248 // but make new profiles default to DEFAULT. |
249 bool old_profile_version = | 249 bool old_profile_version = |
250 !prefs->FindPreference( | 250 !prefs->FindPreference(prefs::kProfileCreatedByVersion) |
251 prefs::kProfileCreatedByVersion)->IsDefaultValue() && | 251 ->IsDefaultValue() && |
252 Version(prefs->GetString(prefs::kProfileCreatedByVersion)).IsOlderThan( | 252 base::Version(prefs->GetString(prefs::kProfileCreatedByVersion)) |
253 "21.0.1180.0"); | 253 .IsOlderThan("21.0.1180.0"); |
254 if (old_profile_version && TypeIsDefault(prefs)) | 254 if (old_profile_version && TypeIsDefault(prefs)) |
255 prefs->SetInteger(prefs::kRestoreOnStartup, kPrefValueLast); | 255 prefs->SetInteger(prefs::kRestoreOnStartup, kPrefValueLast); |
256 #endif | 256 #endif |
257 } | 257 } |
258 | 258 |
259 // static | 259 // static |
260 bool SessionStartupPref::TypeIsManaged(PrefService* prefs) { | 260 bool SessionStartupPref::TypeIsManaged(PrefService* prefs) { |
261 DCHECK(prefs); | 261 DCHECK(prefs); |
262 const PrefService::Preference* pref_restore = | 262 const PrefService::Preference* pref_restore = |
263 prefs->FindPreference(prefs::kRestoreOnStartup); | 263 prefs->FindPreference(prefs::kRestoreOnStartup); |
(...skipping 25 matching lines...) Expand all Loading... |
289 case kPrefValueLast: return SessionStartupPref::LAST; | 289 case kPrefValueLast: return SessionStartupPref::LAST; |
290 case kPrefValueURLs: return SessionStartupPref::URLS; | 290 case kPrefValueURLs: return SessionStartupPref::URLS; |
291 case kPrefValueHomePage: return SessionStartupPref::HOMEPAGE; | 291 case kPrefValueHomePage: return SessionStartupPref::HOMEPAGE; |
292 default: return SessionStartupPref::DEFAULT; | 292 default: return SessionStartupPref::DEFAULT; |
293 } | 293 } |
294 } | 294 } |
295 | 295 |
296 SessionStartupPref::SessionStartupPref(Type type) : type(type) {} | 296 SessionStartupPref::SessionStartupPref(Type type) : type(type) {} |
297 | 297 |
298 SessionStartupPref::~SessionStartupPref() {} | 298 SessionStartupPref::~SessionStartupPref() {} |
OLD | NEW |