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 <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "components/signin/core/browser/gaia_cookie_manager_service.h" | 11 #include "components/signin/core/browser/gaia_cookie_manager_service.h" |
12 #include "components/signin/core/browser/signin_manager.h" | 12 #include "components/signin/core/browser/signin_manager.h" |
13 #include "google_apis/gaia/google_service_auth_error.h" | 13 #include "google_apis/gaia/google_service_auth_error.h" |
14 | 14 |
15 class ProfileOAuth2TokenService; | 15 class ProfileOAuth2TokenService; |
16 class SigninClient; | |
17 | 16 |
18 // The signin flow logic is spread across several classes with varying | 17 // The signin flow logic is spread across several classes with varying |
19 // responsibilities: | 18 // responsibilities: |
20 // | 19 // |
21 // SigninTracker (this class) - This class listens to notifications from various | 20 // SigninTracker (this class) - This class listens to notifications from various |
22 // services (SigninManager, OAuth2TokenService) and coalesces them into | 21 // services (SigninManager, OAuth2TokenService) and coalesces them into |
23 // notifications for the UI layer. This is the class that encapsulates the logic | 22 // notifications for the UI layer. This is the class that encapsulates the logic |
24 // that determines whether a user is fully logged in or not, and exposes | 23 // that determines whether a user is fully logged in or not, and exposes |
25 // callbacks so various pieces of the UI (OneClickSyncStarter) can track the | 24 // callbacks so various pieces of the UI (OneClickSyncStarter) can track the |
26 // current startup state. | 25 // current startup state. |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 }; | 69 }; |
71 | 70 |
72 // Creates a SigninTracker that tracks the signin status on the passed | 71 // Creates a SigninTracker that tracks the signin status on the passed |
73 // classes, and notifies the |observer| on status changes. All of the | 72 // classes, and notifies the |observer| on status changes. All of the |
74 // instances with the exception of |account_reconcilor| must be non-null and | 73 // instances with the exception of |account_reconcilor| must be non-null and |
75 // must outlive the SigninTracker. |account_reconcilor| will be used if it is | 74 // must outlive the SigninTracker. |account_reconcilor| will be used if it is |
76 // non-null. | 75 // non-null. |
77 SigninTracker(ProfileOAuth2TokenService* token_service, | 76 SigninTracker(ProfileOAuth2TokenService* token_service, |
78 SigninManagerBase* signin_manager, | 77 SigninManagerBase* signin_manager, |
79 GaiaCookieManagerService* cookie_manager_service, | 78 GaiaCookieManagerService* cookie_manager_service, |
80 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 GaiaCookieManagerService* cookie_manager_service_; | 101 GaiaCookieManagerService* cookie_manager_service_; |
104 | 102 |
105 // The client associated with this instance. | |
106 SigninClient* client_; | |
107 | |
108 // Weak pointer to the observer we call when the signin state changes. | 103 // Weak pointer to the observer we call when the signin state changes. |
109 Observer* observer_; | 104 Observer* observer_; |
110 | 105 |
111 DISALLOW_COPY_AND_ASSIGN(SigninTracker); | 106 DISALLOW_COPY_AND_ASSIGN(SigninTracker); |
112 }; | 107 }; |
113 | 108 |
114 #endif // COMPONENTS_SIGNIN_CORE_BROWSER_SIGNIN_TRACKER_H_ | 109 #endif // COMPONENTS_SIGNIN_CORE_BROWSER_SIGNIN_TRACKER_H_ |
OLD | NEW |