Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 24 class FilePath; | 24 class FilePath; |
| 25 class PrefService; | 25 class PrefService; |
| 26 class ProfileDownloader; | 26 class ProfileDownloader; |
| 27 | 27 |
| 28 namespace base { | 28 namespace base { |
| 29 template<typename> struct DefaultLazyInstanceTraits; | 29 template<typename> struct DefaultLazyInstanceTraits; |
| 30 } | 30 } |
| 31 | 31 |
| 32 namespace chromeos { | 32 namespace chromeos { |
| 33 | 33 |
| 34 class RemoveUserDelegate; | 34 // Delegate to be used while user removing. |
|
whywhat
2011/12/05 12:14:49
nit: Move to a separate header
Ivan Korotkov
2011/12/05 14:12:48
Done.
| |
| 35 class RemoveUserDelegate { | |
| 36 public: | |
| 37 // Called right before actual user removal process is initiated. | |
| 38 virtual void OnBeforeUserRemoved(const std::string& username) = 0; | |
| 39 | |
| 40 // Called right after user removal process has been initiated. | |
| 41 virtual void OnUserRemoved(const std::string& username) = 0; | |
| 42 }; | |
| 43 | |
| 35 | 44 |
| 36 // This class provides a mechanism for discovering users who have logged | 45 // This class provides a mechanism for discovering users who have logged |
| 37 // into this chromium os device before and updating that list. | 46 // into this chromium os device before and updating that list. |
| 38 class UserManager : public ProfileDownloaderDelegate, | 47 class UserManager : public ProfileDownloaderDelegate, |
| 39 public content::NotificationObserver { | 48 public content::NotificationObserver { |
| 40 public: | 49 public: |
| 41 // Returns a shared instance of a UserManager. Not thread-safe, should only be | 50 // Returns a shared instance of a UserManager. Not thread-safe, should only be |
| 42 // called from the main UI thread. | 51 // called from the main UI thread. |
| 43 static UserManager* Get(); | 52 static UserManager* Get(); |
| 44 | 53 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 76 const User& logged_in_user() const { return *logged_in_user_; } | 85 const User& logged_in_user() const { return *logged_in_user_; } |
| 77 User& logged_in_user() { return *logged_in_user_; } | 86 User& logged_in_user() { return *logged_in_user_; } |
| 78 | 87 |
| 79 // Returns true if given display name is unique. | 88 // Returns true if given display name is unique. |
| 80 bool IsDisplayNameUnique(const std::string& display_name) const; | 89 bool IsDisplayNameUnique(const std::string& display_name) const; |
| 81 | 90 |
| 82 // Saves user's oauth token status in local state preferences. | 91 // Saves user's oauth token status in local state preferences. |
| 83 void SaveUserOAuthStatus(const std::string& username, | 92 void SaveUserOAuthStatus(const std::string& username, |
| 84 User::OAuthTokenStatus oauth_token_status); | 93 User::OAuthTokenStatus oauth_token_status); |
| 85 | 94 |
| 86 // Gets user's oauth token status in local state preferences. | 95 // Save user's displayed (non-canonical) email in local state preferences. |
| 87 User::OAuthTokenStatus GetUserOAuthStatus(const std::string& username) const; | 96 // If |update_if_exists| is false and a display name for |username| already |
| 97 // exists, does nothing. | |
| 98 void SaveUserDisplayEmail(const std::string& username, | |
| 99 const std::string& display_email, | |
| 100 bool update_if_exists); | |
| 101 | |
| 102 // Returns the display email for user |username| if it is known (was | |
| 103 // previously set by a |SaveUserDisplayEmail| call). | |
| 104 // Otherwise, returns |username| itself. | |
| 105 std::string GetUserDisplayEmail(const std::string& username) const; | |
| 88 | 106 |
| 89 // Sets user image to the default image with index |image_index|, sends | 107 // Sets user image to the default image with index |image_index|, sends |
| 90 // LOGIN_USER_IMAGE_CHANGED notification and updates Local State. | 108 // LOGIN_USER_IMAGE_CHANGED notification and updates Local State. |
| 91 void SaveUserDefaultImageIndex(const std::string& username, int image_index); | 109 void SaveUserDefaultImageIndex(const std::string& username, int image_index); |
| 92 | 110 |
| 93 // Saves image to file, sends LOGIN_USER_IMAGE_CHANGED notification and | 111 // Saves image to file, sends LOGIN_USER_IMAGE_CHANGED notification and |
| 94 // updates Local State. | 112 // updates Local State. |
| 95 void SaveUserImage(const std::string& username, const SkBitmap& image); | 113 void SaveUserImage(const std::string& username, const SkBitmap& image); |
| 96 | 114 |
| 97 // Tries to load user image from disk; if successful, sets it for the user, | 115 // Tries to load user image from disk; if successful, sets it for the user, |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 162 // Loads |users_| from Local State if the list has not been loaded yet. | 180 // Loads |users_| from Local State if the list has not been loaded yet. |
| 163 // Subsequent calls have no effect. Must be called on the UI thread. | 181 // Subsequent calls have no effect. Must be called on the UI thread. |
| 164 void EnsureUsersLoaded(); | 182 void EnsureUsersLoaded(); |
| 165 | 183 |
| 166 // Makes stub user the current logged-in user (for test paths). | 184 // Makes stub user the current logged-in user (for test paths). |
| 167 void StubUserLoggedIn(); | 185 void StubUserLoggedIn(); |
| 168 | 186 |
| 169 // Notifies on new user session. | 187 // Notifies on new user session. |
| 170 void NotifyOnLogin(); | 188 void NotifyOnLogin(); |
| 171 | 189 |
| 190 // Reads user's oauth token status from local state preferences. | |
| 191 User::OAuthTokenStatus LoadUserOAuthStatus(const std::string& username) const; | |
| 192 | |
| 172 // Sets one of the default images for the specified user and saves this | 193 // Sets one of the default images for the specified user and saves this |
| 173 // setting in local state. | 194 // setting in local state. |
| 174 // Does not send LOGIN_USER_IMAGE_CHANGED notification. | 195 // Does not send LOGIN_USER_IMAGE_CHANGED notification. |
| 175 void SetInitialUserImage(const std::string& username); | 196 void SetInitialUserImage(const std::string& username); |
| 176 | 197 |
| 177 // Sets image for user |username| and sends LOGIN_USER_IMAGE_CHANGED | 198 // Sets image for user |username| and sends LOGIN_USER_IMAGE_CHANGED |
| 178 // notification unless this is a new user and image is set for the first time. | 199 // notification unless this is a new user and image is set for the first time. |
| 179 void SetUserImage(const std::string& username, | 200 void SetUserImage(const std::string& username, |
| 180 int image_index, | 201 int image_index, |
| 181 const SkBitmap& image); | 202 const SkBitmap& image); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 278 | 299 |
| 279 // Data URL for |downloaded_profile_image_|. | 300 // Data URL for |downloaded_profile_image_|. |
| 280 std::string downloaded_profile_image_data_url_; | 301 std::string downloaded_profile_image_data_url_; |
| 281 | 302 |
| 282 DISALLOW_COPY_AND_ASSIGN(UserManager); | 303 DISALLOW_COPY_AND_ASSIGN(UserManager); |
| 283 }; | 304 }; |
| 284 | 305 |
| 285 } // namespace chromeos | 306 } // namespace chromeos |
| 286 | 307 |
| 287 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_H_ | 308 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_H_ |
| OLD | NEW |