Chromium Code Reviews| 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 26 matching lines...) Expand all Loading... | |
| 57 user_manager::UserManager::Get()->GetLRULoggedInUsers()[index]; | 58 user_manager::UserManager::Get()->GetLRULoggedInUsers()[index]; |
| 58 CHECK(user); | 59 CHECK(user); |
| 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 return user_id.empty() ? NULL |
| 68 user_manager::UserManager::Get()->FindUser(user_id); | 69 : multi_user_util::GetProfileFromUserID(user_id); |
|
xdai1
2015/04/10 22:56:07
I think it might be more cleaner to get profile th
oshima
2015/04/10 23:44:36
lgtm
| |
| 69 DCHECK(user); | 70 } |
| 70 return chromeos::ProfileHelper::Get()->GetProfileByUserUnsafe(user); | 71 |
| 72 content::BrowserContext* | |
| 73 SessionStateDelegateChromeos::GetUserPresentingBrowserContextForWindow( | |
| 74 aura::Window* window) { | |
| 75 const std::string& user_id = | |
| 76 chrome::MultiUserWindowManager::GetInstance()->GetUserPresentingWindow( | |
| 77 window); | |
| 78 return user_id.empty() ? NULL | |
| 79 : multi_user_util::GetProfileFromUserID(user_id); | |
| 71 } | 80 } |
| 72 | 81 |
| 73 int SessionStateDelegateChromeos::GetMaximumNumberOfLoggedInUsers() const { | 82 int SessionStateDelegateChromeos::GetMaximumNumberOfLoggedInUsers() const { |
| 74 // We limit list of logged in users to 10 due to memory constraints. | 83 // 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 | 84 // Note that 10 seems excessive, but we want to test how many users are |
| 76 // actually added to a session. | 85 // actually added to a session. |
| 77 // TODO(nkostylev): Adjust this limitation based on device capabilites. | 86 // TODO(nkostylev): Adjust this limitation based on device capabilites. |
| 78 // http://crbug.com/230865 | 87 // http://crbug.com/230865 |
| 79 return 10; | 88 return 10; |
| 80 } | 89 } |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 284 } | 293 } |
| 285 | 294 |
| 286 void DoSwitchUser(const std::string& user_id) { | 295 void DoSwitchUser(const std::string& user_id) { |
| 287 user_manager::UserManager::Get()->SwitchActiveUser(user_id); | 296 user_manager::UserManager::Get()->SwitchActiveUser(user_id); |
| 288 } | 297 } |
| 289 | 298 |
| 290 void SessionStateDelegateChromeos::TryToSwitchUser( | 299 void SessionStateDelegateChromeos::TryToSwitchUser( |
| 291 const std::string& user_id) { | 300 const std::string& user_id) { |
| 292 ash::TrySwitchingActiveUser(base::Bind(&DoSwitchUser, user_id)); | 301 ash::TrySwitchingActiveUser(base::Bind(&DoSwitchUser, user_id)); |
| 293 } | 302 } |
| OLD | NEW |