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/common/net/gaia/gaia_auth_fetcher.h" | 5 #include "chrome/common/net/gaia/gaia_auth_fetcher.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/json/json_reader.h" | 12 #include "base/json/json_reader.h" |
13 #include "base/json/json_writer.h" | 13 #include "base/json/json_writer.h" |
14 #include "base/string_split.h" | 14 #include "base/string_split.h" |
15 #include "base/string_util.h" | 15 #include "base/string_util.h" |
16 #include "base/stringprintf.h" | 16 #include "base/stringprintf.h" |
17 #include "base/values.h" | 17 #include "base/values.h" |
18 #include "chrome/common/net/gaia/gaia_auth_consumer.h" | 18 #include "chrome/common/net/gaia/gaia_auth_consumer.h" |
19 #include "chrome/common/net/gaia/gaia_constants.h" | 19 #include "chrome/common/net/gaia/gaia_constants.h" |
20 #include "chrome/common/net/gaia/gaia_urls.h" | 20 #include "chrome/common/net/gaia/gaia_urls.h" |
21 #include "chrome/common/net/gaia/google_service_auth_error.h" | 21 #include "chrome/common/net/gaia/google_service_auth_error.h" |
22 #include "content/public/common/url_fetcher.h" | |
23 #include "net/base/escape.h" | 22 #include "net/base/escape.h" |
24 #include "net/base/load_flags.h" | 23 #include "net/base/load_flags.h" |
25 #include "net/http/http_status_code.h" | 24 #include "net/http/http_status_code.h" |
| 25 #include "net/url_request/url_fetcher.h" |
26 #include "net/url_request/url_request_context_getter.h" | 26 #include "net/url_request/url_request_context_getter.h" |
27 #include "net/url_request/url_request_status.h" | 27 #include "net/url_request/url_request_status.h" |
28 | 28 |
29 namespace { | 29 namespace { |
30 const int kLoadFlagsIgnoreCookies = net::LOAD_DO_NOT_SEND_COOKIES | | 30 const int kLoadFlagsIgnoreCookies = net::LOAD_DO_NOT_SEND_COOKIES | |
31 net::LOAD_DO_NOT_SAVE_COOKIES; | 31 net::LOAD_DO_NOT_SAVE_COOKIES; |
32 | 32 |
33 static bool CookiePartsContains(const std::vector<std::string>& parts, | 33 static bool CookiePartsContains(const std::vector<std::string>& parts, |
34 const char* part) { | 34 const char* part) { |
35 return std::find(parts.begin(), parts.end(), part) != parts.end(); | 35 return std::find(parts.begin(), parts.end(), part) != parts.end(); |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 } | 198 } |
199 | 199 |
200 // static | 200 // static |
201 net::URLFetcher* GaiaAuthFetcher::CreateGaiaFetcher( | 201 net::URLFetcher* GaiaAuthFetcher::CreateGaiaFetcher( |
202 net::URLRequestContextGetter* getter, | 202 net::URLRequestContextGetter* getter, |
203 const std::string& body, | 203 const std::string& body, |
204 const std::string& headers, | 204 const std::string& headers, |
205 const GURL& gaia_gurl, | 205 const GURL& gaia_gurl, |
206 int load_flags, | 206 int load_flags, |
207 net::URLFetcherDelegate* delegate) { | 207 net::URLFetcherDelegate* delegate) { |
208 net::URLFetcher* to_return = content::URLFetcher::Create( | 208 net::URLFetcher* to_return = net::URLFetcher::Create( |
209 0, gaia_gurl, | 209 0, gaia_gurl, |
210 body == "" ? net::URLFetcher::GET : net::URLFetcher::POST, | 210 body == "" ? net::URLFetcher::GET : net::URLFetcher::POST, |
211 delegate); | 211 delegate); |
212 to_return->SetRequestContext(getter); | 212 to_return->SetRequestContext(getter); |
213 to_return->SetUploadData("application/x-www-form-urlencoded", body); | 213 to_return->SetUploadData("application/x-www-form-urlencoded", body); |
214 | 214 |
215 DVLOG(2) << "Gaia fetcher URL: " << gaia_gurl.spec(); | 215 DVLOG(2) << "Gaia fetcher URL: " << gaia_gurl.spec(); |
216 DVLOG(2) << "Gaia fetcher headers: " << headers; | 216 DVLOG(2) << "Gaia fetcher headers: " << headers; |
217 DVLOG(2) << "Gaia fetcher body: " << body; | 217 DVLOG(2) << "Gaia fetcher body: " << body; |
218 | 218 |
(...skipping 882 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1101 NOTREACHED(); | 1101 NOTREACHED(); |
1102 } | 1102 } |
1103 } | 1103 } |
1104 | 1104 |
1105 // static | 1105 // static |
1106 bool GaiaAuthFetcher::IsSecondFactorSuccess( | 1106 bool GaiaAuthFetcher::IsSecondFactorSuccess( |
1107 const std::string& alleged_error) { | 1107 const std::string& alleged_error) { |
1108 return alleged_error.find(kSecondFactor) != | 1108 return alleged_error.find(kSecondFactor) != |
1109 std::string::npos; | 1109 std::string::npos; |
1110 } | 1110 } |
OLD | NEW |