Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(205)

Side by Side Diff: components/signin/core/browser/about_signin_internals.h

Issue 1075273002: Handle ListAccount fetches from within the GaiaCookieManagerService. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix a test post rebase Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/chrome_tests_unit.gypi ('k') | components/signin/core/browser/about_signin_internals.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/gaia_cookie_manager_service.h"
16 #include "components/signin/core/browser/signin_client.h" 17 #include "components/signin/core/browser/signin_client.h"
17 #include "components/signin/core/browser/signin_error_controller.h" 18 #include "components/signin/core/browser/signin_error_controller.h"
18 #include "components/signin/core/browser/signin_internals_util.h" 19 #include "components/signin/core/browser/signin_internals_util.h"
19 #include "components/signin/core/browser/signin_manager.h" 20 #include "components/signin/core/browser/signin_manager.h"
20 #include "google_apis/gaia/gaia_auth_consumer.h"
21 #include "google_apis/gaia/oauth2_token_service.h" 21 #include "google_apis/gaia/oauth2_token_service.h"
22 22
23 class AccountTrackerService; 23 class AccountTrackerService;
24 class GaiaAuthFetcher; 24 class GaiaAuthFetcher;
25 class ProfileOAuth2TokenService; 25 class ProfileOAuth2TokenService;
26 class SigninClient; 26 class SigninClient;
27 27
28 // Many values in SigninStatus are also associated with a timestamp. 28 // Many values in SigninStatus are also associated with a timestamp.
29 // 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.
30 typedef std::pair<std::string, std::string> TimedSigninStatusValue; 30 typedef std::pair<std::string, std::string> TimedSigninStatusValue;
31 31
32 // This class collects authentication, signin and token information 32 // This class collects authentication, signin and token information
33 // to propagate to about:signin-internals via SigninInternalsUI. 33 // to propagate to about:signin-internals via SigninInternalsUI.
34 class AboutSigninInternals 34 class AboutSigninInternals
35 : public KeyedService, 35 : public KeyedService,
36 public signin_internals_util::SigninDiagnosticsObserver, 36 public signin_internals_util::SigninDiagnosticsObserver,
37 public OAuth2TokenService::DiagnosticsObserver, 37 public OAuth2TokenService::DiagnosticsObserver,
38 public GaiaAuthConsumer, 38 public GaiaCookieManagerService::Observer,
39 SigninManagerBase::Observer, 39 SigninManagerBase::Observer,
40 SigninErrorController::Observer { 40 SigninErrorController::Observer {
41 public: 41 public:
42 class Observer { 42 class Observer {
43 public: 43 public:
44 // |info| will contain the dictionary of signin_status_ values as indicated 44 // |info| will contain the dictionary of signin_status_ values as indicated
45 // in the comments for GetSigninStatus() below. 45 // in the comments for GetSigninStatus() below.
46 virtual void OnSigninStateChanged(const base::DictionaryValue* info) = 0; 46 virtual void OnSigninStateChanged(const base::DictionaryValue* info) = 0;
47 47
48 // Notification that the cookie accounts are ready to be displayed. 48 // Notification that the cookie accounts are ready to be displayed.
49 virtual void OnCookieAccountsFetched(const base::DictionaryValue* info) = 0; 49 virtual void OnCookieAccountsFetched(const base::DictionaryValue* info) = 0;
50 }; 50 };
51 51
52 AboutSigninInternals(ProfileOAuth2TokenService* token_service, 52 AboutSigninInternals(ProfileOAuth2TokenService* token_service,
53 AccountTrackerService* account_tracker, 53 AccountTrackerService* account_tracker,
54 SigninManagerBase* signin_manager, 54 SigninManagerBase* signin_manager,
55 SigninErrorController* signin_error_controller); 55 SigninErrorController* signin_error_controller,
56 GaiaCookieManagerService* cookie_manager_service);
56 ~AboutSigninInternals() override; 57 ~AboutSigninInternals() override;
57 58
58 // Each instance of SigninInternalsUI adds itself as an observer to be 59 // Each instance of SigninInternalsUI adds itself as an observer to be
59 // notified of all updates that AboutSigninInternals receives. 60 // notified of all updates that AboutSigninInternals receives.
60 void AddSigninObserver(Observer* observer); 61 void AddSigninObserver(Observer* observer);
61 void RemoveSigninObserver(Observer* observer); 62 void RemoveSigninObserver(Observer* observer);
62 63
63 // Pulls all signin values that have been persisted in the user prefs. 64 // Pulls all signin values that have been persisted in the user prefs.
64 void RefreshSigninPrefs(); 65 void RefreshSigninPrefs();
65 66
(...skipping 14 matching lines...) Expand all
80 // }, 81 // },
81 // { "title": "Detailed Information", 82 // { "title": "Detailed Information",
82 // "data": [List of {"label" : "foo-field", "value" : "foo"} elems] 83 // "data": [List of {"label" : "foo-field", "value" : "foo"} elems]
83 // }], 84 // }],
84 // "token_info" : 85 // "token_info" :
85 // [ List of {"name": "foo-name", "token" : "foo-token", 86 // [ List of {"name": "foo-name", "token" : "foo-token",
86 // "status": "foo_stat", "time" : "foo_time"} elems] 87 // "status": "foo_stat", "time" : "foo_time"} elems]
87 // } 88 // }
88 scoped_ptr<base::DictionaryValue> GetSigninStatus(); 89 scoped_ptr<base::DictionaryValue> GetSigninStatus();
89 90
90 // Triggers a ListAccounts call to acquire a list of the email addresses 91 // GaiaCookieManagerService::Observer implementations.
91 // corresponding to the cookies residing on the current cookie jar. 92 void OnGaiaAccountsInCookieUpdated(
92 void GetCookieAccountsAsync(); 93 const std::vector<std::pair<std::string, bool> >& gaia_accounts,
94 const GoogleServiceAuthError& error) override;
93 95
94 private: 96 private:
95 // Encapsulates diagnostic information about tokens for different services. 97 // Encapsulates diagnostic information about tokens for different services.
96 struct TokenInfo { 98 struct TokenInfo {
97 TokenInfo(const std::string& consumer_id, 99 TokenInfo(const std::string& consumer_id,
98 const OAuth2TokenService::ScopeSet& scopes); 100 const OAuth2TokenService::ScopeSet& scopes);
99 ~TokenInfo(); 101 ~TokenInfo();
100 base::DictionaryValue* ToValue() const; 102 base::DictionaryValue* ToValue() const;
101 103
102 static bool LessThan(const TokenInfo* a, const TokenInfo* b); 104 static bool LessThan(const TokenInfo* a, const TokenInfo* b);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 const std::string& consumer_id, 168 const std::string& consumer_id,
167 const OAuth2TokenService::ScopeSet& scopes) override; 169 const OAuth2TokenService::ScopeSet& scopes) override;
168 void OnFetchAccessTokenComplete(const std::string& account_id, 170 void OnFetchAccessTokenComplete(const std::string& account_id,
169 const std::string& consumer_id, 171 const std::string& consumer_id,
170 const OAuth2TokenService::ScopeSet& scopes, 172 const OAuth2TokenService::ScopeSet& scopes,
171 GoogleServiceAuthError error, 173 GoogleServiceAuthError error,
172 base::Time expiration_time) override; 174 base::Time expiration_time) override;
173 void OnTokenRemoved(const std::string& account_id, 175 void OnTokenRemoved(const std::string& account_id,
174 const OAuth2TokenService::ScopeSet& scopes) override; 176 const OAuth2TokenService::ScopeSet& scopes) override;
175 177
176 // GaiaAuthConsumer implementations.
177 void OnListAccountsSuccess(const std::string& data) override;
178 void OnListAccountsFailure(const GoogleServiceAuthError& error) override;
179
180 // SigninManagerBase::Observer implementations. 178 // SigninManagerBase::Observer implementations.
181 void GoogleSigninFailed(const GoogleServiceAuthError& error) override; 179 void GoogleSigninFailed(const GoogleServiceAuthError& error) override;
182 void GoogleSigninSucceeded(const std::string& account_id, 180 void GoogleSigninSucceeded(const std::string& account_id,
183 const std::string& username, 181 const std::string& username,
184 const std::string& password) override; 182 const std::string& password) override;
185 void GoogleSignedOut(const std::string& account_id, 183 void GoogleSignedOut(const std::string& account_id,
186 const std::string& username) override; 184 const std::string& username) override;
187 185
188 void NotifyObservers(); 186 void NotifyObservers();
189 187
190 // Callback for ListAccounts. Once the email addresses are fetched from GAIA,
191 // they are pushed to the signin_internals_ui.
192 void OnListAccountsComplete(
193 std::vector<std::pair<std::string, bool> >& gaia_accounts);
194
195 // Called when a cookie changes. If the cookie relates to a GAIA LSID cookie,
196 // then we call ListAccounts and update the UI element.
197 void OnCookieChanged(const net::CanonicalCookie& cookie, bool removed);
198
199 // SigninErrorController::Observer implementation 188 // SigninErrorController::Observer implementation
200 void OnErrorChanged() override; 189 void OnErrorChanged() override;
201 190
202 // Weak pointer to the token service. 191 // Weak pointer to the token service.
203 ProfileOAuth2TokenService* token_service_; 192 ProfileOAuth2TokenService* token_service_;
204 193
205 // Weak pointer to the account tracker. 194 // Weak pointer to the account tracker.
206 AccountTrackerService* account_tracker_; 195 AccountTrackerService* account_tracker_;
207 196
208 // Weak pointer to the signin manager. 197 // Weak pointer to the signin manager.
209 SigninManagerBase* signin_manager_; 198 SigninManagerBase* signin_manager_;
210 199
211 // Weak pointer to the client. 200 // Weak pointer to the client.
212 SigninClient* client_; 201 SigninClient* client_;
213 202
214 // Weak pointer to the SigninErrorController 203 // Weak pointer to the SigninErrorController
215 SigninErrorController* signin_error_controller_; 204 SigninErrorController* signin_error_controller_;
216 205
217 // Fetcher for information about accounts in the cookie jar from GAIA. 206 // Weak pointer to the GaiaCookieManagerService
218 scoped_ptr<GaiaAuthFetcher> gaia_fetcher_; 207 GaiaCookieManagerService* cookie_manager_service_;
219 208
220 // Encapsulates the actual signin and token related values. 209 // Encapsulates the actual signin and token related values.
221 // Most of the values are mirrored in the prefs for persistence. 210 // Most of the values are mirrored in the prefs for persistence.
222 SigninStatus signin_status_; 211 SigninStatus signin_status_;
223 212
224 ObserverList<Observer> signin_observers_; 213 ObserverList<Observer> signin_observers_;
225 214
226 scoped_ptr<SigninClient::CookieChangedSubscription>
227 cookie_changed_subscription_;
228
229 DISALLOW_COPY_AND_ASSIGN(AboutSigninInternals); 215 DISALLOW_COPY_AND_ASSIGN(AboutSigninInternals);
230 }; 216 };
231 217
232 #endif // COMPONENTS_SIGNIN_CORE_BROWSER_ABOUT_SIGNIN_INTERNALS_H_ 218 #endif // COMPONENTS_SIGNIN_CORE_BROWSER_ABOUT_SIGNIN_INTERNALS_H_
OLDNEW
« no previous file with comments | « chrome/chrome_tests_unit.gypi ('k') | components/signin/core/browser/about_signin_internals.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698