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

Side by Side Diff: components/user_manager/user.cc

Issue 1794323003: Make user_manager::UserImage non-copyable (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/user_manager/user.h" 5 #include "components/user_manager/user.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 // Fallback to the email account name in case display name haven't been set. 129 // Fallback to the email account name in case display name haven't been set.
130 return display_name_.empty() ? base::UTF8ToUTF16(GetAccountName(true)) 130 return display_name_.empty() ? base::UTF8ToUTF16(GetAccountName(true))
131 : display_name_; 131 : display_name_;
132 } 132 }
133 133
134 base::string16 User::GetGivenName() const { 134 base::string16 User::GetGivenName() const {
135 return given_name_; 135 return given_name_;
136 } 136 }
137 137
138 const gfx::ImageSkia& User::GetImage() const { 138 const gfx::ImageSkia& User::GetImage() const {
139 return user_image_.image(); 139 return user_image_->image();
140 } 140 }
141 141
142 const AccountId& User::GetAccountId() const { 142 const AccountId& User::GetAccountId() const {
143 return account_id_; 143 return account_id_;
144 } 144 }
145 145
146 void User::SetIsChild(bool is_child) { 146 void User::SetIsChild(bool is_child) {
147 VLOG(1) << "Ignoring SetIsChild call with param " << is_child; 147 VLOG(1) << "Ignoring SetIsChild call with param " << is_child;
148 if (is_child) { 148 if (is_child) {
149 NOTREACHED() << "Calling SetIsChild(true) for base User class." 149 NOTREACHED() << "Calling SetIsChild(true) for base User class."
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 } 217 }
218 218
219 User* User::CreateSupervisedUser(const AccountId& account_id) { 219 User* User::CreateSupervisedUser(const AccountId& account_id) {
220 return new SupervisedUser(account_id); 220 return new SupervisedUser(account_id);
221 } 221 }
222 222
223 User* User::CreatePublicAccountUser(const AccountId& account_id) { 223 User* User::CreatePublicAccountUser(const AccountId& account_id) {
224 return new PublicAccountUser(account_id); 224 return new PublicAccountUser(account_id);
225 } 225 }
226 226
227 User::User(const AccountId& account_id) : account_id_(account_id) {} 227 User::User(const AccountId& account_id) : account_id_(account_id),
228 user_image_(new UserImage) {}
228 229
229 User::~User() { 230 User::~User() {
230 } 231 }
231 232
232 void User::SetAccountLocale(const std::string& resolved_account_locale) { 233 void User::SetAccountLocale(const std::string& resolved_account_locale) {
233 account_locale_.reset(new std::string(resolved_account_locale)); 234 account_locale_.reset(new std::string(resolved_account_locale));
234 } 235 }
235 236
236 void User::SetImage(const UserImage& user_image, int image_index) { 237 void User::SetImage(scoped_ptr<UserImage> user_image, int image_index) {
237 user_image_ = user_image; 238 user_image_ = std::move(user_image);
238 image_index_ = image_index; 239 image_index_ = image_index;
239 image_is_stub_ = false; 240 image_is_stub_ = false;
240 image_is_loading_ = false; 241 image_is_loading_ = false;
241 DCHECK(HasDefaultImage() || user_image.has_image_bytes()); 242 DCHECK(HasDefaultImage() || user_image_->has_image_bytes());
242 } 243 }
243 244
244 void User::SetImageURL(const GURL& image_url) { 245 void User::SetImageURL(const GURL& image_url) {
245 user_image_.set_url(image_url); 246 user_image_->set_url(image_url);
246 } 247 }
247 248
248 void User::SetStubImage(const UserImage& stub_user_image, 249 void User::SetStubImage(scoped_ptr<UserImage> stub_user_image,
249 int image_index, 250 int image_index,
250 bool is_loading) { 251 bool is_loading) {
251 user_image_ = stub_user_image; 252 user_image_ = std::move(stub_user_image);
252 image_index_ = image_index; 253 image_index_ = image_index;
253 image_is_stub_ = true; 254 image_is_stub_ = true;
254 image_is_loading_ = is_loading; 255 image_is_loading_ = is_loading;
255 } 256 }
256 257
257 RegularUser::RegularUser(const AccountId& account_id) : User(account_id) { 258 RegularUser::RegularUser(const AccountId& account_id) : User(account_id) {
258 set_can_lock(true); 259 set_can_lock(true);
259 set_display_email(account_id.GetUserEmail()); 260 set_display_email(account_id.GetUserEmail());
260 } 261 }
261 262
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 case user_manager::USER_TYPE_SUPERVISED: 355 case user_manager::USER_TYPE_SUPERVISED:
355 case user_manager::USER_TYPE_KIOSK_APP: 356 case user_manager::USER_TYPE_KIOSK_APP:
356 return false; 357 return false;
357 default: 358 default:
358 NOTREACHED(); 359 NOTREACHED();
359 } 360 }
360 return false; 361 return false;
361 } 362 }
362 363
363 } // namespace user_manager 364 } // namespace user_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698