| 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/common/session/session_state_delegate.h" | 7 #include "ash/common/session/session_state_delegate.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/common/wm_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/signin/core/account_id/account_id.h" |
| 13 #include "components/user_manager/user_manager.h" | 13 #include "components/user_manager/user_manager.h" |
| 14 #include "content/public/browser/browser_context.h" | 14 #include "content/public/browser/browser_context.h" |
| 15 | 15 |
| 16 content::BrowserContext* ChromeShellContentState::GetBrowserContextByIndex( | 16 content::BrowserContext* ChromeShellContentState::GetBrowserContextByIndex( |
| 17 ash::UserIndex index) { | 17 ash::UserIndex index) { |
| 18 ash::SessionStateDelegate* session_state_delegate = | 18 ash::SessionStateDelegate* session_state_delegate = |
| 19 ash::Shell::GetInstance()->session_state_delegate(); | 19 ash::WmShell::Get()->GetSessionStateDelegate(); |
| 20 DCHECK_LT(index, session_state_delegate->NumberOfLoggedInUsers()); | 20 DCHECK_LT(index, session_state_delegate->NumberOfLoggedInUsers()); |
| 21 user_manager::User* user = | 21 user_manager::User* user = |
| 22 user_manager::UserManager::Get()->GetLRULoggedInUsers()[index]; | 22 user_manager::UserManager::Get()->GetLRULoggedInUsers()[index]; |
| 23 CHECK(user); | 23 CHECK(user); |
| 24 return chromeos::ProfileHelper::Get()->GetProfileByUser(user); | 24 return chromeos::ProfileHelper::Get()->GetProfileByUser(user); |
| 25 } | 25 } |
| 26 | 26 |
| 27 content::BrowserContext* ChromeShellContentState::GetBrowserContextForWindow( | 27 content::BrowserContext* ChromeShellContentState::GetBrowserContextForWindow( |
| 28 aura::Window* window) { | 28 aura::Window* window) { |
| 29 const AccountId& account_id = | 29 const AccountId& account_id = |
| 30 chrome::MultiUserWindowManager::GetInstance()->GetWindowOwner(window); | 30 chrome::MultiUserWindowManager::GetInstance()->GetWindowOwner(window); |
| 31 return account_id.is_valid() | 31 return account_id.is_valid() |
| 32 ? multi_user_util::GetProfileFromAccountId(account_id) | 32 ? multi_user_util::GetProfileFromAccountId(account_id) |
| 33 : nullptr; | 33 : nullptr; |
| 34 } | 34 } |
| 35 | 35 |
| 36 content::BrowserContext* | 36 content::BrowserContext* |
| 37 ChromeShellContentState::GetUserPresentingBrowserContextForWindow( | 37 ChromeShellContentState::GetUserPresentingBrowserContextForWindow( |
| 38 aura::Window* window) { | 38 aura::Window* window) { |
| 39 const AccountId& account_id = | 39 const AccountId& account_id = |
| 40 chrome::MultiUserWindowManager::GetInstance()->GetUserPresentingWindow( | 40 chrome::MultiUserWindowManager::GetInstance()->GetUserPresentingWindow( |
| 41 window); | 41 window); |
| 42 return account_id.is_valid() | 42 return account_id.is_valid() |
| 43 ? multi_user_util::GetProfileFromAccountId(account_id) | 43 ? multi_user_util::GetProfileFromAccountId(account_id) |
| 44 : nullptr; | 44 : nullptr; |
| 45 } | 45 } |
| OLD | NEW |