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

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

Issue 8773046: [cros] Display emails of users are stored in a separate dictionary in Local State. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge Created 9 years 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
« no previous file with comments | « chrome/browser/chromeos/login/user.h ('k') | chrome/browser/chromeos/login/user_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/stringprintf.h" 7 #include "base/stringprintf.h"
8 #include "chrome/browser/chromeos/login/default_user_images.h" 8 #include "chrome/browser/chromeos/login/default_user_images.h"
9 #include "chrome/browser/chromeos/login/user_manager.h" 9 #include "chrome/browser/chromeos/login/user_manager.h"
10 #include "ui/base/resource/resource_bundle.h" 10 #include "ui/base/resource/resource_bundle.h"
11 11
12 namespace chromeos { 12 namespace chromeos {
13 13
14 User::User(const std::string& email) 14 User::User(const std::string& email)
15 : email_(email), 15 : email_(email),
16 display_email_(email),
16 oauth_token_status_(OAUTH_TOKEN_STATUS_UNKNOWN), 17 oauth_token_status_(OAUTH_TOKEN_STATUS_UNKNOWN),
17 image_index_(kInvalidImageIndex) { 18 image_index_(kInvalidImageIndex) {
18 image_ = *ResourceBundle::GetSharedInstance().GetBitmapNamed( 19 image_ = *ResourceBundle::GetSharedInstance().GetBitmapNamed(
19 kDefaultImageResources[0]); 20 kDefaultImageResources[0]);
20 } 21 }
21 22
22 User::~User() {} 23 User::~User() {}
23 24
24 void User::SetImage(const SkBitmap& image, int image_index) { 25 void User::SetImage(const SkBitmap& image, int image_index) {
25 image_ = image; 26 image_ = image;
26 image_index_ = image_index; 27 image_index_ = image_index;
27 } 28 }
28 29
29 std::string User::GetDisplayName() const { 30 std::string User::GetDisplayName() const {
30 size_t i = email_.find('@'); 31 size_t i = display_email_.find('@');
31 if (i == 0 || i == std::string::npos) { 32 if (i == 0 || i == std::string::npos) {
32 return email_; 33 return display_email_;
33 } 34 }
34 return email_.substr(0, i); 35 return display_email_.substr(0, i);
35 } 36 }
36 37
37 bool User::NeedsNameTooltip() const { 38 bool User::NeedsNameTooltip() const {
38 return UserManager::Get()->IsDisplayNameUnique(GetDisplayName()); 39 return !UserManager::Get()->IsDisplayNameUnique(GetDisplayName());
39 } 40 }
40 41
41 std::string User::GetNameTooltip() const { 42 std::string User::GetNameTooltip() const {
42 const std::string& user_email = email(); 43 const std::string& user_email = display_email_;
43 size_t at_pos = user_email.rfind('@'); 44 size_t at_pos = user_email.rfind('@');
44 if (at_pos == std::string::npos) { 45 if (at_pos == std::string::npos) {
45 NOTREACHED(); 46 NOTREACHED();
46 return std::string(); 47 return std::string();
47 } 48 }
48 size_t domain_start = at_pos + 1; 49 size_t domain_start = at_pos + 1;
49 std::string domain = user_email.substr(domain_start, 50 std::string domain = user_email.substr(domain_start,
50 user_email.length() - domain_start); 51 user_email.length() - domain_start);
51 return base::StringPrintf("%s (%s)", 52 return base::StringPrintf("%s (%s)",
52 GetDisplayName().c_str(), 53 GetDisplayName().c_str(),
53 domain.c_str()); 54 domain.c_str());
54 } 55 }
55 56
56 } // namespace chromeos 57 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/user.h ('k') | chrome/browser/chromeos/login/user_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698