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/session_state_delegate.h" |
9 #include "ash/shell.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/prefs/pref_service.h" | 12 #include "base/prefs/pref_service.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/chromeos/login/user.h" | 15 #include "chrome/browser/chromeos/login/user.h" |
16 #include "chrome/browser/chromeos/login/user_manager.h" | 16 #include "chrome/browser/chromeos/login/user_manager.h" |
17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
18 #include "chrome/browser/profiles/profile_manager.h" | 18 #include "chrome/browser/profiles/profile_manager.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 // If this window is not owned, we don't show the menu addition. | 80 // If this window is not owned, we don't show the menu addition. |
81 chrome::MultiUserWindowManager* manager = | 81 chrome::MultiUserWindowManager* manager = |
82 chrome::MultiUserWindowManager::GetInstance(); | 82 chrome::MultiUserWindowManager::GetInstance(); |
83 const std::string user_id = manager->GetWindowOwner(window); | 83 const std::string user_id = manager->GetWindowOwner(window); |
84 if (user_id.empty() || !window) | 84 if (user_id.empty() || !window) |
85 return model.Pass(); | 85 return model.Pass(); |
86 chromeos::MultiUserContextMenuChromeos* menu = | 86 chromeos::MultiUserContextMenuChromeos* menu = |
87 new chromeos::MultiUserContextMenuChromeos(window); | 87 new chromeos::MultiUserContextMenuChromeos(window); |
88 model.reset(menu); | 88 model.reset(menu); |
89 for (int user_index = 1; user_index < logged_in_users; ++user_index) { | 89 for (int user_index = 1; user_index < logged_in_users; ++user_index) { |
90 menu->AddItem( | 90 const ash::UserInfo* user_info = delegate->GetUserInfo(user_index); |
91 user_index == 1 ? IDC_VISIT_DESKTOP_OF_LRU_USER_2 : | 91 menu->AddItem(user_index == 1 ? IDC_VISIT_DESKTOP_OF_LRU_USER_2 |
92 IDC_VISIT_DESKTOP_OF_LRU_USER_3, | 92 : IDC_VISIT_DESKTOP_OF_LRU_USER_3, |
93 l10n_util::GetStringFUTF16( | 93 l10n_util::GetStringFUTF16( |
94 IDS_VISIT_DESKTOP_OF_LRU_USER, | 94 IDS_VISIT_DESKTOP_OF_LRU_USER, |
95 delegate->GetUserDisplayName(user_index), | 95 user_info->GetDisplayName(), |
96 base::ASCIIToUTF16(delegate->GetUserEmail(user_index)))); | 96 base::ASCIIToUTF16(user_info->GetEmail()))); |
97 } | 97 } |
98 } | 98 } |
99 return model.Pass(); | 99 return model.Pass(); |
100 } | 100 } |
101 | 101 |
102 void OnAcceptTeleportWarning( | 102 void OnAcceptTeleportWarning( |
103 const std::string user_id, aura::Window* window_, bool no_show_again) { | 103 const std::string user_id, aura::Window* window_, bool no_show_again) { |
104 PrefService* pref = ProfileManager::GetActiveUserProfile()->GetPrefs(); | 104 PrefService* pref = ProfileManager::GetActiveUserProfile()->GetPrefs(); |
105 pref->SetBoolean(prefs::kMultiProfileWarningShowDismissed, no_show_again); | 105 pref->SetBoolean(prefs::kMultiProfileWarningShowDismissed, no_show_again); |
106 | 106 |
107 ash::MultiProfileUMA::RecordTeleportAction( | 107 ash::MultiProfileUMA::RecordTeleportAction( |
108 ash::MultiProfileUMA::TELEPORT_WINDOW_CAPTION_MENU); | 108 ash::MultiProfileUMA::TELEPORT_WINDOW_CAPTION_MENU); |
109 | 109 |
110 chrome::MultiUserWindowManager::GetInstance()->ShowWindowForUser(window_, | 110 chrome::MultiUserWindowManager::GetInstance()->ShowWindowForUser(window_, |
111 user_id); | 111 user_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 std::string& user_id = | 120 const std::string& user_id = |
121 ash::Shell::GetInstance()->session_state_delegate()->GetUserID( | 121 ash::Shell::GetInstance() |
122 IDC_VISIT_DESKTOP_OF_LRU_USER_2 == command_id ? 1 : 2); | 122 ->session_state_delegate() |
| 123 ->GetUserInfo(IDC_VISIT_DESKTOP_OF_LRU_USER_2 == command_id ? 1 |
| 124 : 2) |
| 125 ->GetUserID(); |
123 base::Callback<void(bool)> on_accept = | 126 base::Callback<void(bool)> on_accept = |
124 base::Bind(&OnAcceptTeleportWarning, user_id, window); | 127 base::Bind(&OnAcceptTeleportWarning, user_id, window); |
125 | 128 |
126 // 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 |
127 // session dismissed it. | 130 // session dismissed it. |
128 const chromeos::UserList logged_in_users = | 131 const chromeos::UserList logged_in_users = |
129 chromeos::UserManager::Get()->GetLoggedInUsers(); | 132 chromeos::UserManager::Get()->GetLoggedInUsers(); |
130 for (chromeos::UserList::const_iterator it = logged_in_users.begin(); | 133 for (chromeos::UserList::const_iterator it = logged_in_users.begin(); |
131 it != logged_in_users.end(); ++it) { | 134 it != logged_in_users.end(); ++it) { |
132 if (multi_user_util::GetProfileFromUserID( | 135 if (multi_user_util::GetProfileFromUserID( |
133 multi_user_util::GetUserIDFromEmail((*it)->email()))->GetPrefs()-> | 136 multi_user_util::GetUserIDFromEmail((*it)->email()))->GetPrefs()-> |
134 GetBoolean(prefs::kMultiProfileWarningShowDismissed)) { | 137 GetBoolean(prefs::kMultiProfileWarningShowDismissed)) { |
135 bool active_user_show_option = | 138 bool active_user_show_option = |
136 ProfileManager::GetActiveUserProfile()-> | 139 ProfileManager::GetActiveUserProfile()-> |
137 GetPrefs()->GetBoolean(prefs::kMultiProfileWarningShowDismissed); | 140 GetPrefs()->GetBoolean(prefs::kMultiProfileWarningShowDismissed); |
138 on_accept.Run(active_user_show_option); | 141 on_accept.Run(active_user_show_option); |
139 return; | 142 return; |
140 } | 143 } |
141 } | 144 } |
142 chromeos::ShowMultiprofilesWarningDialog(on_accept); | 145 chromeos::ShowMultiprofilesWarningDialog(on_accept); |
143 return; | 146 return; |
144 } | 147 } |
145 default: | 148 default: |
146 NOTREACHED(); | 149 NOTREACHED(); |
147 } | 150 } |
148 } | 151 } |
OLD | NEW |