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

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

Issue 790503002: Methods and types rename for child accounts. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
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 "base/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/threading/thread_restrictions.h" 10 #include "base/threading/thread_restrictions.h"
(...skipping 13 matching lines...) Expand all
24 return email; 24 return email;
25 } 25 }
26 return email.substr(0, i); 26 return email.substr(0, i);
27 } 27 }
28 28
29 } // namespace 29 } // namespace
30 30
31 // static 31 // static
32 bool User::TypeHasGaiaAccount(UserType user_type) { 32 bool User::TypeHasGaiaAccount(UserType user_type) {
33 return user_type == USER_TYPE_REGULAR || 33 return user_type == USER_TYPE_REGULAR ||
34 user_type == USER_TYPE_REGULAR_SUPERVISED; 34 user_type == USER_TYPE_CHILD;
35 } 35 }
36 36
37 // Also used for regular supervised users. 37 // Also used for regular supervised users.
38 class RegularUser : public User { 38 class RegularUser : public User {
39 public: 39 public:
40 explicit RegularUser(const std::string& email); 40 explicit RegularUser(const std::string& email);
41 virtual ~RegularUser(); 41 virtual ~RegularUser();
42 42
43 // Overridden from User: 43 // Overridden from User:
44 virtual UserType GetType() const override; 44 virtual UserType GetType() const override;
45 virtual bool CanSyncImage() const override; 45 virtual bool CanSyncImage() const override;
46 virtual void SetIsSupervised(bool is_supervised) override; 46 virtual void SetIsChild(bool is_child) override;
47 47
48 private: 48 private:
49 bool is_supervised_; 49 bool is_child_;
50 50
51 DISALLOW_COPY_AND_ASSIGN(RegularUser); 51 DISALLOW_COPY_AND_ASSIGN(RegularUser);
52 }; 52 };
53 53
54 class GuestUser : public User { 54 class GuestUser : public User {
55 public: 55 public:
56 GuestUser(); 56 GuestUser();
57 virtual ~GuestUser(); 57 virtual ~GuestUser();
58 58
59 // Overridden from User: 59 // Overridden from User:
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 } 127 }
128 128
129 const gfx::ImageSkia& User::GetImage() const { 129 const gfx::ImageSkia& User::GetImage() const {
130 return user_image_.image(); 130 return user_image_.image();
131 } 131 }
132 132
133 std::string User::GetUserID() const { 133 std::string User::GetUserID() const {
134 return gaia::CanonicalizeEmail(gaia::SanitizeEmail(email())); 134 return gaia::CanonicalizeEmail(gaia::SanitizeEmail(email()));
135 } 135 }
136 136
137 void User::SetIsSupervised(bool is_supervised) { 137 void User::SetIsChild(bool is_child) {
138 VLOG(1) << "Ignoring SetIsSupervised call with param " << is_supervised; 138 VLOG(1) << "Ignoring SetIsChild call with param " << is_child;
139 NOTREACHED() << "Calling SetIsSupervised for base User class."; 139 NOTREACHED() << "Calling SetIsChild for base User class.";
Marc Treib 2014/12/08 13:27:54 This too.
merkulova 2014/12/08 14:56:12 Acknowledged.
140 } 140 }
141 141
142 bool User::HasGaiaAccount() const { 142 bool User::HasGaiaAccount() const {
143 return TypeHasGaiaAccount(GetType()); 143 return TypeHasGaiaAccount(GetType());
144 } 144 }
145 145
146 bool User::IsSupervised() const { 146 bool User::IsSupervised() const {
147 UserType type = GetType(); 147 UserType type = GetType();
148 return type == USER_TYPE_SUPERVISED || 148 return type == USER_TYPE_SUPERVISED ||
149 type == USER_TYPE_REGULAR_SUPERVISED; 149 type == USER_TYPE_CHILD;
150 } 150 }
151 151
152 std::string User::GetAccountName(bool use_display_email) const { 152 std::string User::GetAccountName(bool use_display_email) const {
153 if (use_display_email && !display_email_.empty()) 153 if (use_display_email && !display_email_.empty())
154 return GetUserName(display_email_); 154 return GetUserName(display_email_);
155 else 155 else
156 return GetUserName(email_); 156 return GetUserName(email_);
157 } 157 }
158 158
159 bool User::HasDefaultImage() const { 159 bool User::HasDefaultImage() const {
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 void User::SetStubImage(const UserImage& stub_user_image, 243 void User::SetStubImage(const UserImage& stub_user_image,
244 int image_index, 244 int image_index,
245 bool is_loading) { 245 bool is_loading) {
246 user_image_ = stub_user_image; 246 user_image_ = stub_user_image;
247 image_index_ = image_index; 247 image_index_ = image_index;
248 image_is_stub_ = true; 248 image_is_stub_ = true;
249 image_is_loading_ = is_loading; 249 image_is_loading_ = is_loading;
250 } 250 }
251 251
252 RegularUser::RegularUser(const std::string& email) 252 RegularUser::RegularUser(const std::string& email)
253 : User(email), is_supervised_(false) { 253 : User(email), is_child_(false) {
254 set_can_lock(true); 254 set_can_lock(true);
255 set_display_email(email); 255 set_display_email(email);
256 } 256 }
257 257
258 RegularUser::~RegularUser() { 258 RegularUser::~RegularUser() {
259 } 259 }
260 260
261 UserType RegularUser::GetType() const { 261 UserType RegularUser::GetType() const {
262 return is_supervised_ ? user_manager::USER_TYPE_REGULAR_SUPERVISED : 262 return is_child_ ? user_manager::USER_TYPE_CHILD :
263 user_manager::USER_TYPE_REGULAR; 263 user_manager::USER_TYPE_REGULAR;
264 } 264 }
265 265
266 bool RegularUser::CanSyncImage() const { 266 bool RegularUser::CanSyncImage() const {
267 return true; 267 return true;
268 } 268 }
269 269
270 void RegularUser::SetIsSupervised(bool is_supervised) { 270 void RegularUser::SetIsChild(bool is_child) {
271 VLOG(1) << "Setting user is supervised to " << is_supervised; 271 VLOG(1) << "Setting user is child to " << is_child;
272 is_supervised_ = is_supervised; 272 is_child_ = is_child;
273 } 273 }
274 274
275 GuestUser::GuestUser() : User(chromeos::login::kGuestUserName) { 275 GuestUser::GuestUser() : User(chromeos::login::kGuestUserName) {
276 set_display_email(std::string()); 276 set_display_email(std::string());
277 } 277 }
278 278
279 GuestUser::~GuestUser() { 279 GuestUser::~GuestUser() {
280 } 280 }
281 281
282 UserType GuestUser::GetType() const { 282 UserType GuestUser::GetType() const {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 } 328 }
329 329
330 UserType PublicAccountUser::GetType() const { 330 UserType PublicAccountUser::GetType() const {
331 return user_manager::USER_TYPE_PUBLIC_ACCOUNT; 331 return user_manager::USER_TYPE_PUBLIC_ACCOUNT;
332 } 332 }
333 333
334 bool User::has_gaia_account() const { 334 bool User::has_gaia_account() const {
335 COMPILE_ASSERT(user_manager::NUM_USER_TYPES == 7, num_user_types_unexpected); 335 COMPILE_ASSERT(user_manager::NUM_USER_TYPES == 7, num_user_types_unexpected);
336 switch (GetType()) { 336 switch (GetType()) {
337 case user_manager::USER_TYPE_REGULAR: 337 case user_manager::USER_TYPE_REGULAR:
338 case user_manager::USER_TYPE_REGULAR_SUPERVISED: 338 case user_manager::USER_TYPE_CHILD:
339 return true; 339 return true;
340 case user_manager::USER_TYPE_GUEST: 340 case user_manager::USER_TYPE_GUEST:
341 case user_manager::USER_TYPE_RETAIL_MODE: 341 case user_manager::USER_TYPE_RETAIL_MODE:
342 case user_manager::USER_TYPE_PUBLIC_ACCOUNT: 342 case user_manager::USER_TYPE_PUBLIC_ACCOUNT:
343 case user_manager::USER_TYPE_SUPERVISED: 343 case user_manager::USER_TYPE_SUPERVISED:
344 case user_manager::USER_TYPE_KIOSK_APP: 344 case user_manager::USER_TYPE_KIOSK_APP:
345 return false; 345 return false;
346 default: 346 default:
347 NOTREACHED(); 347 NOTREACHED();
348 } 348 }
349 return false; 349 return false;
350 } 350 }
351 351
352 } // namespace user_manager 352 } // namespace user_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698