| 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 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 <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 // called on the consumer on the original thread. | 141 // called on the consumer on the original thread. |
| 142 void StartGetUserInfo(const std::string& lsid); | 142 void StartGetUserInfo(const std::string& lsid); |
| 143 | 143 |
| 144 // Start a MergeSession request to pre-login the user with the given | 144 // Start a MergeSession request to pre-login the user with the given |
| 145 // credentials. | 145 // credentials. |
| 146 // | 146 // |
| 147 // Start a MergeSession request to fill the browsing cookie jar with | 147 // Start a MergeSession request to fill the browsing cookie jar with |
| 148 // credentials represented by the account whose uber-auth token is | 148 // credentials represented by the account whose uber-auth token is |
| 149 // |uber_token|. This method will modify the cookies of the current profile. | 149 // |uber_token|. This method will modify the cookies of the current profile. |
| 150 // | 150 // |
| 151 // The |external_cc_result| string can specify the result of connetion checks |
| 152 // for various google properties, and MergeSession will set cookies on those |
| 153 // properties too if appropriate. See StartGetCheckConnectionInfo() for |
| 154 // details. The string is a comma separated list of token/result pairs, where |
| 155 // token and result are separated by a colon. This string may be empty, in |
| 156 // which case no specific handling is performed. |
| 157 // |
| 151 // Either OnMergeSessionSuccess or OnMergeSessionFailure will be | 158 // Either OnMergeSessionSuccess or OnMergeSessionFailure will be |
| 152 // called on the consumer on the original thread. | 159 // called on the consumer on the original thread. |
| 153 void StartMergeSession(const std::string& uber_token); | 160 void StartMergeSession(const std::string& uber_token, |
| 161 const std::string& external_cc_result); |
| 154 | 162 |
| 155 // Start a request to exchange an OAuthLogin-scoped oauth2 access token for an | 163 // Start a request to exchange an OAuthLogin-scoped oauth2 access token for an |
| 156 // uber-auth token. The returned token can be used with the method | 164 // uber-auth token. The returned token can be used with the method |
| 157 // StartMergeSession(). | 165 // StartMergeSession(). |
| 158 // | 166 // |
| 159 // Either OnUberAuthTokenSuccess or OnUberAuthTokenFailure will be | 167 // Either OnUberAuthTokenSuccess or OnUberAuthTokenFailure will be |
| 160 // called on the consumer on the original thread. | 168 // called on the consumer on the original thread. |
| 161 void StartTokenFetchForUberAuthExchange(const std::string& access_token); | 169 void StartTokenFetchForUberAuthExchange(const std::string& access_token); |
| 162 | 170 |
| 163 // Start a request to exchange an OAuthLogin-scoped oauth2 access token for a | 171 // Start a request to exchange an OAuthLogin-scoped oauth2 access token for a |
| 164 // ClientLogin-style service tokens. The response to this request is the | 172 // ClientLogin-style service tokens. The response to this request is the |
| 165 // same as the response to a ClientLogin request, except that captcha | 173 // same as the response to a ClientLogin request, except that captcha |
| 166 // challenges are never issued. | 174 // challenges are never issued. |
| 167 // | 175 // |
| 168 // Either OnClientLoginSuccess or OnClientLoginFailure will be | 176 // Either OnClientLoginSuccess or OnClientLoginFailure will be |
| 169 // called on the consumer on the original thread. If |service| is empty, | 177 // called on the consumer on the original thread. If |service| is empty, |
| 170 // the call will attempt to fetch uber auth token. | 178 // the call will attempt to fetch uber auth token. |
| 171 void StartOAuthLogin(const std::string& access_token, | 179 void StartOAuthLogin(const std::string& access_token, |
| 172 const std::string& service); | 180 const std::string& service); |
| 173 | 181 |
| 174 // Starts a request to list the accounts in the GAIA cookie. | 182 // Starts a request to list the accounts in the GAIA cookie. |
| 175 void StartListAccounts(); | 183 void StartListAccounts(); |
| 176 | 184 |
| 185 // Starts a request to get the list of URLs to check for connection info. |
| 186 // Returns token/URL pairs to check, and the resulting status can be given to |
| 187 // /MergeSession requests. |
| 188 void StartGetCheckConnectionInfo(); |
| 189 |
| 177 // Implementation of net::URLFetcherDelegate | 190 // Implementation of net::URLFetcherDelegate |
| 178 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; | 191 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; |
| 179 | 192 |
| 180 // StartClientLogin been called && results not back yet? | 193 // StartClientLogin been called && results not back yet? |
| 181 bool HasPendingFetch(); | 194 bool HasPendingFetch(); |
| 182 | 195 |
| 183 // Stop any URL fetches in progress. | 196 // Stop any URL fetches in progress. |
| 184 void CancelRequest(); | 197 void CancelRequest(); |
| 185 | 198 |
| 186 // From a URLFetcher result, generate an appropriate error. | 199 // From a URLFetcher result, generate an appropriate error. |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 int response_code); | 299 int response_code); |
| 287 | 300 |
| 288 void OnUberAuthTokenFetch(const std::string& data, | 301 void OnUberAuthTokenFetch(const std::string& data, |
| 289 const net::URLRequestStatus& status, | 302 const net::URLRequestStatus& status, |
| 290 int response_code); | 303 int response_code); |
| 291 | 304 |
| 292 void OnOAuthLoginFetched(const std::string& data, | 305 void OnOAuthLoginFetched(const std::string& data, |
| 293 const net::URLRequestStatus& status, | 306 const net::URLRequestStatus& status, |
| 294 int response_code); | 307 int response_code); |
| 295 | 308 |
| 309 void OnGetCheckConnectionInfoFetched(const std::string& data, |
| 310 const net::URLRequestStatus& status, |
| 311 int response_code); |
| 312 |
| 296 // Tokenize the results of a ClientLogin fetch. | 313 // Tokenize the results of a ClientLogin fetch. |
| 297 static void ParseClientLoginResponse(const std::string& data, | 314 static void ParseClientLoginResponse(const std::string& data, |
| 298 std::string* sid, | 315 std::string* sid, |
| 299 std::string* lsid, | 316 std::string* lsid, |
| 300 std::string* token); | 317 std::string* token); |
| 301 | 318 |
| 302 static void ParseClientLoginFailure(const std::string& data, | 319 static void ParseClientLoginFailure(const std::string& data, |
| 303 std::string* error, | 320 std::string* error, |
| 304 std::string* error_url, | 321 std::string* error_url, |
| 305 std::string* captcha_url, | 322 std::string* captcha_url, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 335 // Given auth code, create body to get OAuth2 token pair. | 352 // Given auth code, create body to get OAuth2 token pair. |
| 336 static std::string MakeGetTokenPairBody(const std::string& auth_code); | 353 static std::string MakeGetTokenPairBody(const std::string& auth_code); |
| 337 // Given an OAuth2 token, create body to revoke the token. | 354 // Given an OAuth2 token, create body to revoke the token. |
| 338 std::string MakeRevokeTokenBody(const std::string& auth_token); | 355 std::string MakeRevokeTokenBody(const std::string& auth_token); |
| 339 // Supply the lsid returned from ClientLogin in order to fetch | 356 // Supply the lsid returned from ClientLogin in order to fetch |
| 340 // user information. | 357 // user information. |
| 341 static std::string MakeGetUserInfoBody(const std::string& lsid); | 358 static std::string MakeGetUserInfoBody(const std::string& lsid); |
| 342 | 359 |
| 343 // Supply the authentication token returned from StartIssueAuthToken. | 360 // Supply the authentication token returned from StartIssueAuthToken. |
| 344 static std::string MakeMergeSessionBody(const std::string& auth_token, | 361 static std::string MakeMergeSessionBody(const std::string& auth_token, |
| 345 const std::string& continue_url, | 362 const std::string& external_cc_result, |
| 346 const std::string& source); | 363 const std::string& continue_url, |
| 364 const std::string& source); |
| 347 | 365 |
| 348 static std::string MakeGetAuthCodeHeader(const std::string& auth_token); | 366 static std::string MakeGetAuthCodeHeader(const std::string& auth_token); |
| 349 | 367 |
| 350 static std::string MakeOAuthLoginBody(const std::string& service, | 368 static std::string MakeOAuthLoginBody(const std::string& service, |
| 351 const std::string& source); | 369 const std::string& source); |
| 352 | 370 |
| 353 // Create a fetcher usable for making any Gaia request. |body| is used | 371 // Create a fetcher usable for making any Gaia request. |body| is used |
| 354 // as the body of the POST request sent to GAIA. Any strings listed in | 372 // as the body of the POST request sent to GAIA. Any strings listed in |
| 355 // |headers| are added as extra HTTP headers in the request. | 373 // |headers| are added as extra HTTP headers in the request. |
| 356 // | 374 // |
| (...skipping 20 matching lines...) Expand all Loading... |
| 377 std::string source_; | 395 std::string source_; |
| 378 const GURL client_login_gurl_; | 396 const GURL client_login_gurl_; |
| 379 const GURL issue_auth_token_gurl_; | 397 const GURL issue_auth_token_gurl_; |
| 380 const GURL oauth2_token_gurl_; | 398 const GURL oauth2_token_gurl_; |
| 381 const GURL oauth2_revoke_gurl_; | 399 const GURL oauth2_revoke_gurl_; |
| 382 const GURL get_user_info_gurl_; | 400 const GURL get_user_info_gurl_; |
| 383 const GURL merge_session_gurl_; | 401 const GURL merge_session_gurl_; |
| 384 const GURL uberauth_token_gurl_; | 402 const GURL uberauth_token_gurl_; |
| 385 const GURL oauth_login_gurl_; | 403 const GURL oauth_login_gurl_; |
| 386 const GURL list_accounts_gurl_; | 404 const GURL list_accounts_gurl_; |
| 405 const GURL get_check_connection_info_url_; |
| 387 | 406 |
| 388 // While a fetch is going on: | 407 // While a fetch is going on: |
| 389 scoped_ptr<net::URLFetcher> fetcher_; | 408 scoped_ptr<net::URLFetcher> fetcher_; |
| 390 GURL client_login_to_oauth2_gurl_; | 409 GURL client_login_to_oauth2_gurl_; |
| 391 std::string request_body_; | 410 std::string request_body_; |
| 392 std::string requested_service_; // Currently tracked for IssueAuthToken only. | 411 std::string requested_service_; // Currently tracked for IssueAuthToken only. |
| 393 bool fetch_pending_; | 412 bool fetch_pending_; |
| 394 | 413 |
| 395 friend class GaiaAuthFetcherTest; | 414 friend class GaiaAuthFetcherTest; |
| 396 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, CaptchaParse); | 415 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, CaptchaParse); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 407 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, ParseOAuth2TokenPairResponse); | 426 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, ParseOAuth2TokenPairResponse); |
| 408 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, ClientOAuthSuccess); | 427 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, ClientOAuthSuccess); |
| 409 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, ClientOAuthWithQuote); | 428 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, ClientOAuthWithQuote); |
| 410 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, ClientOAuthChallengeSuccess); | 429 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, ClientOAuthChallengeSuccess); |
| 411 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, ClientOAuthChallengeQuote); | 430 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, ClientOAuthChallengeQuote); |
| 412 | 431 |
| 413 DISALLOW_COPY_AND_ASSIGN(GaiaAuthFetcher); | 432 DISALLOW_COPY_AND_ASSIGN(GaiaAuthFetcher); |
| 414 }; | 433 }; |
| 415 | 434 |
| 416 #endif // GOOGLE_APIS_GAIA_GAIA_AUTH_FETCHER_H_ | 435 #endif // GOOGLE_APIS_GAIA_GAIA_AUTH_FETCHER_H_ |
| OLD | NEW |