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

Side by Side Diff: google_apis/gaia/gaia_auth_fetcher.h

Issue 2872253002: Network traffic annotation added to gaia_auth_fetcher. (Closed)
Patch Set: Comments addressed. Created 3 years, 6 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 | « no previous file | google_apis/gaia/gaia_auth_fetcher.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 GOOGLE_APIS_GAIA_GAIA_AUTH_FETCHER_H_ 5 #ifndef GOOGLE_APIS_GAIA_GAIA_AUTH_FETCHER_H_
6 #define GOOGLE_APIS_GAIA_GAIA_AUTH_FETCHER_H_ 6 #define GOOGLE_APIS_GAIA_GAIA_AUTH_FETCHER_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/gtest_prod_util.h" 12 #include "base/gtest_prod_util.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "google_apis/gaia/gaia_auth_consumer.h" 14 #include "google_apis/gaia/gaia_auth_consumer.h"
15 #include "google_apis/gaia/google_service_auth_error.h" 15 #include "google_apis/gaia/google_service_auth_error.h"
16 #include "net/traffic_annotation/network_traffic_annotation.h"
16 #include "net/url_request/url_fetcher_delegate.h" 17 #include "net/url_request/url_fetcher_delegate.h"
17 #include "url/gurl.h" 18 #include "url/gurl.h"
18 19
19 // Authenticate a user against the Google Accounts ClientLogin API 20 // Authenticate a user against the Google Accounts ClientLogin API
20 // with various capabilities and return results to a GaiaAuthConsumer. 21 // with various capabilities and return results to a GaiaAuthConsumer.
21 // 22 //
22 // In the future, we will also issue auth tokens from this class. 23 // In the future, we will also issue auth tokens from this class.
23 // This class should be used on a single thread, but it can be whichever thread 24 // This class should be used on a single thread, but it can be whichever thread
24 // that you like. 25 // that you like.
25 // 26 //
(...skipping 18 matching lines...) Expand all
44 // Apps enabled, the user provided the right password. 45 // Apps enabled, the user provided the right password.
45 static const char kWebLoginRequired[]; 46 static const char kWebLoginRequired[];
46 47
47 // This will later be hidden behind an auth service which caches 48 // This will later be hidden behind an auth service which caches
48 // tokens. 49 // tokens.
49 GaiaAuthFetcher(GaiaAuthConsumer* consumer, 50 GaiaAuthFetcher(GaiaAuthConsumer* consumer,
50 const std::string& source, 51 const std::string& source,
51 net::URLRequestContextGetter* getter); 52 net::URLRequestContextGetter* getter);
52 ~GaiaAuthFetcher() override; 53 ~GaiaAuthFetcher() override;
53 54
54 // Start a request to obtain service token for the the account identified by
55 // |sid| and |lsid| and the |service|.
56 //
57 // Either OnIssueAuthTokenSuccess or OnIssueAuthTokenFailure will be
58 // called on the consumer on the original thread.
59 void StartIssueAuthToken(const std::string& sid,
60 const std::string& lsid,
61 const char* const service);
62
63 // Start a request to obtain |service| token for the the account identified by 55 // Start a request to obtain |service| token for the the account identified by
64 // |uber_token|. 56 // |uber_token|.
65 // 57 //
66 // Either OnIssueAuthTokenSuccess or OnIssueAuthTokenFailure will be 58 // Either OnIssueAuthTokenSuccess or OnIssueAuthTokenFailure will be
67 // called on the consumer on the original thread. 59 // called on the consumer on the original thread.
68 void StartTokenAuth(const std::string& uber_token, 60 void StartTokenAuth(const std::string& uber_token,
69 const char* const service); 61 const char* const service);
70 62
71 // Start a request to obtain service token for the the account identified by 63 // Start a request to obtain service token for the the account identified by
72 // |oauth2_access_token| and the |service|. 64 // |oauth2_access_token| and the |service|.
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 void StartListAccounts(); 183 void StartListAccounts();
192 184
193 // Starts a request to log out the accounts in the GAIA cookie. 185 // Starts a request to log out the accounts in the GAIA cookie.
194 void StartLogOut(); 186 void StartLogOut();
195 187
196 // Starts a request to get the list of URLs to check for connection info. 188 // Starts a request to get the list of URLs to check for connection info.
197 // Returns token/URL pairs to check, and the resulting status can be given to 189 // Returns token/URL pairs to check, and the resulting status can be given to
198 // /MergeSession requests. 190 // /MergeSession requests.
199 void StartGetCheckConnectionInfo(); 191 void StartGetCheckConnectionInfo();
200 192
201 // Starts listing any sessions that exist for the IDP. If all requested scopes
202 // have been approved by the session user, then a login hint is included in
203 // the response.
204 void StartListIDPSessions(const std::string& scopes,
205 const std::string& domain);
206
207 // Generates an access token for the session, specifying the scopes and
208 // |login_hint|.
209 void StartGetTokenResponse(const std::string& scopes,
210 const std::string& domain,
211 const std::string& login_hint);
212
213 // Implementation of net::URLFetcherDelegate 193 // Implementation of net::URLFetcherDelegate
214 void OnURLFetchComplete(const net::URLFetcher* source) override; 194 void OnURLFetchComplete(const net::URLFetcher* source) override;
215 195
216 // StartClientLogin been called && results not back yet? 196 // StartClientLogin been called && results not back yet?
217 bool HasPendingFetch(); 197 bool HasPendingFetch();
218 198
219 // Stop any URL fetches in progress. 199 // Stop any URL fetches in progress.
220 virtual void CancelRequest(); 200 virtual void CancelRequest();
221 201
222 // From a URLFetcher result, generate an appropriate error. 202 // From a URLFetcher result, generate an appropriate error.
223 // From the API documentation, both IssueAuthToken and ClientLogin have 203 // From the API documentation, both IssueAuthToken and ClientLogin have
224 // the same error returns. 204 // the same error returns.
225 static GoogleServiceAuthError GenerateOAuthLoginError( 205 static GoogleServiceAuthError GenerateOAuthLoginError(
226 const std::string& data, 206 const std::string& data,
227 const net::URLRequestStatus& status); 207 const net::URLRequestStatus& status);
228 208
229 protected: 209 protected:
230 // Create and start |fetcher_|, used to make all Gaia request. |body| is 210 // Create and start |fetcher_|, used to make all Gaia request. |body| is
231 // used as the body of the POST request sent to GAIA. Any strings listed in 211 // used as the body of the POST request sent to GAIA. Any strings listed in
232 // |headers| are added as extra HTTP headers in the request. 212 // |headers| are added as extra HTTP headers in the request.
233 // 213 //
234 // |load_flags| are passed to directly to net::URLFetcher::Create() when 214 // |load_flags| are passed to directly to net::URLFetcher::Create() when
235 // creating the URL fetcher. 215 // creating the URL fetcher.
236 // 216 //
237 // HasPendingFetch() should return false before calling this method, and will 217 // HasPendingFetch() should return false before calling this method, and will
238 // return true afterwards. 218 // return true afterwards.
239 virtual void CreateAndStartGaiaFetcher(const std::string& body, 219 virtual void CreateAndStartGaiaFetcher(
240 const std::string& headers, 220 const std::string& body,
241 const GURL& gaia_gurl, 221 const std::string& headers,
242 int load_flags); 222 const GURL& gaia_gurl,
223 int load_flags,
224 const net::NetworkTrafficAnnotationTag& traffic_annotation);
243 225
244 // Dispatch the results of a request. 226 // Dispatch the results of a request.
245 void DispatchFetchedRequest(const GURL& url, 227 void DispatchFetchedRequest(const GURL& url,
246 const std::string& data, 228 const std::string& data,
247 const net::ResponseCookies& cookies, 229 const net::ResponseCookies& cookies,
248 const net::URLRequestStatus& status, 230 const net::URLRequestStatus& status,
249 int response_code); 231 int response_code);
250 232
251 void SetPendingFetch(bool pending_fetch); 233 void SetPendingFetch(bool pending_fetch);
252 234
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, ParseOAuth2TokenPairResponse); 456 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, ParseOAuth2TokenPairResponse);
475 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, ClientOAuthSuccess); 457 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, ClientOAuthSuccess);
476 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, ClientOAuthWithQuote); 458 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, ClientOAuthWithQuote);
477 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, ClientOAuthChallengeSuccess); 459 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, ClientOAuthChallengeSuccess);
478 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, ClientOAuthChallengeQuote); 460 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, ClientOAuthChallengeQuote);
479 461
480 DISALLOW_COPY_AND_ASSIGN(GaiaAuthFetcher); 462 DISALLOW_COPY_AND_ASSIGN(GaiaAuthFetcher);
481 }; 463 };
482 464
483 #endif // GOOGLE_APIS_GAIA_GAIA_AUTH_FETCHER_H_ 465 #endif // GOOGLE_APIS_GAIA_GAIA_AUTH_FETCHER_H_
OLDNEW
« no previous file with comments | « no previous file | google_apis/gaia/gaia_auth_fetcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698