| 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 #ifndef COMPONENTS_SIGNIN_CORE_BROWSER_SIGNIN_TRACKER_H_ | 5 #ifndef COMPONENTS_SIGNIN_CORE_BROWSER_SIGNIN_TRACKER_H_ |
| 6 #define COMPONENTS_SIGNIN_CORE_BROWSER_SIGNIN_TRACKER_H_ | 6 #define COMPONENTS_SIGNIN_CORE_BROWSER_SIGNIN_TRACKER_H_ |
| 7 | 7 |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "components/signin/core/browser/gaia_cookie_manager_service.h" | 9 #include "components/signin/core/browser/gaia_cookie_manager_service.h" |
| 10 #include "components/signin/core/browser/signin_manager.h" | 10 #include "components/signin/core/browser/signin_manager.h" |
| 11 #include "google_apis/gaia/google_service_auth_error.h" | 11 #include "google_apis/gaia/google_service_auth_error.h" |
| 12 | 12 |
| 13 class AccountReconcilor; | |
| 14 class ProfileOAuth2TokenService; | 13 class ProfileOAuth2TokenService; |
| 15 class SigninClient; | 14 class SigninClient; |
| 16 | 15 |
| 17 // The signin flow logic is spread across several classes with varying | 16 // The signin flow logic is spread across several classes with varying |
| 18 // responsibilities: | 17 // responsibilities: |
| 19 // | 18 // |
| 20 // SigninTracker (this class) - This class listens to notifications from various | 19 // SigninTracker (this class) - This class listens to notifications from various |
| 21 // services (SigninManager, OAuth2TokenService) and coalesces them into | 20 // services (SigninManager, OAuth2TokenService) and coalesces them into |
| 22 // notifications for the UI layer. This is the class that encapsulates the logic | 21 // notifications for the UI layer. This is the class that encapsulates the logic |
| 23 // that determines whether a user is fully logged in or not, and exposes | 22 // that determines whether a user is fully logged in or not, and exposes |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 virtual void MergeSessionComplete(const GoogleServiceAuthError& error) = 0; | 67 virtual void MergeSessionComplete(const GoogleServiceAuthError& error) = 0; |
| 69 }; | 68 }; |
| 70 | 69 |
| 71 // Creates a SigninTracker that tracks the signin status on the passed | 70 // Creates a SigninTracker that tracks the signin status on the passed |
| 72 // classes, and notifies the |observer| on status changes. All of the | 71 // classes, and notifies the |observer| on status changes. All of the |
| 73 // instances with the exception of |account_reconcilor| must be non-null and | 72 // instances with the exception of |account_reconcilor| must be non-null and |
| 74 // must outlive the SigninTracker. |account_reconcilor| will be used if it is | 73 // must outlive the SigninTracker. |account_reconcilor| will be used if it is |
| 75 // non-null. | 74 // non-null. |
| 76 SigninTracker(ProfileOAuth2TokenService* token_service, | 75 SigninTracker(ProfileOAuth2TokenService* token_service, |
| 77 SigninManagerBase* signin_manager, | 76 SigninManagerBase* signin_manager, |
| 78 AccountReconcilor* account_reconcilor, | |
| 79 GaiaCookieManagerService* cookie_manager_service, | 77 GaiaCookieManagerService* cookie_manager_service, |
| 80 SigninClient* client, | 78 SigninClient* client, |
| 81 Observer* observer); | 79 Observer* observer); |
| 82 ~SigninTracker() override; | 80 ~SigninTracker() override; |
| 83 | 81 |
| 84 // SigninManagerBase::Observer implementation. | 82 // SigninManagerBase::Observer implementation. |
| 85 void GoogleSigninFailed(const GoogleServiceAuthError& error) override; | 83 void GoogleSigninFailed(const GoogleServiceAuthError& error) override; |
| 86 | 84 |
| 87 // OAuth2TokenService::Observer implementation. | 85 // OAuth2TokenService::Observer implementation. |
| 88 void OnRefreshTokenAvailable(const std::string& account_id) override; | 86 void OnRefreshTokenAvailable(const std::string& account_id) override; |
| 89 void OnRefreshTokenRevoked(const std::string& account_id) override; | 87 void OnRefreshTokenRevoked(const std::string& account_id) override; |
| 90 | 88 |
| 91 private: | 89 private: |
| 92 // Initializes this by adding notifications and observers. | 90 // Initializes this by adding notifications and observers. |
| 93 void Initialize(); | 91 void Initialize(); |
| 94 | 92 |
| 95 // GaiaCookieManagerService::Observer implementation. | 93 // GaiaCookieManagerService::Observer implementation. |
| 96 void OnAddAccountToCookieCompleted( | 94 void OnAddAccountToCookieCompleted( |
| 97 const std::string& account_id, | 95 const std::string& account_id, |
| 98 const GoogleServiceAuthError& error) override; | 96 const GoogleServiceAuthError& error) override; |
| 99 | 97 |
| 100 // The classes whose collective signin status we are tracking. | 98 // The classes whose collective signin status we are tracking. |
| 101 ProfileOAuth2TokenService* token_service_; | 99 ProfileOAuth2TokenService* token_service_; |
| 102 SigninManagerBase* signin_manager_; | 100 SigninManagerBase* signin_manager_; |
| 103 AccountReconcilor* account_reconcilor_; | |
| 104 GaiaCookieManagerService* cookie_manager_service_; | 101 GaiaCookieManagerService* cookie_manager_service_; |
| 105 | 102 |
| 106 // The client associated with this instance. | 103 // The client associated with this instance. |
| 107 SigninClient* client_; | 104 SigninClient* client_; |
| 108 | 105 |
| 109 // Weak pointer to the observer we call when the signin state changes. | 106 // Weak pointer to the observer we call when the signin state changes. |
| 110 Observer* observer_; | 107 Observer* observer_; |
| 111 | 108 |
| 112 DISALLOW_COPY_AND_ASSIGN(SigninTracker); | 109 DISALLOW_COPY_AND_ASSIGN(SigninTracker); |
| 113 }; | 110 }; |
| 114 | 111 |
| 115 #endif // COMPONENTS_SIGNIN_CORE_BROWSER_SIGNIN_TRACKER_H_ | 112 #endif // COMPONENTS_SIGNIN_CORE_BROWSER_SIGNIN_TRACKER_H_ |
| OLD | NEW |