| 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/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/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" |
| 20 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
| 21 #include "chrome/grit/generated_resources.h" | 21 #include "chrome/grit/generated_resources.h" |
| 22 #include "components/signin/core/account_id/account_id.h" | |
| 23 #include "components/user_manager/user.h" | 22 #include "components/user_manager/user.h" |
| 24 #include "components/user_manager/user_manager.h" | 23 #include "components/user_manager/user_manager.h" |
| 25 #include "ui/aura/window.h" | 24 #include "ui/aura/window.h" |
| 26 #include "ui/base/l10n/l10n_util.h" | 25 #include "ui/base/l10n/l10n_util.h" |
| 27 #include "ui/base/models/simple_menu_model.h" | 26 #include "ui/base/models/simple_menu_model.h" |
| 28 | 27 |
| 29 namespace chromeos { | 28 namespace chromeos { |
| 30 | 29 |
| 31 namespace { | 30 namespace { |
| 32 | 31 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 : IDC_VISIT_DESKTOP_OF_LRU_USER_3, | 88 : IDC_VISIT_DESKTOP_OF_LRU_USER_3, |
| 90 l10n_util::GetStringFUTF16( | 89 l10n_util::GetStringFUTF16( |
| 91 IDS_VISIT_DESKTOP_OF_LRU_USER, | 90 IDS_VISIT_DESKTOP_OF_LRU_USER, |
| 92 user_info->GetDisplayName(), | 91 user_info->GetDisplayName(), |
| 93 base::ASCIIToUTF16(user_info->GetEmail()))); | 92 base::ASCIIToUTF16(user_info->GetEmail()))); |
| 94 } | 93 } |
| 95 } | 94 } |
| 96 return model.Pass(); | 95 return model.Pass(); |
| 97 } | 96 } |
| 98 | 97 |
| 99 void OnAcceptTeleportWarning(const AccountId& account_id, | 98 void OnAcceptTeleportWarning(const std::string& user_id, |
| 100 aura::Window* window_, | 99 aura::Window* window_, |
| 101 bool no_show_again) { | 100 bool no_show_again) { |
| 102 PrefService* pref = ProfileManager::GetActiveUserProfile()->GetPrefs(); | 101 PrefService* pref = ProfileManager::GetActiveUserProfile()->GetPrefs(); |
| 103 pref->SetBoolean(prefs::kMultiProfileWarningShowDismissed, no_show_again); | 102 pref->SetBoolean(prefs::kMultiProfileWarningShowDismissed, no_show_again); |
| 104 | 103 |
| 105 ash::MultiProfileUMA::RecordTeleportAction( | 104 ash::MultiProfileUMA::RecordTeleportAction( |
| 106 ash::MultiProfileUMA::TELEPORT_WINDOW_CAPTION_MENU); | 105 ash::MultiProfileUMA::TELEPORT_WINDOW_CAPTION_MENU); |
| 107 | 106 |
| 108 chrome::MultiUserWindowManager::GetInstance()->ShowWindowForUser( | 107 chrome::MultiUserWindowManager::GetInstance()->ShowWindowForUser(window_, |
| 109 window_, account_id.GetUserEmail()); | 108 user_id); |
| 110 } | 109 } |
| 111 | 110 |
| 112 void ExecuteVisitDesktopCommand(int command_id, aura::Window* window) { | 111 void ExecuteVisitDesktopCommand(int command_id, aura::Window* window) { |
| 113 switch (command_id) { | 112 switch (command_id) { |
| 114 case IDC_VISIT_DESKTOP_OF_LRU_USER_2: | 113 case IDC_VISIT_DESKTOP_OF_LRU_USER_2: |
| 115 case IDC_VISIT_DESKTOP_OF_LRU_USER_3: { | 114 case IDC_VISIT_DESKTOP_OF_LRU_USER_3: { |
| 116 // When running the multi user mode on Chrome OS, windows can "visit" | 115 // When running the multi user mode on Chrome OS, windows can "visit" |
| 117 // another user's desktop. | 116 // another user's desktop. |
| 118 const AccountId account_id = | 117 const std::string& user_id = |
| 119 ash::Shell::GetInstance() | 118 ash::Shell::GetInstance() |
| 120 ->session_state_delegate() | 119 ->session_state_delegate() |
| 121 ->GetUserInfo(IDC_VISIT_DESKTOP_OF_LRU_USER_2 == command_id ? 1 | 120 ->GetUserInfo(IDC_VISIT_DESKTOP_OF_LRU_USER_2 == command_id ? 1 |
| 122 : 2) | 121 : 2) |
| 123 ->GetAccountId(); | 122 ->GetUserID(); |
| 124 base::Callback<void(bool)> on_accept = | 123 base::Callback<void(bool)> on_accept = |
| 125 base::Bind(&OnAcceptTeleportWarning, account_id, window); | 124 base::Bind(&OnAcceptTeleportWarning, user_id, window); |
| 126 | 125 |
| 127 // Don't show warning dialog if any logged in user in multi-profiles | 126 // Don't show warning dialog if any logged in user in multi-profiles |
| 128 // session dismissed it. | 127 // session dismissed it. |
| 129 const user_manager::UserList logged_in_users = | 128 const user_manager::UserList logged_in_users = |
| 130 user_manager::UserManager::Get()->GetLoggedInUsers(); | 129 user_manager::UserManager::Get()->GetLoggedInUsers(); |
| 131 for (user_manager::UserList::const_iterator it = logged_in_users.begin(); | 130 for (user_manager::UserList::const_iterator it = logged_in_users.begin(); |
| 132 it != logged_in_users.end(); | 131 it != logged_in_users.end(); |
| 133 ++it) { | 132 ++it) { |
| 134 if (multi_user_util::GetProfileFromUserID( | 133 if (multi_user_util::GetProfileFromUserID( |
| 135 multi_user_util::GetUserIDFromEmail((*it)->email()))->GetPrefs()-> | 134 multi_user_util::GetUserIDFromEmail((*it)->email()))->GetPrefs()-> |
| 136 GetBoolean(prefs::kMultiProfileWarningShowDismissed)) { | 135 GetBoolean(prefs::kMultiProfileWarningShowDismissed)) { |
| 137 bool active_user_show_option = | 136 bool active_user_show_option = |
| 138 ProfileManager::GetActiveUserProfile()-> | 137 ProfileManager::GetActiveUserProfile()-> |
| 139 GetPrefs()->GetBoolean(prefs::kMultiProfileWarningShowDismissed); | 138 GetPrefs()->GetBoolean(prefs::kMultiProfileWarningShowDismissed); |
| 140 on_accept.Run(active_user_show_option); | 139 on_accept.Run(active_user_show_option); |
| 141 return; | 140 return; |
| 142 } | 141 } |
| 143 } | 142 } |
| 144 chromeos::ShowMultiprofilesWarningDialog(on_accept); | 143 chromeos::ShowMultiprofilesWarningDialog(on_accept); |
| 145 return; | 144 return; |
| 146 } | 145 } |
| 147 default: | 146 default: |
| 148 NOTREACHED(); | 147 NOTREACHED(); |
| 149 } | 148 } |
| 150 } | 149 } |
| OLD | NEW |