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

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

Issue 421583002: Show GAIA/cookie accounts on the signin-internals page. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Final touches before review Created 6 years, 4 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 | Annotate | Revision Log
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/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/observer_list.h" 12 #include "base/observer_list.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "components/keyed_service/core/keyed_service.h" 14 #include "components/keyed_service/core/keyed_service.h"
15 #include "components/signin/core/browser/signin_client.h"
15 #include "components/signin/core/browser/signin_internals_util.h" 16 #include "components/signin/core/browser/signin_internals_util.h"
16 #include "components/signin/core/browser/signin_manager.h" 17 #include "components/signin/core/browser/signin_manager.h"
18 #include "google_apis/gaia/gaia_auth_consumer.h"
17 #include "google_apis/gaia/oauth2_token_service.h" 19 #include "google_apis/gaia/oauth2_token_service.h"
18 20
21 class GaiaAuthFetcher;
19 class ProfileOAuth2TokenService; 22 class ProfileOAuth2TokenService;
20 class SigninClient; 23 class SigninClient;
21 class SigninManagerBase; 24 class SigninManagerBase;
22 25
23 // Many values in SigninStatus are also associated with a timestamp. 26 // Many values in SigninStatus are also associated with a timestamp.
24 // This makes it easier to keep values and their associated times together. 27 // This makes it easier to keep values and their associated times together.
25 typedef std::pair<std::string, std::string> TimedSigninStatusValue; 28 typedef std::pair<std::string, std::string> TimedSigninStatusValue;
26 29
27 // This class collects authentication, signin and token information 30 // This class collects authentication, signin and token information
28 // to propagate to about:signin-internals via SigninInternalsUI. 31 // to propagate to about:signin-internals via SigninInternalsUI.
29 class AboutSigninInternals 32 class AboutSigninInternals
30 : public KeyedService, 33 : public KeyedService,
31 public signin_internals_util::SigninDiagnosticsObserver, 34 public signin_internals_util::SigninDiagnosticsObserver,
32 public OAuth2TokenService::DiagnosticsObserver { 35 public OAuth2TokenService::DiagnosticsObserver,
36 public GaiaAuthConsumer {
33 public: 37 public:
34 class Observer { 38 class Observer {
35 public: 39 public:
36 // |info| will contain the dictionary of signin_status_ values as indicated 40 // |info| will contain the dictionary of signin_status_ values as indicated
37 // in the comments for GetSigninStatus() below. 41 // in the comments for GetSigninStatus() below.
38 virtual void OnSigninStateChanged( 42 virtual void OnSigninStateChanged(
39 scoped_ptr<base::DictionaryValue> info) = 0; 43 scoped_ptr<base::DictionaryValue> info) = 0;
44
45 // Notification that the cookie accounts are ready to be displayed.
46 virtual void OnCookieAccountsFetched(
47 scoped_ptr<base::DictionaryValue> info) = 0;
40 }; 48 };
41 49
42 AboutSigninInternals(ProfileOAuth2TokenService* token_service, 50 AboutSigninInternals(ProfileOAuth2TokenService* token_service,
43 SigninManagerBase* signin_manager); 51 SigninManagerBase* signin_manager);
44 virtual ~AboutSigninInternals(); 52 virtual ~AboutSigninInternals();
45 53
46 // Each instance of SigninInternalsUI adds itself as an observer to be 54 // Each instance of SigninInternalsUI adds itself as an observer to be
47 // notified of all updates that AboutSigninInternals receives. 55 // notified of all updates that AboutSigninInternals receives.
48 void AddSigninObserver(Observer* observer); 56 void AddSigninObserver(Observer* observer);
49 void RemoveSigninObserver(Observer* observer); 57 void RemoveSigninObserver(Observer* observer);
(...skipping 24 matching lines...) Expand all
74 // }, 82 // },
75 // { "title": "Detailed Information", 83 // { "title": "Detailed Information",
76 // "data": [List of {"label" : "foo-field", "value" : "foo"} elems] 84 // "data": [List of {"label" : "foo-field", "value" : "foo"} elems]
77 // }], 85 // }],
78 // "token_info" : 86 // "token_info" :
79 // [ List of {"name": "foo-name", "token" : "foo-token", 87 // [ List of {"name": "foo-name", "token" : "foo-token",
80 // "status": "foo_stat", "time" : "foo_time"} elems] 88 // "status": "foo_stat", "time" : "foo_time"} elems]
81 // } 89 // }
82 scoped_ptr<base::DictionaryValue> GetSigninStatus(); 90 scoped_ptr<base::DictionaryValue> GetSigninStatus();
83 91
92 // Triggers a ListAccounts call to acquire a list of the email addresses
93 // corresponding to the cookies residing on the current cookie jar.
94 void GetCookieAccountsAsync();
95
84 // OAuth2TokenService::DiagnosticsObserver implementations. 96 // OAuth2TokenService::DiagnosticsObserver implementations.
85 virtual void OnAccessTokenRequested( 97 virtual void OnAccessTokenRequested(
86 const std::string& account_id, 98 const std::string& account_id,
87 const std::string& consumer_id, 99 const std::string& consumer_id,
88 const OAuth2TokenService::ScopeSet& scopes) OVERRIDE; 100 const OAuth2TokenService::ScopeSet& scopes) OVERRIDE;
89 virtual void OnFetchAccessTokenComplete( 101 virtual void OnFetchAccessTokenComplete(
90 const std::string& account_id, 102 const std::string& account_id,
91 const std::string& consumer_id, 103 const std::string& consumer_id,
92 const OAuth2TokenService::ScopeSet& scopes, 104 const OAuth2TokenService::ScopeSet& scopes,
93 GoogleServiceAuthError error, 105 GoogleServiceAuthError error,
(...skipping 20 matching lines...) Expand all
114 126
115 std::string consumer_id; // service that requested the token. 127 std::string consumer_id; // service that requested the token.
116 OAuth2TokenService::ScopeSet scopes; // Scoped that are requested. 128 OAuth2TokenService::ScopeSet scopes; // Scoped that are requested.
117 base::Time request_time; 129 base::Time request_time;
118 base::Time receive_time; 130 base::Time receive_time;
119 base::Time expiration_time; 131 base::Time expiration_time;
120 GoogleServiceAuthError error; 132 GoogleServiceAuthError error;
121 bool removed_; 133 bool removed_;
122 }; 134 };
123 135
136 // Encapsulates diagnostic information about cookie accounts
137 struct CookieInfo {
138 CookieInfo(const std::string& email);
139 ~CookieInfo();
140 base::DictionaryValue* ToValue() const;
141
142 static bool LessThan(const TokenInfo* a, const TokenInfo* b);
143
144 // Called when the cookie is invalidated.
145 void Invalidate();
146
147 std::string email; // Email address of the token.
148 bool valid; // If the cookie is considered valid.
149 bool removed_;
Roger Tawa OOO till Jul 10th 2014/08/06 20:29:42 Don't need trailing _ for struct. Or put it on al
Mike Lerman 2014/08/07 16:39:26 Removed the whole struct, not even using it!
150 };
151
124 // Map account id to tokens associated to the account. 152 // Map account id to tokens associated to the account.
125 typedef std::map<std::string, std::vector<TokenInfo*> > TokenInfoMap; 153 typedef std::map<std::string, std::vector<TokenInfo*> > TokenInfoMap;
126 154
127 // Encapsulates both authentication and token related information. Used 155 // Encapsulates both authentication and token related information. Used
128 // by SigninInternals to maintain information that needs to be shown in 156 // by SigninInternals to maintain information that needs to be shown in
129 // the about:signin-internals page. 157 // the about:signin-internals page.
130 struct SigninStatus { 158 struct SigninStatus {
131 std::vector<std::string> untimed_signin_fields; 159 std::vector<std::string> untimed_signin_fields;
132 std::vector<TimedSigninStatusValue> timed_signin_fields; 160 std::vector<TimedSigninStatusValue> timed_signin_fields;
133 TokenInfoMap token_info_map; 161 TokenInfoMap token_info_map;
(...skipping 20 matching lines...) Expand all
154 // "scopes" : requested scoped, 182 // "scopes" : requested scoped,
155 // "request_time" : request time, 183 // "request_time" : request time,
156 // "status" : request status} elems] 184 // "status" : request status} elems]
157 // }], 185 // }],
158 // } 186 // }
159 scoped_ptr<base::DictionaryValue> ToValue(std::string product_version); 187 scoped_ptr<base::DictionaryValue> ToValue(std::string product_version);
160 }; 188 };
161 189
162 void NotifyObservers(); 190 void NotifyObservers();
163 191
192
193 // Overriden from GaiaAuthConsumer.
194 virtual void OnListAccountsSuccess(const std::string& data) OVERRIDE;
195 virtual void OnListAccountsFailure(const GoogleServiceAuthError& error)
196 OVERRIDE;
197
198 // Callback for ListAccounts. Once the email addresses are fetched from GAIA,
199 // they are pushed to the signin_internals_ui.
200 void OnListAccountsComplete(
201 std::vector<std::pair<std::string, bool> >& gaia_accounts);
202
203 // Called when a cookie changes. If the cookie relates to a GAIA LSID cookie,
204 // then we call ListAccounts and update the UI element.
205 void OnCookieChanged(const net::CanonicalCookie* cookie);
206
164 // Weak pointer to the token service. 207 // Weak pointer to the token service.
165 ProfileOAuth2TokenService* token_service_; 208 ProfileOAuth2TokenService* token_service_;
166 209
167 // Weak pointer to the signin manager. 210 // Weak pointer to the signin manager.
168 SigninManagerBase* signin_manager_; 211 SigninManagerBase* signin_manager_;
169 212
170 // Weak pointer to the client. 213 // Weak pointer to the client.
171 SigninClient* client_; 214 SigninClient* client_;
172 215
216 // Fetcher for information about accounts in the cookie jar from GAIA.
217 scoped_ptr<GaiaAuthFetcher> gaia_fetcher_;
218
173 // Encapsulates the actual signin and token related values. 219 // Encapsulates the actual signin and token related values.
174 // Most of the values are mirrored in the prefs for persistence. 220 // Most of the values are mirrored in the prefs for persistence.
175 SigninStatus signin_status_; 221 SigninStatus signin_status_;
176 222
177 ObserverList<Observer> signin_observers_; 223 ObserverList<Observer> signin_observers_;
178 224
225 scoped_ptr<SigninClient::CookieChangedCallbackList::Subscription>
226 cookie_changed_subscription_;
227
179 DISALLOW_COPY_AND_ASSIGN(AboutSigninInternals); 228 DISALLOW_COPY_AND_ASSIGN(AboutSigninInternals);
180 }; 229 };
181 230
182 #endif // COMPONENTS_SIGNIN_CORE_BROWSER_ABOUT_SIGNIN_INTERNALS_H_ 231 #endif // COMPONENTS_SIGNIN_CORE_BROWSER_ABOUT_SIGNIN_INTERNALS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698