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

Unified Diff: components/user_manager/user.cc

Issue 718673002: New user type introduced. Combines regular and supervised features. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Logical expression fixed. Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: components/user_manager/user.cc
diff --git a/components/user_manager/user.cc b/components/user_manager/user.cc
index 664aa4ba5041bfb84ed780decfb0e281336b1137..7035096fe374448b5547ab67913f6b0ecacab11b 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::TypeHasGaiaAccount(UserType user_type) {
+ 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 TypeHasGaiaAccount(GetType());
+}
+
+bool User::IsSupervised() const {
+ UserType type = GetType();
bartfab (slow) 2014/11/27 12:51:51 Nit: Const.
+ 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:

Powered by Google App Engine
This is Rietveld 408576698