| 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/multi_profile_uma.h" | 7 #include "ash/multi_profile_uma.h" |
| 8 #include "ash/session_state_delegate.h" | 8 #include "ash/session_state_delegate.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 } | 71 } |
| 72 } | 72 } |
| 73 | 73 |
| 74 } // namespace | 74 } // namespace |
| 75 | 75 |
| 76 scoped_ptr<ui::MenuModel> CreateMultiUserContextMenu( | 76 scoped_ptr<ui::MenuModel> CreateMultiUserContextMenu( |
| 77 aura::Window* window) { | 77 aura::Window* window) { |
| 78 scoped_ptr<ui::MenuModel> model; | 78 scoped_ptr<ui::MenuModel> model; |
| 79 ash::SessionStateDelegate* delegate = | 79 ash::SessionStateDelegate* delegate = |
| 80 ash::Shell::GetInstance()->session_state_delegate(); | 80 ash::Shell::GetInstance()->session_state_delegate(); |
| 81 if (!delegate) |
| 82 return model.Pass(); |
| 83 |
| 81 int logged_in_users = delegate->NumberOfLoggedInUsers(); | 84 int logged_in_users = delegate->NumberOfLoggedInUsers(); |
| 82 if (delegate && logged_in_users > 1) { | 85 if (logged_in_users > 1) { |
| 83 // If this window is not owned, we don't show the menu addition. | 86 // If this window is not owned, we don't show the menu addition. |
| 84 chrome::MultiUserWindowManager* manager = | 87 chrome::MultiUserWindowManager* manager = |
| 85 chrome::MultiUserWindowManager::GetInstance(); | 88 chrome::MultiUserWindowManager::GetInstance(); |
| 86 const std::string user_id = manager->GetWindowOwner(window); | 89 const std::string user_id = manager->GetWindowOwner(window); |
| 87 if (user_id.empty() || !window || | 90 if (user_id.empty() || !window || |
| 88 manager->GetWindowOwner(window).empty()) | 91 manager->GetWindowOwner(window).empty()) |
| 89 return model.Pass(); | 92 return model.Pass(); |
| 90 MultiUserContextMenuChromeos* menu = | 93 MultiUserContextMenuChromeos* menu = |
| 91 new MultiUserContextMenuChromeos(window); | 94 new MultiUserContextMenuChromeos(window); |
| 92 model.reset(menu); | 95 model.reset(menu); |
| 93 for (int user_index = 1; user_index < logged_in_users; ++user_index) { | 96 for (int user_index = 1; user_index < logged_in_users; ++user_index) { |
| 94 menu->AddItem( | 97 menu->AddItem( |
| 95 user_index == 1 ? IDC_VISIT_DESKTOP_OF_LRU_USER_2 : | 98 user_index == 1 ? IDC_VISIT_DESKTOP_OF_LRU_USER_2 : |
| 96 IDC_VISIT_DESKTOP_OF_LRU_USER_3, | 99 IDC_VISIT_DESKTOP_OF_LRU_USER_3, |
| 97 l10n_util::GetStringFUTF16(IDS_VISIT_DESKTOP_OF_LRU_USER, | 100 l10n_util::GetStringFUTF16(IDS_VISIT_DESKTOP_OF_LRU_USER, |
| 98 delegate->GetUserDisplayName( | 101 delegate->GetUserDisplayName( |
| 99 user_index))); | 102 user_index))); |
| 100 } | 103 } |
| 101 } | 104 } |
| 102 return model.Pass(); | 105 return model.Pass(); |
| 103 } | 106 } |
| OLD | NEW |