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 // The signin manager encapsulates some functionality tracking | 5 // The signin manager encapsulates some functionality tracking |
6 // which user is signed in. See SigninManagerBase for full description of | 6 // which user is signed in. See SigninManagerBase for full description of |
7 // responsibilities. The class defined in this file provides functionality | 7 // responsibilities. The class defined in this file provides functionality |
8 // required by all platforms except Chrome OS. | 8 // required by all platforms except Chrome OS. |
9 // | 9 // |
10 // When a user is signed in, a ClientLogin request is run on their behalf. | 10 // When a user is signed in, a ClientLogin request is run on their behalf. |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 // OneClickSigninHelper. | 68 // OneClickSigninHelper. |
69 static const char* kChromeSigninEffectiveSite; | 69 static const char* kChromeSigninEffectiveSite; |
70 | 70 |
71 explicit SigninManager(scoped_ptr<SigninManagerDelegate> delegate); | 71 explicit SigninManager(scoped_ptr<SigninManagerDelegate> delegate); |
72 virtual ~SigninManager(); | 72 virtual ~SigninManager(); |
73 | 73 |
74 // Returns true if the username is allowed based on the policy string. | 74 // Returns true if the username is allowed based on the policy string. |
75 static bool IsUsernameAllowedByPolicy(const std::string& username, | 75 static bool IsUsernameAllowedByPolicy(const std::string& username, |
76 const std::string& policy); | 76 const std::string& policy); |
77 | 77 |
78 // Attempt to sign in this user with ClientLogin. If successful, set a | |
79 // preference indicating the signed in user and send out a notification, | |
80 // then start fetching tokens for the user. | |
81 // This is overridden for test subclasses that don't want to issue auth | |
82 // requests. | |
83 virtual void StartSignIn(const std::string& username, | |
84 const std::string& password, | |
85 const std::string& login_token, | |
86 const std::string& login_captcha); | |
87 | |
88 // Used when a second factor access code was required to complete a signin | |
89 // attempt. | |
90 void ProvideSecondFactorAccessCode(const std::string& access_code); | |
91 | |
92 // Attempt to sign in this user with existing credentials from the cookie jar. | 78 // Attempt to sign in this user with existing credentials from the cookie jar. |
93 // |session_index| indicates which user account to use if the cookie jar | 79 // |session_index| indicates which user account to use if the cookie jar |
94 // contains a multi-login session. Otherwise the end result of this call is | 80 // contains a multi-login session. Otherwise the end result of this call is |
95 // the same as StartSignIn(). | 81 // the same as StartSignIn(). |
96 // If non-null, the passed |signin_complete| callback is invoked once signin | 82 // If non-null, the passed |signin_complete| callback is invoked once signin |
97 // has been completed and the oauth login token has been generated - the | 83 // has been completed and the oauth login token has been generated - the |
98 // callback will not be invoked if no token is generated (either because of | 84 // callback will not be invoked if no token is generated (either because of |
99 // a failed signin or because web-based signin is not enabled). | 85 // a failed signin or because web-based signin is not enabled). |
100 // The callback should invoke SignOut() or CompletePendingSignin() to either | 86 // The callback should invoke SignOut() or CompletePendingSignin() to either |
101 // continue or cancel the in-process signin. | 87 // continue or cancel the in-process signin. |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 bool HasSigninProcess() const; | 176 bool HasSigninProcess() const; |
191 | 177 |
192 protected: | 178 protected: |
193 // If user was signed in, load tokens from DB if available. | 179 // If user was signed in, load tokens from DB if available. |
194 virtual void InitTokenService() OVERRIDE; | 180 virtual void InitTokenService() OVERRIDE; |
195 | 181 |
196 // Flag saying whether signing out is allowed. | 182 // Flag saying whether signing out is allowed. |
197 bool prohibit_signout_; | 183 bool prohibit_signout_; |
198 | 184 |
199 private: | 185 private: |
| 186 // TODO(guohui): Leaving the sign in type here because a follow up CL by |
| 187 // Hui will add a new type. Hui: please remove this comment in your CL. |
200 enum SigninType { | 188 enum SigninType { |
201 SIGNIN_TYPE_NONE, | 189 SIGNIN_TYPE_NONE, |
202 SIGNIN_TYPE_CLIENT_LOGIN, | |
203 SIGNIN_TYPE_WITH_CREDENTIALS, | 190 SIGNIN_TYPE_WITH_CREDENTIALS, |
204 }; | 191 }; |
205 | 192 |
206 std::string SigninTypeToString(SigninType type); | 193 std::string SigninTypeToString(SigninType type); |
207 | |
208 friend class FakeSigninManager; | 194 friend class FakeSigninManager; |
209 FRIEND_TEST_ALL_PREFIXES(SigninManagerTest, ClearTransientSigninData); | 195 FRIEND_TEST_ALL_PREFIXES(SigninManagerTest, ClearTransientSigninData); |
210 FRIEND_TEST_ALL_PREFIXES(SigninManagerTest, ProvideSecondFactorSuccess); | 196 FRIEND_TEST_ALL_PREFIXES(SigninManagerTest, ProvideSecondFactorSuccess); |
211 FRIEND_TEST_ALL_PREFIXES(SigninManagerTest, ProvideSecondFactorFailure); | 197 FRIEND_TEST_ALL_PREFIXES(SigninManagerTest, ProvideSecondFactorFailure); |
212 | 198 |
213 // Called to setup the transient signin data during one of the | 199 // Called to setup the transient signin data during one of the |
214 // StartSigninXXX methods. |type| indicates which of the methods is being | 200 // StartSigninXXX methods. |type| indicates which of the methods is being |
215 // used to perform the signin while |username| and |password| identify the | 201 // used to perform the signin while |username| and |password| identify the |
216 // account to be signed in. Returns false and generates an auth error if the | 202 // account to be signed in. Returns false and generates an auth error if the |
217 // passed |username| is not allowed by policy. | 203 // passed |username| is not allowed by policy. |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 | 282 |
297 // Helper object to listen for changes to the signin allowed preference. | 283 // Helper object to listen for changes to the signin allowed preference. |
298 BooleanPrefMember signin_allowed_; | 284 BooleanPrefMember signin_allowed_; |
299 | 285 |
300 DISALLOW_COPY_AND_ASSIGN(SigninManager); | 286 DISALLOW_COPY_AND_ASSIGN(SigninManager); |
301 }; | 287 }; |
302 | 288 |
303 #endif // !defined(OS_CHROMEOS) | 289 #endif // !defined(OS_CHROMEOS) |
304 | 290 |
305 #endif // CHROME_BROWSER_SIGNIN_SIGNIN_MANAGER_H_ | 291 #endif // CHROME_BROWSER_SIGNIN_SIGNIN_MANAGER_H_ |
OLD | NEW |