Chromium Code Reviews| 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 "google_apis/gaia/gaia_auth_fetcher.h" | 5 #include "google_apis/gaia/gaia_auth_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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 65 } | 65 } |
| 66 | 66 |
| 67 // Refresh token may not be required. | 67 // Refresh token may not be required. |
| 68 if (refresh_token) { | 68 if (refresh_token) { |
| 69 if (!dict->GetStringWithoutPathExpansion("refresh_token", refresh_token)) | 69 if (!dict->GetStringWithoutPathExpansion("refresh_token", refresh_token)) |
| 70 return false; | 70 return false; |
| 71 } | 71 } |
| 72 return true; | 72 return true; |
| 73 } | 73 } |
| 74 | 74 |
| 75 void GetCookiesFromResponse(net::HttpResponseHeaders* headers, | |
|
Roger Tawa OOO till Jul 10th
2016/06/14 15:57:40
This should be a const ptr.
martijnc
2016/06/14 22:18:08
Done.
| |
| 76 net::ResponseCookies* cookies) { | |
| 77 if (!headers) | |
| 78 return; | |
| 79 | |
| 80 std::string value; | |
| 81 size_t iter = 0; | |
| 82 while (headers->EnumerateHeader(&iter, "Set-Cookie", &value)) { | |
| 83 if (!value.empty()) | |
| 84 cookies->push_back(value); | |
| 85 } | |
| 86 } | |
| 87 | |
| 75 const char kListIdpServiceRequested[] = "list_idp"; | 88 const char kListIdpServiceRequested[] = "list_idp"; |
| 76 const char kGetTokenResponseRequested[] = "get_token"; | 89 const char kGetTokenResponseRequested[] = "get_token"; |
| 77 | 90 |
| 78 } // namespace | 91 } // namespace |
| 79 | 92 |
| 80 // static | 93 // static |
| 81 const char GaiaAuthFetcher::kIssueAuthTokenFormat[] = | 94 const char GaiaAuthFetcher::kIssueAuthTokenFormat[] = |
| 82 "SID=%s&" | 95 "SID=%s&" |
| 83 "LSID=%s&" | 96 "LSID=%s&" |
| 84 "service=%s&" | 97 "service=%s&" |
| (...skipping 852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 937 // the OnURLFetchComplete callback has run. | 950 // the OnURLFetchComplete callback has run. |
| 938 #ifndef NDEBUG | 951 #ifndef NDEBUG |
| 939 std::string headers; | 952 std::string headers; |
| 940 if (source->GetResponseHeaders()) | 953 if (source->GetResponseHeaders()) |
| 941 source->GetResponseHeaders()->GetNormalizedHeaders(&headers); | 954 source->GetResponseHeaders()->GetNormalizedHeaders(&headers); |
| 942 DVLOG(2) << "Response " << url.spec() << ", code = " << response_code << "\n" | 955 DVLOG(2) << "Response " << url.spec() << ", code = " << response_code << "\n" |
| 943 << headers << "\n"; | 956 << headers << "\n"; |
| 944 DVLOG(2) << "data: " << data << "\n"; | 957 DVLOG(2) << "data: " << data << "\n"; |
| 945 #endif | 958 #endif |
| 946 | 959 |
| 947 DispatchFetchedRequest(url, data, source->GetCookies(), status, | 960 net::ResponseCookies cookies; |
| 948 response_code); | 961 GetCookiesFromResponse(source->GetResponseHeaders(), &cookies); |
| 962 DispatchFetchedRequest(url, data, cookies, status, response_code); | |
| 949 } | 963 } |
| 950 | 964 |
| 951 void GaiaAuthFetcher::DispatchFetchedRequest( | 965 void GaiaAuthFetcher::DispatchFetchedRequest( |
| 952 const GURL& url, | 966 const GURL& url, |
| 953 const std::string& data, | 967 const std::string& data, |
| 954 const net::ResponseCookies& cookies, | 968 const net::ResponseCookies& cookies, |
| 955 const net::URLRequestStatus& status, | 969 const net::URLRequestStatus& status, |
| 956 int response_code) { | 970 int response_code) { |
| 957 if (url == issue_auth_token_gurl_) { | 971 if (url == issue_auth_token_gurl_) { |
| 958 OnIssueAuthTokenFetched(data, status, response_code); | 972 OnIssueAuthTokenFetched(data, status, response_code); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 997 return alleged_error.find(kSecondFactor) != | 1011 return alleged_error.find(kSecondFactor) != |
| 998 std::string::npos; | 1012 std::string::npos; |
| 999 } | 1013 } |
| 1000 | 1014 |
| 1001 // static | 1015 // static |
| 1002 bool GaiaAuthFetcher::IsWebLoginRequiredSuccess( | 1016 bool GaiaAuthFetcher::IsWebLoginRequiredSuccess( |
| 1003 const std::string& alleged_error) { | 1017 const std::string& alleged_error) { |
| 1004 return alleged_error.find(kWebLoginRequired) != | 1018 return alleged_error.find(kWebLoginRequired) != |
| 1005 std::string::npos; | 1019 std::string::npos; |
| 1006 } | 1020 } |
| OLD | NEW |