| Index: chrome/browser/managed_mode/managed_user_service.cc
|
| ===================================================================
|
| --- chrome/browser/managed_mode/managed_user_service.cc (revision 207746)
|
| +++ chrome/browser/managed_mode/managed_user_service.cc (working copy)
|
| @@ -176,8 +176,11 @@
|
| prefs::kDefaultManagedModeFilteringBehavior, ManagedModeURLFilter::ALLOW,
|
| user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
|
| registry->RegisterStringPref(
|
| - prefs::kManagedUserCustodian, std::string(),
|
| + prefs::kManagedUserCustodianEmail, std::string(),
|
| user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
|
| + registry->RegisterStringPref(
|
| + prefs::kManagedUserCustodianName, std::string(),
|
| + user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
|
| }
|
|
|
| // static
|
| @@ -218,9 +221,15 @@
|
| }
|
|
|
| std::string ManagedUserService::GetCustodianEmailAddress() const {
|
| - return profile_->GetPrefs()->GetString(prefs::kManagedUserCustodian);
|
| + return profile_->GetPrefs()->GetString(prefs::kManagedUserCustodianEmail);
|
| }
|
|
|
| +std::string ManagedUserService::GetCustodianName() const {
|
| + std::string name = profile_->GetPrefs()->GetString(
|
| + prefs::kManagedUserCustodianName);
|
| + return name.empty() ? GetCustodianEmailAddress() : name;
|
| +}
|
| +
|
| std::string ManagedUserService::GetDebugPolicyProviderName() const {
|
| // Save the string space in official builds.
|
| #ifdef NDEBUG
|
| @@ -347,7 +356,7 @@
|
| return true;
|
|
|
| if (error)
|
| - *error = l10n_util::GetStringUTF16(IDS_EXTENSIONS_LOCKED_MANAGED_MODE);
|
| + *error = l10n_util::GetStringUTF16(IDS_EXTENSIONS_LOCKED_MANAGED_USER);
|
| return false;
|
| }
|
|
|
| @@ -536,6 +545,8 @@
|
| void ManagedUserService::RegisterAndInitSync(
|
| Profile* custodian_profile,
|
| const ProfileManager::CreateCallback& callback) {
|
| +
|
| + // Register the managed user with the custodian's account.
|
| ManagedUserRegistrationService* registration_service =
|
| ManagedUserRegistrationServiceFactory::GetForProfile(custodian_profile);
|
| string16 name = UTF8ToUTF16(
|
| @@ -545,8 +556,22 @@
|
| info,
|
| base::Bind(&ManagedUserService::OnManagedUserRegistered,
|
| weak_ptr_factory_.GetWeakPtr(), callback, custodian_profile));
|
| +
|
| + // Fetch the custodian's profile information, to store the name.
|
| + registration_service->DownloadProfile(custodian_profile,
|
| + base::Bind(&ManagedUserService::OnCustodianProfileDownloaded,
|
| + weak_ptr_factory_.GetWeakPtr()));
|
| }
|
|
|
| +void ManagedUserService::OnCustodianProfileDownloaded(
|
| + const string16& full_name) {
|
| + // Store the custodian's display name in our prefs.
|
| + // TODO(pamg): If --gaia-profile-info (keyword: switches::kGaiaProfileInfo)
|
| + // is ever enabled, integrate with it properly.
|
| + profile_->GetPrefs()->SetString(prefs::kManagedUserCustodianName,
|
| + UTF16ToUTF8(full_name));
|
| +}
|
| +
|
| void ManagedUserService::OnManagedUserRegistered(
|
| const ProfileManager::CreateCallback& callback,
|
| Profile* custodian_profile,
|
| @@ -555,6 +580,7 @@
|
| if (auth_error.state() != GoogleServiceAuthError::NONE) {
|
| LOG(ERROR) << "Managed user OAuth error: " << auth_error.ToString();
|
| DCHECK_EQ(std::string(), token);
|
| +
|
| callback.Run(profile_, Profile::CREATE_STATUS_REMOTE_FAIL);
|
| return;
|
| }
|
| @@ -562,7 +588,7 @@
|
| InitSync(token);
|
| SigninManagerBase* signin =
|
| SigninManagerFactory::GetForProfile(custodian_profile);
|
| - profile_->GetPrefs()->SetString(prefs::kManagedUserCustodian,
|
| + profile_->GetPrefs()->SetString(prefs::kManagedUserCustodianEmail,
|
| signin->GetAuthenticatedUsername());
|
| callback.Run(profile_, Profile::CREATE_STATUS_INITIALIZED);
|
| }
|
|
|