| 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_context_menu.h" | 5 #include "chrome/browser/ui/ash/multi_user/multi_user_context_menu.h" |
| 6 | 6 |
| 7 #include "ash/common/session/session_state_delegate.h" | 7 #include "ash/common/session/session_state_delegate.h" |
| 8 #include "ash/common/wm_shell.h" |
| 8 #include "ash/multi_profile_uma.h" | 9 #include "ash/multi_profile_uma.h" |
| 9 #include "ash/shell.h" | |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "chrome/app/chrome_command_ids.h" | 14 #include "chrome/app/chrome_command_ids.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/profiles/profile_manager.h" | 16 #include "chrome/browser/profiles/profile_manager.h" |
| 17 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" | 17 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" |
| 18 #include "chrome/browser/ui/ash/multi_user/multi_user_warning_dialog.h" | 18 #include "chrome/browser/ui/ash/multi_user/multi_user_warning_dialog.h" |
| 19 #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" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 int event_flags) { | 62 int event_flags) { |
| 63 ExecuteVisitDesktopCommand(command_id, window_); | 63 ExecuteVisitDesktopCommand(command_id, window_); |
| 64 } | 64 } |
| 65 } // namespace | 65 } // namespace |
| 66 } // namespace chromeos | 66 } // namespace chromeos |
| 67 | 67 |
| 68 std::unique_ptr<ui::MenuModel> CreateMultiUserContextMenu( | 68 std::unique_ptr<ui::MenuModel> CreateMultiUserContextMenu( |
| 69 aura::Window* window) { | 69 aura::Window* window) { |
| 70 std::unique_ptr<ui::MenuModel> model; | 70 std::unique_ptr<ui::MenuModel> model; |
| 71 ash::SessionStateDelegate* delegate = | 71 ash::SessionStateDelegate* delegate = |
| 72 ash::Shell::GetInstance()->session_state_delegate(); | 72 ash::WmShell::Get()->GetSessionStateDelegate(); |
| 73 if (!delegate) | 73 if (!delegate) |
| 74 return model; | 74 return model; |
| 75 | 75 |
| 76 int logged_in_users = delegate->NumberOfLoggedInUsers(); | 76 int logged_in_users = delegate->NumberOfLoggedInUsers(); |
| 77 if (logged_in_users > 1) { | 77 if (logged_in_users > 1) { |
| 78 // If this window is not owned, we don't show the menu addition. | 78 // If this window is not owned, we don't show the menu addition. |
| 79 chrome::MultiUserWindowManager* manager = | 79 chrome::MultiUserWindowManager* manager = |
| 80 chrome::MultiUserWindowManager::GetInstance(); | 80 chrome::MultiUserWindowManager::GetInstance(); |
| 81 const AccountId& account_id = manager->GetWindowOwner(window); | 81 const AccountId& account_id = manager->GetWindowOwner(window); |
| 82 if (!account_id.is_valid() || !window) | 82 if (!account_id.is_valid() || !window) |
| (...skipping 28 matching lines...) Expand all Loading... |
| 111 account_id); | 111 account_id); |
| 112 } | 112 } |
| 113 | 113 |
| 114 void ExecuteVisitDesktopCommand(int command_id, aura::Window* window) { | 114 void ExecuteVisitDesktopCommand(int command_id, aura::Window* window) { |
| 115 switch (command_id) { | 115 switch (command_id) { |
| 116 case IDC_VISIT_DESKTOP_OF_LRU_USER_2: | 116 case IDC_VISIT_DESKTOP_OF_LRU_USER_2: |
| 117 case IDC_VISIT_DESKTOP_OF_LRU_USER_3: { | 117 case IDC_VISIT_DESKTOP_OF_LRU_USER_3: { |
| 118 // When running the multi user mode on Chrome OS, windows can "visit" | 118 // When running the multi user mode on Chrome OS, windows can "visit" |
| 119 // another user's desktop. | 119 // another user's desktop. |
| 120 const AccountId account_id = | 120 const AccountId account_id = |
| 121 ash::Shell::GetInstance() | 121 ash::WmShell::Get() |
| 122 ->session_state_delegate() | 122 ->GetSessionStateDelegate() |
| 123 ->GetUserInfo(IDC_VISIT_DESKTOP_OF_LRU_USER_2 == command_id ? 1 | 123 ->GetUserInfo(IDC_VISIT_DESKTOP_OF_LRU_USER_2 == command_id ? 1 |
| 124 : 2) | 124 : 2) |
| 125 ->GetAccountId(); | 125 ->GetAccountId(); |
| 126 base::Callback<void(bool)> on_accept = | 126 base::Callback<void(bool)> on_accept = |
| 127 base::Bind(&OnAcceptTeleportWarning, account_id, window); | 127 base::Bind(&OnAcceptTeleportWarning, account_id, window); |
| 128 | 128 |
| 129 // Don't show warning dialog if any logged in user in multi-profiles | 129 // Don't show warning dialog if any logged in user in multi-profiles |
| 130 // session dismissed it. | 130 // session dismissed it. |
| 131 const user_manager::UserList logged_in_users = | 131 const user_manager::UserList logged_in_users = |
| 132 user_manager::UserManager::Get()->GetLoggedInUsers(); | 132 user_manager::UserManager::Get()->GetLoggedInUsers(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 143 return; | 143 return; |
| 144 } | 144 } |
| 145 } | 145 } |
| 146 chromeos::ShowMultiprofilesWarningDialog(on_accept); | 146 chromeos::ShowMultiprofilesWarningDialog(on_accept); |
| 147 return; | 147 return; |
| 148 } | 148 } |
| 149 default: | 149 default: |
| 150 NOTREACHED(); | 150 NOTREACHED(); |
| 151 } | 151 } |
| 152 } | 152 } |
| OLD | NEW |