| OLD | NEW |
| 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 "grit/theme_resources.h" |
| 10 #include "ui/base/resource/resource_bundle.h" | 11 #include "ui/base/resource/resource_bundle.h" |
| 11 | 12 |
| 12 namespace chromeos { | 13 namespace chromeos { |
| 13 | 14 |
| 15 namespace { |
| 16 |
| 17 // Resource ID of the image to use as stub image. |
| 18 const int kStubImageResourceID = IDR_PROFILE_PICTURE_LOADING; |
| 19 |
| 20 } // namespace |
| 21 |
| 14 User::User(const std::string& email) | 22 User::User(const std::string& email) |
| 15 : email_(email), | 23 : email_(email), |
| 16 display_email_(email), | 24 display_email_(email), |
| 17 oauth_token_status_(OAUTH_TOKEN_STATUS_UNKNOWN), | 25 oauth_token_status_(OAUTH_TOKEN_STATUS_UNKNOWN), |
| 18 image_index_(kInvalidImageIndex) { | 26 image_index_(kInvalidImageIndex), |
| 27 image_is_stub_(false) { |
| 19 image_ = *ResourceBundle::GetSharedInstance().GetBitmapNamed( | 28 image_ = *ResourceBundle::GetSharedInstance().GetBitmapNamed( |
| 20 kDefaultImageResources[0]); | 29 kDefaultImageResources[0]); |
| 21 } | 30 } |
| 22 | 31 |
| 23 User::~User() {} | 32 User::~User() {} |
| 24 | 33 |
| 25 void User::SetImage(const SkBitmap& image, int image_index) { | 34 void User::SetImage(const SkBitmap& image, int image_index) { |
| 26 image_ = image; | 35 image_ = image; |
| 27 image_index_ = image_index; | 36 image_index_ = image_index; |
| 37 image_is_stub_ = false; |
| 38 } |
| 39 |
| 40 void User::SetStubImage(int image_index) { |
| 41 image_ = *ResourceBundle::GetSharedInstance(). |
| 42 GetBitmapNamed(kStubImageResourceID); |
| 43 image_index_ = image_index; |
| 44 image_is_stub_ = true; |
| 28 } | 45 } |
| 29 | 46 |
| 30 std::string User::GetDisplayName() const { | 47 std::string User::GetDisplayName() const { |
| 31 size_t i = display_email_.find('@'); | 48 size_t i = display_email_.find('@'); |
| 32 if (i == 0 || i == std::string::npos) { | 49 if (i == 0 || i == std::string::npos) { |
| 33 return display_email_; | 50 return display_email_; |
| 34 } | 51 } |
| 35 return display_email_.substr(0, i); | 52 return display_email_.substr(0, i); |
| 36 } | 53 } |
| 37 | 54 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 48 } | 65 } |
| 49 size_t domain_start = at_pos + 1; | 66 size_t domain_start = at_pos + 1; |
| 50 std::string domain = user_email.substr(domain_start, | 67 std::string domain = user_email.substr(domain_start, |
| 51 user_email.length() - domain_start); | 68 user_email.length() - domain_start); |
| 52 return base::StringPrintf("%s (%s)", | 69 return base::StringPrintf("%s (%s)", |
| 53 GetDisplayName().c_str(), | 70 GetDisplayName().c_str(), |
| 54 domain.c_str()); | 71 domain.c_str()); |
| 55 } | 72 } |
| 56 | 73 |
| 57 } // namespace chromeos | 74 } // namespace chromeos |
| OLD | NEW |