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

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

Issue 1704623002: GetProfileFromAccountId() should not return a null point if a valid account id is provided. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add comment. Created 4 years, 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 f9b4655402afffdf0233e9f03ae972856083c478..c273936497f34c1a98de094902c66fd42c4c2eea 100644
--- a/chrome/browser/ui/ash/multi_user/multi_user_util.cc
+++ b/chrome/browser/ui/ash/multi_user/multi_user_util.cc
@@ -15,6 +15,7 @@
#include "google_apis/gaia/gaia_auth_util.h"
#if defined(OS_CHROMEOS)
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h"
#include "components/user_manager/user_manager.h"
#endif
@@ -36,7 +37,7 @@ AccountId GetAccountIdFromEmail(const std::string& email) {
Profile* GetProfileFromAccountId(const AccountId& account_id) {
// Unit tests can end up here without a |g_browser_process|.
if (!g_browser_process || !g_browser_process->profile_manager())
- return NULL;
+ return nullptr;
std::vector<Profile*> profiles =
g_browser_process->profile_manager()->GetLoadedProfiles();
@@ -46,7 +47,21 @@ Profile* GetProfileFromAccountId(const AccountId& account_id) {
if (GetAccountIdFromProfile(*profile_iterator) == account_id)
return *profile_iterator;
}
- return NULL;
+
+#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;
}
Profile* GetProfileFromWindow(aura::Window* window) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698