| 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/session_state_observer.h" | 8 #include "ash/session/session_state_observer.h" |
| 9 #include "ash/system/chromeos/multi_user/user_switch_util.h" | 9 #include "ash/system/chromeos/multi_user/user_switch_util.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/prefs/pref_service.h" | 14 #include "base/prefs/pref_service.h" |
| 15 #include "chrome/browser/chromeos/login/lock/screen_locker.h" | 15 #include "chrome/browser/chromeos/login/lock/screen_locker.h" |
| 16 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" | 16 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" |
| 17 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h" | 17 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h" |
| 18 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 18 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 19 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
| 20 #include "chrome/browser/profiles/profile_manager.h" | 20 #include "chrome/browser/profiles/profile_manager.h" |
| 21 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" |
| 21 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" | 22 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" |
| 22 #include "chrome/common/pref_names.h" | 23 #include "chrome/common/pref_names.h" |
| 23 #include "chromeos/chromeos_switches.h" | 24 #include "chromeos/chromeos_switches.h" |
| 24 #include "chromeos/dbus/dbus_thread_manager.h" | 25 #include "chromeos/dbus/dbus_thread_manager.h" |
| 25 #include "chromeos/dbus/session_manager_client.h" | 26 #include "chromeos/dbus/session_manager_client.h" |
| 26 #include "chromeos/login/login_state.h" | 27 #include "chromeos/login/login_state.h" |
| 27 #include "components/user_manager/user.h" | 28 #include "components/user_manager/user.h" |
| 28 #include "components/user_manager/user_manager.h" | 29 #include "components/user_manager/user_manager.h" |
| 29 #include "google_apis/gaia/gaia_auth_util.h" | 30 #include "google_apis/gaia/gaia_auth_util.h" |
| 30 | 31 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 59 return chromeos::ProfileHelper::Get()->GetProfileByUserUnsafe(user); | 60 return chromeos::ProfileHelper::Get()->GetProfileByUserUnsafe(user); |
| 60 } | 61 } |
| 61 | 62 |
| 62 content::BrowserContext* | 63 content::BrowserContext* |
| 63 SessionStateDelegateChromeos::GetBrowserContextForWindow( | 64 SessionStateDelegateChromeos::GetBrowserContextForWindow( |
| 64 aura::Window* window) { | 65 aura::Window* window) { |
| 65 const std::string& user_id = | 66 const std::string& user_id = |
| 66 chrome::MultiUserWindowManager::GetInstance()->GetWindowOwner(window); | 67 chrome::MultiUserWindowManager::GetInstance()->GetWindowOwner(window); |
| 67 const user_manager::User* user = | 68 const user_manager::User* user = |
| 68 user_manager::UserManager::Get()->FindUser(user_id); | 69 user_manager::UserManager::Get()->FindUser(user_id); |
| 69 DCHECK(user); | 70 return user ? (chromeos::ProfileHelper::Get()->GetProfileByUserUnsafe(user)) |
| 70 return chromeos::ProfileHelper::Get()->GetProfileByUserUnsafe(user); | 71 : NULL; |
| 72 } |
| 73 |
| 74 content::BrowserContext* |
| 75 SessionStateDelegateChromeos::GetUserPresentingBrowserContextForWindow( |
| 76 aura::Window* window) { |
| 77 const std::string user_id = |
| 78 chrome::MultiUserWindowManager::GetInstance()->GetUserPresentingWindow( |
| 79 window); |
| 80 return multi_user_util::GetProfileFromUserID(user_id); |
| 71 } | 81 } |
| 72 | 82 |
| 73 int SessionStateDelegateChromeos::GetMaximumNumberOfLoggedInUsers() const { | 83 int SessionStateDelegateChromeos::GetMaximumNumberOfLoggedInUsers() const { |
| 74 // We limit list of logged in users to 10 due to memory constraints. | 84 // We limit list of logged in users to 10 due to memory constraints. |
| 75 // Note that 10 seems excessive, but we want to test how many users are | 85 // Note that 10 seems excessive, but we want to test how many users are |
| 76 // actually added to a session. | 86 // actually added to a session. |
| 77 // TODO(nkostylev): Adjust this limitation based on device capabilites. | 87 // TODO(nkostylev): Adjust this limitation based on device capabilites. |
| 78 // http://crbug.com/230865 | 88 // http://crbug.com/230865 |
| 79 return 10; | 89 return 10; |
| 80 } | 90 } |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 } | 294 } |
| 285 | 295 |
| 286 void DoSwitchUser(const std::string& user_id) { | 296 void DoSwitchUser(const std::string& user_id) { |
| 287 user_manager::UserManager::Get()->SwitchActiveUser(user_id); | 297 user_manager::UserManager::Get()->SwitchActiveUser(user_id); |
| 288 } | 298 } |
| 289 | 299 |
| 290 void SessionStateDelegateChromeos::TryToSwitchUser( | 300 void SessionStateDelegateChromeos::TryToSwitchUser( |
| 291 const std::string& user_id) { | 301 const std::string& user_id) { |
| 292 ash::TrySwitchingActiveUser(base::Bind(&DoSwitchUser, user_id)); | 302 ash::TrySwitchingActiveUser(base::Bind(&DoSwitchUser, user_id)); |
| 293 } | 303 } |
| OLD | NEW |