Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(116)

Side by Side Diff: chrome/browser/ui/ash/multi_user/multi_user_context_menu_chromeos.cc

Issue 1165323004: We should use UserID object to identify users instead of username. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 ash::SessionStateDelegate* delegate = 68 ash::SessionStateDelegate* delegate =
69 ash::Shell::GetInstance()->session_state_delegate(); 69 ash::Shell::GetInstance()->session_state_delegate();
70 if (!delegate) 70 if (!delegate)
71 return model.Pass(); 71 return model.Pass();
72 72
73 int logged_in_users = delegate->NumberOfLoggedInUsers(); 73 int logged_in_users = delegate->NumberOfLoggedInUsers();
74 if (logged_in_users > 1) { 74 if (logged_in_users > 1) {
75 // If this window is not owned, we don't show the menu addition. 75 // If this window is not owned, we don't show the menu addition.
76 chrome::MultiUserWindowManager* manager = 76 chrome::MultiUserWindowManager* manager =
77 chrome::MultiUserWindowManager::GetInstance(); 77 chrome::MultiUserWindowManager::GetInstance();
78 const std::string user_id = manager->GetWindowOwner(window); 78 const user_manager::UserID user_id = manager->GetWindowOwner(window);
79 if (user_id.empty() || !window) 79 if (user_id.empty() || !window)
80 return model.Pass(); 80 return model.Pass();
81 chromeos::MultiUserContextMenuChromeos* menu = 81 chromeos::MultiUserContextMenuChromeos* menu =
82 new chromeos::MultiUserContextMenuChromeos(window); 82 new chromeos::MultiUserContextMenuChromeos(window);
83 model.reset(menu); 83 model.reset(menu);
84 for (int user_index = 1; user_index < logged_in_users; ++user_index) { 84 for (int user_index = 1; user_index < logged_in_users; ++user_index) {
85 const user_manager::UserInfo* user_info = 85 const user_manager::UserInfo* user_info =
86 delegate->GetUserInfo(user_index); 86 delegate->GetUserInfo(user_index);
87 menu->AddItem(user_index == 1 ? IDC_VISIT_DESKTOP_OF_LRU_USER_2 87 menu->AddItem(user_index == 1 ? IDC_VISIT_DESKTOP_OF_LRU_USER_2
88 : IDC_VISIT_DESKTOP_OF_LRU_USER_3, 88 : IDC_VISIT_DESKTOP_OF_LRU_USER_3,
89 l10n_util::GetStringFUTF16( 89 l10n_util::GetStringFUTF16(
90 IDS_VISIT_DESKTOP_OF_LRU_USER, 90 IDS_VISIT_DESKTOP_OF_LRU_USER,
91 user_info->GetDisplayName(), 91 user_info->GetDisplayName(),
92 base::ASCIIToUTF16(user_info->GetEmail()))); 92 base::ASCIIToUTF16(user_info->GetEmail())));
93 } 93 }
94 } 94 }
95 return model.Pass(); 95 return model.Pass();
96 } 96 }
97 97
98 void OnAcceptTeleportWarning( 98 void OnAcceptTeleportWarning(
99 const std::string user_id, aura::Window* window_, bool no_show_again) { 99 const user_manager::UserID user_id, aura::Window* window_, bool no_show_agai n) {
100 PrefService* pref = ProfileManager::GetActiveUserProfile()->GetPrefs(); 100 PrefService* pref = ProfileManager::GetActiveUserProfile()->GetPrefs();
101 pref->SetBoolean(prefs::kMultiProfileWarningShowDismissed, no_show_again); 101 pref->SetBoolean(prefs::kMultiProfileWarningShowDismissed, no_show_again);
102 102
103 ash::MultiProfileUMA::RecordTeleportAction( 103 ash::MultiProfileUMA::RecordTeleportAction(
104 ash::MultiProfileUMA::TELEPORT_WINDOW_CAPTION_MENU); 104 ash::MultiProfileUMA::TELEPORT_WINDOW_CAPTION_MENU);
105 105
106 chrome::MultiUserWindowManager::GetInstance()->ShowWindowForUser(window_, 106 chrome::MultiUserWindowManager::GetInstance()->ShowWindowForUser(window_,
107 user_id); 107 user_id);
108 } 108 }
109 109
110 void ExecuteVisitDesktopCommand(int command_id, aura::Window* window) { 110 void ExecuteVisitDesktopCommand(int command_id, aura::Window* window) {
111 switch (command_id) { 111 switch (command_id) {
112 case IDC_VISIT_DESKTOP_OF_LRU_USER_2: 112 case IDC_VISIT_DESKTOP_OF_LRU_USER_2:
113 case IDC_VISIT_DESKTOP_OF_LRU_USER_3: { 113 case IDC_VISIT_DESKTOP_OF_LRU_USER_3: {
114 // When running the multi user mode on Chrome OS, windows can "visit" 114 // When running the multi user mode on Chrome OS, windows can "visit"
115 // another user's desktop. 115 // another user's desktop.
116 const std::string& user_id = 116 const user_manager::UserID& user_id =
117 ash::Shell::GetInstance() 117 ash::Shell::GetInstance()
118 ->session_state_delegate() 118 ->session_state_delegate()
119 ->GetUserInfo(IDC_VISIT_DESKTOP_OF_LRU_USER_2 == command_id ? 1 119 ->GetUserInfo(IDC_VISIT_DESKTOP_OF_LRU_USER_2 == command_id ? 1
120 : 2) 120 : 2)
121 ->GetUserID(); 121 ->GetUserID();
122 base::Callback<void(bool)> on_accept = 122 base::Callback<void(bool)> on_accept =
123 base::Bind(&OnAcceptTeleportWarning, user_id, window); 123 base::Bind(&OnAcceptTeleportWarning, user_id, window);
124 124
125 // Don't show warning dialog if any logged in user in multi-profiles 125 // Don't show warning dialog if any logged in user in multi-profiles
126 // session dismissed it. 126 // session dismissed it.
127 const user_manager::UserList logged_in_users = 127 const user_manager::UserList logged_in_users =
128 user_manager::UserManager::Get()->GetLoggedInUsers(); 128 user_manager::UserManager::Get()->GetLoggedInUsers();
129 for (user_manager::UserList::const_iterator it = logged_in_users.begin(); 129 for (user_manager::UserList::const_iterator it = logged_in_users.begin();
130 it != logged_in_users.end(); 130 it != logged_in_users.end();
131 ++it) { 131 ++it) {
132 if (multi_user_util::GetProfileFromUserID( 132 if (multi_user_util::GetProfileFromUserID(
133 multi_user_util::GetUserIDFromEmail((*it)->email()))->GetPrefs()-> 133 multi_user_util::GetUserIDFromEmail((*it)->GetUserID().GetUserEmail( )))->GetPrefs()->
134 GetBoolean(prefs::kMultiProfileWarningShowDismissed)) { 134 GetBoolean(prefs::kMultiProfileWarningShowDismissed)) {
135 bool active_user_show_option = 135 bool active_user_show_option =
136 ProfileManager::GetActiveUserProfile()-> 136 ProfileManager::GetActiveUserProfile()->
137 GetPrefs()->GetBoolean(prefs::kMultiProfileWarningShowDismissed); 137 GetPrefs()->GetBoolean(prefs::kMultiProfileWarningShowDismissed);
138 on_accept.Run(active_user_show_option); 138 on_accept.Run(active_user_show_option);
139 return; 139 return;
140 } 140 }
141 } 141 }
142 chromeos::ShowMultiprofilesWarningDialog(on_accept); 142 chromeos::ShowMultiprofilesWarningDialog(on_accept);
143 return; 143 return;
144 } 144 }
145 default: 145 default:
146 NOTREACHED(); 146 NOTREACHED();
147 } 147 }
148 } 148 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698