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

Unified Diff: chrome/browser/ui/ash/multi_user/multi_user_util.cc

Issue 1962463002: Revert of GetAccountIdFromProfile() should not return an empty account id if a valid profile is provided. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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/ui/ash/multi_user/multi_user_util.cc
diff --git a/chrome/browser/ui/ash/multi_user/multi_user_util.cc b/chrome/browser/ui/ash/multi_user/multi_user_util.cc
index 5b46b3784468d0f854f85641033c3b10e1edebc9..c273936497f34c1a98de094902c66fd42c4c2eea 100644
--- a/chrome/browser/ui/ash/multi_user/multi_user_util.cc
+++ b/chrome/browser/ui/ash/multi_user/multi_user_util.cc
@@ -23,21 +23,8 @@
namespace multi_user_util {
AccountId GetAccountIdFromProfile(Profile* profile) {
-#if defined(OS_CHROMEOS)
- // If in a session the refresh token is revoked, GetProfileUserName() might
- // returns an empty user email which will cause GetAccountIdFromProfile()
- // returns an empty account id, which might cause weird behaviors or crash.
- // Note: If the refresh token is revoked because the user changes his GAIA
- // password, we will force log out the user within 120 seconds. See crbug.com/
- // 587318 for more detail.
- const user_manager::User* user =
- chromeos::ProfileHelper::Get()->GetUserByProfile(
- profile->GetOriginalProfile());
- return user ? user->GetAccountId() : EmptyAccountId();
-#else
return GetAccountIdFromEmail(
profile->GetOriginalProfile()->GetProfileUserName());
-#endif
}
AccountId GetAccountIdFromEmail(const std::string& email) {
@@ -60,6 +47,19 @@
if (GetAccountIdFromProfile(*profile_iterator) == account_id)
return *profile_iterator;
}
+
+#if defined(OS_CHROMEOS)
+ // If in a session the refresh token is revoked, GetAccountIdFromProfile()
+ // returns an empty account id which will cause the profile not being fetched
+ // properly. In this case we fall back to use GetProfileByUser() function.
+ // Note: If the refresh token is revoked because the user changes his GAIA
+ // password, we will force log out the user within 120 seconds. See crbug.com/
+ // 587318 for more detail.
+ const user_manager::User* user =
+ user_manager::UserManager::Get()->FindUser(account_id);
+ if (user)
+ return chromeos::ProfileHelper::Get()->GetProfileByUser(user);
+#endif
return nullptr;
}

Powered by Google App Engine
This is Rietveld 408576698