diff options
-rw-r--r-- | chrome/browser/automation/automation_profile_impl.cc | 4 | ||||
-rw-r--r-- | chrome/browser/automation/url_request_automation_job.cc | 60 | ||||
-rw-r--r-- | chrome_frame/http_negotiate.cc | 2 | ||||
-rw-r--r-- | chrome_frame/test/chrome_frame_unittests.cc | 4 | ||||
-rw-r--r-- | chrome_frame/test/data/fulltab_delete_cookie_test.html | 20 | ||||
-rw-r--r-- | chrome_frame/urlmon_url_request.cc | 5 |
6 files changed, 62 insertions, 33 deletions
diff --git a/chrome/browser/automation/automation_profile_impl.cc b/chrome/browser/automation/automation_profile_impl.cc index b8685be..3a1387d 100644 --- a/chrome/browser/automation/automation_profile_impl.cc +++ b/chrome/browser/automation/automation_profile_impl.cc @@ -110,6 +110,10 @@ class AutomationCookieStore : public net::CookieStore { return original_cookie_store_->DeleteCookie(url, cookie_name); } + virtual net::CookieMonster* GetCookieMonster() { + return original_cookie_store_->GetCookieMonster(); + } + protected: void SendIPCMessageOnIOThread(IPC::Message* m) { if (ChromeThread::CurrentlyOn(ChromeThread::IO)) { diff --git a/chrome/browser/automation/url_request_automation_job.cc b/chrome/browser/automation/url_request_automation_job.cc index ec01660..5e35ab8 100644 --- a/chrome/browser/automation/url_request_automation_job.cc +++ b/chrome/browser/automation/url_request_automation_job.cc @@ -49,6 +49,24 @@ URLRequest::ProtocolFactory* URLRequestAutomationJob::old_http_factory_ 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 @@ void URLRequestAutomationJob::OnRequestStarted(int tab, int id, 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,12 +323,20 @@ void URLRequestAutomationJob::OnRequestStarted(int tab, int id, 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 @@ void URLRequestAutomationJob::DisconnectFromMessageFilter() { } 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); } - diff --git a/chrome_frame/http_negotiate.cc b/chrome_frame/http_negotiate.cc index f118baf..e725f3d 100644 --- a/chrome_frame/http_negotiate.cc +++ b/chrome_frame/http_negotiate.cc @@ -199,6 +199,8 @@ HRESULT HttpNegotiatePatch::BeginningTransaction( HRESULT HttpNegotiatePatch::OnResponse(IHttpNegotiate_OnResponse_Fn original, IHttpNegotiate* me, DWORD response_code, LPCWSTR response_header, LPCWSTR request_header, LPWSTR* additional_request_headers) { + DLOG(INFO) << __FUNCTION__ << " headers: " << std::endl << response_header; + HRESULT hr = original(me, response_code, response_header, request_header, additional_request_headers); return hr; diff --git a/chrome_frame/test/chrome_frame_unittests.cc b/chrome_frame/test/chrome_frame_unittests.cc index ab12d9e..76a41bc 100644 --- a/chrome_frame/test/chrome_frame_unittests.cc +++ b/chrome_frame/test/chrome_frame_unittests.cc @@ -1819,10 +1819,8 @@ TEST_F(ChromeFrameTestWithWebServer, const wchar_t kChromeFrameFullTabModeDeleteCookieTest[] = L"files/fulltab_delete_cookie_test.html"; -// TODO(ananta): DISABLED due to: -// http://code.google.com/p/chromium/issues/detail?id=32546 TEST_F(ChromeFrameTestWithWebServer, - DISABLED_FullTabModeIE_ChromeFrameDeleteCookieTest) { + FullTabModeIE_ChromeFrameDeleteCookieTest) { chrome_frame_test::TimedMsgLoop loop; ASSERT_TRUE(LaunchBrowser(IE, kChromeFrameFullTabModeDeleteCookieTest)); diff --git a/chrome_frame/test/data/fulltab_delete_cookie_test.html b/chrome_frame/test/data/fulltab_delete_cookie_test.html index 62c5df0..975d290 100644 --- a/chrome_frame/test/data/fulltab_delete_cookie_test.html +++ b/chrome_frame/test/data/fulltab_delete_cookie_test.html @@ -14,26 +14,22 @@ return; } - // The path of the cookie in this test is set to "/." As a result it - // is set twice, once for the original URL and once for the - // chrome_frame_tester_helpers.js script. We attempt to delete - // the cookie twice and validate that the end result is null. + // The path of the cookie in this test is set to "/." so it should be + // available for all files on the domain but should be set only once. // First validate that the document cookie contains the substring - // CF_FullTabDeleteCookie=1; CF_FullTabDeleteCookie=1 + // "CF_FullTabDeleteCookie=1". // Then erase the first cookie and validate that it no longer contains // this string. - var cookie_found = - /CF_FullTabDeleteCookie=1; CF_FullTabDeleteCookie=1/.test( - document.cookie); + var original_cookies = document.cookie; + var cookie_found = /CF_FullTabDeleteCookie=1/.test(document.cookie); if (cookie_found) { eraseCookie("CF_FullTabDeleteCookie"); - cookie_found = - /CF_FullTabDeleteCookie=1; CF_FullTabDeleteCookie=1/.test( - document.cookie); + cookie_found = /CF_FullTabDeleteCookie=1/.test(document.cookie); if (!cookie_found) { onSuccess("FullTab_DeleteCookieTest", 1); } else { - onFailure("FullTab_DeleteCookieTest", 1, "Delete cookie failed"); + onFailure("FullTab_DeleteCookieTest", 1, + "CF_FullTabDeleteCookie still exists: " + original_cookies); } } else { onFailure("FullTab_DeleteCookieTest", 1, "Expected cookies not set"); diff --git a/chrome_frame/urlmon_url_request.cc b/chrome_frame/urlmon_url_request.cc index 5a946ce..0c16dc5 100644 --- a/chrome_frame/urlmon_url_request.cc +++ b/chrome_frame/urlmon_url_request.cc @@ -650,6 +650,8 @@ STDMETHODIMP UrlmonUrlRequest::OnResponse(DWORD dwResponseCode, const wchar_t* response_headers, const wchar_t* request_headers, wchar_t** additional_headers) { DCHECK(worker_thread_ != NULL); + DLOG(INFO) << __FUNCTION__ << " " << url() << std::endl << " headers: " << + std::endl << response_headers; DCHECK_EQ(PlatformThread::CurrentId(), worker_thread_->thread_id()); if (!binding_) { @@ -693,6 +695,9 @@ STDMETHODIMP UrlmonUrlRequest::OnResponse(DWORD dwResponseCode, std::string persistent_cookies; DWORD cookie_size = 0; // NOLINT + // Note that there's really no way for us here to distinguish session cookies + // from persistent cookies here. Session cookies should get filtered + // out on the chrome side as to not be added again. InternetGetCookie(url_for_persistent_cookies.c_str(), NULL, NULL, &cookie_size); if (cookie_size) { |