| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/multi_user/multi_user_util.h" | 5 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" |
| 6 | 6 |
| 7 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 7 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" | 9 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" |
| 10 #include "components/signin/core/account_id/account_id.h" | 10 #include "components/signin/core/account_id/account_id.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 | 52 |
| 53 const AccountId GetCurrentAccountId() { | 53 const AccountId GetCurrentAccountId() { |
| 54 const user_manager::User* user = | 54 const user_manager::User* user = |
| 55 user_manager::UserManager::Get()->GetActiveUser(); | 55 user_manager::UserManager::Get()->GetActiveUser(); |
| 56 // In unit tests user login phase is usually skipped. | 56 // In unit tests user login phase is usually skipped. |
| 57 return user ? user->GetAccountId() : EmptyAccountId(); | 57 return user ? user->GetAccountId() : EmptyAccountId(); |
| 58 } | 58 } |
| 59 | 59 |
| 60 // Move the window to the current user's desktop. | 60 // Move the window to the current user's desktop. |
| 61 void MoveWindowToCurrentDesktop(aura::Window* window) { | 61 void MoveWindowToCurrentDesktop(aura::Window* window) { |
| 62 if (!chrome::MultiUserWindowManager::GetInstance()->IsWindowOnDesktopOfUser( | 62 chrome::MultiUserWindowManager* manager = |
| 63 window, GetCurrentAccountId())) { | 63 chrome::MultiUserWindowManager::GetInstance(); |
| 64 chrome::MultiUserWindowManager::GetInstance()->ShowWindowForUser( | 64 |
| 65 window, GetCurrentAccountId()); | 65 // Some unit tests have no manager instantiated. |
| 66 } | 66 if (!manager) |
| 67 return; |
| 68 |
| 69 if (!manager->IsWindowOnDesktopOfUser(window, GetCurrentAccountId())) |
| 70 manager->ShowWindowForUser(window, GetCurrentAccountId()); |
| 67 } | 71 } |
| 68 | 72 |
| 69 } // namespace multi_user_util | 73 } // namespace multi_user_util |
| OLD | NEW |