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

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

Issue 10454044: Added support for animated/nonanimated user image. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Comment is fixed. Created 8 years, 6 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
« no previous file with comments | « chrome/browser/chromeos/login/user.h ('k') | chrome/browser/chromeos/login/user_image.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) 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"
(...skipping 13 matching lines...) Expand all
24 if (i == 0 || i == std::string::npos) { 24 if (i == 0 || i == std::string::npos) {
25 return email; 25 return email;
26 } 26 }
27 return email.substr(0, i); 27 return email.substr(0, i);
28 } 28 }
29 29
30 } // namespace 30 } // namespace
31 31
32 User::User(const std::string& email, bool is_guest) 32 User::User(const std::string& email, bool is_guest)
33 : email_(email), 33 : email_(email),
34 image_(*ResourceBundle::GetSharedInstance().GetImageSkiaNamed( 34 user_image_(*ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
35 kDefaultImageResources[0])), 35 kDefaultImageResources[0])),
36 oauth_token_status_(OAUTH_TOKEN_STATUS_UNKNOWN), 36 oauth_token_status_(OAUTH_TOKEN_STATUS_UNKNOWN),
37 image_index_(kInvalidImageIndex), 37 image_index_(kInvalidImageIndex),
38 image_is_stub_(false), 38 image_is_stub_(false),
39 is_guest_(is_guest) { 39 is_guest_(is_guest) {
40 // The email address of a demo user is for internal purposes only, 40 // The email address of a demo user is for internal purposes only,
41 // never meant for display. 41 // never meant for display.
42 if (email != kDemoUser) { 42 if (email != kDemoUser) {
43 display_email_ = email; 43 display_email_ = email;
44 is_demo_user_ = false; 44 is_demo_user_ = false;
45 } else { 45 } else {
46 is_demo_user_ = true; 46 is_demo_user_ = true;
47 } 47 }
48 } 48 }
49 49
50 User::~User() {} 50 User::~User() {}
51 51
52 void User::SetImage(const gfx::ImageSkia& image, int image_index) { 52 void User::SetImage(const UserImage& user_image, int image_index) {
53 image_ = image; 53 user_image_ = user_image;
54 image_index_ = image_index; 54 image_index_ = image_index;
55 image_is_stub_ = false; 55 image_is_stub_ = false;
56 } 56 }
57 57
58 void User::SetStubImage(int image_index) { 58 void User::SetStubImage(int image_index) {
59 image_ = *ResourceBundle::GetSharedInstance().GetImageSkiaNamed( 59 user_image_.SetImage(*ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
60 kStubImageResourceID); 60 kStubImageResourceID));
61 image_index_ = image_index; 61 image_index_ = image_index;
62 image_is_stub_ = true; 62 image_is_stub_ = true;
63 } 63 }
64 64
65 void User::SetWallpaperThumbnail(const SkBitmap& wallpaper_thumbnail) { 65 void User::SetWallpaperThumbnail(const SkBitmap& wallpaper_thumbnail) {
66 wallpaper_thumbnail_ = wallpaper_thumbnail; 66 wallpaper_thumbnail_ = wallpaper_thumbnail;
67 } 67 }
68 68
69 std::string User::GetAccountName(bool use_display_email) const { 69 std::string User::GetAccountName(bool use_display_email) const {
70 if (use_display_email && !display_email_.empty()) 70 if (use_display_email && !display_email_.empty())
71 return GetUserName(display_email_); 71 return GetUserName(display_email_);
72 else 72 else
73 return GetUserName(email_); 73 return GetUserName(email_);
74 } 74 }
75 75
76 string16 User::GetDisplayName() const { 76 string16 User::GetDisplayName() const {
77 return display_name_; 77 return display_name_;
78 } 78 }
79 79
80 bool User::GetAnimatedImage(UserImage::RawImage* raw_image) const {
81 if (raw_image && has_animated_image()) {
82 *raw_image = user_image_.raw_image();
83 return true;
84 }
85 return false;
86 }
87
80 } // namespace chromeos 88 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/user.h ('k') | chrome/browser/chromeos/login/user_image.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698