summaryrefslogtreecommitdiffstats
path: root/chrome/browser/automation/url_request_automation_job.cc
diff options
context:
space:
mode:
authoramit@chromium.org <amit@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-28 13:28:11 +0000
committeramit@chromium.org <amit@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-28 13:28:11 +0000
commit5f450e5c6fc98a762cebb38cd080731bedd61ae3 (patch)
treede1e6a257709c220222a6ab9defac23aade6e45c /chrome/browser/automation/url_request_automation_job.cc
parent60147f3b071444f0abfb320e62a0c9f2b666d443 (diff)
downloadchromium_src-5f450e5c6fc98a762cebb38cd080731bedd61ae3.zip
chromium_src-5f450e5c6fc98a762cebb38cd080731bedd61ae3.tar.gz
chromium_src-5f450e5c6fc98a762cebb38cd080731bedd61ae3.tar.bz2
Navigation and cookies for Automation
Give Automation better visibility and control over navigations. Also, make it possible for automation to implement a dummy cookie store to go with dummy request serving over automation. BUG=none TEST=none Review URL: http://codereview.chromium.org/159189 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21836 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/automation/url_request_automation_job.cc')
-rw-r--r--chrome/browser/automation/url_request_automation_job.cc28
1 files changed, 27 insertions, 1 deletions
diff --git a/chrome/browser/automation/url_request_automation_job.cc b/chrome/browser/automation/url_request_automation_job.cc
index 6ab7f87..5d4cac6 100644
--- a/chrome/browser/automation/url_request_automation_job.cc
+++ b/chrome/browser/automation/url_request_automation_job.cc
@@ -12,6 +12,7 @@
#include "net/base/io_buffer.h"
#include "net/base/net_errors.h"
#include "net/url_request/url_request.h"
+#include "net/url_request/url_request_context.h"
// This class manages the interception of network requests for automation.
@@ -191,9 +192,34 @@ void URLRequestAutomationJob::OnRequestStarted(
set_expected_content_size(response.content_length);
mime_type_ = response.mime_type;
- if (!response.headers.empty())
+ if (!response.headers.empty()) {
headers_ = new net::HttpResponseHeaders(response.headers);
+ // Parse and set HTTP cookies.
+ const std::string name = "Set-Cookie";
+ std::string value;
+ std::vector<std::string> response_cookies;
+
+ void* iter = NULL;
+ while (headers_->EnumerateHeader(&iter, name, &value)) {
+ if (request_->context()->InterceptCookie(request_, &value))
+ response_cookies.push_back(value);
+ }
+
+ if (response_cookies.size()) {
+ URLRequestContext* ctx = request_->context();
+ if (ctx && ctx->cookie_store() &&
+ ctx->cookie_policy()->CanSetCookie(
+ request_->url(), request_->first_party_for_cookies())) {
+ net::CookieOptions options;
+ options.set_include_httponly();
+ ctx->cookie_store()->SetCookiesWithOptions(request_->url(),
+ response_cookies,
+ options);
+ }
+ }
+ }
+
NotifyHeadersComplete();
}