This source file includes following definitions.
- RegisterProfilePrefs
- SetVersion
- GetVersion
- OnProfileLoaded
#include "chrome/browser/profiles/chrome_version_service.h"
#include "base/prefs/pref_service.h"
#include "base/version.h"
#include "chrome/common/chrome_version_info.h"
#include "chrome/common/pref_names.h"
#include "components/user_prefs/pref_registry_syncable.h"
void ChromeVersionService::RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable* registry) {
registry->RegisterStringPref(
prefs::kProfileCreatedByVersion,
"1.0.0.0",
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
}
void ChromeVersionService::SetVersion(PrefService* prefs,
const std::string& version) {
prefs->SetString(prefs::kProfileCreatedByVersion, version);
}
std::string ChromeVersionService::GetVersion(PrefService* prefs) {
return prefs->GetString(prefs::kProfileCreatedByVersion);
}
void ChromeVersionService::OnProfileLoaded(PrefService* prefs,
bool is_new_profile) {
chrome::VersionInfo version_info;
std::string version = version_info.Version();
if (prefs->FindPreference(prefs::kProfileCreatedByVersion)->
IsDefaultValue() && is_new_profile) {
SetVersion(prefs, version);
}
}