OLD | NEW |
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/stringprintf.h" | 7 #include "base/stringprintf.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/browser/chromeos/login/default_user_images.h" | 9 #include "chrome/browser/chromeos/login/default_user_images.h" |
10 #include "chrome/browser/chromeos/login/user_manager.h" | 10 #include "chrome/browser/chromeos/login/user_manager.h" |
| 11 #include "grit/theme_resources.h" |
| 12 #include "ui/base/resource/resource_bundle.h" |
11 | 13 |
12 namespace chromeos { | 14 namespace chromeos { |
13 | 15 |
14 namespace { | 16 namespace { |
15 | 17 |
16 // Returns account name portion of an email. | 18 // Returns account name portion of an email. |
17 std::string GetUserName(const std::string& email) { | 19 std::string GetUserName(const std::string& email) { |
18 std::string::size_type i = email.find('@'); | 20 std::string::size_type i = email.find('@'); |
19 if (i == 0 || i == std::string::npos) { | 21 if (i == 0 || i == std::string::npos) { |
20 return email; | 22 return email; |
(...skipping 27 matching lines...) Expand all Loading... |
48 image_index_ = image_index; | 50 image_index_ = image_index; |
49 image_is_stub_ = false; | 51 image_is_stub_ = false; |
50 DCHECK(HasDefaultImage() || user_image.has_raw_image()); | 52 DCHECK(HasDefaultImage() || user_image.has_raw_image()); |
51 } | 53 } |
52 | 54 |
53 void User::SetImageURL(const GURL& image_url) { | 55 void User::SetImageURL(const GURL& image_url) { |
54 user_image_.set_url(image_url); | 56 user_image_.set_url(image_url); |
55 } | 57 } |
56 | 58 |
57 void User::SetStubImage(int image_index) { | 59 void User::SetStubImage(int image_index) { |
58 user_image_ = UserImage(); | 60 user_image_ = UserImage( |
| 61 *ResourceBundle::GetSharedInstance(). |
| 62 GetImageSkiaNamed(IDR_PROFILE_PICTURE_LOADING)); |
59 image_index_ = image_index; | 63 image_index_ = image_index; |
60 image_is_stub_ = true; | 64 image_is_stub_ = true; |
61 } | 65 } |
62 | 66 |
63 std::string User::GetAccountName(bool use_display_email) const { | 67 std::string User::GetAccountName(bool use_display_email) const { |
64 if (use_display_email && !display_email_.empty()) | 68 if (use_display_email && !display_email_.empty()) |
65 return GetUserName(display_email_); | 69 return GetUserName(display_email_); |
66 else | 70 else |
67 return GetUserName(email_); | 71 return GetUserName(email_); |
68 } | 72 } |
69 | 73 |
70 bool User::HasDefaultImage() const { | 74 bool User::HasDefaultImage() const { |
71 return image_index_ >= 0 && image_index_ < kDefaultImagesCount; | 75 return image_index_ >= 0 && image_index_ < kDefaultImagesCount; |
72 } | 76 } |
73 | 77 |
74 string16 User::GetDisplayName() const { | 78 string16 User::GetDisplayName() const { |
75 // Fallback to the email account name in case display name haven't been set. | 79 // Fallback to the email account name in case display name haven't been set. |
76 return display_name_.empty() ? | 80 return display_name_.empty() ? |
77 UTF8ToUTF16(GetAccountName(true)) : | 81 UTF8ToUTF16(GetAccountName(true)) : |
78 display_name_; | 82 display_name_; |
79 } | 83 } |
80 | 84 |
81 } // namespace chromeos | 85 } // namespace chromeos |
OLD | NEW |