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

Unified Diff: chrome/browser/chromeos/policy/device_local_account.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/chromeos/policy/device_local_account.cc
diff --git a/chrome/browser/chromeos/policy/device_local_account.cc b/chrome/browser/chromeos/policy/device_local_account.cc
index 63c7a14778f00948bb286a471db6b78e375ad8d6..eb4e45feabd3b7e51aa1389a7f27be7a24583338 100644
--- a/chrome/browser/chromeos/policy/device_local_account.cc
+++ b/chrome/browser/chromeos/policy/device_local_account.cc
@@ -16,6 +16,7 @@
#include "chrome/browser/chromeos/settings/cros_settings.h"
#include "chromeos/login/user_names.h"
#include "chromeos/settings/cros_settings_names.h"
+#include "components/user_manager/user_id.h"
#include "google_apis/gaia/gaia_auth_util.h"
namespace policy {
@@ -42,7 +43,7 @@ DeviceLocalAccount::DeviceLocalAccount(Type type,
DeviceLocalAccount::~DeviceLocalAccount() {
}
-std::string GenerateDeviceLocalAccountUserId(const std::string& account_id,
+user_manager::UserID GenerateDeviceLocalAccountUserId(const std::string& account_id,
DeviceLocalAccount::Type type) {
std::string domain_prefix;
switch (type) {
@@ -56,18 +57,20 @@ std::string GenerateDeviceLocalAccountUserId(const std::string& account_id,
NOTREACHED();
break;
}
- return gaia::CanonicalizeEmail(
+
+ const std::string email = gaia::CanonicalizeEmail(
base::HexEncode(account_id.c_str(), account_id.size()) + "@" +
domain_prefix + kDeviceLocalAccountDomainSuffix);
+ return user_manager::UserID(std::string() /* gaia_id */, email);
}
-bool IsDeviceLocalAccountUser(const std::string& user_id,
+bool IsDeviceLocalAccountUser(const user_manager::UserID& user_id,
DeviceLocalAccount::Type* type) {
// For historical reasons, the guest user ID does not contain an @ symbol and
// therefore, cannot be parsed by gaia::ExtractDomainName().
- if (user_id == chromeos::login::kGuestUserName)
+ if (user_id == chromeos::login::GetGuestUserID())
return false;
- const std::string domain = gaia::ExtractDomainName(user_id);
+ const std::string domain = gaia::ExtractDomainName(user_id.GetUserEmail());
if (!EndsWith(domain, kDeviceLocalAccountDomainSuffix, true))
return false;

Powered by Google App Engine
This is Rietveld 408576698