| 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/profiles/chrome_version_service.h" | 5 #include "chrome/browser/profiles/chrome_version_service.h" |
| 6 | 6 |
| 7 #include "base/version.h" | 7 #include "base/version.h" |
| 8 #include "chrome/browser/prefs/pref_service.h" | 8 #include "chrome/browser/prefs/pref_service.h" |
| 9 #include "chrome/common/chrome_version_info.h" | 9 #include "chrome/common/chrome_version_info.h" |
| 10 #include "chrome/common/pref_names.h" | 10 #include "chrome/common/pref_names.h" |
| 11 | 11 |
| 12 // static | 12 // static |
| 13 void ChromeVersionService::RegisterUserPrefs(PrefService* prefs) { | 13 void ChromeVersionService::RegisterUserPrefs(PrefServiceSyncable* prefs) { |
| 14 prefs->RegisterStringPref(prefs::kProfileCreatedByVersion, "1.0.0.0", | 14 prefs->RegisterStringPref(prefs::kProfileCreatedByVersion, "1.0.0.0", |
| 15 PrefService::UNSYNCABLE_PREF); | 15 PrefServiceSyncable::UNSYNCABLE_PREF); |
| 16 } | 16 } |
| 17 | 17 |
| 18 // static | 18 // static |
| 19 void ChromeVersionService::SetVersion(PrefService* prefs, | 19 void ChromeVersionService::SetVersion(PrefService* prefs, |
| 20 const std::string& version) { | 20 const std::string& version) { |
| 21 prefs->SetString(prefs::kProfileCreatedByVersion, version); | 21 prefs->SetString(prefs::kProfileCreatedByVersion, version); |
| 22 } | 22 } |
| 23 | 23 |
| 24 // static | 24 // static |
| 25 std::string ChromeVersionService::GetVersion(PrefService* prefs) { | 25 std::string ChromeVersionService::GetVersion(PrefService* prefs) { |
| 26 return prefs->GetString(prefs::kProfileCreatedByVersion); | 26 return prefs->GetString(prefs::kProfileCreatedByVersion); |
| 27 } | 27 } |
| 28 | 28 |
| 29 // static | 29 // static |
| 30 void ChromeVersionService::OnProfileLoaded(PrefService* prefs, | 30 void ChromeVersionService::OnProfileLoaded(PrefService* prefs, |
| 31 bool is_new_profile) { | 31 bool is_new_profile) { |
| 32 // Obtain the Chrome version info. | 32 // Obtain the Chrome version info. |
| 33 chrome::VersionInfo version_info; | 33 chrome::VersionInfo version_info; |
| 34 | 34 |
| 35 // If this is a new profile set version to current version, otherwise | 35 // If this is a new profile set version to current version, otherwise |
| 36 // (pre-existing profile), leave pref at default value (1.0.0.0) to | 36 // (pre-existing profile), leave pref at default value (1.0.0.0) to |
| 37 // avoid any first-run behavior. | 37 // avoid any first-run behavior. |
| 38 std::string version = version_info.Version(); | 38 std::string version = version_info.Version(); |
| 39 if (prefs->FindPreference(prefs::kProfileCreatedByVersion)-> | 39 if (prefs->FindPreference(prefs::kProfileCreatedByVersion)-> |
| 40 IsDefaultValue() && is_new_profile) { | 40 IsDefaultValue() && is_new_profile) { |
| 41 SetVersion(prefs, version); | 41 SetVersion(prefs, version); |
| 42 } | 42 } |
| 43 } | 43 } |
| OLD | NEW |