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 COMPONENTS_SIGNIN_CORE_BROWSER_ABOUT_SIGNIN_INTERNALS_H_ | 5 #ifndef COMPONENTS_SIGNIN_CORE_BROWSER_ABOUT_SIGNIN_INTERNALS_H_ |
6 #define COMPONENTS_SIGNIN_CORE_BROWSER_ABOUT_SIGNIN_INTERNALS_H_ | 6 #define COMPONENTS_SIGNIN_CORE_BROWSER_ABOUT_SIGNIN_INTERNALS_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/memory/linked_ptr.h" | 11 #include "base/memory/linked_ptr.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
14 #include "base/values.h" | 14 #include "base/values.h" |
15 #include "components/keyed_service/core/keyed_service.h" | 15 #include "components/keyed_service/core/keyed_service.h" |
16 #include "components/signin/core/browser/signin_client.h" | 16 #include "components/signin/core/browser/signin_client.h" |
| 17 #include "components/signin/core/browser/signin_error_controller.h" |
17 #include "components/signin/core/browser/signin_internals_util.h" | 18 #include "components/signin/core/browser/signin_internals_util.h" |
18 #include "components/signin/core/browser/signin_manager.h" | 19 #include "components/signin/core/browser/signin_manager.h" |
19 #include "google_apis/gaia/gaia_auth_consumer.h" | 20 #include "google_apis/gaia/gaia_auth_consumer.h" |
20 #include "google_apis/gaia/oauth2_token_service.h" | 21 #include "google_apis/gaia/oauth2_token_service.h" |
21 | 22 |
22 class AccountTrackerService; | 23 class AccountTrackerService; |
23 class GaiaAuthFetcher; | 24 class GaiaAuthFetcher; |
24 class ProfileOAuth2TokenService; | 25 class ProfileOAuth2TokenService; |
25 class SigninClient; | 26 class SigninClient; |
26 | 27 |
27 // Many values in SigninStatus are also associated with a timestamp. | 28 // Many values in SigninStatus are also associated with a timestamp. |
28 // This makes it easier to keep values and their associated times together. | 29 // This makes it easier to keep values and their associated times together. |
29 typedef std::pair<std::string, std::string> TimedSigninStatusValue; | 30 typedef std::pair<std::string, std::string> TimedSigninStatusValue; |
30 | 31 |
31 // This class collects authentication, signin and token information | 32 // This class collects authentication, signin and token information |
32 // to propagate to about:signin-internals via SigninInternalsUI. | 33 // to propagate to about:signin-internals via SigninInternalsUI. |
33 class AboutSigninInternals | 34 class AboutSigninInternals |
34 : public KeyedService, | 35 : public KeyedService, |
35 public signin_internals_util::SigninDiagnosticsObserver, | 36 public signin_internals_util::SigninDiagnosticsObserver, |
36 public OAuth2TokenService::DiagnosticsObserver, | 37 public OAuth2TokenService::DiagnosticsObserver, |
37 public GaiaAuthConsumer, | 38 public GaiaAuthConsumer, |
38 SigninManagerBase::Observer { | 39 SigninManagerBase::Observer, |
| 40 SigninErrorController::Observer { |
39 public: | 41 public: |
40 class Observer { | 42 class Observer { |
41 public: | 43 public: |
42 // |info| will contain the dictionary of signin_status_ values as indicated | 44 // |info| will contain the dictionary of signin_status_ values as indicated |
43 // in the comments for GetSigninStatus() below. | 45 // in the comments for GetSigninStatus() below. |
44 virtual void OnSigninStateChanged(const base::DictionaryValue* info) = 0; | 46 virtual void OnSigninStateChanged(const base::DictionaryValue* info) = 0; |
45 | 47 |
46 // Notification that the cookie accounts are ready to be displayed. | 48 // Notification that the cookie accounts are ready to be displayed. |
47 virtual void OnCookieAccountsFetched(const base::DictionaryValue* info) = 0; | 49 virtual void OnCookieAccountsFetched(const base::DictionaryValue* info) = 0; |
48 }; | 50 }; |
49 | 51 |
50 AboutSigninInternals(ProfileOAuth2TokenService* token_service, | 52 AboutSigninInternals(ProfileOAuth2TokenService* token_service, |
51 AccountTrackerService* account_tracker, | 53 AccountTrackerService* account_tracker, |
52 SigninManagerBase* signin_manager); | 54 SigninManagerBase* signin_manager, |
| 55 SigninErrorController* signin_error_controller); |
53 ~AboutSigninInternals() override; | 56 ~AboutSigninInternals() override; |
54 | 57 |
55 // Each instance of SigninInternalsUI adds itself as an observer to be | 58 // Each instance of SigninInternalsUI adds itself as an observer to be |
56 // notified of all updates that AboutSigninInternals receives. | 59 // notified of all updates that AboutSigninInternals receives. |
57 void AddSigninObserver(Observer* observer); | 60 void AddSigninObserver(Observer* observer); |
58 void RemoveSigninObserver(Observer* observer); | 61 void RemoveSigninObserver(Observer* observer); |
59 | 62 |
60 // Pulls all signin values that have been persisted in the user prefs. | 63 // Pulls all signin values that have been persisted in the user prefs. |
61 void RefreshSigninPrefs(); | 64 void RefreshSigninPrefs(); |
62 | 65 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 // { "title": account id, | 143 // { "title": account id, |
141 // "data": [List of {"service" : service name, | 144 // "data": [List of {"service" : service name, |
142 // "scopes" : requested scoped, | 145 // "scopes" : requested scoped, |
143 // "request_time" : request time, | 146 // "request_time" : request time, |
144 // "status" : request status} elems] | 147 // "status" : request status} elems] |
145 // }], | 148 // }], |
146 // } | 149 // } |
147 scoped_ptr<base::DictionaryValue> ToValue( | 150 scoped_ptr<base::DictionaryValue> ToValue( |
148 AccountTrackerService* account_tracker, | 151 AccountTrackerService* account_tracker, |
149 SigninManagerBase* signin_manager, | 152 SigninManagerBase* signin_manager, |
| 153 SigninErrorController* signin_error_controller, |
150 const std::string& product_version); | 154 const std::string& product_version); |
151 }; | 155 }; |
152 | 156 |
153 // SigninManager::SigninDiagnosticsObserver implementation. | 157 // SigninManager::SigninDiagnosticsObserver implementation. |
154 void NotifySigninValueChanged( | 158 void NotifySigninValueChanged( |
155 const signin_internals_util::TimedSigninStatusField& field, | 159 const signin_internals_util::TimedSigninStatusField& field, |
156 const std::string& value) override; | 160 const std::string& value) override; |
157 | 161 |
158 // OAuth2TokenService::DiagnosticsObserver implementations. | 162 // OAuth2TokenService::DiagnosticsObserver implementations. |
159 void OnAccessTokenRequested( | 163 void OnAccessTokenRequested( |
(...skipping 24 matching lines...) Expand all Loading... |
184 | 188 |
185 // Callback for ListAccounts. Once the email addresses are fetched from GAIA, | 189 // Callback for ListAccounts. Once the email addresses are fetched from GAIA, |
186 // they are pushed to the signin_internals_ui. | 190 // they are pushed to the signin_internals_ui. |
187 void OnListAccountsComplete( | 191 void OnListAccountsComplete( |
188 std::vector<std::pair<std::string, bool> >& gaia_accounts); | 192 std::vector<std::pair<std::string, bool> >& gaia_accounts); |
189 | 193 |
190 // Called when a cookie changes. If the cookie relates to a GAIA LSID cookie, | 194 // Called when a cookie changes. If the cookie relates to a GAIA LSID cookie, |
191 // then we call ListAccounts and update the UI element. | 195 // then we call ListAccounts and update the UI element. |
192 void OnCookieChanged(const net::CanonicalCookie& cookie, bool removed); | 196 void OnCookieChanged(const net::CanonicalCookie& cookie, bool removed); |
193 | 197 |
| 198 // SigninErrorController::Observer implementation |
| 199 void OnErrorChanged() override; |
| 200 |
194 // Weak pointer to the token service. | 201 // Weak pointer to the token service. |
195 ProfileOAuth2TokenService* token_service_; | 202 ProfileOAuth2TokenService* token_service_; |
196 | 203 |
197 // Weak pointer to the account tracker. | 204 // Weak pointer to the account tracker. |
198 AccountTrackerService* account_tracker_; | 205 AccountTrackerService* account_tracker_; |
199 | 206 |
200 // Weak pointer to the signin manager. | 207 // Weak pointer to the signin manager. |
201 SigninManagerBase* signin_manager_; | 208 SigninManagerBase* signin_manager_; |
202 | 209 |
203 // Weak pointer to the client. | 210 // Weak pointer to the client. |
204 SigninClient* client_; | 211 SigninClient* client_; |
205 | 212 |
| 213 // Weak pointer to the SigninErrorController |
| 214 SigninErrorController* signin_error_controller_; |
| 215 |
206 // Fetcher for information about accounts in the cookie jar from GAIA. | 216 // Fetcher for information about accounts in the cookie jar from GAIA. |
207 scoped_ptr<GaiaAuthFetcher> gaia_fetcher_; | 217 scoped_ptr<GaiaAuthFetcher> gaia_fetcher_; |
208 | 218 |
209 // Encapsulates the actual signin and token related values. | 219 // Encapsulates the actual signin and token related values. |
210 // Most of the values are mirrored in the prefs for persistence. | 220 // Most of the values are mirrored in the prefs for persistence. |
211 SigninStatus signin_status_; | 221 SigninStatus signin_status_; |
212 | 222 |
213 ObserverList<Observer> signin_observers_; | 223 ObserverList<Observer> signin_observers_; |
214 | 224 |
215 scoped_ptr<SigninClient::CookieChangedSubscription> | 225 scoped_ptr<SigninClient::CookieChangedSubscription> |
216 cookie_changed_subscription_; | 226 cookie_changed_subscription_; |
217 | 227 |
218 DISALLOW_COPY_AND_ASSIGN(AboutSigninInternals); | 228 DISALLOW_COPY_AND_ASSIGN(AboutSigninInternals); |
219 }; | 229 }; |
220 | 230 |
221 #endif // COMPONENTS_SIGNIN_CORE_BROWSER_ABOUT_SIGNIN_INTERNALS_H_ | 231 #endif // COMPONENTS_SIGNIN_CORE_BROWSER_ABOUT_SIGNIN_INTERNALS_H_ |
OLD | NEW |