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

Side by Side Diff: chrome/browser/chromeos/login/user.cc

Issue 11419184: Add public accounts to UserManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Re-upload against the correct upstream commit. Created 8 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/chromeos/login/user.h" 5 #include "chrome/browser/chromeos/login/user.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/stringprintf.h" 8 #include "base/stringprintf.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/chromeos/login/default_user_images.h" 10 #include "chrome/browser/chromeos/login/default_user_images.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 DISALLOW_COPY_AND_ASSIGN(RegularUser); 49 DISALLOW_COPY_AND_ASSIGN(RegularUser);
50 }; 50 };
51 51
52 class GuestUser : public User { 52 class GuestUser : public User {
53 public: 53 public:
54 GuestUser(); 54 GuestUser();
55 virtual ~GuestUser(); 55 virtual ~GuestUser();
56 56
57 // Overridden from User: 57 // Overridden from User:
58 virtual UserType GetType() const OVERRIDE; 58 virtual UserType GetType() const OVERRIDE;
59 virtual bool is_device_local_account() const OVERRIDE;
60 virtual bool is_builtin_account() const OVERRIDE;
59 61
60 private: 62 private:
61 DISALLOW_COPY_AND_ASSIGN(GuestUser); 63 DISALLOW_COPY_AND_ASSIGN(GuestUser);
62 }; 64 };
63 65
64 class RetailModeUser : public User { 66 class RetailModeUser : public User {
65 public: 67 public:
66 RetailModeUser(); 68 RetailModeUser();
67 virtual ~RetailModeUser(); 69 virtual ~RetailModeUser();
68 70
69 // Overridden from User: 71 // Overridden from User:
70 virtual UserType GetType() const OVERRIDE; 72 virtual UserType GetType() const OVERRIDE;
73 virtual bool is_device_local_account() const OVERRIDE;
71 74
72 private: 75 private:
73 DISALLOW_COPY_AND_ASSIGN(RetailModeUser); 76 DISALLOW_COPY_AND_ASSIGN(RetailModeUser);
74 }; 77 };
75 78
76 class PublicAccountUser : public User { 79 class PublicAccountUser : public User {
77 public: 80 public:
78 explicit PublicAccountUser(const std::string& email); 81 explicit PublicAccountUser(const std::string& email);
79 virtual ~PublicAccountUser(); 82 virtual ~PublicAccountUser();
80 83
81 // Overridden from User: 84 // Overridden from User:
82 virtual UserType GetType() const OVERRIDE; 85 virtual UserType GetType() const OVERRIDE;
86 virtual bool is_device_local_account() const OVERRIDE;
83 87
84 private: 88 private:
85 DISALLOW_COPY_AND_ASSIGN(PublicAccountUser); 89 DISALLOW_COPY_AND_ASSIGN(PublicAccountUser);
86 }; 90 };
87 91
88 string16 User::GetDisplayName() const { 92 string16 User::GetDisplayName() const {
89 // Fallback to the email account name in case display name haven't been set. 93 // Fallback to the email account name in case display name haven't been set.
90 return display_name_.empty() ? 94 return display_name_.empty() ?
91 UTF8ToUTF16(GetAccountName(true)) : 95 UTF8ToUTF16(GetAccountName(true)) :
92 display_name_; 96 display_name_;
93 } 97 }
94 98
95 std::string User::GetAccountName(bool use_display_email) const { 99 std::string User::GetAccountName(bool use_display_email) const {
96 if (use_display_email && !display_email_.empty()) 100 if (use_display_email && !display_email_.empty())
97 return GetUserName(display_email_); 101 return GetUserName(display_email_);
98 else 102 else
99 return GetUserName(email_); 103 return GetUserName(email_);
100 } 104 }
101 105
102 bool User::HasDefaultImage() const { 106 bool User::HasDefaultImage() const {
103 return image_index_ >= 0 && image_index_ < kDefaultImagesCount; 107 return image_index_ >= 0 && image_index_ < kDefaultImagesCount;
104 } 108 }
105 109
106 bool User::can_lock() const { 110 bool User::can_lock() const {
107 return false; 111 return false;
108 } 112 }
109 113
114 bool User::is_device_local_account() const {
115 return false;
116 }
117
118 bool User::is_builtin_account() const {
119 return false;
120 }
121
110 User* User::CreateRegularUser(const std::string& email) { 122 User* User::CreateRegularUser(const std::string& email) {
111 return new RegularUser(email); 123 return new RegularUser(email);
112 } 124 }
113 125
114 User* User::CreateGuestUser() { 126 User* User::CreateGuestUser() {
115 return new GuestUser; 127 return new GuestUser;
116 } 128 }
117 129
118 User* User::CreateRetailModeUser() { 130 User* User::CreateRetailModeUser() {
119 return new RetailModeUser; 131 return new RetailModeUser;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 GuestUser::GuestUser() : User(kGuestUserEMail) { 183 GuestUser::GuestUser() : User(kGuestUserEMail) {
172 set_display_email(""); 184 set_display_email("");
173 } 185 }
174 186
175 GuestUser::~GuestUser() {} 187 GuestUser::~GuestUser() {}
176 188
177 User::UserType GuestUser::GetType() const { 189 User::UserType GuestUser::GetType() const {
178 return USER_TYPE_GUEST; 190 return USER_TYPE_GUEST;
179 } 191 }
180 192
193 bool GuestUser::is_device_local_account() const {
194 return true;
195 }
196
197 bool GuestUser::is_builtin_account() const {
198 return true;
199 }
200
181 RetailModeUser::RetailModeUser() : User(kRetailModeUserEMail) { 201 RetailModeUser::RetailModeUser() : User(kRetailModeUserEMail) {
182 set_display_email(""); 202 set_display_email("");
183 } 203 }
184 204
185 RetailModeUser::~RetailModeUser() {} 205 RetailModeUser::~RetailModeUser() {}
186 206
187 User::UserType RetailModeUser::GetType() const { 207 User::UserType RetailModeUser::GetType() const {
188 return USER_TYPE_RETAIL_MODE; 208 return USER_TYPE_RETAIL_MODE;
189 } 209 }
190 210
211 bool RetailModeUser::is_device_local_account() const {
212 return true;
213 }
214
191 PublicAccountUser::PublicAccountUser(const std::string& email) : User(email) { 215 PublicAccountUser::PublicAccountUser(const std::string& email) : User(email) {
192 } 216 }
193 217
194 PublicAccountUser::~PublicAccountUser() {} 218 PublicAccountUser::~PublicAccountUser() {}
195 219
196 User::UserType PublicAccountUser::GetType() const { 220 User::UserType PublicAccountUser::GetType() const {
197 return USER_TYPE_PUBLIC_ACCOUNT; 221 return USER_TYPE_PUBLIC_ACCOUNT;
198 } 222 }
199 223
224 bool PublicAccountUser::is_device_local_account() const {
225 return true;
226 }
227
200 } // namespace chromeos 228 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698