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

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

Issue 2519823006: Chromad: Add authentication flow (Closed)
Patch Set: Rename HandleAdAuth. Use system_api enums Created 3 years, 12 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
« no previous file with comments | « components/user_manager/user.h ('k') | components/user_manager/user_manager_base.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 UserType GetType() const override; 46 UserType GetType() const override;
47 bool CanSyncImage() const override; 47 bool CanSyncImage() const override;
48 void SetIsChild(bool is_child) override; 48 void SetIsChild(bool is_child) override;
49 49
50 private: 50 private:
51 bool is_child_ = false; 51 bool is_child_ = false;
52 52
53 DISALLOW_COPY_AND_ASSIGN(RegularUser); 53 DISALLOW_COPY_AND_ASSIGN(RegularUser);
54 }; 54 };
55 55
56 class ActiveDirectoryUser : public RegularUser {
57 public:
58 explicit ActiveDirectoryUser(const AccountId& account_id);
59 ~ActiveDirectoryUser() override;
60 // Overridden from User:
61 UserType GetType() const override;
62 };
63
56 class GuestUser : public User { 64 class GuestUser : public User {
57 public: 65 public:
58 explicit GuestUser(const AccountId& guest_account_id); 66 explicit GuestUser(const AccountId& guest_account_id);
59 ~GuestUser() override; 67 ~GuestUser() override;
60 68
61 // Overridden from User: 69 // Overridden from User:
62 UserType GetType() const override; 70 UserType GetType() const override;
63 71
64 private: 72 private:
65 DISALLOW_COPY_AND_ASSIGN(GuestUser); 73 DISALLOW_COPY_AND_ASSIGN(GuestUser);
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 if (is_child) { 170 if (is_child) {
163 NOTREACHED() << "Calling SetIsChild(true) for base User class." 171 NOTREACHED() << "Calling SetIsChild(true) for base User class."
164 << "Base class cannot be set as child"; 172 << "Base class cannot be set as child";
165 } 173 }
166 } 174 }
167 175
168 bool User::HasGaiaAccount() const { 176 bool User::HasGaiaAccount() const {
169 return TypeHasGaiaAccount(GetType()); 177 return TypeHasGaiaAccount(GetType());
170 } 178 }
171 179
180 bool User::IsActiveDirectoryUser() const {
181 return GetType() == user_manager::USER_TYPE_ACTIVE_DIRECTORY;
182 }
183
172 bool User::IsSupervised() const { 184 bool User::IsSupervised() const {
173 UserType type = GetType(); 185 UserType type = GetType();
174 return type == USER_TYPE_SUPERVISED || 186 return type == USER_TYPE_SUPERVISED ||
175 type == USER_TYPE_CHILD; 187 type == USER_TYPE_CHILD;
176 } 188 }
177 189
178 std::string User::GetAccountName(bool use_display_email) const { 190 std::string User::GetAccountName(bool use_display_email) const {
179 if (use_display_email && !display_email_.empty()) 191 if (use_display_email && !display_email_.empty())
180 return GetUserName(display_email_); 192 return GetUserName(display_email_);
181 else 193 else
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 228
217 void User::SetAffiliation(bool is_affiliated) { 229 void User::SetAffiliation(bool is_affiliated) {
218 is_affiliated_ = is_affiliated; 230 is_affiliated_ = is_affiliated;
219 } 231 }
220 232
221 bool User::IsDeviceLocalAccount() const { 233 bool User::IsDeviceLocalAccount() const {
222 return false; 234 return false;
223 } 235 }
224 236
225 User* User::CreateRegularUser(const AccountId& account_id) { 237 User* User::CreateRegularUser(const AccountId& account_id) {
238 if (account_id.GetAccountType() == AccountType::ACTIVE_DIRECTORY)
239 return new ActiveDirectoryUser(account_id);
226 return new RegularUser(account_id); 240 return new RegularUser(account_id);
227 } 241 }
228 242
229 User* User::CreateGuestUser(const AccountId& guest_account_id) { 243 User* User::CreateGuestUser(const AccountId& guest_account_id) {
230 return new GuestUser(guest_account_id); 244 return new GuestUser(guest_account_id);
231 } 245 }
232 246
233 User* User::CreateKioskAppUser(const AccountId& kiosk_app_account_id) { 247 User* User::CreateKioskAppUser(const AccountId& kiosk_app_account_id) {
234 return new KioskAppUser(kiosk_app_account_id); 248 return new KioskAppUser(kiosk_app_account_id);
235 } 249 }
(...skipping 28 matching lines...) Expand all
264 278
265 void User::SetStubImage(std::unique_ptr<UserImage> stub_user_image, 279 void User::SetStubImage(std::unique_ptr<UserImage> stub_user_image,
266 int image_index, 280 int image_index,
267 bool is_loading) { 281 bool is_loading) {
268 user_image_ = std::move(stub_user_image); 282 user_image_ = std::move(stub_user_image);
269 image_index_ = image_index; 283 image_index_ = image_index;
270 image_is_stub_ = true; 284 image_is_stub_ = true;
271 image_is_loading_ = is_loading; 285 image_is_loading_ = is_loading;
272 } 286 }
273 287
288 UserType ActiveDirectoryUser::GetType() const {
289 return user_manager::USER_TYPE_ACTIVE_DIRECTORY;
290 }
291
274 RegularUser::RegularUser(const AccountId& account_id) : User(account_id) { 292 RegularUser::RegularUser(const AccountId& account_id) : User(account_id) {
275 set_can_lock(true); 293 set_can_lock(true);
276 set_display_email(account_id.GetUserEmail()); 294 set_display_email(account_id.GetUserEmail());
277 } 295 }
278 296
297 ActiveDirectoryUser::ActiveDirectoryUser(const AccountId& account_id)
298 : RegularUser(account_id) {}
299
279 RegularUser::~RegularUser() { 300 RegularUser::~RegularUser() {
280 } 301 }
281 302
303 ActiveDirectoryUser::~ActiveDirectoryUser() {}
304
282 UserType RegularUser::GetType() const { 305 UserType RegularUser::GetType() const {
283 return is_child_ ? user_manager::USER_TYPE_CHILD : 306 return is_child_ ? user_manager::USER_TYPE_CHILD :
284 user_manager::USER_TYPE_REGULAR; 307 user_manager::USER_TYPE_REGULAR;
285 } 308 }
286 309
287 bool RegularUser::CanSyncImage() const { 310 bool RegularUser::CanSyncImage() const {
288 return true; 311 return true;
289 } 312 }
290 313
291 void RegularUser::SetIsChild(bool is_child) { 314 void RegularUser::SetIsChild(bool is_child) {
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 : DeviceLocalAccountUserBase(account_id) {} 392 : DeviceLocalAccountUserBase(account_id) {}
370 393
371 PublicAccountUser::~PublicAccountUser() { 394 PublicAccountUser::~PublicAccountUser() {
372 } 395 }
373 396
374 UserType PublicAccountUser::GetType() const { 397 UserType PublicAccountUser::GetType() const {
375 return user_manager::USER_TYPE_PUBLIC_ACCOUNT; 398 return user_manager::USER_TYPE_PUBLIC_ACCOUNT;
376 } 399 }
377 400
378 bool User::has_gaia_account() const { 401 bool User::has_gaia_account() const {
379 static_assert(user_manager::NUM_USER_TYPES == 8, 402 static_assert(user_manager::NUM_USER_TYPES == 9,
380 "NUM_USER_TYPES should equal 8"); 403 "NUM_USER_TYPES should equal 9");
381 switch (GetType()) { 404 switch (GetType()) {
382 case user_manager::USER_TYPE_REGULAR: 405 case user_manager::USER_TYPE_REGULAR:
383 case user_manager::USER_TYPE_CHILD: 406 case user_manager::USER_TYPE_CHILD:
384 return true; 407 return true;
385 case user_manager::USER_TYPE_GUEST: 408 case user_manager::USER_TYPE_GUEST:
386 case user_manager::USER_TYPE_PUBLIC_ACCOUNT: 409 case user_manager::USER_TYPE_PUBLIC_ACCOUNT:
387 case user_manager::USER_TYPE_SUPERVISED: 410 case user_manager::USER_TYPE_SUPERVISED:
388 case user_manager::USER_TYPE_KIOSK_APP: 411 case user_manager::USER_TYPE_KIOSK_APP:
389 case user_manager::USER_TYPE_ARC_KIOSK_APP: 412 case user_manager::USER_TYPE_ARC_KIOSK_APP:
413 case user_manager::USER_TYPE_ACTIVE_DIRECTORY:
390 return false; 414 return false;
391 default: 415 default:
392 NOTREACHED(); 416 NOTREACHED();
393 } 417 }
394 return false; 418 return false;
395 } 419 }
396 420
397 } // namespace user_manager 421 } // namespace user_manager
OLDNEW
« no previous file with comments | « components/user_manager/user.h ('k') | components/user_manager/user_manager_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698