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

Side by Side Diff: trunk/src/chrome/browser/ui/ash/session_state_delegate_chromeos.cc

Issue 260783002: Revert 267158 "CleanUp: Introduce UserInfo. Move session_state s..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/session_state_delegate_chromeos.h" 5 #include "chrome/browser/ui/ash/session_state_delegate_chromeos.h"
6 6
7 #include "ash/multi_profile_uma.h" 7 #include "ash/multi_profile_uma.h"
8 #include "ash/session/session_state_observer.h" 8 #include "ash/session_state_observer.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/prefs/pref_service.h" 11 #include "base/prefs/pref_service.h"
12 #include "chrome/browser/chromeos/login/screen_locker.h" 12 #include "chrome/browser/chromeos/login/screen_locker.h"
13 #include "chrome/browser/chromeos/login/user.h" 13 #include "chrome/browser/chromeos/login/user.h"
14 #include "chrome/browser/chromeos/login/user_adding_screen.h" 14 #include "chrome/browser/chromeos/login/user_adding_screen.h"
15 #include "chrome/browser/chromeos/login/user_manager.h" 15 #include "chrome/browser/chromeos/login/user_manager.h"
16 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/profiles/profile_manager.h" 17 #include "chrome/browser/profiles/profile_manager.h"
18 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" 18 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 return (has_login_manager && !IsActiveUserSessionStarted()) || 125 return (has_login_manager && !IsActiveUserSessionStarted()) ||
126 IsScreenLocked() || 126 IsScreenLocked() ||
127 chromeos::UserAddingScreen::Get()->IsRunning(); 127 chromeos::UserAddingScreen::Get()->IsRunning();
128 } 128 }
129 129
130 ash::SessionStateDelegate::SessionState 130 ash::SessionStateDelegate::SessionState
131 SessionStateDelegateChromeos::GetSessionState() const { 131 SessionStateDelegateChromeos::GetSessionState() const {
132 return session_state_; 132 return session_state_;
133 } 133 }
134 134
135 const ash::UserInfo* SessionStateDelegateChromeos::GetUserInfo( 135 const base::string16 SessionStateDelegateChromeos::GetUserDisplayName(
136 ash::MultiProfileIndex index) const { 136 ash::MultiProfileIndex index) const {
137 DCHECK_LT(index, NumberOfLoggedInUsers()); 137 DCHECK_LT(index, NumberOfLoggedInUsers());
138 return chromeos::UserManager::Get()->GetLRULoggedInUsers()[index]; 138 return chromeos::UserManager::Get()->
139 GetLRULoggedInUsers()[index]->display_name();
139 } 140 }
140 141
141 const ash::UserInfo* SessionStateDelegateChromeos::GetUserInfo( 142 const base::string16 SessionStateDelegateChromeos::GetUserGivenName(
143 ash::MultiProfileIndex index) const {
144 DCHECK_LT(index, NumberOfLoggedInUsers());
145 return chromeos::UserManager::Get()
146 ->GetLRULoggedInUsers()[index]
147 ->given_name();
148 }
149
150 const std::string SessionStateDelegateChromeos::GetUserEmail(
151 ash::MultiProfileIndex index) const {
152 DCHECK_LT(index, NumberOfLoggedInUsers());
153 return chromeos::UserManager::Get()->
154 GetLRULoggedInUsers()[index]->display_email();
155 }
156
157 const std::string SessionStateDelegateChromeos::GetUserID(
158 ash::MultiProfileIndex index) const {
159 DCHECK_LT(index, NumberOfLoggedInUsers());
160 return gaia::CanonicalizeEmail(gaia::SanitizeEmail(
161 chromeos::UserManager::Get()->
162 GetLRULoggedInUsers()[index]->email()));
163 }
164
165 const gfx::ImageSkia& SessionStateDelegateChromeos::GetUserImage(
142 content::BrowserContext* context) const { 166 content::BrowserContext* context) const {
143 DCHECK(context); 167 DCHECK(context);
144 return chromeos::UserManager::Get()->GetUserByProfile( 168 return chromeos::UserManager::Get()->GetUserByProfile(
145 Profile::FromBrowserContext(context)); 169 Profile::FromBrowserContext(context))->image();
146 } 170 }
147 171
148 bool SessionStateDelegateChromeos::ShouldShowAvatar( 172 bool SessionStateDelegateChromeos::ShouldShowAvatar(aura::Window* window) {
149 aura::Window* window) const {
150 return chrome::MultiUserWindowManager::GetInstance()-> 173 return chrome::MultiUserWindowManager::GetInstance()->
151 ShouldShowAvatar(window); 174 ShouldShowAvatar(window);
152 } 175 }
153 176
154 void SessionStateDelegateChromeos::SwitchActiveUser( 177 void SessionStateDelegateChromeos::SwitchActiveUser(
155 const std::string& user_id) { 178 const std::string& user_id) {
156 // Disallow switching to an already active user since that might crash. 179 // Disallow switching to an already active user since that might crash.
157 // Also check that we got a user id and not an email address. 180 // Also check that we got a user id and not an email address.
158 DCHECK_EQ(user_id, 181 DCHECK_EQ(user_id,
159 gaia::CanonicalizeEmail(gaia::SanitizeEmail(user_id))); 182 gaia::CanonicalizeEmail(gaia::SanitizeEmail(user_id)));
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 271
249 session_state_ = new_state; 272 session_state_ = new_state;
250 NotifySessionStateChanged(); 273 NotifySessionStateChanged();
251 } 274 }
252 275
253 void SessionStateDelegateChromeos::NotifySessionStateChanged() { 276 void SessionStateDelegateChromeos::NotifySessionStateChanged() {
254 FOR_EACH_OBSERVER(ash::SessionStateObserver, 277 FOR_EACH_OBSERVER(ash::SessionStateObserver,
255 session_state_observer_list_, 278 session_state_observer_list_,
256 SessionStateChanged(session_state_)); 279 SessionStateChanged(session_state_));
257 } 280 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698