Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 10 matching lines...) Expand all Loading... | |
| 21 std::string GetUserName(const std::string& email) { | 21 std::string GetUserName(const std::string& email) { |
| 22 std::string::size_type i = email.find('@'); | 22 std::string::size_type i = email.find('@'); |
| 23 if (i == 0 || i == std::string::npos) { | 23 if (i == 0 || i == std::string::npos) { |
| 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 bool User::IsSupervised() const { | |
| 32 return false; | |
| 33 } | |
| 34 | |
| 35 void User::SetIsSupervised(bool is_supervised) { | |
| 36 VLOG(1) << "Ignoring SetIsSupervised call with param " << is_supervised; | |
| 37 } | |
| 38 | |
| 31 class RegularUser : public User { | 39 class RegularUser : public User { |
| 32 public: | 40 public: |
| 33 explicit RegularUser(const std::string& email); | 41 explicit RegularUser(const std::string& email); |
| 34 virtual ~RegularUser(); | 42 virtual ~RegularUser(); |
| 35 | 43 |
| 36 // Overridden from User: | 44 // Overridden from User: |
| 37 virtual UserType GetType() const OVERRIDE; | 45 virtual UserType GetType() const OVERRIDE; |
| 38 virtual bool CanSyncImage() const OVERRIDE; | 46 virtual bool CanSyncImage() const OVERRIDE; |
| 47 virtual void SetIsSupervised(bool is_supervised) OVERRIDE { | |
| 48 VLOG(1) << "Setting user is supervised to " << is_supervised; | |
| 49 is_supervised_ = is_supervised; | |
| 50 } | |
| 51 virtual bool IsSupervised() const OVERRIDE { | |
| 52 return is_supervised_; | |
| 53 } | |
| 39 | 54 |
| 40 private: | 55 private: |
| 56 bool is_supervised_; | |
| 57 | |
| 41 DISALLOW_COPY_AND_ASSIGN(RegularUser); | 58 DISALLOW_COPY_AND_ASSIGN(RegularUser); |
| 42 }; | 59 }; |
| 43 | 60 |
| 44 class GuestUser : public User { | 61 class GuestUser : public User { |
| 45 public: | 62 public: |
| 46 GuestUser(); | 63 GuestUser(); |
| 47 virtual ~GuestUser(); | 64 virtual ~GuestUser(); |
| 48 | 65 |
| 49 // Overridden from User: | 66 // Overridden from User: |
| 50 virtual UserType GetType() const OVERRIDE; | 67 virtual UserType GetType() const OVERRIDE; |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 65 DISALLOW_COPY_AND_ASSIGN(KioskAppUser); | 82 DISALLOW_COPY_AND_ASSIGN(KioskAppUser); |
| 66 }; | 83 }; |
| 67 | 84 |
| 68 class SupervisedUser : public User { | 85 class SupervisedUser : public User { |
| 69 public: | 86 public: |
| 70 explicit SupervisedUser(const std::string& username); | 87 explicit SupervisedUser(const std::string& username); |
| 71 virtual ~SupervisedUser(); | 88 virtual ~SupervisedUser(); |
| 72 | 89 |
| 73 // Overridden from User: | 90 // Overridden from User: |
| 74 virtual UserType GetType() const OVERRIDE; | 91 virtual UserType GetType() const OVERRIDE; |
| 92 virtual bool IsSupervised() const OVERRIDE; | |
| 75 virtual std::string display_email() const OVERRIDE; | 93 virtual std::string display_email() const OVERRIDE; |
| 76 | 94 |
| 77 private: | 95 private: |
| 78 DISALLOW_COPY_AND_ASSIGN(SupervisedUser); | 96 DISALLOW_COPY_AND_ASSIGN(SupervisedUser); |
| 79 }; | 97 }; |
| 80 | 98 |
| 81 class RetailModeUser : public User { | 99 class RetailModeUser : public User { |
| 82 public: | 100 public: |
| 83 RetailModeUser(); | 101 RetailModeUser(); |
| 84 virtual ~RetailModeUser(); | 102 virtual ~RetailModeUser(); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 217 | 235 |
| 218 void User::SetStubImage(const UserImage& stub_user_image, | 236 void User::SetStubImage(const UserImage& stub_user_image, |
| 219 int image_index, | 237 int image_index, |
| 220 bool is_loading) { | 238 bool is_loading) { |
| 221 user_image_ = stub_user_image; | 239 user_image_ = stub_user_image; |
| 222 image_index_ = image_index; | 240 image_index_ = image_index; |
| 223 image_is_stub_ = true; | 241 image_is_stub_ = true; |
| 224 image_is_loading_ = is_loading; | 242 image_is_loading_ = is_loading; |
| 225 } | 243 } |
| 226 | 244 |
| 227 RegularUser::RegularUser(const std::string& email) : User(email) { | 245 RegularUser::RegularUser(const std::string& email) : User(email) { |
|
Nikita (slow)
2014/09/17 18:25:26
You need to initialize is_supervised_(false) in ct
merkulova
2014/09/18 08:51:29
Done.
| |
| 228 set_can_lock(true); | 246 set_can_lock(true); |
| 229 set_display_email(email); | 247 set_display_email(email); |
| 230 } | 248 } |
| 231 | 249 |
| 232 RegularUser::~RegularUser() { | 250 RegularUser::~RegularUser() { |
| 233 } | 251 } |
| 234 | 252 |
| 235 UserType RegularUser::GetType() const { | 253 UserType RegularUser::GetType() const { |
| 236 return user_manager::USER_TYPE_REGULAR; | 254 return user_manager::USER_TYPE_REGULAR; |
| 237 } | 255 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 271 } | 289 } |
| 272 | 290 |
| 273 UserType SupervisedUser::GetType() const { | 291 UserType SupervisedUser::GetType() const { |
| 274 return user_manager::USER_TYPE_SUPERVISED; | 292 return user_manager::USER_TYPE_SUPERVISED; |
| 275 } | 293 } |
| 276 | 294 |
| 277 std::string SupervisedUser::display_email() const { | 295 std::string SupervisedUser::display_email() const { |
| 278 return base::UTF16ToUTF8(display_name()); | 296 return base::UTF16ToUTF8(display_name()); |
| 279 } | 297 } |
| 280 | 298 |
| 299 bool SupervisedUser::IsSupervised() const { | |
| 300 return true; | |
| 301 } | |
| 302 | |
| 281 RetailModeUser::RetailModeUser() : User(chromeos::login::kRetailModeUserName) { | 303 RetailModeUser::RetailModeUser() : User(chromeos::login::kRetailModeUserName) { |
| 282 set_display_email(std::string()); | 304 set_display_email(std::string()); |
| 283 } | 305 } |
| 284 | 306 |
| 285 RetailModeUser::~RetailModeUser() { | 307 RetailModeUser::~RetailModeUser() { |
| 286 } | 308 } |
| 287 | 309 |
| 288 UserType RetailModeUser::GetType() const { | 310 UserType RetailModeUser::GetType() const { |
| 289 return user_manager::USER_TYPE_RETAIL_MODE; | 311 return user_manager::USER_TYPE_RETAIL_MODE; |
| 290 } | 312 } |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 310 case user_manager::USER_TYPE_SUPERVISED: | 332 case user_manager::USER_TYPE_SUPERVISED: |
| 311 case user_manager::USER_TYPE_KIOSK_APP: | 333 case user_manager::USER_TYPE_KIOSK_APP: |
| 312 return false; | 334 return false; |
| 313 default: | 335 default: |
| 314 NOTREACHED(); | 336 NOTREACHED(); |
| 315 } | 337 } |
| 316 return false; | 338 return false; |
| 317 } | 339 } |
| 318 | 340 |
| 319 } // namespace user_manager | 341 } // namespace user_manager |
| OLD | NEW |