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

Side by Side Diff: chrome/browser/chromeos/login/user.cc

Issue 253063002: CleanUp: Introduce UserInfo. Move session_state stuff to ash/session. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix tests 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/chromeos/login/user.h" 5 #include "chrome/browser/chromeos/login/user.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/threading/thread_restrictions.h" 10 #include "base/threading/thread_restrictions.h"
11 #include "chrome/browser/chromeos/login/default_user_images.h" 11 #include "chrome/browser/chromeos/login/default_user_images.h"
12 #include "chrome/browser/chromeos/login/user_manager.h" 12 #include "chrome/browser/chromeos/login/user_manager.h"
13 #include "google_apis/gaia/gaia_auth_util.h"
13 #include "grit/theme_resources.h" 14 #include "grit/theme_resources.h"
14 #include "ui/base/resource/resource_bundle.h" 15 #include "ui/base/resource/resource_bundle.h"
15 16
16 namespace chromeos { 17 namespace chromeos {
17 18
18 namespace { 19 namespace {
19 20
20 // Returns account name portion of an email. 21 // Returns account name portion of an email.
21 std::string GetUserName(const std::string& email) { 22 std::string GetUserName(const std::string& email) {
22 std::string::size_type i = email.find('@'); 23 std::string::size_type i = email.find('@');
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 username = other.username; 162 username = other.username;
162 password = other.password; 163 password = other.password;
163 key_label = other.key_label; 164 key_label = other.key_label;
164 need_password_hashing = other.need_password_hashing; 165 need_password_hashing = other.need_password_hashing;
165 auth_code = other.auth_code; 166 auth_code = other.auth_code;
166 username_hash = other.username_hash; 167 username_hash = other.username_hash;
167 using_oauth = other.using_oauth; 168 using_oauth = other.using_oauth;
168 auth_flow = other.auth_flow; 169 auth_flow = other.auth_flow;
169 } 170 }
170 171
172 std::string User::GetEmail() const {
173 return display_email();
174 }
175
171 base::string16 User::GetDisplayName() const { 176 base::string16 User::GetDisplayName() const {
172 // Fallback to the email account name in case display name haven't been set. 177 // Fallback to the email account name in case display name haven't been set.
173 return display_name_.empty() ? 178 return display_name_.empty() ?
174 base::UTF8ToUTF16(GetAccountName(true)) : 179 base::UTF8ToUTF16(GetAccountName(true)) :
175 display_name_; 180 display_name_;
176 } 181 }
177 182
183 base::string16 User::GetGivenName() const {
184 return given_name_;
185 }
186
187 const gfx::ImageSkia& User::GetImage() const {
188 return user_image_.image();
189 }
190
191 std::string User::GetUserID() const {
192 return gaia::CanonicalizeEmail(gaia::SanitizeEmail(email()));
193 }
194
178 std::string User::GetAccountName(bool use_display_email) const { 195 std::string User::GetAccountName(bool use_display_email) const {
179 if (use_display_email && !display_email_.empty()) 196 if (use_display_email && !display_email_.empty())
180 return GetUserName(display_email_); 197 return GetUserName(display_email_);
181 else 198 else
182 return GetUserName(email_); 199 return GetUserName(email_);
183 } 200 }
184 201
185 bool User::HasDefaultImage() const { 202 bool User::HasDefaultImage() const {
186 return image_index_ >= 0 && image_index_ < kDefaultImagesCount; 203 return image_index_ >= 0 && image_index_ < kDefaultImagesCount;
187 } 204 }
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 case USER_TYPE_LOCALLY_MANAGED: 372 case USER_TYPE_LOCALLY_MANAGED:
356 case USER_TYPE_KIOSK_APP: 373 case USER_TYPE_KIOSK_APP:
357 return false; 374 return false;
358 default: 375 default:
359 NOTREACHED(); 376 NOTREACHED();
360 } 377 }
361 return false; 378 return false;
362 } 379 }
363 380
364 } // namespace chromeos 381 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/user.h ('k') | chrome/browser/chromeos/login/user_adding_screen_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698