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

Unified Diff: chrome/browser/profiles/profile_info_cache.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/profiles/profile_info_cache.cc
diff --git a/chrome/browser/profiles/profile_info_cache.cc b/chrome/browser/profiles/profile_info_cache.cc
index e80e0304a4f78b564b1f23f672230c73931bf196..3041439c216698ab43db7d3298ce13d7851d99d2 100644
--- a/chrome/browser/profiles/profile_info_cache.cc
+++ b/chrome/browser/profiles/profile_info_cache.cc
@@ -26,6 +26,7 @@
#include "chrome/common/pref_names.h"
#include "chrome/grit/generated_resources.h"
#include "components/signin/core/common/profile_management_switches.h"
+#include "components/user_manager/user_id.h"
#include "content/public/browser/browser_thread.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
@@ -201,7 +202,7 @@ void ProfileInfoCache::AddProfileToCache(
const std::string& gaia_id,
const base::string16& user_name,
size_t icon_index,
- const std::string& supervised_user_id) {
+ const user_manager::UserID& supervised_user_id) {
std::string key = CacheKeyFromProfilePath(profile_path);
DictionaryPrefUpdate update(prefs_, prefs::kProfileInfoCache);
base::DictionaryValue* cache = update.Get();
@@ -214,7 +215,7 @@ void ProfileInfoCache::AddProfileToCache(
profiles::GetDefaultAvatarIconUrl(icon_index));
// Default value for whether background apps are running is false.
info->SetBoolean(kBackgroundAppsKey, false);
- info->SetString(kSupervisedUserId, supervised_user_id);
+ info->SetString(kSupervisedUserId, supervised_user_id.GetUserEmail());
info->SetBoolean(kIsOmittedFromProfileListKey, !supervised_user_id.empty());
info->SetBoolean(kProfileIsEphemeral, false);
info->SetBoolean(kIsUsingDefaultNameKey, IsDefaultProfileName(name));
@@ -414,7 +415,7 @@ bool ProfileInfoCache::ProfileIsSupervisedAtIndex(size_t index) const {
bool ProfileInfoCache::ProfileIsChildAtIndex(size_t index) const {
#if defined(ENABLE_SUPERVISED_USERS)
return GetSupervisedUserIdOfProfileAtIndex(index) ==
- supervised_users::kChildAccountSUID;
+ supervised_users::GetChildAccountSUID();
#else
return false;
#endif
@@ -437,12 +438,12 @@ bool ProfileInfoCache::ProfileIsSigninRequiredAtIndex(size_t index) const {
return value;
}
-std::string ProfileInfoCache::GetSupervisedUserIdOfProfileAtIndex(
+user_manager::UserID ProfileInfoCache::GetSupervisedUserIdOfProfileAtIndex(
size_t index) const {
- std::string supervised_user_id;
+ std::string supervised_user_email;
GetInfoForProfileAtIndex(index)->GetString(kSupervisedUserId,
- &supervised_user_id);
- return supervised_user_id;
+ &supervised_user_email);
+ return user_manager::UserID::FromUserEmail(supervised_user_email);
}
bool ProfileInfoCache::ProfileIsEphemeralAtIndex(size_t index) const {
@@ -602,12 +603,12 @@ void ProfileInfoCache::SetIsOmittedProfileAtIndex(size_t index,
void ProfileInfoCache::SetSupervisedUserIdOfProfileAtIndex(
size_t index,
- const std::string& id) {
+ const user_manager::UserID& id) {
if (GetSupervisedUserIdOfProfileAtIndex(index) == id)
return;
scoped_ptr<base::DictionaryValue> info(
GetInfoForProfileAtIndex(index)->DeepCopy());
- info->SetString(kSupervisedUserId, id);
+ info->SetString(kSupervisedUserId, id.GetUserEmail());
// This takes ownership of |info|.
SetInfoForProfileAtIndex(index, info.release());

Powered by Google App Engine
This is Rietveld 408576698