| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/ash/chrome_shell_content_state.h" | 5 #include "chrome/browser/ui/ash/chrome_shell_content_state.h" |
| 6 | 6 |
| 7 #include "ash/session/session_state_delegate.h" | 7 #include "ash/session/session_state_delegate.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 9 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 10 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" | 10 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" |
| 11 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" | 11 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" |
| 12 #include "components/signin/core/account_id/account_id.h" |
| 12 #include "components/user_manager/user_manager.h" | 13 #include "components/user_manager/user_manager.h" |
| 13 #include "content/public/browser/browser_context.h" | 14 #include "content/public/browser/browser_context.h" |
| 14 | 15 |
| 15 content::BrowserContext* ChromeShellContentState::GetBrowserContextByIndex( | 16 content::BrowserContext* ChromeShellContentState::GetBrowserContextByIndex( |
| 16 ash::UserIndex index) { | 17 ash::UserIndex index) { |
| 17 ash::SessionStateDelegate* session_state_delegate = | 18 ash::SessionStateDelegate* session_state_delegate = |
| 18 ash::Shell::GetInstance()->session_state_delegate(); | 19 ash::Shell::GetInstance()->session_state_delegate(); |
| 19 DCHECK_LT(index, session_state_delegate->NumberOfLoggedInUsers()); | 20 DCHECK_LT(index, session_state_delegate->NumberOfLoggedInUsers()); |
| 20 user_manager::User* user = | 21 user_manager::User* user = |
| 21 user_manager::UserManager::Get()->GetLRULoggedInUsers()[index]; | 22 user_manager::UserManager::Get()->GetLRULoggedInUsers()[index]; |
| 22 CHECK(user); | 23 CHECK(user); |
| 23 return chromeos::ProfileHelper::Get()->GetProfileByUser(user); | 24 return chromeos::ProfileHelper::Get()->GetProfileByUser(user); |
| 24 } | 25 } |
| 25 | 26 |
| 26 content::BrowserContext* ChromeShellContentState::GetBrowserContextForWindow( | 27 content::BrowserContext* ChromeShellContentState::GetBrowserContextForWindow( |
| 27 aura::Window* window) { | 28 aura::Window* window) { |
| 28 const std::string& user_id = | 29 const AccountId& account_id = |
| 29 chrome::MultiUserWindowManager::GetInstance()->GetWindowOwner(window); | 30 chrome::MultiUserWindowManager::GetInstance()->GetWindowOwner(window); |
| 30 return user_id.empty() ? nullptr | 31 return account_id.is_valid() |
| 31 : multi_user_util::GetProfileFromUserID(user_id); | 32 ? multi_user_util::GetProfileFromAccountId(account_id) |
| 33 : nullptr; |
| 32 } | 34 } |
| 33 | 35 |
| 34 content::BrowserContext* | 36 content::BrowserContext* |
| 35 ChromeShellContentState::GetUserPresentingBrowserContextForWindow( | 37 ChromeShellContentState::GetUserPresentingBrowserContextForWindow( |
| 36 aura::Window* window) { | 38 aura::Window* window) { |
| 37 const std::string& user_id = | 39 const AccountId& account_id = |
| 38 chrome::MultiUserWindowManager::GetInstance()->GetUserPresentingWindow( | 40 chrome::MultiUserWindowManager::GetInstance()->GetUserPresentingWindow( |
| 39 window); | 41 window); |
| 40 return user_id.empty() ? nullptr | 42 return account_id.is_valid() |
| 41 : multi_user_util::GetProfileFromUserID(user_id); | 43 ? multi_user_util::GetProfileFromAccountId(account_id) |
| 44 : nullptr; |
| 42 } | 45 } |
| OLD | NEW |