Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(418)

Unified Diff: chrome/browser/automation/url_request_automation_job.cc

Issue 546104: Fix FullTabModeIE_ChromeFrameDeleteCookieTest. The problem was that a domain... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/automation/automation_profile_impl.cc ('k') | chrome_frame/http_negotiate.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/automation/url_request_automation_job.cc
===================================================================
--- chrome/browser/automation/url_request_automation_job.cc (revision 36629)
+++ chrome/browser/automation/url_request_automation_job.cc (working copy)
@@ -49,6 +49,24 @@
URLRequest::ProtocolFactory* URLRequestAutomationJob::old_https_factory_
= NULL;
+namespace {
+
+// Returns true if the cookie passed in exists in the list of cookies
+// parsed from the HTTP response header.
+bool IsParsedCookiePresentInCookieHeader(
+ const net::CookieMonster::ParsedCookie& parsed_cookie,
+ const std::vector<std::string>& header_cookies) {
+ for (size_t i = 0; i < header_cookies.size(); ++i) {
+ net::CookieMonster::ParsedCookie parsed_header_cookie(header_cookies[i]);
+ if (parsed_header_cookie.Name() == parsed_cookie.Name())
+ return true;
+ }
+
+ return false;
+}
+
+} // end namespace
+
URLRequestAutomationJob::URLRequestAutomationJob(URLRequest* request, int tab,
int request_id, AutomationResourceMessageFilter* filter)
: URLRequestJob(request),
@@ -291,6 +309,13 @@
url_for_cookies, request_->first_party_for_cookies())) {
StringTokenizer cookie_parser(response.persistent_cookies, ";");
+ std::vector<net::CookieMonster::CanonicalCookie> existing_cookies;
+ net::CookieMonster* monster = ctx->cookie_store()->GetCookieMonster();
+ DCHECK(monster);
+ if (monster) {
+ monster->GetRawCookies(url_for_cookies, &existing_cookies);
+ }
+
while (cookie_parser.GetNext()) {
std::string cookie_string = cookie_parser.token();
// Only allow cookies with valid name value pairs.
@@ -298,13 +323,21 @@
TrimWhitespace(cookie_string, TRIM_ALL, &cookie_string);
// Ignore duplicate cookies, i.e. cookies passed in from the host
// browser which also exist in the response header.
- if (!IsCookiePresentInCookieHeader(cookie_string,
- response_cookies)) {
- net::CookieOptions options;
- ctx->cookie_store()->SetCookieWithOptions(url_for_cookies,
- cookie_string,
- options);
+ net::CookieMonster::ParsedCookie parsed_cookie(cookie_string);
+ std::vector<net::CookieMonster::CanonicalCookie>::const_iterator i;
+ for (i = existing_cookies.begin(); i != existing_cookies.end(); ++i) {
+ if ((*i).Name() == parsed_cookie.Name())
+ break;
}
+
+ if (i == existing_cookies.end() &&
+ !IsParsedCookiePresentInCookieHeader(parsed_cookie,
+ response_cookies)) {
+ net::CookieOptions options;
+ ctx->cookie_store()->SetCookieWithOptions(url_for_cookies,
+ cookie_string,
+ options);
+ }
}
}
}
@@ -449,17 +482,8 @@
}
bool URLRequestAutomationJob::IsCookiePresentInCookieHeader(
- const std::string& cookie_line,
+ const std::string& cookie_name,
const std::vector<std::string>& header_cookies) {
- net::CookieMonster::ParsedCookie parsed_current_cookie(cookie_line);
- for (size_t index = 0; index < header_cookies.size(); index++) {
- net::CookieMonster::ParsedCookie parsed_header_cookie(
- header_cookies[index]);
-
- if (parsed_header_cookie.Name() == parsed_current_cookie.Name())
- return true;
- }
-
- return false;
+ net::CookieMonster::ParsedCookie parsed_cookie(cookie_name);
+ return IsParsedCookiePresentInCookieHeader(parsed_cookie, header_cookies);
}
-
« no previous file with comments | « chrome/browser/automation/automation_profile_impl.cc ('k') | chrome_frame/http_negotiate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698