| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/automation/url_request_automation_job.h" | 5 #include "chrome/browser/automation/url_request_automation_job.h" |
| 6 | 6 |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/time.h" | 8 #include "base/time.h" |
| 9 #include "chrome/browser/automation/automation_resource_message_filter.h" | 9 #include "chrome/browser/automation/automation_resource_message_filter.h" |
| 10 #include "chrome/browser/chrome_thread.h" | 10 #include "chrome/browser/chrome_thread.h" |
| 11 #include "chrome/browser/renderer_host/render_view_host.h" | 11 #include "chrome/browser/renderer_host/render_view_host.h" |
| 12 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" | 12 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" |
| 13 #include "chrome/browser/renderer_host/resource_dispatcher_host_request_info.h" | 13 #include "chrome/browser/renderer_host/resource_dispatcher_host_request_info.h" |
| 14 #include "chrome/test/automation/automation_messages.h" | 14 #include "chrome/test/automation/automation_messages.h" |
| 15 #include "net/base/cookie_monster.h" | 15 #include "net/base/cookie_monster.h" |
| 16 #include "net/base/cookie_policy.h" |
| 16 #include "net/base/io_buffer.h" | 17 #include "net/base/io_buffer.h" |
| 17 #include "net/base/net_errors.h" | 18 #include "net/base/net_errors.h" |
| 18 #include "net/http/http_util.h" | 19 #include "net/http/http_util.h" |
| 19 #include "net/url_request/url_request_context.h" | 20 #include "net/url_request/url_request_context.h" |
| 20 | 21 |
| 21 using base::Time; | 22 using base::Time; |
| 22 using base::TimeDelta; | 23 using base::TimeDelta; |
| 23 | 24 |
| 24 // The list of filtered headers that are removed from requests sent via | 25 // The list of filtered headers that are removed from requests sent via |
| 25 // StartAsync(). These must be lower case. | 26 // StartAsync(). These must be lower case. |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 const std::string name = "Set-Cookie"; | 306 const std::string name = "Set-Cookie"; |
| 306 std::string value; | 307 std::string value; |
| 307 | 308 |
| 308 void* iter = NULL; | 309 void* iter = NULL; |
| 309 while (headers_->EnumerateHeader(&iter, name, &value)) { | 310 while (headers_->EnumerateHeader(&iter, name, &value)) { |
| 310 if (request_->context()->InterceptResponseCookie(request_, value)) | 311 if (request_->context()->InterceptResponseCookie(request_, value)) |
| 311 response_cookies.push_back(value); | 312 response_cookies.push_back(value); |
| 312 } | 313 } |
| 313 | 314 |
| 314 if (response_cookies.size()) { | 315 if (response_cookies.size()) { |
| 315 if (ctx && ctx->cookie_store() && | 316 if (ctx && ctx->cookie_store() && ctx->cookie_policy() && |
| 316 ctx->cookie_policy()->CanSetCookie( | 317 ctx->cookie_policy()->CanSetCookie( |
| 317 url_for_cookies, request_->first_party_for_cookies())) { | 318 url_for_cookies, request_->first_party_for_cookies())) { |
| 318 net::CookieOptions options; | 319 net::CookieOptions options; |
| 319 options.set_include_httponly(); | 320 options.set_include_httponly(); |
| 320 ctx->cookie_store()->SetCookiesWithOptions(url_for_cookies, | 321 ctx->cookie_store()->SetCookiesWithOptions(url_for_cookies, |
| 321 response_cookies, | 322 response_cookies, |
| 322 options); | 323 options); |
| 323 } | 324 } |
| 324 } | 325 } |
| 325 } | 326 } |
| 326 | 327 |
| 327 if (ctx && ctx->cookie_store() && !response.persistent_cookies.empty() && | 328 if (ctx && ctx->cookie_store() && ctx->cookie_policy() && |
| 329 !response.persistent_cookies.empty() && |
| 328 ctx->cookie_policy()->CanSetCookie( | 330 ctx->cookie_policy()->CanSetCookie( |
| 329 url_for_cookies, request_->first_party_for_cookies())) { | 331 url_for_cookies, request_->first_party_for_cookies())) { |
| 330 StringTokenizer cookie_parser(response.persistent_cookies, ";"); | 332 StringTokenizer cookie_parser(response.persistent_cookies, ";"); |
| 331 | 333 |
| 332 std::vector<net::CookieMonster::CanonicalCookie> existing_cookies; | 334 std::vector<net::CookieMonster::CanonicalCookie> existing_cookies; |
| 333 net::CookieMonster* monster = ctx->cookie_store()->GetCookieMonster(); | 335 net::CookieMonster* monster = ctx->cookie_store()->GetCookieMonster(); |
| 334 DCHECK(monster); | 336 DCHECK(monster); |
| 335 if (monster) { | 337 if (monster) { |
| 336 monster->GetRawCookies(url_for_cookies, &existing_cookies); | 338 monster->GetRawCookies(url_for_cookies, &existing_cookies); |
| 337 } | 339 } |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 net::CookieMonster::ParsedCookie parsed(*cookie_string); | 539 net::CookieMonster::ParsedCookie parsed(*cookie_string); |
| 538 if (parsed.IsValid() && !parsed.HasPath()) { | 540 if (parsed.IsValid() && !parsed.HasPath()) { |
| 539 DCHECK(cookie_string->length() > 0); | 541 DCHECK(cookie_string->length() > 0); |
| 540 | 542 |
| 541 // The path is not specified, add it at the end. | 543 // The path is not specified, add it at the end. |
| 542 if ((*cookie_string)[cookie_string->length() - 1] != ';') | 544 if ((*cookie_string)[cookie_string->length() - 1] != ';') |
| 543 *cookie_string += ';'; | 545 *cookie_string += ';'; |
| 544 cookie_string->append(" path=/"); | 546 cookie_string->append(" path=/"); |
| 545 } | 547 } |
| 546 } | 548 } |
| OLD | NEW |