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

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

Issue 1865133002: kiosk: Fix kiosk session restart (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase, comments in #4 Created 4 years, 8 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 class DeviceLocalAccountUserBase : public User { 72 class DeviceLocalAccountUserBase : public User {
73 public: 73 public:
74 // User: 74 // User:
75 bool IsAffiliated() const override; 75 bool IsAffiliated() const override;
76 76
77 protected: 77 protected:
78 explicit DeviceLocalAccountUserBase(const AccountId& account_id); 78 explicit DeviceLocalAccountUserBase(const AccountId& account_id);
79 ~DeviceLocalAccountUserBase() override; 79 ~DeviceLocalAccountUserBase() override;
80 // User: 80 // User:
81 void SetAffiliation(bool) override; 81 void SetAffiliation(bool) override;
82 bool IsDeviceLocalAccountUser() const override;
82 83
83 private: 84 private:
84 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountUserBase); 85 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountUserBase);
85 }; 86 };
86 87
87 class KioskAppUser : public DeviceLocalAccountUserBase { 88 class KioskAppUser : public DeviceLocalAccountUserBase {
88 public: 89 public:
89 explicit KioskAppUser(const AccountId& kiosk_app_account_id); 90 explicit KioskAppUser(const AccountId& kiosk_app_account_id);
90 ~KioskAppUser() override; 91 ~KioskAppUser() override;
91 92
(...skipping 22 matching lines...) Expand all
114 explicit PublicAccountUser(const AccountId& account_id); 115 explicit PublicAccountUser(const AccountId& account_id);
115 ~PublicAccountUser() override; 116 ~PublicAccountUser() override;
116 117
117 // Overridden from User: 118 // Overridden from User:
118 UserType GetType() const override; 119 UserType GetType() const override;
119 120
120 private: 121 private:
121 DISALLOW_COPY_AND_ASSIGN(PublicAccountUser); 122 DISALLOW_COPY_AND_ASSIGN(PublicAccountUser);
122 }; 123 };
123 124
125 User::User(const AccountId& account_id)
126 : account_id_(account_id), user_image_(new UserImage) {}
127
128 User::~User() {}
129
124 std::string User::GetEmail() const { 130 std::string User::GetEmail() const {
125 return display_email(); 131 return display_email();
126 } 132 }
127 133
128 base::string16 User::GetDisplayName() const { 134 base::string16 User::GetDisplayName() const {
129 // Fallback to the email account name in case display name haven't been set. 135 // Fallback to the email account name in case display name haven't been set.
130 return display_name_.empty() ? base::UTF8ToUTF16(GetAccountName(true)) 136 return display_name_.empty() ? base::UTF8ToUTF16(GetAccountName(true))
131 : display_name_; 137 : display_name_;
132 } 138 }
133 139
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 } 203 }
198 204
199 bool User::IsAffiliated() const { 205 bool User::IsAffiliated() const {
200 return is_affiliated_; 206 return is_affiliated_;
201 } 207 }
202 208
203 void User::SetAffiliation(bool is_affiliated) { 209 void User::SetAffiliation(bool is_affiliated) {
204 is_affiliated_ = is_affiliated; 210 is_affiliated_ = is_affiliated;
205 } 211 }
206 212
213 bool User::IsDeviceLocalAccountUser() const {
214 return false;
215 }
216
207 User* User::CreateRegularUser(const AccountId& account_id) { 217 User* User::CreateRegularUser(const AccountId& account_id) {
208 return new RegularUser(account_id); 218 return new RegularUser(account_id);
209 } 219 }
210 220
211 User* User::CreateGuestUser(const AccountId& guest_account_id) { 221 User* User::CreateGuestUser(const AccountId& guest_account_id) {
212 return new GuestUser(guest_account_id); 222 return new GuestUser(guest_account_id);
213 } 223 }
214 224
215 User* User::CreateKioskAppUser(const AccountId& kiosk_app_account_id) { 225 User* User::CreateKioskAppUser(const AccountId& kiosk_app_account_id) {
216 return new KioskAppUser(kiosk_app_account_id); 226 return new KioskAppUser(kiosk_app_account_id);
217 } 227 }
218 228
219 User* User::CreateSupervisedUser(const AccountId& account_id) { 229 User* User::CreateSupervisedUser(const AccountId& account_id) {
220 return new SupervisedUser(account_id); 230 return new SupervisedUser(account_id);
221 } 231 }
222 232
223 User* User::CreatePublicAccountUser(const AccountId& account_id) { 233 User* User::CreatePublicAccountUser(const AccountId& account_id) {
224 return new PublicAccountUser(account_id); 234 return new PublicAccountUser(account_id);
225 } 235 }
226 236
227 User::User(const AccountId& account_id) : account_id_(account_id),
228 user_image_(new UserImage) {}
229
230 User::~User() {
231 }
232
233 void User::SetAccountLocale(const std::string& resolved_account_locale) { 237 void User::SetAccountLocale(const std::string& resolved_account_locale) {
234 account_locale_.reset(new std::string(resolved_account_locale)); 238 account_locale_.reset(new std::string(resolved_account_locale));
235 } 239 }
236 240
237 void User::SetImage(scoped_ptr<UserImage> user_image, int image_index) { 241 void User::SetImage(scoped_ptr<UserImage> user_image, int image_index) {
238 user_image_ = std::move(user_image); 242 user_image_ = std::move(user_image);
239 image_index_ = image_index; 243 image_index_ = image_index;
240 image_is_stub_ = false; 244 image_is_stub_ = false;
241 image_is_loading_ = false; 245 image_is_loading_ = false;
242 DCHECK(HasDefaultImage() || user_image_->has_image_bytes()); 246 DCHECK(HasDefaultImage() || user_image_->has_image_bytes());
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 bool DeviceLocalAccountUserBase::IsAffiliated() const { 303 bool DeviceLocalAccountUserBase::IsAffiliated() const {
300 return true; 304 return true;
301 } 305 }
302 306
303 void DeviceLocalAccountUserBase::SetAffiliation(bool) { 307 void DeviceLocalAccountUserBase::SetAffiliation(bool) {
304 // Device local accounts are always affiliated. No affiliation modification 308 // Device local accounts are always affiliated. No affiliation modification
305 // must happen. 309 // must happen.
306 NOTREACHED(); 310 NOTREACHED();
307 } 311 }
308 312
313 bool DeviceLocalAccountUserBase::IsDeviceLocalAccountUser() const {
314 return true;
315 }
316
309 KioskAppUser::KioskAppUser(const AccountId& kiosk_app_account_id) 317 KioskAppUser::KioskAppUser(const AccountId& kiosk_app_account_id)
310 : DeviceLocalAccountUserBase(kiosk_app_account_id) { 318 : DeviceLocalAccountUserBase(kiosk_app_account_id) {
311 set_display_email(kiosk_app_account_id.GetUserEmail()); 319 set_display_email(kiosk_app_account_id.GetUserEmail());
312 } 320 }
313 321
314 KioskAppUser::~KioskAppUser() { 322 KioskAppUser::~KioskAppUser() {
315 } 323 }
316 324
317 UserType KioskAppUser::GetType() const { 325 UserType KioskAppUser::GetType() const {
318 return user_manager::USER_TYPE_KIOSK_APP; 326 return user_manager::USER_TYPE_KIOSK_APP;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 case user_manager::USER_TYPE_SUPERVISED: 363 case user_manager::USER_TYPE_SUPERVISED:
356 case user_manager::USER_TYPE_KIOSK_APP: 364 case user_manager::USER_TYPE_KIOSK_APP:
357 return false; 365 return false;
358 default: 366 default:
359 NOTREACHED(); 367 NOTREACHED();
360 } 368 }
361 return false; 369 return false;
362 } 370 }
363 371
364 } // namespace user_manager 372 } // namespace user_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698