| 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/string_split.h" | 13 #include "base/string_split.h" |
| 14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
| 15 #include "base/stringprintf.h" | 15 #include "base/stringprintf.h" |
| 16 #include "base/values.h" | 16 #include "base/values.h" |
| 17 #include "chrome/common/net/gaia/gaia_auth_consumer.h" | 17 #include "chrome/common/net/gaia/gaia_auth_consumer.h" |
| 18 #include "chrome/common/net/gaia/gaia_constants.h" | 18 #include "chrome/common/net/gaia/gaia_constants.h" |
| 19 #include "chrome/common/net/gaia/gaia_urls.h" | 19 #include "chrome/common/net/gaia/gaia_urls.h" |
| 20 #include "chrome/common/net/gaia/google_service_auth_error.h" | 20 #include "chrome/common/net/gaia/google_service_auth_error.h" |
| 21 #include "content/public/common/content_url_request_user_data.h" |
| 21 #include "content/public/common/url_fetcher.h" | 22 #include "content/public/common/url_fetcher.h" |
| 22 #include "net/base/escape.h" | 23 #include "net/base/escape.h" |
| 23 #include "net/base/load_flags.h" | 24 #include "net/base/load_flags.h" |
| 24 #include "net/http/http_status_code.h" | 25 #include "net/http/http_status_code.h" |
| 25 #include "net/url_request/url_request_context_getter.h" | 26 #include "net/url_request/url_request_context_getter.h" |
| 26 #include "net/url_request/url_request_status.h" | 27 #include "net/url_request/url_request_status.h" |
| 27 | 28 |
| 28 namespace { | 29 namespace { |
| 29 static bool CookiePartsContains(const std::vector<std::string>& parts, | 30 static bool CookiePartsContains(const std::vector<std::string>& parts, |
| 30 const char* part) { | 31 const char* part) { |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 const std::string& body, | 183 const std::string& body, |
| 183 const std::string& headers, | 184 const std::string& headers, |
| 184 const GURL& gaia_gurl, | 185 const GURL& gaia_gurl, |
| 185 bool use_cookies, | 186 bool use_cookies, |
| 186 content::URLFetcherDelegate* delegate) { | 187 content::URLFetcherDelegate* delegate) { |
| 187 content::URLFetcher* to_return = content::URLFetcher::Create( | 188 content::URLFetcher* to_return = content::URLFetcher::Create( |
| 188 0, gaia_gurl, | 189 0, gaia_gurl, |
| 189 body == "" ? content::URLFetcher::GET : content::URLFetcher::POST, | 190 body == "" ? content::URLFetcher::GET : content::URLFetcher::POST, |
| 190 delegate); | 191 delegate); |
| 191 to_return->SetRequestContext(getter); | 192 to_return->SetRequestContext(getter); |
| 193 // TODO(jochen): Do cookie audit. |
| 194 to_return->SetContentURLRequestUserData( |
| 195 new content::ContentURLRequestUserData()); |
| 192 to_return->SetUploadData("application/x-www-form-urlencoded", body); | 196 to_return->SetUploadData("application/x-www-form-urlencoded", body); |
| 193 | 197 |
| 194 // The Gaia token exchange requests do not require any cookie-based | 198 // The Gaia token exchange requests do not require any cookie-based |
| 195 // identification as part of requests. We suppress sending any cookies to | 199 // identification as part of requests. We suppress sending any cookies to |
| 196 // maintain a separation between the user's browsing and Chrome's internal | 200 // maintain a separation between the user's browsing and Chrome's internal |
| 197 // services. Where such mixing is desired (MergeSession), it will be done | 201 // services. Where such mixing is desired (MergeSession), it will be done |
| 198 // explicitly. | 202 // explicitly. |
| 199 if (!use_cookies) { | 203 if (!use_cookies) { |
| 200 to_return->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | | 204 to_return->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | |
| 201 net::LOAD_DO_NOT_SAVE_COOKIES); | 205 net::LOAD_DO_NOT_SAVE_COOKIES); |
| (...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 857 NOTREACHED(); | 861 NOTREACHED(); |
| 858 } | 862 } |
| 859 } | 863 } |
| 860 | 864 |
| 861 // static | 865 // static |
| 862 bool GaiaAuthFetcher::IsSecondFactorSuccess( | 866 bool GaiaAuthFetcher::IsSecondFactorSuccess( |
| 863 const std::string& alleged_error) { | 867 const std::string& alleged_error) { |
| 864 return alleged_error.find(kSecondFactor) != | 868 return alleged_error.find(kSecondFactor) != |
| 865 std::string::npos; | 869 std::string::npos; |
| 866 } | 870 } |
| OLD | NEW |