| OLD | NEW |
| 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 #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 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
| 11 #include "chrome/browser/chromeos/login/user.h" | 11 #include "chrome/browser/chromeos/login/user.h" |
| 12 | 12 |
| 13 class PrefService; | 13 class PrefService; |
| 14 | 14 |
| 15 namespace chromeos { | 15 namespace chromeos { |
| 16 | 16 |
| 17 class RemoveUserDelegate; | 17 class RemoveUserDelegate; |
| 18 class UserImageManager; | 18 class UserImageManager; |
| 19 | 19 |
| 20 // Base class for UserManagerImpl - provides a mechanism for discovering users | 20 // Base class for UserManagerImpl - provides a mechanism for discovering users |
| 21 // who have logged into this Chrome OS device before and updating that list. | 21 // who have logged into this Chrome OS device before and updating that list. |
| 22 class UserManager { | 22 class UserManager { |
| 23 public: | 23 public: |
| 24 // Status of merge sessions process which is responsible for exchanging | |
| 25 // user OAuth2 refresh token for GAIA cookies. | |
| 26 enum MergeSessionState { | |
| 27 // Session merge hasn't started yet. | |
| 28 MERGE_STATUS_NOT_STARTED, | |
| 29 // Session merge is in process. | |
| 30 MERGE_STATUS_IN_PROCESS, | |
| 31 // Session merge is completed. | |
| 32 MERGE_STATUS_DONE, | |
| 33 }; | |
| 34 | |
| 35 // Interface that observers of UserManager must implement in order | 24 // Interface that observers of UserManager must implement in order |
| 36 // to receive notification when local state preferences is changed | 25 // to receive notification when local state preferences is changed |
| 37 class Observer { | 26 class Observer { |
| 38 public: | 27 public: |
| 39 // Called when the local state preferences is changed. | 28 // Called when the local state preferences is changed |
| 40 virtual void LocalStateChanged(UserManager* user_manager) = 0; | 29 virtual void LocalStateChanged(UserManager* user_manager) = 0; |
| 41 | 30 |
| 42 // Called when merge session state is changed. | |
| 43 virtual void MergeSessionStateChanged(MergeSessionState state) {} | |
| 44 | |
| 45 protected: | 31 protected: |
| 46 virtual ~Observer() {} | 32 virtual ~Observer() {} |
| 47 }; | 33 }; |
| 48 | 34 |
| 49 // Username for stub login when not running on ChromeOS. | 35 // Username for stub login when not running on ChromeOS. |
| 50 static const char kStubUser[]; | 36 static const char kStubUser[]; |
| 51 | 37 |
| 52 // Returns a shared instance of a UserManager. Not thread-safe, should only be | 38 // Returns a shared instance of a UserManager. Not thread-safe, should only be |
| 53 // called from the main UI thread. | 39 // called from the main UI thread. |
| 54 static UserManager* Get(); | 40 static UserManager* Get(); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 virtual bool IsLoggedInAsGuest() const = 0; | 183 virtual bool IsLoggedInAsGuest() const = 0; |
| 198 | 184 |
| 199 // Returns true if we're logged in as the stub user used for testing on Linux. | 185 // Returns true if we're logged in as the stub user used for testing on Linux. |
| 200 virtual bool IsLoggedInAsStub() const = 0; | 186 virtual bool IsLoggedInAsStub() const = 0; |
| 201 | 187 |
| 202 // Returns true if we're logged in and browser has been started i.e. | 188 // Returns true if we're logged in and browser has been started i.e. |
| 203 // browser_creator.LaunchBrowser(...) was called after sign in | 189 // browser_creator.LaunchBrowser(...) was called after sign in |
| 204 // or restart after crash. | 190 // or restart after crash. |
| 205 virtual bool IsSessionStarted() const = 0; | 191 virtual bool IsSessionStarted() const = 0; |
| 206 | 192 |
| 207 // Returns merge session status. | |
| 208 virtual MergeSessionState GetMergeSessionState() const = 0; | |
| 209 | |
| 210 // Changes merge session status. | |
| 211 virtual void SetMergeSessionState(MergeSessionState status) = 0; | |
| 212 | |
| 213 // Returns true when the browser has crashed and restarted during the current | 193 // Returns true when the browser has crashed and restarted during the current |
| 214 // user's session. | 194 // user's session. |
| 215 virtual bool HasBrowserRestarted() const = 0; | 195 virtual bool HasBrowserRestarted() const = 0; |
| 216 | 196 |
| 217 // Returns true if data stored or cached for the user with the given email | 197 // Returns true if data stored or cached for the user with the given email |
| 218 // address outside that user's cryptohome (wallpaper, avatar, OAuth token | 198 // address outside that user's cryptohome (wallpaper, avatar, OAuth token |
| 219 // status, display name, display email) is to be treated as ephemeral. | 199 // status, display name, display email) is to be treated as ephemeral. |
| 220 virtual bool IsUserNonCryptohomeDataEphemeral( | 200 virtual bool IsUserNonCryptohomeDataEphemeral( |
| 221 const std::string& email) const = 0; | 201 const std::string& email) const = 0; |
| 222 | 202 |
| 223 virtual void AddObserver(Observer* obs) = 0; | 203 virtual void AddObserver(Observer* obs) = 0; |
| 224 virtual void RemoveObserver(Observer* obs) = 0; | 204 virtual void RemoveObserver(Observer* obs) = 0; |
| 225 | 205 |
| 226 virtual void NotifyLocalStateChanged() = 0; | 206 virtual void NotifyLocalStateChanged() = 0; |
| 227 }; | 207 }; |
| 228 | 208 |
| 229 } // namespace chromeos | 209 } // namespace chromeos |
| 230 | 210 |
| 231 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_H_ | 211 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_MANAGER_H_ |
| OLD | NEW |