| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/session_state_delegate_chromeos.h" | 5 #include "chrome/browser/ui/ash/session_state_delegate_chromeos.h" |
| 6 | 6 |
| 7 #include "ash/multi_profile_uma.h" | 7 #include "ash/multi_profile_uma.h" |
| 8 #include "ash/session_state_observer.h" | 8 #include "ash/session_state_observer.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 | 31 |
| 32 content::BrowserContext* SessionStateDelegateChromeos::GetBrowserContextByIndex( | 32 content::BrowserContext* SessionStateDelegateChromeos::GetBrowserContextByIndex( |
| 33 ash::MultiProfileIndex index) { | 33 ash::MultiProfileIndex index) { |
| 34 DCHECK_LT(index, NumberOfLoggedInUsers()); | 34 DCHECK_LT(index, NumberOfLoggedInUsers()); |
| 35 chromeos::User* user = | 35 chromeos::User* user = |
| 36 chromeos::UserManager::Get()->GetLRULoggedInUsers()[index]; | 36 chromeos::UserManager::Get()->GetLRULoggedInUsers()[index]; |
| 37 DCHECK(user); | 37 DCHECK(user); |
| 38 return chromeos::UserManager::Get()->GetProfileByUser(user); | 38 return chromeos::UserManager::Get()->GetProfileByUser(user); |
| 39 } | 39 } |
| 40 | 40 |
| 41 content::BrowserContext* |
| 42 SessionStateDelegateChromeos::GetBrowserContextForWindow( |
| 43 aura::Window* window) { |
| 44 const std::string& user_id = |
| 45 chrome::MultiUserWindowManager::GetInstance()->GetWindowOwner(window); |
| 46 const chromeos::User* user = chromeos::UserManager::Get()->FindUser(user_id); |
| 47 DCHECK(user); |
| 48 return chromeos::UserManager::Get()->GetProfileByUser(user); |
| 49 } |
| 50 |
| 41 int SessionStateDelegateChromeos::GetMaximumNumberOfLoggedInUsers() const { | 51 int SessionStateDelegateChromeos::GetMaximumNumberOfLoggedInUsers() const { |
| 42 // We limit list of logged in users to 10 due to memory constraints. | 52 // We limit list of logged in users to 10 due to memory constraints. |
| 43 // Note that 10 seems excessive, but we want to test how many users are | 53 // Note that 10 seems excessive, but we want to test how many users are |
| 44 // actually added to a session. | 54 // actually added to a session. |
| 45 // TODO(nkostylev): Adjust this limitation based on device capabilites. | 55 // TODO(nkostylev): Adjust this limitation based on device capabilites. |
| 46 // http://crbug.com/230865 | 56 // http://crbug.com/230865 |
| 47 return 10; | 57 return 10; |
| 48 } | 58 } |
| 49 | 59 |
| 50 int SessionStateDelegateChromeos::NumberOfLoggedInUsers() const { | 60 int SessionStateDelegateChromeos::NumberOfLoggedInUsers() const { |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 session_state_observer_list_, | 214 session_state_observer_list_, |
| 205 ActiveUserChanged(active_user->email())); | 215 ActiveUserChanged(active_user->email())); |
| 206 } | 216 } |
| 207 | 217 |
| 208 void SessionStateDelegateChromeos::UserAddedToSession( | 218 void SessionStateDelegateChromeos::UserAddedToSession( |
| 209 const chromeos::User* added_user) { | 219 const chromeos::User* added_user) { |
| 210 FOR_EACH_OBSERVER(ash::SessionStateObserver, | 220 FOR_EACH_OBSERVER(ash::SessionStateObserver, |
| 211 session_state_observer_list_, | 221 session_state_observer_list_, |
| 212 UserAddedToSession(added_user->email())); | 222 UserAddedToSession(added_user->email())); |
| 213 } | 223 } |
| OLD | NEW |