summaryrefslogtreecommitdiffstats
path: root/chrome/browser/automation/url_request_automation_job.cc
diff options
context:
space:
mode:
authorananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-12 22:21:10 +0000
committerananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-12 22:21:10 +0000
commita7659318ed6c379ba782f61d8fb80e665d3a45d7 (patch)
treea6add177ad993709b6d3a3cca4f974cac1817044 /chrome/browser/automation/url_request_automation_job.cc
parent8c3dc79bc13ba84f418d3c135e1bf296a3e29722 (diff)
downloadchromium_src-a7659318ed6c379ba782f61d8fb80e665d3a45d7.zip
chromium_src-a7659318ed6c379ba782f61d8fb80e665d3a45d7.tar.gz
chromium_src-a7659318ed6c379ba782f61d8fb80e665d3a45d7.tar.bz2
Added support for the URLRequestAutomationJob object which issues HTTP requests through automation to receive persistent cookies from the automation client. These cookies are passed in when the automation client notifies Chrome that a HTTP request was started.
The URLRequestAutomationJob object now informs Chrome whether an automation URL request was redirected. The ExternalTabContainer now handles the NEW_FOREGROUND_TAB and displays a popup window in response. This gets around an ASSERT. This fixes bug http://b/issue?id=2048046 Bug=2048046 Review URL: http://codereview.chromium.org/165350 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23233 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.cc43
1 files changed, 30 insertions, 13 deletions
diff --git a/chrome/browser/automation/url_request_automation_job.cc b/chrome/browser/automation/url_request_automation_job.cc
index 4b69cca..206d1c4 100644
--- a/chrome/browser/automation/url_request_automation_job.cc
+++ b/chrome/browser/automation/url_request_automation_job.cc
@@ -185,16 +185,14 @@ int URLRequestAutomationJob::GetResponseCode() const {
bool URLRequestAutomationJob::IsRedirectResponse(
GURL* location, int* http_status_code) {
- if (!request_->response_headers())
- return false;
+ static const int kHttpRedirectResponseCode = 301;
- std::string value;
- if (!request_->response_headers()->IsRedirect(&value))
- return false;
-
- *location = request_->url().Resolve(value);
- *http_status_code = request_->response_headers()->response_code();
- return true;
+ if (!redirect_url_.empty()) {
+ *http_status_code = kHttpRedirectResponseCode;
+ *location = GURL(redirect_url_);
+ return true;
+ }
+ return false;
}
int URLRequestAutomationJob::MayFilterMessage(const IPC::Message& message) {
@@ -231,6 +229,14 @@ void URLRequestAutomationJob::OnRequestStarted(
set_expected_content_size(response.content_length);
mime_type_ = response.mime_type;
+ redirect_url_ = response.redirect_url;
+
+ GURL url_for_cookies =
+ GURL(redirect_url_.empty() ? request_->url().spec().c_str() :
+ redirect_url_.c_str());
+
+ URLRequestContext* ctx = request_->context();
+
if (!response.headers.empty()) {
headers_ = new net::HttpResponseHeaders(response.headers);
@@ -246,19 +252,31 @@ void URLRequestAutomationJob::OnRequestStarted(
}
if (response_cookies.size()) {
- URLRequestContext* ctx = request_->context();
if (ctx && ctx->cookie_store() &&
ctx->cookie_policy()->CanSetCookie(
- request_->url(), request_->first_party_for_cookies())) {
+ url_for_cookies, request_->first_party_for_cookies())) {
net::CookieOptions options;
options.set_include_httponly();
- ctx->cookie_store()->SetCookiesWithOptions(request_->url(),
+ ctx->cookie_store()->SetCookiesWithOptions(url_for_cookies,
response_cookies,
options);
}
}
}
+ if (ctx && ctx->cookie_store() && !response.persistent_cookies.empty() &&
+ ctx->cookie_policy()->CanSetCookie(
+ url_for_cookies, request_->first_party_for_cookies())) {
+ StringTokenizer cookie_parser(response.persistent_cookies, ";");
+
+ while (cookie_parser.GetNext()) {
+ net::CookieOptions options;
+ ctx->cookie_store()->SetCookieWithOptions(url_for_cookies,
+ cookie_parser.token(),
+ options);
+ }
+ }
+
NotifyHeadersComplete();
}
@@ -358,4 +376,3 @@ void URLRequestAutomationJob::DisconnectFromMessageFilter() {
message_filter_ = NULL;
}
}
-