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

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

Issue 1794323003: Make user_manager::UserImage non-copyable (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 4 years, 9 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
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 #ifndef COMPONENTS_USER_MANAGER_USER_H_ 5 #ifndef COMPONENTS_USER_MANAGER_USER_H_
6 #define COMPONENTS_USER_MANAGER_USER_H_ 6 #define COMPONENTS_USER_MANAGER_USER_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 bool using_saml() const { return using_saml_; } 120 bool using_saml() const { return using_saml_; }
121 121
122 // Returns the account name part of the email. Use the display form of the 122 // Returns the account name part of the email. Use the display form of the
123 // email if available and use_display_name == true. Otherwise use canonical. 123 // email if available and use_display_name == true. Otherwise use canonical.
124 std::string GetAccountName(bool use_display_email) const; 124 std::string GetAccountName(bool use_display_email) const;
125 125
126 // Whether the user has a default image. 126 // Whether the user has a default image.
127 bool HasDefaultImage() const; 127 bool HasDefaultImage() const;
128 128
129 int image_index() const { return image_index_; } 129 int image_index() const { return image_index_; }
130 bool has_image_bytes() const { return user_image_.has_image_bytes(); } 130 bool has_image_bytes() const { return user_image_->has_image_bytes(); }
131 // Returns bytes representation of static user image for WebUI. 131 // Returns bytes representation of static user image for WebUI.
132 const UserImage::Bytes& image_bytes() const { 132 const UserImage::Bytes& image_bytes() const {
133 return user_image_.image_bytes(); 133 return user_image_->image_bytes();
134 } 134 }
135 135
136 // Whether |user_image_| contains data in format that is considered safe to 136 // Whether |user_image_| contains data in format that is considered safe to
137 // decode in sensitive environment (on Login screen). 137 // decode in sensitive environment (on Login screen).
138 bool image_is_safe_format() const { return user_image_.is_safe_format(); } 138 bool image_is_safe_format() const { return user_image_->is_safe_format(); }
139 139
140 // Returns the URL of user image, if there is any. Currently only the profile 140 // Returns the URL of user image, if there is any. Currently only the profile
141 // image has a URL, for other images empty URL is returned. 141 // image has a URL, for other images empty URL is returned.
142 GURL image_url() const { return user_image_.url(); } 142 GURL image_url() const { return user_image_->url(); }
143 143
144 // True if user image is a stub (while real image is being loaded from file). 144 // True if user image is a stub (while real image is being loaded from file).
145 bool image_is_stub() const { return image_is_stub_; } 145 bool image_is_stub() const { return image_is_stub_; }
146 146
147 // True if image is being loaded from file. 147 // True if image is being loaded from file.
148 bool image_is_loading() const { return image_is_loading_; } 148 bool image_is_loading() const { return image_is_loading_; }
149 149
150 // OAuth token status for this user. 150 // OAuth token status for this user.
151 OAuthTokenStatus oauth_token_status() const { return oauth_token_status_; } 151 OAuthTokenStatus oauth_token_status() const { return oauth_token_status_; }
152 152
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 static User* CreatePublicAccountUser(const AccountId& account_id); 192 static User* CreatePublicAccountUser(const AccountId& account_id);
193 193
194 explicit User(const AccountId& account_id); 194 explicit User(const AccountId& account_id);
195 ~User() override; 195 ~User() override;
196 196
197 const std::string* GetAccountLocale() const { return account_locale_.get(); } 197 const std::string* GetAccountLocale() const { return account_locale_.get(); }
198 198
199 // Setters are private so only UserManager can call them. 199 // Setters are private so only UserManager can call them.
200 void SetAccountLocale(const std::string& resolved_account_locale); 200 void SetAccountLocale(const std::string& resolved_account_locale);
201 201
202 void SetImage(const UserImage& user_image, int image_index); 202 void SetImage(scoped_ptr<UserImage> user_image, int image_index);
203 203
204 void SetImageURL(const GURL& image_url); 204 void SetImageURL(const GURL& image_url);
205 205
206 // Sets a stub image until the next |SetImage| call. |image_index| may be 206 // Sets a stub image until the next |SetImage| call. |image_index| may be
207 // one of |USER_IMAGE_EXTERNAL| or |USER_IMAGE_PROFILE|. 207 // one of |USER_IMAGE_EXTERNAL| or |USER_IMAGE_PROFILE|.
208 // If |is_loading| is |true|, that means user image is being loaded from file. 208 // If |is_loading| is |true|, that means user image is being loaded from file.
209 void SetStubImage(const UserImage& stub_user_image, 209 void SetStubImage(scoped_ptr<UserImage> stub_user_image,
210 int image_index, 210 int image_index,
211 bool is_loading); 211 bool is_loading);
212 212
213 void set_display_name(const base::string16& display_name) { 213 void set_display_name(const base::string16& display_name) {
214 display_name_ = display_name; 214 display_name_ = display_name;
215 } 215 }
216 216
217 void set_given_name(const base::string16& given_name) { 217 void set_given_name(const base::string16& given_name) {
218 given_name_ = given_name; 218 given_name_ = given_name;
219 } 219 }
220 220
221 void set_display_email(const std::string& display_email) { 221 void set_display_email(const std::string& display_email) {
222 display_email_ = display_email; 222 display_email_ = display_email;
223 } 223 }
224 224
225 void set_using_saml(const bool using_saml) { using_saml_ = using_saml; } 225 void set_using_saml(const bool using_saml) { using_saml_ = using_saml; }
226 226
227 const UserImage& user_image() const { return user_image_; } 227 const UserImage& user_image() const { return *user_image_; }
achuithb 2016/03/18 18:57:47 The method name should be GetUserImage since it is
satorux1 2016/03/18 22:46:36 I think it's ok to keep the name as is because the
228 228
229 void set_oauth_token_status(OAuthTokenStatus status) { 229 void set_oauth_token_status(OAuthTokenStatus status) {
230 oauth_token_status_ = status; 230 oauth_token_status_ = status;
231 } 231 }
232 232
233 void set_force_online_signin(bool force_online_signin) { 233 void set_force_online_signin(bool force_online_signin) {
234 force_online_signin_ = force_online_signin; 234 force_online_signin_ = force_online_signin;
235 } 235 }
236 236
237 void set_username_hash(const std::string& username_hash) { 237 void set_username_hash(const std::string& username_hash) {
(...skipping 13 matching lines...) Expand all
251 251
252 virtual void SetAffiliation(bool is_affiliated); 252 virtual void SetAffiliation(bool is_affiliated);
253 253
254 private: 254 private:
255 AccountId account_id_; 255 AccountId account_id_;
256 base::string16 display_name_; 256 base::string16 display_name_;
257 base::string16 given_name_; 257 base::string16 given_name_;
258 // The displayed user email, defaults to |email_|. 258 // The displayed user email, defaults to |email_|.
259 std::string display_email_; 259 std::string display_email_;
260 bool using_saml_ = false; 260 bool using_saml_ = false;
261 UserImage user_image_; 261 scoped_ptr<UserImage> user_image_;
262 OAuthTokenStatus oauth_token_status_ = OAUTH_TOKEN_STATUS_UNKNOWN; 262 OAuthTokenStatus oauth_token_status_ = OAUTH_TOKEN_STATUS_UNKNOWN;
263 bool force_online_signin_ = false; 263 bool force_online_signin_ = false;
264 264
265 // This is set to chromeos locale if account data has been downloaded. 265 // This is set to chromeos locale if account data has been downloaded.
266 // (Or failed to download, but at least one download attempt finished). 266 // (Or failed to download, but at least one download attempt finished).
267 // An empty string indicates error in data load, or in 267 // An empty string indicates error in data load, or in
268 // translation of Account locale to chromeos locale. 268 // translation of Account locale to chromeos locale.
269 scoped_ptr<std::string> account_locale_; 269 scoped_ptr<std::string> account_locale_;
270 270
271 // Used to identify homedir mount point. 271 // Used to identify homedir mount point.
(...skipping 26 matching lines...) Expand all
298 298
299 DISALLOW_COPY_AND_ASSIGN(User); 299 DISALLOW_COPY_AND_ASSIGN(User);
300 }; 300 };
301 301
302 // List of known users. 302 // List of known users.
303 using UserList = std::vector<User*>; 303 using UserList = std::vector<User*>;
304 304
305 } // namespace user_manager 305 } // namespace user_manager
306 306
307 #endif // COMPONENTS_USER_MANAGER_USER_H_ 307 #endif // COMPONENTS_USER_MANAGER_USER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698