| 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 ef2e7cd29a88a8eae74fe71ff9bd7183a89c488e..b00fb431f9193e349d4059bf40cb5674e91524f2 100644
|
| --- a/chrome/browser/ui/ash/multi_user/multi_user_util.cc
|
| +++ b/chrome/browser/ui/ash/multi_user/multi_user_util.cc
|
| @@ -4,24 +4,21 @@
|
|
|
| #include "chrome/browser/ui/ash/multi_user/multi_user_util.h"
|
|
|
| -#include <vector>
|
| -
|
| -#include "base/strings/string_util.h"
|
| -#include "build/build_config.h"
|
| -#include "chrome/browser/browser_process.h"
|
| #include "chrome/browser/chromeos/profiles/profile_helper.h"
|
| #include "chrome/browser/profiles/profile.h"
|
| -#include "chrome/browser/profiles/profile_manager.h"
|
| #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h"
|
| #include "components/signin/core/account_id/account_id.h"
|
| #include "components/user_manager/user_manager.h"
|
| -#include "google_apis/gaia/gaia_auth_util.h"
|
|
|
| namespace multi_user_util {
|
|
|
| AccountId GetAccountIdFromProfile(Profile* profile) {
|
| - return GetAccountIdFromEmail(
|
| - profile->GetOriginalProfile()->GetProfileUserName());
|
| + // This will guarantee an nonempty AccountId be returned if a valid profile is
|
| + // provided.
|
| + const user_manager::User* user =
|
| + chromeos::ProfileHelper::Get()->GetUserByProfile(
|
| + profile->GetOriginalProfile());
|
| + return user ? user->GetAccountId() : EmptyAccountId();
|
| }
|
|
|
| AccountId GetAccountIdFromEmail(const std::string& email) {
|
| @@ -32,31 +29,10 @@ 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 nullptr;
|
| -
|
| - std::vector<Profile*> profiles =
|
| - g_browser_process->profile_manager()->GetLoadedProfiles();
|
| -
|
| - std::vector<Profile*>::const_iterator profile_iterator = profiles.begin();
|
| - for (; profile_iterator != profiles.end(); ++profile_iterator) {
|
| - if (GetAccountIdFromProfile(*profile_iterator) == account_id)
|
| - return *profile_iterator;
|
| - }
|
| -
|
| - // 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);
|
| -
|
| - return nullptr;
|
| + return user ? chromeos::ProfileHelper::Get()->GetProfileByUser(user)
|
| + : nullptr;
|
| }
|
|
|
| Profile* GetProfileFromWindow(aura::Window* window) {
|
|
|