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) |
| 246 : User(email), is_supervised_(false) { |
228 set_can_lock(true); | 247 set_can_lock(true); |
229 set_display_email(email); | 248 set_display_email(email); |
230 } | 249 } |
231 | 250 |
232 RegularUser::~RegularUser() { | 251 RegularUser::~RegularUser() { |
233 } | 252 } |
234 | 253 |
235 UserType RegularUser::GetType() const { | 254 UserType RegularUser::GetType() const { |
236 return user_manager::USER_TYPE_REGULAR; | 255 return user_manager::USER_TYPE_REGULAR; |
237 } | 256 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 } | 290 } |
272 | 291 |
273 UserType SupervisedUser::GetType() const { | 292 UserType SupervisedUser::GetType() const { |
274 return user_manager::USER_TYPE_SUPERVISED; | 293 return user_manager::USER_TYPE_SUPERVISED; |
275 } | 294 } |
276 | 295 |
277 std::string SupervisedUser::display_email() const { | 296 std::string SupervisedUser::display_email() const { |
278 return base::UTF16ToUTF8(display_name()); | 297 return base::UTF16ToUTF8(display_name()); |
279 } | 298 } |
280 | 299 |
| 300 bool SupervisedUser::IsSupervised() const { |
| 301 return true; |
| 302 } |
| 303 |
281 RetailModeUser::RetailModeUser() : User(chromeos::login::kRetailModeUserName) { | 304 RetailModeUser::RetailModeUser() : User(chromeos::login::kRetailModeUserName) { |
282 set_display_email(std::string()); | 305 set_display_email(std::string()); |
283 } | 306 } |
284 | 307 |
285 RetailModeUser::~RetailModeUser() { | 308 RetailModeUser::~RetailModeUser() { |
286 } | 309 } |
287 | 310 |
288 UserType RetailModeUser::GetType() const { | 311 UserType RetailModeUser::GetType() const { |
289 return user_manager::USER_TYPE_RETAIL_MODE; | 312 return user_manager::USER_TYPE_RETAIL_MODE; |
290 } | 313 } |
(...skipping 19 matching lines...) Expand all Loading... |
310 case user_manager::USER_TYPE_SUPERVISED: | 333 case user_manager::USER_TYPE_SUPERVISED: |
311 case user_manager::USER_TYPE_KIOSK_APP: | 334 case user_manager::USER_TYPE_KIOSK_APP: |
312 return false; | 335 return false; |
313 default: | 336 default: |
314 NOTREACHED(); | 337 NOTREACHED(); |
315 } | 338 } |
316 return false; | 339 return false; |
317 } | 340 } |
318 | 341 |
319 } // namespace user_manager | 342 } // namespace user_manager |
OLD | NEW |