OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 } else { | 652 } else { |
653 consumer_->OnUserInfoFailure(GenerateAuthError(data, status)); | 653 consumer_->OnUserInfoFailure(GenerateAuthError(data, status)); |
654 } | 654 } |
655 } | 655 } |
656 | 656 |
657 void GaiaOAuthFetcher::OnURLFetchComplete(const content::URLFetcher* source) { | 657 void GaiaOAuthFetcher::OnURLFetchComplete(const content::URLFetcher* source) { |
658 // Keep |fetcher_| around to avoid invalidating its |status| (accessed below). | 658 // Keep |fetcher_| around to avoid invalidating its |status| (accessed below). |
659 scoped_ptr<content::URLFetcher> current_fetcher(fetcher_.release()); | 659 scoped_ptr<content::URLFetcher> current_fetcher(fetcher_.release()); |
660 fetch_pending_ = false; | 660 fetch_pending_ = false; |
661 GaiaUrls* gaia_urls = GaiaUrls::GetInstance(); | 661 GaiaUrls* gaia_urls = GaiaUrls::GetInstance(); |
662 GURL url = source->GetUrl(); | 662 GURL url = source->GetURL(); |
663 std::string data; | 663 std::string data; |
664 source->GetResponseAsString(&data); | 664 source->GetResponseAsString(&data); |
665 net::URLRequestStatus status = source->GetStatus(); | 665 net::URLRequestStatus status = source->GetStatus(); |
666 int response_code = source->GetResponseCode(); | 666 int response_code = source->GetResponseCode(); |
667 if (StartsWithASCII(url.spec(), gaia_urls->get_oauth_token_url(), true)) { | 667 if (StartsWithASCII(url.spec(), gaia_urls->get_oauth_token_url(), true)) { |
668 OnGetOAuthTokenUrlFetched(source->GetCookies(), status, response_code); | 668 OnGetOAuthTokenUrlFetched(source->GetCookies(), status, response_code); |
669 } else if (url.spec() == gaia_urls->oauth1_login_url()) { | 669 } else if (url.spec() == gaia_urls->oauth1_login_url()) { |
670 OnOAuthLoginFetched(data, status, response_code); | 670 OnOAuthLoginFetched(data, status, response_code); |
671 } else if (url.spec() == gaia_urls->oauth_get_access_token_url()) { | 671 } else if (url.spec() == gaia_urls->oauth_get_access_token_url()) { |
672 OnOAuthGetAccessTokenFetched(data, status, response_code); | 672 OnOAuthGetAccessTokenFetched(data, status, response_code); |
673 } else if (url.spec() == gaia_urls->oauth_wrap_bridge_url()) { | 673 } else if (url.spec() == gaia_urls->oauth_wrap_bridge_url()) { |
674 OnOAuthWrapBridgeFetched(data, status, response_code); | 674 OnOAuthWrapBridgeFetched(data, status, response_code); |
675 } else if (url.spec() == gaia_urls->oauth_user_info_url()) { | 675 } else if (url.spec() == gaia_urls->oauth_user_info_url()) { |
676 OnUserInfoFetched(data, status, response_code); | 676 OnUserInfoFetched(data, status, response_code); |
677 } else if (StartsWithASCII(url.spec(), | 677 } else if (StartsWithASCII(url.spec(), |
678 gaia_urls->oauth_revoke_token_url(), | 678 gaia_urls->oauth_revoke_token_url(), |
679 true)) { | 679 true)) { |
680 OnOAuthRevokeTokenFetched(data, status, response_code); | 680 OnOAuthRevokeTokenFetched(data, status, response_code); |
681 } else { | 681 } else { |
682 NOTREACHED(); | 682 NOTREACHED(); |
683 } | 683 } |
684 } | 684 } |
685 | 685 |
686 bool GaiaOAuthFetcher::ShouldAutoFetch(AutoFetchLimit fetch_step) { | 686 bool GaiaOAuthFetcher::ShouldAutoFetch(AutoFetchLimit fetch_step) { |
687 return fetch_step <= auto_fetch_limit_; | 687 return fetch_step <= auto_fetch_limit_; |
688 } | 688 } |
OLD | NEW |