Chromium Code Reviews| Index: components/user_manager/user.cc |
| diff --git a/components/user_manager/user.cc b/components/user_manager/user.cc |
| index 664aa4ba5041bfb84ed780decfb0e281336b1137..4c5696ae5abbb5eb2b1a781c4a1792c450a20b33 100644 |
| --- a/components/user_manager/user.cc |
| +++ b/components/user_manager/user.cc |
| @@ -28,14 +28,13 @@ std::string GetUserName(const std::string& email) { |
| } // namespace |
| -bool User::IsSupervised() const { |
| - return false; |
| -} |
| - |
| -void User::SetIsSupervised(bool is_supervised) { |
| - VLOG(1) << "Ignoring SetIsSupervised call with param " << is_supervised; |
| +// static |
| +bool User::TypeHasGaia(UserType user_type) { |
|
Nikita (slow)
2014/11/14 09:34:52
nit: TypeHasGaiaAccount
merkulova
2014/11/14 10:09:49
Done.
|
| + return user_type == USER_TYPE_REGULAR || |
| + user_type == USER_TYPE_REGULAR_SUPERVISED; |
| } |
| +// Also used for regular supervised users. |
| class RegularUser : public User { |
| public: |
| explicit RegularUser(const std::string& email); |
| @@ -44,13 +43,7 @@ class RegularUser : public User { |
| // Overridden from User: |
| virtual UserType GetType() const override; |
| virtual bool CanSyncImage() const override; |
| - virtual void SetIsSupervised(bool is_supervised) override { |
| - VLOG(1) << "Setting user is supervised to " << is_supervised; |
| - is_supervised_ = is_supervised; |
| - } |
| - virtual bool IsSupervised() const override { |
| - return is_supervised_; |
| - } |
| + virtual void SetIsSupervised(bool is_supervised) override; |
| private: |
| bool is_supervised_; |
| @@ -89,7 +82,6 @@ class SupervisedUser : public User { |
| // Overridden from User: |
| virtual UserType GetType() const override; |
| - virtual bool IsSupervised() const override; |
| virtual std::string display_email() const override; |
| private: |
| @@ -142,6 +134,21 @@ std::string User::GetUserID() const { |
| return gaia::CanonicalizeEmail(gaia::SanitizeEmail(email())); |
| } |
| +void User::SetIsSupervised(bool is_supervised) { |
| + VLOG(1) << "Ignoring SetIsSupervised call with param " << is_supervised; |
| + NOTREACHED() << "Calling SetIsSupervised for base User class."; |
| +} |
| + |
| +bool User::HasGaiaAccount() const { |
| + return TypeHasGaia(GetType()); |
| +} |
| + |
| +bool User::IsSupervised() const { |
| + UserType type = GetType(); |
| + return type == USER_TYPE_SUPERVISED || |
| + type == USER_TYPE_REGULAR_SUPERVISED; |
| +} |
| + |
| std::string User::GetAccountName(bool use_display_email) const { |
| if (use_display_email && !display_email_.empty()) |
| return GetUserName(display_email_); |
| @@ -252,13 +259,19 @@ RegularUser::~RegularUser() { |
| } |
| UserType RegularUser::GetType() const { |
| - return user_manager::USER_TYPE_REGULAR; |
| + return is_supervised_ ? user_manager::USER_TYPE_REGULAR_SUPERVISED : |
| + user_manager::USER_TYPE_REGULAR; |
| } |
| bool RegularUser::CanSyncImage() const { |
| return true; |
| } |
| +void RegularUser::SetIsSupervised(bool is_supervised) { |
| + VLOG(1) << "Setting user is supervised to " << is_supervised; |
| + is_supervised_ = is_supervised; |
| +} |
| + |
| GuestUser::GuestUser() : User(chromeos::login::kGuestUserName) { |
| set_display_email(std::string()); |
| } |
| @@ -297,10 +310,6 @@ std::string SupervisedUser::display_email() const { |
| return base::UTF16ToUTF8(display_name()); |
| } |
| -bool SupervisedUser::IsSupervised() const { |
| - return true; |
| -} |
| - |
| RetailModeUser::RetailModeUser() : User(chromeos::login::kRetailModeUserName) { |
| set_display_email(std::string()); |
| } |
| @@ -323,9 +332,10 @@ UserType PublicAccountUser::GetType() const { |
| } |
| bool User::has_gaia_account() const { |
| - COMPILE_ASSERT(user_manager::NUM_USER_TYPES == 6, num_user_types_unexpected); |
| + COMPILE_ASSERT(user_manager::NUM_USER_TYPES == 7, num_user_types_unexpected); |
| switch (GetType()) { |
| case user_manager::USER_TYPE_REGULAR: |
| + case user_manager::USER_TYPE_REGULAR_SUPERVISED: |
| return true; |
| case user_manager::USER_TYPE_GUEST: |
| case user_manager::USER_TYPE_RETAIL_MODE: |