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 #include "chrome/browser/net/gaia/gaia_oauth_fetcher.h" | 5 #include "chrome/browser/net/gaia/gaia_oauth_fetcher.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 bool GaiaOAuthFetcher::HasPendingFetch() const { | 53 bool GaiaOAuthFetcher::HasPendingFetch() const { |
54 return fetch_pending_; | 54 return fetch_pending_; |
55 } | 55 } |
56 | 56 |
57 void GaiaOAuthFetcher::CancelRequest() { | 57 void GaiaOAuthFetcher::CancelRequest() { |
58 fetcher_.reset(); | 58 fetcher_.reset(); |
59 fetch_pending_ = false; | 59 fetch_pending_ = false; |
60 } | 60 } |
61 | 61 |
62 // static | 62 // static |
63 content::URLFetcher* GaiaOAuthFetcher::CreateGaiaFetcher( | 63 net::URLFetcher* GaiaOAuthFetcher::CreateGaiaFetcher( |
64 net::URLRequestContextGetter* getter, | 64 net::URLRequestContextGetter* getter, |
65 const GURL& gaia_gurl, | 65 const GURL& gaia_gurl, |
66 const std::string& body, | 66 const std::string& body, |
67 const std::string& headers, | 67 const std::string& headers, |
68 bool send_cookies, | 68 bool send_cookies, |
69 content::URLFetcherDelegate* delegate) { | 69 net::URLFetcherDelegate* delegate) { |
70 bool empty_body = body.empty(); | 70 bool empty_body = body.empty(); |
71 content::URLFetcher* result = content::URLFetcher::Create( | 71 net::URLFetcher* result = content::URLFetcher::Create( |
72 0, gaia_gurl, | 72 0, gaia_gurl, |
73 empty_body ? content::URLFetcher::GET : content::URLFetcher::POST, | 73 empty_body ? content::URLFetcher::GET : content::URLFetcher::POST, |
74 delegate); | 74 delegate); |
75 result->SetRequestContext(getter); | 75 result->SetRequestContext(getter); |
76 | 76 |
77 // The Gaia/OAuth token exchange requests do not require any cookie-based | 77 // The Gaia/OAuth token exchange requests do not require any cookie-based |
78 // identification as part of requests. We suppress sending any cookies to | 78 // identification as part of requests. We suppress sending any cookies to |
79 // maintain a separation between the user's browsing and Chrome's internal | 79 // maintain a separation between the user's browsing and Chrome's internal |
80 // services. Where such mixing is desired (prelogin, autologin | 80 // services. Where such mixing is desired (prelogin, autologin |
81 // or chromeos login), it will be done explicitly. | 81 // or chromeos login), it will be done explicitly. |
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
676 consumer_->OnUserInfoSuccess(email); | 676 consumer_->OnUserInfoSuccess(email); |
677 return; | 677 return; |
678 } | 678 } |
679 } | 679 } |
680 consumer_->OnUserInfoFailure(GenerateAuthError(data, status, | 680 consumer_->OnUserInfoFailure(GenerateAuthError(data, status, |
681 response_code)); | 681 response_code)); |
682 } | 682 } |
683 | 683 |
684 void GaiaOAuthFetcher::OnURLFetchComplete(const net::URLFetcher* source) { | 684 void GaiaOAuthFetcher::OnURLFetchComplete(const net::URLFetcher* source) { |
685 // Keep |fetcher_| around to avoid invalidating its |status| (accessed below). | 685 // Keep |fetcher_| around to avoid invalidating its |status| (accessed below). |
686 scoped_ptr<content::URLFetcher> current_fetcher(fetcher_.release()); | 686 scoped_ptr<net::URLFetcher> current_fetcher(fetcher_.release()); |
687 fetch_pending_ = false; | 687 fetch_pending_ = false; |
688 std::string data; | 688 std::string data; |
689 source->GetResponseAsString(&data); | 689 source->GetResponseAsString(&data); |
690 net::URLRequestStatus status = source->GetStatus(); | 690 net::URLRequestStatus status = source->GetStatus(); |
691 int response_code = source->GetResponseCode(); | 691 int response_code = source->GetResponseCode(); |
692 | 692 |
693 switch (request_type_) { | 693 switch (request_type_) { |
694 case OAUTH1_LOGIN: | 694 case OAUTH1_LOGIN: |
695 OnOAuthLoginFetched(data, status, response_code); | 695 OnOAuthLoginFetched(data, status, response_code); |
696 break; | 696 break; |
(...skipping 11 matching lines...) Expand all Loading... |
708 break; | 708 break; |
709 case OAUTH2_REVOKE_TOKEN: | 709 case OAUTH2_REVOKE_TOKEN: |
710 OnOAuthRevokeTokenFetched(data, status, response_code); | 710 OnOAuthRevokeTokenFetched(data, status, response_code); |
711 break; | 711 break; |
712 } | 712 } |
713 } | 713 } |
714 | 714 |
715 bool GaiaOAuthFetcher::ShouldAutoFetch(RequestType fetch_step) { | 715 bool GaiaOAuthFetcher::ShouldAutoFetch(RequestType fetch_step) { |
716 return fetch_step <= auto_fetch_limit_; | 716 return fetch_step <= auto_fetch_limit_; |
717 } | 717 } |
OLD | NEW |