| 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 "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
| 12 #include "chrome/browser/chromeos/login/lock/screen_locker.h" | 12 #include "chrome/browser/chromeos/login/lock/screen_locker.h" |
| 13 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" | 13 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" |
| 14 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller.h" |
| 14 #include "chrome/browser/chromeos/login/users/user_manager.h" | 15 #include "chrome/browser/chromeos/login/users/user_manager.h" |
| 15 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 16 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 16 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 17 #include "chrome/browser/profiles/profile_manager.h" | 18 #include "chrome/browser/profiles/profile_manager.h" |
| 18 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" | 19 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" |
| 19 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
| 20 #include "chromeos/chromeos_switches.h" | 21 #include "chromeos/chromeos_switches.h" |
| 21 #include "chromeos/dbus/dbus_thread_manager.h" | 22 #include "chromeos/dbus/dbus_thread_manager.h" |
| 22 #include "chromeos/dbus/session_manager_client.h" | 23 #include "chromeos/dbus/session_manager_client.h" |
| 23 #include "chromeos/login/login_state.h" | 24 #include "chromeos/login/login_state.h" |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 if (it == logged_in_users.begin()) | 201 if (it == logged_in_users.begin()) |
| 201 it = logged_in_users.end(); | 202 it = logged_in_users.end(); |
| 202 user_id = (*(--it))->email(); | 203 user_id = (*(--it))->email(); |
| 203 break; | 204 break; |
| 204 } | 205 } |
| 205 | 206 |
| 206 // Switch using the transformed |user_id|. | 207 // Switch using the transformed |user_id|. |
| 207 chromeos::UserManager::Get()->SwitchActiveUser(user_id); | 208 chromeos::UserManager::Get()->SwitchActiveUser(user_id); |
| 208 } | 209 } |
| 209 | 210 |
| 211 bool SessionStateDelegateChromeos::IsMultiProfileAllowedByPrimaryUserPolicy() |
| 212 const { |
| 213 chromeos::UserManager* user_manager = chromeos::UserManager::Get(); |
| 214 CHECK(user_manager); |
| 215 chromeos::MultiProfileUserController* multi_controller = |
| 216 user_manager->GetMultiProfileUserController(); |
| 217 DCHECK(multi_controller); |
| 218 return multi_controller->GetPrimaryUserPolicy() == |
| 219 chromeos::MultiProfileUserController::ALLOWED; |
| 220 } |
| 221 |
| 210 void SessionStateDelegateChromeos::AddSessionStateObserver( | 222 void SessionStateDelegateChromeos::AddSessionStateObserver( |
| 211 ash::SessionStateObserver* observer) { | 223 ash::SessionStateObserver* observer) { |
| 212 session_state_observer_list_.AddObserver(observer); | 224 session_state_observer_list_.AddObserver(observer); |
| 213 } | 225 } |
| 214 | 226 |
| 215 void SessionStateDelegateChromeos::RemoveSessionStateObserver( | 227 void SessionStateDelegateChromeos::RemoveSessionStateObserver( |
| 216 ash::SessionStateObserver* observer) { | 228 ash::SessionStateObserver* observer) { |
| 217 session_state_observer_list_.RemoveObserver(observer); | 229 session_state_observer_list_.RemoveObserver(observer); |
| 218 } | 230 } |
| 219 | 231 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 | 263 |
| 252 session_state_ = new_state; | 264 session_state_ = new_state; |
| 253 NotifySessionStateChanged(); | 265 NotifySessionStateChanged(); |
| 254 } | 266 } |
| 255 | 267 |
| 256 void SessionStateDelegateChromeos::NotifySessionStateChanged() { | 268 void SessionStateDelegateChromeos::NotifySessionStateChanged() { |
| 257 FOR_EACH_OBSERVER(ash::SessionStateObserver, | 269 FOR_EACH_OBSERVER(ash::SessionStateObserver, |
| 258 session_state_observer_list_, | 270 session_state_observer_list_, |
| 259 SessionStateChanged(session_state_)); | 271 SessionStateChanged(session_state_)); |
| 260 } | 272 } |
| OLD | NEW |