| 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" |
| 11 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
| 12 #include "chrome/browser/chromeos/login/screen_locker.h" | 12 #include "chrome/browser/chromeos/login/screen_locker.h" |
| 13 #include "chrome/browser/chromeos/login/user.h" | 13 #include "chrome/browser/chromeos/login/user.h" |
| 14 #include "chrome/browser/chromeos/login/user_adding_screen.h" | 14 #include "chrome/browser/chromeos/login/user_adding_screen.h" |
| 15 #include "chrome/browser/chromeos/login/user_manager.h" | 15 #include "chrome/browser/chromeos/login/user_manager.h" |
| 16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 17 #include "chrome/browser/profiles/profile_manager.h" | 17 #include "chrome/browser/profiles/profile_manager.h" |
| 18 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" | |
| 19 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
| 20 #include "chromeos/chromeos_switches.h" | 19 #include "chromeos/chromeos_switches.h" |
| 21 #include "chromeos/dbus/dbus_thread_manager.h" | 20 #include "chromeos/dbus/dbus_thread_manager.h" |
| 22 #include "chromeos/dbus/session_manager_client.h" | 21 #include "chromeos/dbus/session_manager_client.h" |
| 23 #include "google_apis/gaia/gaia_auth_util.h" | 22 #include "google_apis/gaia/gaia_auth_util.h" |
| 24 | 23 |
| 25 SessionStateDelegateChromeos::SessionStateDelegateChromeos() { | 24 SessionStateDelegateChromeos::SessionStateDelegateChromeos() { |
| 26 chromeos::UserManager::Get()->AddSessionStateObserver(this); | 25 chromeos::UserManager::Get()->AddSessionStateObserver(this); |
| 27 } | 26 } |
| 28 | 27 |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 void SessionStateDelegateChromeos::AddSessionStateObserver( | 185 void SessionStateDelegateChromeos::AddSessionStateObserver( |
| 187 ash::SessionStateObserver* observer) { | 186 ash::SessionStateObserver* observer) { |
| 188 session_state_observer_list_.AddObserver(observer); | 187 session_state_observer_list_.AddObserver(observer); |
| 189 } | 188 } |
| 190 | 189 |
| 191 void SessionStateDelegateChromeos::RemoveSessionStateObserver( | 190 void SessionStateDelegateChromeos::RemoveSessionStateObserver( |
| 192 ash::SessionStateObserver* observer) { | 191 ash::SessionStateObserver* observer) { |
| 193 session_state_observer_list_.RemoveObserver(observer); | 192 session_state_observer_list_.RemoveObserver(observer); |
| 194 } | 193 } |
| 195 | 194 |
| 196 bool SessionStateDelegateChromeos::TransferWindowToDesktopOfUser( | |
| 197 aura::Window* window, | |
| 198 ash::MultiProfileIndex index) { | |
| 199 if (chrome::MultiUserWindowManager::GetMultiProfileMode() != | |
| 200 chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_SEPARATED) | |
| 201 return false; | |
| 202 chrome::MultiUserWindowManager* window_manager = | |
| 203 chrome::MultiUserWindowManager::GetInstance(); | |
| 204 if (window_manager->GetWindowOwner(window).empty()) | |
| 205 return false; | |
| 206 | |
| 207 ash::MultiProfileUMA::RecordTeleportAction( | |
| 208 ash::MultiProfileUMA::TELEPORT_WINDOW_DRAG_AND_DROP); | |
| 209 | |
| 210 DCHECK_LT(index, NumberOfLoggedInUsers()); | |
| 211 window_manager->ShowWindowForUser(window, | |
| 212 chromeos::UserManager::Get()->GetLRULoggedInUsers()[index]->email()); | |
| 213 return true; | |
| 214 } | |
| 215 | |
| 216 void SessionStateDelegateChromeos::ActiveUserChanged( | 195 void SessionStateDelegateChromeos::ActiveUserChanged( |
| 217 const chromeos::User* active_user) { | 196 const chromeos::User* active_user) { |
| 218 FOR_EACH_OBSERVER(ash::SessionStateObserver, | 197 FOR_EACH_OBSERVER(ash::SessionStateObserver, |
| 219 session_state_observer_list_, | 198 session_state_observer_list_, |
| 220 ActiveUserChanged(active_user->email())); | 199 ActiveUserChanged(active_user->email())); |
| 221 } | 200 } |
| 222 | 201 |
| 223 void SessionStateDelegateChromeos::UserAddedToSession( | 202 void SessionStateDelegateChromeos::UserAddedToSession( |
| 224 const chromeos::User* added_user) { | 203 const chromeos::User* added_user) { |
| 225 FOR_EACH_OBSERVER(ash::SessionStateObserver, | 204 FOR_EACH_OBSERVER(ash::SessionStateObserver, |
| 226 session_state_observer_list_, | 205 session_state_observer_list_, |
| 227 UserAddedToSession(added_user->email())); | 206 UserAddedToSession(added_user->email())); |
| 228 } | 207 } |
| OLD | NEW |