summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome_frame/chrome_frame_activex_base.h73
-rw-r--r--chrome_frame/chrome_frame_automation.cc29
-rw-r--r--chrome_frame/chrome_frame_automation.h1
-rw-r--r--chrome_frame/plugin_url_request.h26
-rw-r--r--chrome_frame/test/test_mock_with_web_server.cc3
-rw-r--r--chrome_frame/urlmon_url_request.cc77
-rw-r--r--chrome_frame/urlmon_url_request.h5
7 files changed, 139 insertions, 75 deletions
diff --git a/chrome_frame/chrome_frame_activex_base.h b/chrome_frame/chrome_frame_activex_base.h
index ebb57b0..5d663c6 100644
--- a/chrome_frame/chrome_frame_activex_base.h
+++ b/chrome_frame/chrome_frame_activex_base.h
@@ -442,79 +442,6 @@ END_MSG_MAP()
return TRUE;
}
- virtual void OnSetCookieAsync(int tab_handle, const GURL& url,
- const std::string& cookie) {
- std::string name;
- std::string data;
-
- size_t name_end = cookie.find('=');
- if (std::string::npos != name_end) {
- net::CookieMonster::ParsedCookie parsed_cookie = cookie;
- name = parsed_cookie.Name();
- // 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, 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;
- }
-
- int32 flags = INTERNET_COOKIE_EVALUATE_P3P;
-
- InternetCookieState cookie_state = static_cast<InternetCookieState>(
- InternetSetCookieExA(url.spec().c_str(), name.c_str(), data.c_str(),
- flags, NULL));
-
- int32 cookie_action = MapCookieStateToCookieAction(cookie_state);
- url_fetcher_.AddPrivacyDataForUrl(url.spec(), "", cookie_action);
- }
-
- virtual void OnGetCookiesFromHost(int tab_handle, const GURL& url,
- int cookie_id) {
- DWORD cookie_size = 0;
- bool success = true;
- std::string cookie_string;
-
- int32 cookie_action = COOKIEACTION_READ;
- BOOL result = InternetGetCookieA(url.spec().c_str(), NULL, NULL,
- &cookie_size);
- DWORD error = 0;
- 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;
- error = GetLastError();
- NOTREACHED() << "InternetGetCookie failed. Error: " << error;
- } else {
- cookie_string = cookies.get();
- }
- } else {
- success = false;
- error = GetLastError();
- DLOG(INFO) << "InternetGetCookie failed. Error: " << error;
- }
-
- if (automation_client_->automation_server()) {
- automation_client_->automation_server()->Send(
- new AutomationMsg_GetCookiesHostResponse(0, tab_handle, success,
- url, cookie_string,
- cookie_id));
- }
-
- if (!success && !error)
- cookie_action = COOKIEACTION_SUPPRESS;
-
- url_fetcher_.AddPrivacyDataForUrl(url.spec(), "", cookie_action);
- }
-
virtual void OnAttachExternalTab(int tab_handle,
const IPC::AttachExternalTabParams& params) {
std::string url;
diff --git a/chrome_frame/chrome_frame_automation.cc b/chrome_frame/chrome_frame_automation.cc
index bf11755..295bb48 100644
--- a/chrome_frame/chrome_frame_automation.cc
+++ b/chrome_frame/chrome_frame_automation.cc
@@ -1012,6 +1012,28 @@ bool ChromeFrameAutomationClient::ProcessUrlRequestMessage(TabProxy* tab,
AutomationMsg_DownloadRequestInHost::Dispatch(&msg, url_fetcher_,
&PluginUrlRequestManager::DownloadUrlRequestInHost);
break;
+
+ case AutomationMsg_GetCookiesFromHost::ID: {
+ if (invoke) {
+ // If the PluginUrlRequestManager does not handle the GetCookies
+ // request then fall through to the original handling which sends
+ // the request to the delegate.
+ invoke = AutomationMsg_GetCookiesFromHost::Dispatch(&msg, url_fetcher_,
+ &PluginUrlRequestManager::GetCookiesFromHost);
+ }
+ break;
+ }
+
+ case AutomationMsg_SetCookieAsync::ID: {
+ if (invoke) {
+ // If the PluginUrlRequestManager does not handle the SetCookies
+ // request then fall through to the original handling which sends
+ // the request to the delegate.
+ invoke = AutomationMsg_SetCookieAsync::Dispatch(&msg, url_fetcher_,
+ &PluginUrlRequestManager::SetCookiesInHost);
+ }
+ break;
+ }
}
if (!invoke) {
@@ -1282,3 +1304,10 @@ void ChromeFrameAutomationClient::OnResponseEnd(int request_id,
request_id, status));
}
+bool ChromeFrameAutomationClient::SendIPCMessage(IPC::Message* msg) {
+ if (automation_server_)
+ return automation_server_->Send(msg);
+ return false;
+}
+
+
diff --git a/chrome_frame/chrome_frame_automation.h b/chrome_frame/chrome_frame_automation.h
index 1a1948e..c995883 100644
--- a/chrome_frame/chrome_frame_automation.h
+++ b/chrome_frame/chrome_frame_automation.h
@@ -359,6 +359,7 @@ class ChromeFrameAutomationClient
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);
+ virtual bool SendIPCMessage(IPC::Message* msg);
public:
void SetUrlFetcher(PluginUrlRequestManager* url_fetcher) {
diff --git a/chrome_frame/plugin_url_request.h b/chrome_frame/plugin_url_request.h
index 511dea7..9bfedb7 100644
--- a/chrome_frame/plugin_url_request.h
+++ b/chrome_frame/plugin_url_request.h
@@ -32,6 +32,9 @@ class DECLSPEC_NOVTABLE PluginUrlRequestDelegate { // NOLINT
virtual void AddPrivacyDataForUrl(const std::string& url,
const std::string& policy_ref,
int32 flags) {}
+ virtual bool SendIPCMessage(IPC::Message* message) {
+ return false;
+ }
protected:
PluginUrlRequestDelegate() {}
~PluginUrlRequestDelegate() {}
@@ -77,6 +80,16 @@ class DECLSPEC_NOVTABLE PluginUrlRequestManager { // NOLINT
StopAll();
}
+ bool GetCookiesFromHost(int tab_handle, const GURL& url,
+ int cookie_id) {
+ return GetCookiesForUrl(tab_handle, url, cookie_id);
+ }
+
+ bool SetCookiesInHost(int tab_handle, const GURL& url,
+ const std::string& cookie) {
+ return SetCookiesForUrl(tab_handle, url, cookie);
+ }
+
protected:
PluginUrlRequestDelegate* delegate_;
bool enable_frame_busting_;
@@ -88,6 +101,19 @@ class DECLSPEC_NOVTABLE PluginUrlRequestManager { // NOLINT
virtual void EndRequest(int request_id) = 0;
virtual void DownloadRequestInHost(int request_id) = 0;
virtual void StopAll() = 0;
+
+ // The default handling for these functions which get and set cookies
+ // is to return false, which basically ensures that the default handling
+ // of processing the corresponding cookie IPCs occurs in the UI thread.
+ virtual bool GetCookiesForUrl(int tab_handle, const GURL& url,
+ int cookie_id) {
+ return false;
+ }
+
+ virtual bool SetCookiesForUrl(int tab_handle, const GURL& url,
+ const std::string& cookie) {
+ return false;
+ }
};
// Used as base class. Holds Url request properties (url, method, referrer..)
diff --git a/chrome_frame/test/test_mock_with_web_server.cc b/chrome_frame/test/test_mock_with_web_server.cc
index a2bd962..cedaf87 100644
--- a/chrome_frame/test/test_mock_with_web_server.cc
+++ b/chrome_frame/test/test_mock_with_web_server.cc
@@ -805,8 +805,7 @@ const wchar_t kBeforeUnloadTest[] =
const wchar_t kBeforeUnloadMain[] =
L"http://localhost:1337/files/fulltab_before_unload_event_main.html";
-// http://code.google.com/p/chromium/issues/detail?id=37231
-TEST_F(ChromeFrameTestWithWebServer, DISABLED_FullTabModeIE_UnloadEventTest) {
+TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_UnloadEventTest) {
CloseIeAtEndOfScope last_resort_close_ie;
chrome_frame_test::TimedMsgLoop loop;
ComStackObjectWithUninitialize<MockWebBrowserEventSink> mock;
diff --git a/chrome_frame/urlmon_url_request.cc b/chrome_frame/urlmon_url_request.cc
index 3b03bf9..3b15628 100644
--- a/chrome_frame/urlmon_url_request.cc
+++ b/chrome_frame/urlmon_url_request.cc
@@ -968,6 +968,83 @@ void UrlmonUrlRequestManager::DownloadRequestInHost(int request_id) {
}
}
+bool UrlmonUrlRequestManager::GetCookiesForUrl(int tab_handle,
+ const GURL& url,
+ int cookie_id) {
+ DWORD cookie_size = 0;
+ bool success = true;
+ std::string cookie_string;
+
+ int32 cookie_action = COOKIEACTION_READ;
+ BOOL result = InternetGetCookieA(url.spec().c_str(), NULL, NULL,
+ &cookie_size);
+ DWORD error = 0;
+ 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;
+ error = GetLastError();
+ NOTREACHED() << "InternetGetCookie failed. Error: " << error;
+ } else {
+ cookie_string = cookies.get();
+ }
+ } else {
+ success = false;
+ error = GetLastError();
+ DLOG(INFO) << "InternetGetCookie failed. Error: " << error;
+ }
+
+ if (delegate_) {
+ delegate_->SendIPCMessage(
+ new AutomationMsg_GetCookiesHostResponse(0, tab_handle, success,
+ url, cookie_string,
+ cookie_id));
+ }
+
+ if (!success && !error)
+ cookie_action = COOKIEACTION_SUPPRESS;
+
+ AddPrivacyDataForUrl(url.spec(), "", cookie_action);
+ return true;
+}
+
+bool UrlmonUrlRequestManager::SetCookiesForUrl(int tab_handle,
+ const GURL& url,
+ const std::string& cookie) {
+ std::string name;
+ std::string data;
+
+ size_t name_end = cookie.find('=');
+ if (std::string::npos != name_end) {
+ net::CookieMonster::ParsedCookie parsed_cookie = cookie;
+ name = parsed_cookie.Name();
+ // 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, 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;
+ }
+
+ int32 flags = INTERNET_COOKIE_EVALUATE_P3P;
+
+ InternetCookieState cookie_state = static_cast<InternetCookieState>(
+ InternetSetCookieExA(url.spec().c_str(), name.c_str(), data.c_str(),
+ flags, NULL));
+
+ int32 cookie_action = MapCookieStateToCookieAction(cookie_state);
+ AddPrivacyDataForUrl(url.spec(), "", cookie_action);
+ return true;
+}
+
void UrlmonUrlRequestManager::EndRequestWorker(int request_id) {
DLOG(INFO) << __FUNCTION__ << " id: " << request_id;
DCHECK_EQ(worker_thread_.thread_id(), PlatformThread::CurrentId());
diff --git a/chrome_frame/urlmon_url_request.h b/chrome_frame/urlmon_url_request.h
index 1a0fc5f..52d2221 100644
--- a/chrome_frame/urlmon_url_request.h
+++ b/chrome_frame/urlmon_url_request.h
@@ -107,6 +107,11 @@ class UrlmonUrlRequestManager
virtual void DownloadRequestInHost(int request_id);
virtual void StopAll();
+ virtual bool GetCookiesForUrl(int tab_handle, const GURL& url,
+ int cookie_id);
+ virtual bool SetCookiesForUrl(int tab_handle, const GURL& url,
+ const std::string& cookie);
+
// PluginUrlRequestDelegate implementation
virtual void OnResponseStarted(int request_id, const char* mime_type,
const char* headers, int size,