summaryrefslogtreecommitdiffstats
path: root/chrome_frame
diff options
context:
space:
mode:
authorananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-02 19:13:00 +0000
committerananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-02 19:13:00 +0000
commit70daf0b18defd88e97f5f9ebcc9486c22898b66b (patch)
tree71e5c7cd9c7733ecafd589e8be81a67c67b2070a /chrome_frame
parent47b950579d39dc79127c1dc69f44c33c8ad269b0 (diff)
downloadchromium_src-70daf0b18defd88e97f5f9ebcc9486c22898b66b.zip
chromium_src-70daf0b18defd88e97f5f9ebcc9486c22898b66b.tar.gz
chromium_src-70daf0b18defd88e97f5f9ebcc9486c22898b66b.tar.bz2
ChromeFrame should honor the host browser's cookie policy. To achieve this we always read the cookies from
the host browser when the renderer requests them. This also cleans up the mess with the host network stack code parsing cookies from the host looking for persistent cookies. Fixes bug http://code.google.com/p/chromium/issues/detail?id=34151 Bug=34151 Test=Covered by existing host network stack tests and chrome frame cookie tests. Review URL: http://codereview.chromium.org/661290 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40402 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame')
-rw-r--r--chrome_frame/chrome_frame_activex_base.h37
-rw-r--r--chrome_frame/chrome_frame_automation.cc5
-rw-r--r--chrome_frame/chrome_frame_automation.h7
-rw-r--r--chrome_frame/chrome_frame_delegate.cc3
-rw-r--r--chrome_frame/chrome_frame_delegate.h3
-rw-r--r--chrome_frame/chrome_frame_npapi.cc49
-rw-r--r--chrome_frame/chrome_frame_npapi.h3
-rw-r--r--chrome_frame/npapi_url_request.cc11
-rw-r--r--chrome_frame/npapi_url_request.h3
-rw-r--r--chrome_frame/plugin_url_request.h11
-rw-r--r--chrome_frame/test/automation_client_mock.h2
-rw-r--r--chrome_frame/test/html_util_unittests.cc42
-rw-r--r--chrome_frame/test/test_mock_with_web_server.cc52
-rw-r--r--chrome_frame/test/url_request_test.cc15
-rw-r--r--chrome_frame/urlmon_url_request.cc35
-rw-r--r--chrome_frame/urlmon_url_request.h9
16 files changed, 147 insertions, 140 deletions
diff --git a/chrome_frame/chrome_frame_activex_base.h b/chrome_frame/chrome_frame_activex_base.h
index 6d27604..487a3f6 100644
--- a/chrome_frame/chrome_frame_activex_base.h
+++ b/chrome_frame/chrome_frame_activex_base.h
@@ -492,9 +492,14 @@ END_MSG_MAP()
// Verify if the cookie is being deleted. The cookie format is as below
// value[; expires=date][; domain=domain][; path=path][; secure]
// If the first semicolon appears immediately after the name= string,
- // it means that the cookie is being deleted.
- if (!parsed_cookie.Value().empty())
+ // it means that the cookie is being deleted, in which case we should
+ // pass the data as is to the InternetSetCookie function.
+ if (!parsed_cookie.Value().empty()) {
+ name.clear();
+ data = cookie;
+ } else {
data = cookie.substr(name_end + 1);
+ }
} else {
data = cookie;
}
@@ -504,6 +509,34 @@ END_MSG_MAP()
DCHECK(ret) << "InternetSetcookie failed. Error: " << GetLastError();
}
+ virtual void OnGetCookiesFromHost(int tab_handle, const GURL& url,
+ int cookie_id) {
+ DWORD cookie_size = 0;
+ bool success = true;
+ std::string cookie_string;
+ InternetGetCookieA(url.spec().c_str(), NULL, NULL, &cookie_size);
+ if (cookie_size) {
+ scoped_array<char> cookies(new char[cookie_size + 1]);
+ if (!InternetGetCookieA(url.spec().c_str(), NULL, cookies.get(),
+ &cookie_size)) {
+ success = false;
+ NOTREACHED() << "InternetGetCookie failed. Error: " << GetLastError();
+ } else {
+ cookie_string = cookies.get();
+ }
+ } else {
+ success = false;
+ DLOG(INFO) << "InternetGetCookie failed. Error: " << GetLastError();
+ }
+
+ if (automation_client_->automation_server()) {
+ automation_client_->automation_server()->Send(
+ new AutomationMsg_GetCookiesHostResponse(0, tab_handle, success,
+ url, cookie_string,
+ cookie_id));
+ }
+ }
+
virtual void OnAttachExternalTab(int tab_handle,
intptr_t cookie,
int disposition) {
diff --git a/chrome_frame/chrome_frame_automation.cc b/chrome_frame/chrome_frame_automation.cc
index 746340d..321d09d 100644
--- a/chrome_frame/chrome_frame_automation.cc
+++ b/chrome_frame/chrome_frame_automation.cc
@@ -1130,14 +1130,13 @@ void ChromeFrameAutomationClient::SetPageFontSize(
void ChromeFrameAutomationClient::OnResponseStarted(int request_id,
const char* mime_type, const char* headers, int size,
- base::Time last_modified, const std::string& peristent_cookies,
- const std::string& redirect_url, int redirect_status) {
+ base::Time last_modified, const std::string& redirect_url,
+ int redirect_status) {
const IPC::AutomationURLResponse response = {
mime_type,
headers ? headers : "",
size,
last_modified,
- peristent_cookies,
redirect_url,
redirect_status
};
diff --git a/chrome_frame/chrome_frame_automation.h b/chrome_frame/chrome_frame_automation.h
index f9e37c4..9c5b186 100644
--- a/chrome_frame/chrome_frame_automation.h
+++ b/chrome_frame/chrome_frame_automation.h
@@ -257,6 +257,10 @@ class ChromeFrameAutomationClient
void SetPageFontSize(enum AutomationPageFontSize);
+ ChromeFrameAutomationProxy* automation_server() {
+ return automation_server_;
+ }
+
protected:
// ChromeFrameAutomationProxy::LaunchDelegate implementation.
virtual void LaunchComplete(ChromeFrameAutomationProxy* proxy,
@@ -346,8 +350,7 @@ class ChromeFrameAutomationClient
// as parameter and forwards to Chrome via IPC.
virtual void OnResponseStarted(int request_id, const char* mime_type,
const char* headers, int size, base::Time last_modified,
- const std::string& peristent_cookies, const std::string& redirect_url,
- int redirect_status);
+ const std::string& redirect_url, int redirect_status);
virtual void OnReadComplete(int request_id, const void* buffer, int len);
virtual void OnResponseEnd(int request_id, const URLRequestStatus& status);
diff --git a/chrome_frame/chrome_frame_delegate.cc b/chrome_frame/chrome_frame_delegate.cc
index eb97186..f286b08 100644
--- a/chrome_frame/chrome_frame_delegate.cc
+++ b/chrome_frame/chrome_frame_delegate.cc
@@ -26,6 +26,7 @@ bool ChromeFrameDelegateImpl::IsTabMessage(const IPC::Message& message,
IPC_MESSAGE_HANDLER_GENERIC(AutomationMsg_SetCookieAsync, )
IPC_MESSAGE_HANDLER_GENERIC(AutomationMsg_AttachExternalTab, )
IPC_MESSAGE_HANDLER_GENERIC(AutomationMsg_RequestGoToHistoryEntryOffset, )
+ IPC_MESSAGE_HANDLER_GENERIC(AutomationMsg_GetCookiesFromHost, )
IPC_MESSAGE_UNHANDLED(is_tab_message = false);
IPC_END_MESSAGE_MAP()
@@ -69,5 +70,7 @@ void ChromeFrameDelegateImpl::OnMessageReceived(const IPC::Message& msg) {
IPC_MESSAGE_HANDLER(AutomationMsg_AttachExternalTab, OnAttachExternalTab)
IPC_MESSAGE_HANDLER(AutomationMsg_RequestGoToHistoryEntryOffset,
OnGoToHistoryEntryOffset)
+ IPC_MESSAGE_HANDLER(AutomationMsg_GetCookiesFromHost,
+ OnGetCookiesFromHost)
IPC_END_MESSAGE_MAP()
}
diff --git a/chrome_frame/chrome_frame_delegate.h b/chrome_frame/chrome_frame_delegate.h
index 93d4645..d577dfd 100644
--- a/chrome_frame/chrome_frame_delegate.h
+++ b/chrome_frame/chrome_frame_delegate.h
@@ -113,6 +113,9 @@ class ChromeFrameDelegateImpl : public ChromeFrameDelegate {
virtual void OnAttachExternalTab(int tab_handle, intptr_t cookie,
int disposition) {}
virtual void OnGoToHistoryEntryOffset(int tab_handle, int offset) {}
+
+ virtual void OnGetCookiesFromHost(int tab_handle, const GURL& url,
+ int cookie_id) {}
};
// This interface enables tasks to be marshalled to desired threads.
diff --git a/chrome_frame/chrome_frame_npapi.cc b/chrome_frame/chrome_frame_npapi.cc
index fe734a8c..d147a40 100644
--- a/chrome_frame/chrome_frame_npapi.cc
+++ b/chrome_frame/chrome_frame_npapi.cc
@@ -529,6 +529,55 @@ void ChromeFrameNPAPI::OnSetCookieAsync(int tab_handle, const GURL& url,
}
}
+void ChromeFrameNPAPI::OnGetCookiesFromHost(int tab_handle, const GURL& url,
+ int cookie_id) {
+ std::string cookie_string;
+ bool success = true;
+
+ if (npapi::VersionMinor() >= NPVERS_HAS_URL_AND_AUTH_INFO) {
+ char* cookies = NULL;
+ unsigned int cookie_length = 0;
+ NPError ret = npapi::GetValueForURL(instance_, NPNURLVCookie,
+ url.spec().c_str(), &cookies,
+ &cookie_length);
+ if (ret == NPERR_NO_ERROR) {
+ DLOG(INFO) << "Obtained cookies:" << cookies << " from host";
+ cookie_string.append(cookies, cookie_length);
+ npapi::MemFree(cookies);
+ } else {
+ success = false;
+ }
+ } else {
+ DLOG(INFO) << "Host does not support NPVERS_HAS_URL_AND_AUTH_INFO.";
+ if (url == GURL(document_url_)) {
+ DLOG(INFO) << "Reading document.cookie";
+ NPVariant cookies = {};
+ ExecuteScript("javascript:document.cookie", &cookies);
+ if (cookies.type == NPVariantType_String) {
+ cookie_string.append(cookies.value.stringValue.UTF8Characters,
+ cookies.value.stringValue.UTF8Length);
+ DLOG(INFO) << "Obtained cookies:" << cookie_string.c_str()
+ << " from host";
+ npapi::ReleaseVariantValue(&cookies);
+ } else {
+ success = false;
+ }
+ } else {
+ success = false;
+ }
+ }
+
+ if (!success)
+ DLOG(INFO) << "Failed to return cookies for url:" << url.spec().c_str();
+
+ if (automation_client_->automation_server()) {
+ automation_client_->automation_server()->Send(
+ new AutomationMsg_GetCookiesHostResponse(0, tab_handle, success,
+ url, cookie_string,
+ cookie_id));
+ }
+}
+
bool ChromeFrameNPAPI::HasMethod(NPObject* obj, NPIdentifier name) {
for (int i = 0; i < arraysize(plugin_methods_); ++i) {
if (name == plugin_method_identifiers_[i])
diff --git a/chrome_frame/chrome_frame_npapi.h b/chrome_frame/chrome_frame_npapi.h
index 6ba130e..cc21ff5 100644
--- a/chrome_frame/chrome_frame_npapi.h
+++ b/chrome_frame/chrome_frame_npapi.h
@@ -139,6 +139,9 @@ END_MSG_MAP()
virtual void OnSetCookieAsync(int tab_handle, const GURL& url,
const std::string& cookie);
+ virtual void OnGetCookiesFromHost(int tab_handle, const GURL& url,
+ int cookie_id);
+
// ChromeFrameDelegate overrides
virtual void OnLoadFailed(int error_code, const std::string& url);
virtual void OnAutomationServerReady();
diff --git a/chrome_frame/npapi_url_request.cc b/chrome_frame/npapi_url_request.cc
index d551901..c71659a 100644
--- a/chrome_frame/npapi_url_request.cc
+++ b/chrome_frame/npapi_url_request.cc
@@ -1,4 +1,4 @@
-// Copyright 2009, Google Inc.
+// Copyright 2010, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
@@ -134,8 +134,7 @@ NPError NPAPIUrlRequest::OnStreamCreated(const char* mime_type,
// Add support for passing persistent cookies and information about any URL
// redirects to Chrome.
delegate_->OnResponseStarted(id(), mime_type, stream->headers, stream->end,
- base::Time::FromTimeT(stream->lastmodified), std::string(),
- std::string(), 0);
+ base::Time::FromTimeT(stream->lastmodified), std::string(), 0);
return NPERR_NO_ERROR;
}
@@ -250,10 +249,10 @@ void NPAPIUrlRequestManager::StopAll() {
// Callbacks from NPAPIUrlRequest. Simply forward to the delegate.
void NPAPIUrlRequestManager::OnResponseStarted(int request_id,
const char* mime_type, const char* headers, int size,
- base::Time last_modified, const std::string& peristent_cookies,
- const std::string& redirect_url, int redirect_status) {
+ base::Time last_modified, const std::string& redirect_url,
+ int redirect_status) {
delegate_->OnResponseStarted(request_id, mime_type, headers, size,
- last_modified, peristent_cookies, redirect_url, redirect_status);
+ last_modified, redirect_url, redirect_status);
}
void NPAPIUrlRequestManager::OnReadComplete(int request_id, const void* buffer,
diff --git a/chrome_frame/npapi_url_request.h b/chrome_frame/npapi_url_request.h
index 0fec438..5b82de7 100644
--- a/chrome_frame/npapi_url_request.h
+++ b/chrome_frame/npapi_url_request.h
@@ -48,8 +48,7 @@ class NPAPIUrlRequestManager : public PluginUrlRequestManager,
// PluginUrlRequestDelegate implementation. Forwards back to delegate.
virtual void OnResponseStarted(int request_id, const char* mime_type,
- const char* headers, int size,
- base::Time last_modified, const std::string& peristent_cookies,
+ const char* headers, int size, base::Time last_modified,
const std::string& redirect_url, int redirect_status);
virtual void OnReadComplete(int request_id, const void* buffer, int len);
virtual void OnResponseEnd(int request_id, const URLRequestStatus& status);
diff --git a/chrome_frame/plugin_url_request.h b/chrome_frame/plugin_url_request.h
index efd6741..ffe0c73 100644
--- a/chrome_frame/plugin_url_request.h
+++ b/chrome_frame/plugin_url_request.h
@@ -23,18 +23,9 @@ class PluginUrlRequestManager;
class DECLSPEC_NOVTABLE PluginUrlRequestDelegate {
public:
- // Persistent cookies are read from the host browser and passed off to Chrome
- // These cookies are sent when we receive a response for every URL request
- // initiated by Chrome. Ideally we should only send cookies for the top level
- // URL and any subframes. However we don't receive information from Chrome
- // about the context for a URL, i.e. whether it is a subframe, etc.
- // Additionally cookies for a URL should be sent once for the page. This
- // is not done now as it is difficult to track URLs, specifically if they
- // are redirected, etc.
virtual void OnResponseStarted(int request_id, const char* mime_type,
const char* headers, int size, base::Time last_modified,
- const std::string& peristent_cookies, const std::string& redirect_url,
- int redirect_status) = 0;
+ const std::string& redirect_url, int redirect_status) = 0;
virtual void OnReadComplete(int request_id, const void* buffer, int len) = 0;
virtual void OnResponseEnd(int request_id, const URLRequestStatus& status) = 0;
protected:
diff --git a/chrome_frame/test/automation_client_mock.h b/chrome_frame/test/automation_client_mock.h
index da51759..b81a582 100644
--- a/chrome_frame/test/automation_client_mock.h
+++ b/chrome_frame/test/automation_client_mock.h
@@ -65,7 +65,7 @@ struct MockCFDelegate : public ChromeFrameDelegateImpl {
void ReplyStarted(int request_id, const char* headers) {
request_delegate_->OnResponseStarted(request_id, "text/html", headers,
- 0, base::Time::Now(), EmptyString(), EmptyString(), 0);
+ 0, base::Time::Now(), EmptyString(), 0);
}
void ReplyData(int request_id, const std::string* data) {
diff --git a/chrome_frame/test/html_util_unittests.cc b/chrome_frame/test/html_util_unittests.cc
index b993129..7248b80 100644
--- a/chrome_frame/test/html_util_unittests.cc
+++ b/chrome_frame/test/html_util_unittests.cc
@@ -362,45 +362,3 @@ TEST(HttpUtils, HasFrameBustingHeader) {
"X-Frame-Options: ALLOWall\r\n"));
}
-TEST(HttpCookieTest, IdentifyDuplicateCookieTest) {
- std::vector<std::string> header_cookies;
- header_cookies.push_back("BLAHHH; Path=/;");
-
- EXPECT_FALSE(URLRequestAutomationJob::IsCookiePresentInCookieHeader(
- "BLAHHH=1", header_cookies));
-
- header_cookies.clear();
-
- header_cookies.push_back("BLAHHH=1; Path=/;");
-
- EXPECT_TRUE(URLRequestAutomationJob::IsCookiePresentInCookieHeader(
- "BLAHHH=1", header_cookies));
-
- header_cookies.clear();
-
- header_cookies.push_back("BLAH=1; Path=/blah;");
-
- EXPECT_FALSE(URLRequestAutomationJob::IsCookiePresentInCookieHeader(
- "BLAH", header_cookies));
-}
-
-TEST(HttpCookieTest, SetCookiePathToRootIfNotPresentTest) {
- struct TestCase {
- std::string input;
- std::string expected;
- } test_cases[] = {
- { "", "" },
- { "Cookie=value", "Cookie=value; path=/" },
- { "Cookie=value;", "Cookie=value; path=/" },
- { "Cookie=value; ", "Cookie=value; path=/" },
- { " Cookie=value; ", "Cookie=value; path=/" },
- { "Cookie=", "Cookie=; path=/" },
- { "Cookie=foo; path=/bar", "Cookie=foo; path=/bar" },
- };
-
- for (int i = 0; i < arraysize(test_cases); ++i) {
- std::string& cookie(test_cases[i].input);
- URLRequestAutomationJob::SetCookiePathToRootIfNotPresent(&cookie);
- EXPECT_EQ(cookie, test_cases[i].expected);
- }
-}
diff --git a/chrome_frame/test/test_mock_with_web_server.cc b/chrome_frame/test/test_mock_with_web_server.cc
index d4a045e..c376638 100644
--- a/chrome_frame/test/test_mock_with_web_server.cc
+++ b/chrome_frame/test/test_mock_with_web_server.cc
@@ -345,6 +345,10 @@ TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_BackForward) {
CloseIeAtEndOfScope last_resort_close_ie;
chrome_frame_test::TimedMsgLoop loop;
ComStackObjectWithUninitialize<MockWebBrowserEventSink> mock;
+
+ EXPECT_CALL(mock, OnFileDownload(VARIANT_TRUE, _))
+ .Times(testing::AnyNumber()).WillRepeatedly(testing::Return());
+
::testing::InSequence sequence; // Everything in sequence
// When the onhttpequiv patch is enabled, we will get two
@@ -359,9 +363,6 @@ TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_BackForward) {
_, _, _, _, _))
.WillOnce(testing::Return(S_OK));
- EXPECT_CALL(mock, OnFileDownload(VARIANT_TRUE, _))
- .WillOnce(testing::Return());
-
EXPECT_CALL(mock, OnNavigateComplete2(_, _))
.WillOnce(testing::Return());
@@ -371,9 +372,6 @@ TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_BackForward) {
_, _, _, _, _))
.Times(testing::AnyNumber()).WillRepeatedly(testing::Return(S_OK));
- EXPECT_CALL(mock, OnFileDownload(VARIANT_TRUE, _))
- .Times(testing::AnyNumber()).WillOnce(testing::Return());
-
EXPECT_CALL(mock, OnNavigateComplete2(_, _))
.Times(testing::AnyNumber()).WillRepeatedly(testing::Return());
@@ -391,9 +389,6 @@ TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_BackForward) {
_, _, _, _, _))
.WillOnce(testing::Return(S_OK));
- EXPECT_CALL(mock, OnFileDownload(VARIANT_TRUE, _))
- .Times(testing::AnyNumber()).WillOnce(testing::Return());
-
EXPECT_CALL(mock, OnNavigateComplete2(_, _))
.WillOnce(testing::Return());
@@ -403,9 +398,6 @@ TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_BackForward) {
_, _, _, _, _))
.Times(testing::AnyNumber()).WillRepeatedly(testing::Return(S_OK));
- EXPECT_CALL(mock, OnFileDownload(VARIANT_TRUE, _))
- .Times(testing::AnyNumber()).WillOnce(testing::Return());
-
EXPECT_CALL(mock, OnNavigateComplete2(_, _))
.Times(testing::AnyNumber()).WillRepeatedly(testing::Return());
@@ -424,9 +416,6 @@ TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_BackForward) {
_, _, _, _, _))
.WillOnce(testing::Return(S_OK));
- EXPECT_CALL(mock, OnFileDownload(VARIANT_TRUE, _))
- .Times(testing::AnyNumber()).WillOnce(testing::Return());
-
EXPECT_CALL(mock, OnNavigateComplete2(_, _))
.WillOnce(testing::Return());
@@ -436,9 +425,6 @@ TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_BackForward) {
_, _, _, _, _))
.Times(testing::AnyNumber()).WillRepeatedly(testing::Return(S_OK));
- EXPECT_CALL(mock, OnFileDownload(VARIANT_TRUE, _))
- .Times(testing::AnyNumber()).WillOnce(testing::Return());
-
EXPECT_CALL(mock, OnNavigateComplete2(_, _))
.Times(testing::AnyNumber()).WillRepeatedly(testing::Return());
@@ -459,6 +445,15 @@ TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_BackForward) {
EXPECT_CALL(mock, OnNavigateComplete2(_, _))
.WillOnce(testing::Return());
+ EXPECT_CALL(mock,
+ OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal,
+ testing::StrCaseEq(kSubFrameUrl2)),
+ _, _, _, _, _))
+ .Times(testing::AnyNumber()).WillRepeatedly(testing::Return(S_OK));
+
+ EXPECT_CALL(mock, OnNavigateComplete2(_, _))
+ .Times(testing::AnyNumber()).WillRepeatedly(testing::Return());
+
EXPECT_CALL(mock, OnLoad(testing::StrEq(kSubFrameUrl2)))
.WillOnce(testing::IgnoreResult(testing::InvokeWithoutArgs(
CreateFunctor(ReceivePointer(mock.web_browser2_),
@@ -474,6 +469,15 @@ TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_BackForward) {
EXPECT_CALL(mock, OnNavigateComplete2(_, _))
.WillOnce(testing::Return());
+ EXPECT_CALL(mock,
+ OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal,
+ testing::StrCaseEq(kSubFrameUrl1)),
+ _, _, _, _, _))
+ .Times(testing::AnyNumber()).WillRepeatedly(testing::Return(S_OK));
+
+ EXPECT_CALL(mock, OnNavigateComplete2(_, _))
+ .Times(testing::AnyNumber()).WillRepeatedly(testing::Return());
+
EXPECT_CALL(mock, OnLoad(testing::StrEq(kSubFrameUrl1)))
.WillOnce(testing::IgnoreResult(testing::InvokeWithoutArgs(
CreateFunctor(&mock,
@@ -927,20 +931,19 @@ TEST_F(ChromeFrameTestWithWebServer, FLAKY_FullTabModeIE_ContextMenuBackForward)
chrome_frame_test::TimedMsgLoop loop;
ComStackObjectWithUninitialize<MockWebBrowserEventSink> mock;
+ EXPECT_CALL(mock, OnFileDownload(VARIANT_TRUE, _))
+ .Times(testing::AnyNumber()).WillRepeatedly(testing::Return());
+
::testing::InSequence sequence; // Everything in sequence
EXPECT_CALL(mock, OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal,
testing::StrCaseEq(kSubFrameUrl1)),
_, _, _, _, _))
.WillOnce(testing::Return(S_OK));
- EXPECT_CALL(mock, OnFileDownload(VARIANT_TRUE, _))
- .Times(testing::AnyNumber()).WillRepeatedly(testing::Return());
EXPECT_CALL(mock, OnNavigateComplete2(_, _)).WillOnce(testing::Return());
EXPECT_CALL(mock, OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal,
testing::StrCaseEq(kSubFrameUrl1)),
_, _, _, _, _))
.Times(testing::AnyNumber()).WillRepeatedly(testing::Return(S_OK));
- EXPECT_CALL(mock, OnFileDownload(VARIANT_TRUE, _))
- .Times(testing::AnyNumber()).WillRepeatedly(testing::Return());
EXPECT_CALL(mock, OnNavigateComplete2(_, _))
.Times(testing::AnyNumber()).WillRepeatedly(testing::Return());
@@ -955,15 +958,11 @@ TEST_F(ChromeFrameTestWithWebServer, FLAKY_FullTabModeIE_ContextMenuBackForward)
testing::StrCaseEq(kSubFrameUrl2)),
_, _, _, _, _))
.WillOnce(testing::Return(S_OK));
- EXPECT_CALL(mock, OnFileDownload(VARIANT_TRUE, _))
- .Times(testing::AnyNumber()).WillRepeatedly(testing::Return());
EXPECT_CALL(mock, OnNavigateComplete2(_, _)).WillOnce(testing::Return());
EXPECT_CALL(mock, OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal,
testing::StrCaseEq(kSubFrameUrl2)),
_, _, _, _, _))
.Times(testing::AnyNumber()).WillRepeatedly(testing::Return(S_OK));
- EXPECT_CALL(mock, OnFileDownload(VARIANT_TRUE, _))
- .Times(testing::AnyNumber()).WillRepeatedly(testing::Return());
EXPECT_CALL(mock, OnNavigateComplete2(_, _))
.Times(testing::AnyNumber()).WillRepeatedly(testing::Return());
@@ -1038,6 +1037,7 @@ TEST_F(ChromeFrameTestWithWebServer, FLAKY_FullTabModeIE_ContextMenuBackForward)
CreateFunctor(&mock,
&MockWebBrowserEventSink::CloseWebBrowser))));
EXPECT_CALL(mock, OnQuit()).WillOnce(QUIT_LOOP(loop));
+
HRESULT hr = mock.LaunchIEAndNavigate(kSubFrameUrl1);
ASSERT_HRESULT_SUCCEEDED(hr);
if (hr == S_FALSE)
diff --git a/chrome_frame/test/url_request_test.cc b/chrome_frame/test/url_request_test.cc
index aad95a9..03428e5 100644
--- a/chrome_frame/test/url_request_test.cc
+++ b/chrome_frame/test/url_request_test.cc
@@ -18,9 +18,8 @@ const int kChromeFrameLongNavigationTimeoutInSeconds = 10;
class MockUrlDelegate : public PluginUrlRequestDelegate {
public:
- MOCK_METHOD8(OnResponseStarted, void(int request_id, const char* mime_type,
- const char* headers, int size,
- base::Time last_modified, const std::string& peristent_cookies,
+ MOCK_METHOD7(OnResponseStarted, void(int request_id, const char* mime_type,
+ const char* headers, int size, base::Time last_modified,
const std::string& redirect_url, int redirect_status));
MOCK_METHOD3(OnReadComplete, void(int request_id, const void* buffer,
int len));
@@ -65,8 +64,7 @@ TEST(UrlmonUrlRequestTest, Simple1) {
testing::InSequence s;
EXPECT_CALL(mock, OnResponseStarted(1, testing::_, testing::_, testing::_,
- testing::_, testing::_, testing::_,
- testing::_))
+ testing::_, testing::_, testing::_))
.Times(1)
.WillOnce(testing::IgnoreResult(testing::InvokeWithoutArgs(CreateFunctor(
&request, &UrlmonUrlRequest::Read, 512))));
@@ -133,8 +131,7 @@ TEST(UrlmonUrlRequestTest, ZeroLengthResponse) {
// Expect headers
EXPECT_CALL(mock, OnResponseStarted(1, testing::_, testing::_, testing::_,
- testing::_, testing::_, testing::_,
- testing::_))
+ testing::_, testing::_, testing::_))
.Times(1)
.WillOnce(QUIT_LOOP(loop));
@@ -168,7 +165,7 @@ TEST(UrlmonUrlRequestManagerTest, Simple1) {
server.Resolve(L"files/chrome_frame_window_open.html").spec(), "get" };
EXPECT_CALL(mock, OnResponseStarted(1, testing::_, testing::_, testing::_,
- testing::_, testing::_, testing::_, testing::_))
+ testing::_, testing::_, testing::_))
.Times(1)
.WillOnce(testing::InvokeWithoutArgs(CreateFunctor(mgr.get(),
&PluginUrlRequestManager::ReadUrlRequest, 0, 1, 512)));
@@ -199,7 +196,7 @@ TEST(UrlmonUrlRequestManagerTest, Abort1) {
server.Resolve(L"files/chrome_frame_window_open.html").spec(), "get" };
EXPECT_CALL(mock, OnResponseStarted(1, testing::_, testing::_, testing::_,
- testing::_, testing::_, testing::_, testing::_))
+ testing::_, testing::_, testing::_))
.Times(1)
.WillOnce(testing::DoAll(
testing::InvokeWithoutArgs(CreateFunctor(mgr.get(),
diff --git a/chrome_frame/urlmon_url_request.cc b/chrome_frame/urlmon_url_request.cc
index 149c94b..dbb50d6 100644
--- a/chrome_frame/urlmon_url_request.cc
+++ b/chrome_frame/urlmon_url_request.cc
@@ -477,34 +477,6 @@ STDMETHODIMP UrlmonUrlRequest::OnResponse(DWORD dwResponseCode,
}
}
- std::string url_for_persistent_cookies;
- std::string persistent_cookies;
-
- if (status_.was_redirected())
- url_for_persistent_cookies = status_.get_redirection().utf8_url;
-
- if (url_for_persistent_cookies.empty())
- url_for_persistent_cookies = url();
-
- // Grab cookies for the specific Url from WININET.
- {
- DWORD cookie_size = 0; // NOLINT
- std::wstring url = UTF8ToWide(url_for_persistent_cookies);
-
- // 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.c_str(), NULL, NULL, &cookie_size);
- if (cookie_size) {
- scoped_array<wchar_t> cookies(new wchar_t[cookie_size + 1]);
- if (!InternetGetCookie(url.c_str(), NULL, cookies.get(), &cookie_size)) {
- NOTREACHED() << "InternetGetCookie failed. Error: " << GetLastError();
- } else {
- persistent_cookies = WideToUTF8(cookies.get());
- }
- }
- }
-
// Inform the delegate.
headers_received_ = true;
delegate_->OnResponseStarted(id(),
@@ -512,7 +484,6 @@ STDMETHODIMP UrlmonUrlRequest::OnResponse(DWORD dwResponseCode,
raw_headers.c_str(), // headers
0, // size
base::Time(), // last_modified
- persistent_cookies,
status_.get_redirection().utf8_url,
status_.get_redirection().http_code);
return S_OK;
@@ -991,12 +962,12 @@ void UrlmonUrlRequestManager::StopAllWorker() {
void UrlmonUrlRequestManager::OnResponseStarted(int request_id,
const char* mime_type, const char* headers, int size,
- base::Time last_modified, const std::string& peristent_cookies,
- const std::string& redirect_url, int redirect_status) {
+ base::Time last_modified, const std::string& redirect_url,
+ int redirect_status) {
DCHECK_EQ(worker_thread_.thread_id(), PlatformThread::CurrentId());
DCHECK(LookupRequest(request_id).get() != NULL);
delegate_->OnResponseStarted(request_id, mime_type, headers, size,
- last_modified, peristent_cookies, redirect_url, redirect_status);
+ last_modified, redirect_url, redirect_status);
}
void UrlmonUrlRequestManager::OnReadComplete(int request_id, const void* buffer,
diff --git a/chrome_frame/urlmon_url_request.h b/chrome_frame/urlmon_url_request.h
index ebb9f56..6fbc147 100644
--- a/chrome_frame/urlmon_url_request.h
+++ b/chrome_frame/urlmon_url_request.h
@@ -19,9 +19,9 @@
class UrlmonUrlRequest;
-class UrlmonUrlRequestManager :
- public PluginUrlRequestManager,
- public PluginUrlRequestDelegate {
+class UrlmonUrlRequestManager
+ : public PluginUrlRequestManager,
+ public PluginUrlRequestDelegate {
public:
UrlmonUrlRequestManager();
~UrlmonUrlRequestManager();
@@ -59,8 +59,7 @@ class UrlmonUrlRequestManager :
// PluginUrlRequestDelegate implementation
virtual void OnResponseStarted(int request_id, const char* mime_type,
const char* headers, int size, base::Time last_modified,
- const std::string& peristent_cookies, const std::string& redirect_url,
- int redirect_status);
+ const std::string& redirect_url, int redirect_status);
virtual void OnReadComplete(int request_id, const void* buffer, int len);
virtual void OnResponseEnd(int request_id, const URLRequestStatus& status);