OLD | NEW |
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 // 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 28 matching lines...) Expand all Loading... |
39 #include "google_apis/gaia/google_service_auth_error.h" | 39 #include "google_apis/gaia/google_service_auth_error.h" |
40 #include "google_apis/gaia/merge_session_helper.h" | 40 #include "google_apis/gaia/merge_session_helper.h" |
41 #include "net/cookies/canonical_cookie.h" | 41 #include "net/cookies/canonical_cookie.h" |
42 | 42 |
43 class PrefService; | 43 class PrefService; |
44 class ProfileOAuth2TokenService; | 44 class ProfileOAuth2TokenService; |
45 class SigninAccountIdHelper; | 45 class SigninAccountIdHelper; |
46 class SigninClient; | 46 class SigninClient; |
47 | 47 |
48 class SigninManager : public SigninManagerBase, | 48 class SigninManager : public SigninManagerBase, |
49 public AccountTrackerService::Observer { | 49 public AccountTrackerService::Observer, |
| 50 public MergeSessionHelper::Observer { |
50 public: | 51 public: |
51 // The callback invoked once the OAuth token has been fetched during signin, | 52 // The callback invoked once the OAuth token has been fetched during signin, |
52 // but before the profile transitions to the "signed-in" state. This allows | 53 // but before the profile transitions to the "signed-in" state. This allows |
53 // callers to load policy and prompt the user appropriately before completing | 54 // callers to load policy and prompt the user appropriately before completing |
54 // signin. The callback is passed the just-fetched OAuth login refresh token. | 55 // signin. The callback is passed the just-fetched OAuth login refresh token. |
55 typedef base::Callback<void(const std::string&)> OAuthTokenFetchedCallback; | 56 typedef base::Callback<void(const std::string&)> OAuthTokenFetchedCallback; |
56 | 57 |
57 // Returns true if |url| is a web signin URL and should be hosted in an | 58 // Returns true if |url| is a web signin URL and should be hosted in an |
58 // isolated, privileged signin process. | 59 // isolated, privileged signin process. |
59 static bool IsWebBasedSigninFlowURL(const GURL& url); | 60 static bool IsWebBasedSigninFlowURL(const GURL& url); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 | 172 |
172 // Waits for the AccountTrackerService, then sends GoogleSigninSucceeded to | 173 // Waits for the AccountTrackerService, then sends GoogleSigninSucceeded to |
173 // the client and clears the local password. | 174 // the client and clears the local password. |
174 void PostSignedIn(); | 175 void PostSignedIn(); |
175 | 176 |
176 // AccountTrackerService::Observer implementation. | 177 // AccountTrackerService::Observer implementation. |
177 void OnAccountUpdated(const AccountTrackerService::AccountInfo& info) | 178 void OnAccountUpdated(const AccountTrackerService::AccountInfo& info) |
178 override; | 179 override; |
179 void OnAccountUpdateFailed(const std::string& account_id) override; | 180 void OnAccountUpdateFailed(const std::string& account_id) override; |
180 | 181 |
| 182 // MergeSessionHelper::Observer implementation. SigninManager controls the |
| 183 // lifetime if the MergeSessionHelper, so SigninManager takes responsibility |
| 184 // for propogating these notifications. |
| 185 void MergeSessionCompleted(const std::string& account_id, |
| 186 const GoogleServiceAuthError& error) override; |
| 187 void GetCheckConnectionInfoCompleted(bool succeeded) override; |
| 188 |
181 // Called when a new request to re-authenticate a user is in progress. | 189 // Called when a new request to re-authenticate a user is in progress. |
182 // Will clear in memory data but leaves the db as such so when the browser | 190 // Will clear in memory data but leaves the db as such so when the browser |
183 // restarts we can use the old token(which might throw a password error). | 191 // restarts we can use the old token(which might throw a password error). |
184 void ClearTransientSigninData(); | 192 void ClearTransientSigninData(); |
185 | 193 |
186 // Called to handle an error from a GAIA auth fetch. Sets the last error | 194 // Called to handle an error from a GAIA auth fetch. Sets the last error |
187 // to |error|, sends out a notification of login failure and clears the | 195 // to |error|, sends out a notification of login failure and clears the |
188 // transient signin data. | 196 // transient signin data. |
189 void HandleAuthError(const GoogleServiceAuthError& error); | 197 void HandleAuthError(const GoogleServiceAuthError& error); |
190 | 198 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 // Helper object to listen for changes to signin preferences stored in non- | 230 // Helper object to listen for changes to signin preferences stored in non- |
223 // profile-specific local prefs (like kGoogleServicesUsernamePattern). | 231 // profile-specific local prefs (like kGoogleServicesUsernamePattern). |
224 PrefChangeRegistrar local_state_pref_registrar_; | 232 PrefChangeRegistrar local_state_pref_registrar_; |
225 | 233 |
226 // Helper object to listen for changes to the signin allowed preference. | 234 // Helper object to listen for changes to the signin allowed preference. |
227 BooleanPrefMember signin_allowed_; | 235 BooleanPrefMember signin_allowed_; |
228 | 236 |
229 // Helper to merge signed in account into the content area. | 237 // Helper to merge signed in account into the content area. |
230 scoped_ptr<MergeSessionHelper> merge_session_helper_; | 238 scoped_ptr<MergeSessionHelper> merge_session_helper_; |
231 | 239 |
| 240 // Observers of the |merge_session_helper_| across reset()s. |
| 241 ObserverList<MergeSessionHelper::Observer, true> merge_session_observer_list_; |
| 242 |
232 // Two gate conditions for when PostSignedIn should be called. Verify | 243 // Two gate conditions for when PostSignedIn should be called. Verify |
233 // that the SigninManager has reached OnSignedIn() and the AccountTracker | 244 // that the SigninManager has reached OnSignedIn() and the AccountTracker |
234 // has completed calling GetUserInfo. | 245 // has completed calling GetUserInfo. |
235 bool signin_manager_signed_in_; | 246 bool signin_manager_signed_in_; |
236 bool user_info_fetched_by_account_tracker_; | 247 bool user_info_fetched_by_account_tracker_; |
237 | 248 |
238 base::WeakPtrFactory<SigninManager> weak_pointer_factory_; | 249 base::WeakPtrFactory<SigninManager> weak_pointer_factory_; |
239 | 250 |
240 DISALLOW_COPY_AND_ASSIGN(SigninManager); | 251 DISALLOW_COPY_AND_ASSIGN(SigninManager); |
241 }; | 252 }; |
242 | 253 |
243 #endif // !defined(OS_CHROMEOS) | 254 #endif // !defined(OS_CHROMEOS) |
244 | 255 |
245 #endif // COMPONENTS_SIGNIN_CORE_BROWSER_SIGNIN_MANAGER_H_ | 256 #endif // COMPONENTS_SIGNIN_CORE_BROWSER_SIGNIN_MANAGER_H_ |
OLD | NEW |