Chromium Code Reviews| 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" | |
| 22 #include "components/user_manager/user.h" | 23 #include "components/user_manager/user.h" |
| 23 #include "components/user_manager/user_manager.h" | 24 #include "components/user_manager/user_manager.h" |
| 24 #include "ui/aura/window.h" | 25 #include "ui/aura/window.h" |
| 25 #include "ui/base/l10n/l10n_util.h" | 26 #include "ui/base/l10n/l10n_util.h" |
| 26 #include "ui/base/models/simple_menu_model.h" | 27 #include "ui/base/models/simple_menu_model.h" |
| 27 | 28 |
| 28 namespace chromeos { | 29 namespace chromeos { |
| 29 | 30 |
| 30 namespace { | 31 namespace { |
| 31 | 32 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 112 switch (command_id) { | 113 switch (command_id) { |
| 113 case IDC_VISIT_DESKTOP_OF_LRU_USER_2: | 114 case IDC_VISIT_DESKTOP_OF_LRU_USER_2: |
| 114 case IDC_VISIT_DESKTOP_OF_LRU_USER_3: { | 115 case IDC_VISIT_DESKTOP_OF_LRU_USER_3: { |
| 115 // When running the multi user mode on Chrome OS, windows can "visit" | 116 // When running the multi user mode on Chrome OS, windows can "visit" |
| 116 // another user's desktop. | 117 // another user's desktop. |
| 117 const std::string& user_id = | 118 const std::string& user_id = |
| 118 ash::Shell::GetInstance() | 119 ash::Shell::GetInstance() |
| 119 ->session_state_delegate() | 120 ->session_state_delegate() |
| 120 ->GetUserInfo(IDC_VISIT_DESKTOP_OF_LRU_USER_2 == command_id ? 1 | 121 ->GetUserInfo(IDC_VISIT_DESKTOP_OF_LRU_USER_2 == command_id ? 1 |
| 121 : 2) | 122 : 2) |
| 122 ->GetUserID(); | 123 ->GetUserID() |
| 124 .GetUserEmail(); | |
| 123 base::Callback<void(bool)> on_accept = | 125 base::Callback<void(bool)> on_accept = |
| 124 base::Bind(&OnAcceptTeleportWarning, user_id, window); | 126 base::Bind(&OnAcceptTeleportWarning, user_id, window); |
|
stevenjb
2015/10/22 17:52:36
I would change OnAcceptTeleportWarning to take an
Alexander Alekseev
2015/10/23 09:11:23
Done.
| |
| 125 | 127 |
| 126 // Don't show warning dialog if any logged in user in multi-profiles | 128 // Don't show warning dialog if any logged in user in multi-profiles |
| 127 // session dismissed it. | 129 // session dismissed it. |
| 128 const user_manager::UserList logged_in_users = | 130 const user_manager::UserList logged_in_users = |
| 129 user_manager::UserManager::Get()->GetLoggedInUsers(); | 131 user_manager::UserManager::Get()->GetLoggedInUsers(); |
| 130 for (user_manager::UserList::const_iterator it = logged_in_users.begin(); | 132 for (user_manager::UserList::const_iterator it = logged_in_users.begin(); |
| 131 it != logged_in_users.end(); | 133 it != logged_in_users.end(); |
| 132 ++it) { | 134 ++it) { |
| 133 if (multi_user_util::GetProfileFromUserID( | 135 if (multi_user_util::GetProfileFromUserID( |
| 134 multi_user_util::GetUserIDFromEmail((*it)->email()))->GetPrefs()-> | 136 multi_user_util::GetUserIDFromEmail((*it)->email()))->GetPrefs()-> |
| 135 GetBoolean(prefs::kMultiProfileWarningShowDismissed)) { | 137 GetBoolean(prefs::kMultiProfileWarningShowDismissed)) { |
| 136 bool active_user_show_option = | 138 bool active_user_show_option = |
| 137 ProfileManager::GetActiveUserProfile()-> | 139 ProfileManager::GetActiveUserProfile()-> |
| 138 GetPrefs()->GetBoolean(prefs::kMultiProfileWarningShowDismissed); | 140 GetPrefs()->GetBoolean(prefs::kMultiProfileWarningShowDismissed); |
| 139 on_accept.Run(active_user_show_option); | 141 on_accept.Run(active_user_show_option); |
| 140 return; | 142 return; |
| 141 } | 143 } |
| 142 } | 144 } |
| 143 chromeos::ShowMultiprofilesWarningDialog(on_accept); | 145 chromeos::ShowMultiprofilesWarningDialog(on_accept); |
| 144 return; | 146 return; |
| 145 } | 147 } |
| 146 default: | 148 default: |
| 147 NOTREACHED(); | 149 NOTREACHED(); |
| 148 } | 150 } |
| 149 } | 151 } |
| OLD | NEW |