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

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: First comments addressed. 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..795456836101e99f16dda748c60a3cacded453cf 100644
--- a/components/user_manager/user.cc
+++ b/components/user_manager/user.cc
@@ -28,14 +28,32 @@ std::string GetUserName(const std::string& email) {
} // namespace
-bool User::IsSupervised() const {
- return false;
-}
-
void User::SetIsSupervised(bool is_supervised) {
bartfab (slow) 2014/11/11 19:42:07 The definition order does not match the declaratio
merkulova 2014/11/12 10:01:01 Done.
VLOG(1) << "Ignoring SetIsSupervised call with param " << is_supervised;
+ NOTREACHED() << "Calling SetIsSupervised for base User class.";
+}
+
+// static
+bool User::TypeIsRegular(UserType user_type) {
+ return user_type == USER_TYPE_REGULAR ||
+ user_type == USER_TYPE_REGULAR_SUPERVISED;
+}
+
+// static
+bool User::TypeIsSupervised(UserType user_type) {
Daniel Erat 2014/11/11 16:02:49 i don't see this static method getting called anyw
bartfab (slow) 2014/11/11 19:42:07 The definition order does not match the declaratio
merkulova 2014/11/12 10:01:01 Done.
merkulova 2014/11/12 10:01:02 Done.
+ return user_type == USER_TYPE_SUPERVISED ||
+ user_type == USER_TYPE_REGULAR_SUPERVISED;
+}
+
+bool User::IsRegular() const {
bartfab (slow) 2014/11/11 19:42:07 1: This should be implemented in the same way as t
merkulova 2014/11/12 10:01:02 Why would you prefer that approach? That would lea
bartfab (slow) 2014/11/12 16:20:25 The idea is that you have a class which encapsulat
+ return TypeIsRegular(GetType());
}
+bool User::IsSupervised() const {
bartfab (slow) 2014/11/11 19:42:06 The definition order does not match the declaratio
merkulova 2014/11/12 10:01:01 Done.
+ return TypeIsSupervised(GetType());
+}
+
+// Also used for regular supervised users.
class RegularUser : public User {
public:
explicit RegularUser(const std::string& email);
@@ -44,13 +62,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 {
bartfab (slow) 2014/11/11 19:42:07 This was the right way of doing things. Why did yo
merkulova 2014/11/12 10:01:01 Because new user type was introduced. Before there
- return is_supervised_;
- }
+ virtual void SetIsSupervised(bool is_supervised) override;
private:
bool is_supervised_;
@@ -89,7 +101,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:
@@ -252,13 +263,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 +314,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 +336,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