Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(100)

Unified Diff: chrome/browser/supervised_user/legacy/supervised_user_registration_utility.cc

Issue 1165323004: We should use UserID object to identify users instead of username. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/supervised_user/legacy/supervised_user_registration_utility.cc
diff --git a/chrome/browser/supervised_user/legacy/supervised_user_registration_utility.cc b/chrome/browser/supervised_user/legacy/supervised_user_registration_utility.cc
index 5242fd63e96a717e0fd220107d3db88d9e04997c..8a377360f97d61f52cf715c6d70738f507e94371 100644
--- a/chrome/browser/supervised_user/legacy/supervised_user_registration_utility.cc
+++ b/chrome/browser/supervised_user/legacy/supervised_user_registration_utility.cc
@@ -27,6 +27,7 @@
#include "components/signin/core/browser/profile_oauth2_token_service.h"
#include "components/signin/core/browser/signin_client.h"
#include "components/signin/core/browser/signin_manager.h"
+#include "components/user_manager/user_id.h"
#include "content/public/browser/browser_thread.h"
#include "google_apis/gaia/gaia_urls.h"
#include "google_apis/gaia/google_service_auth_error.h"
@@ -59,13 +60,13 @@ class SupervisedUserRegistrationUtilityImpl
// the user and his avatar. |callback| is called with the result of the
// registration. We use the info here and not the profile, because on Chrome
// OS the profile of the supervised user does not yet exist.
- void Register(const std::string& supervised_user_id,
+ void Register(const user_manager::UserID& supervised_user_id,
const SupervisedUserRegistrationInfo& info,
const RegistrationCallback& callback) override;
// SupervisedUserSyncServiceObserver:
void OnSupervisedUserAcknowledged(
- const std::string& supervised_user_id) override;
+ const user_manager::UserID& supervised_user_id) override;
void OnSupervisedUsersSyncingStopped() override;
void OnSupervisedUsersChanged() override;
@@ -108,7 +109,7 @@ class SupervisedUserRegistrationUtilityImpl
// A |KeyedService| owned by the custodian profile.
SupervisedUserSharedSettingsService* supervised_user_shared_settings_service_;
- std::string pending_supervised_user_id_;
+ user_manager::UserID pending_supervised_user_id_;
std::string pending_supervised_user_token_;
bool pending_supervised_user_acknowledged_;
bool is_existing_supervised_user_;
@@ -178,10 +179,10 @@ SupervisedUserRegistrationUtility::Create(Profile* profile) {
}
// static
-std::string SupervisedUserRegistrationUtility::GenerateNewSupervisedUserId() {
- std::string new_supervised_user_id;
- base::Base64Encode(base::RandBytesAsString(8), &new_supervised_user_id);
- return new_supervised_user_id;
+user_manager::UserID SupervisedUserRegistrationUtility::GenerateNewSupervisedUserId() {
+ std::string new_supervised_user_id_str;
+ base::Base64Encode(base::RandBytesAsString(8), &new_supervised_user_id_str);
+ return user_manager::UserID::FromUserEmail(new_supervised_user_id_str);
}
// static
@@ -216,6 +217,7 @@ SupervisedUserRegistrationUtilityImpl::SupervisedUserRegistrationUtilityImpl(
token_fetcher_(token_fetcher.Pass()),
supervised_user_sync_service_(service),
supervised_user_shared_settings_service_(shared_settings_service),
+ pending_supervised_user_id_(std::string(), std::string()),
pending_supervised_user_acknowledged_(false),
is_existing_supervised_user_(false),
avatar_updated_(false),
@@ -230,7 +232,7 @@ SupervisedUserRegistrationUtilityImpl::
}
void SupervisedUserRegistrationUtilityImpl::Register(
- const std::string& supervised_user_id,
+ const user_manager::UserID& supervised_user_id,
const SupervisedUserRegistrationInfo& info,
const RegistrationCallback& callback) {
DCHECK(pending_supervised_user_id_.empty());
@@ -240,7 +242,7 @@ void SupervisedUserRegistrationUtilityImpl::Register(
bool need_password_update = !info.password_data.empty();
const base::DictionaryValue* dict =
prefs_->GetDictionary(prefs::kSupervisedUsers);
- is_existing_supervised_user_ = dict->HasKey(supervised_user_id);
+ is_existing_supervised_user_ = dict->HasKey(supervised_user_id.GetUserEmail());
if (!is_existing_supervised_user_) {
supervised_user_sync_service_->AddSupervisedUser(
pending_supervised_user_id_,
@@ -252,7 +254,7 @@ void SupervisedUserRegistrationUtilityImpl::Register(
} else {
const base::DictionaryValue* value = NULL;
bool success =
- dict->GetDictionaryWithoutPathExpansion(supervised_user_id, &value);
+ dict->GetDictionaryWithoutPathExpansion(supervised_user_id.GetUserEmail(), &value);
DCHECK(success);
std::string key;
bool need_keys = !info.password_signature_key.empty() ||
@@ -291,12 +293,12 @@ void SupervisedUserRegistrationUtilityImpl::Register(
const char* kAvatarKey = supervised_users::kChromeAvatarIndex;
#endif
supervised_user_shared_settings_service_->SetValue(
- pending_supervised_user_id_, kAvatarKey,
+ pending_supervised_user_id_.GetUserEmail(), kAvatarKey,
base::FundamentalValue(info.avatar_index));
if (need_password_update) {
password_update_.reset(new SupervisedUserSharedSettingsUpdate(
supervised_user_shared_settings_service_,
- pending_supervised_user_id_,
+ pending_supervised_user_id_.GetUserEmail(),
supervised_users::kChromeOSPasswordData,
scoped_ptr<base::Value>(info.password_data.DeepCopy()),
base::Bind(
@@ -320,8 +322,8 @@ void SupervisedUserRegistrationUtilityImpl::CancelPendingRegistration() {
}
void SupervisedUserRegistrationUtilityImpl::OnSupervisedUserAcknowledged(
- const std::string& supervised_user_id) {
- DCHECK_EQ(pending_supervised_user_id_, supervised_user_id);
+ const user_manager::UserID& supervised_user_id) {
+ DCHECK(pending_supervised_user_id_ == supervised_user_id);
DCHECK(!pending_supervised_user_acknowledged_);
pending_supervised_user_acknowledged_ = true;
CompleteRegistrationIfReady();

Powered by Google App Engine
This is Rietveld 408576698