Commit 6a3eeded authored by ananta@chromium.org's avatar ananta@chromium.org

Remove handling for the ViewHostMsg_GetCookies and ViewHostMsg_SetCookies from...

Remove handling for the ViewHostMsg_GetCookies and ViewHostMsg_SetCookies from Chrome. These messages
were being handled in Chrome only for ChromeFrame processes, i.e. to route the cookie requests to the
host browser.

We now send out the ChromeViewHostMsg_GetCookies and ChromeViewHostMsg_SetCookies IPCs for ChromeFrame
processes. These are sent out by the embedder instance which lives in the renderer. ChromeRenderMessageFilter
handles these messages.

This is a continuation of the changes to not handle IPC messages from content in Chrome and vice versa.

BUG=87335
TEST=No change in functionality. chrome frame net tests and chrome frame tests should pass.
Review URL: http://codereview.chromium.org/7764014

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@98735 0039d316-1c4b-4281-b951-d872f2087c98
parent 6005d68f
...@@ -12,9 +12,9 @@ ...@@ -12,9 +12,9 @@
#include "chrome/browser/net/url_request_mock_util.h" #include "chrome/browser/net/url_request_mock_util.h"
#include "chrome/common/automation_messages.h" #include "chrome/common/automation_messages.h"
#include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_paths.h"
#include "chrome/common/render_messages.h"
#include "content/browser/browser_message_filter.h" #include "content/browser/browser_message_filter.h"
#include "content/browser/browser_thread.h" #include "content/browser/browser_thread.h"
#include "content/common/view_messages.h"
#include "googleurl/src/gurl.h" #include "googleurl/src/gurl.h"
#include "net/base/net_errors.h" #include "net/base/net_errors.h"
#include "net/url_request/url_request_context.h" #include "net/url_request/url_request_context.h"
...@@ -446,7 +446,8 @@ void AutomationResourceMessageFilter::OnGetCookiesHostResponse( ...@@ -446,7 +446,8 @@ void AutomationResourceMessageFilter::OnGetCookiesHostResponse(
return; return;
} }
ViewHostMsg_GetCookies::WriteReplyParams(index->second.reply_msg, cookies); ChromeViewHostMsg_GetCookies::WriteReplyParams(index->second.reply_msg,
cookies);
index->second.filter->Send(index->second.reply_msg); index->second.filter->Send(index->second.reply_msg);
completion_callback_map_.Get().erase(index); completion_callback_map_.Get().erase(index);
......
...@@ -143,15 +143,16 @@ bool ChromeRenderMessageFilter::OnMessageReceived(const IPC::Message& message, ...@@ -143,15 +143,16 @@ bool ChromeRenderMessageFilter::OnMessageReceived(const IPC::Message& message,
IPC_MESSAGE_UNHANDLED(handled = false) IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP() IPC_END_MESSAGE_MAP()
if ((message.type() == ViewHostMsg_GetCookies::ID || if ((message.type() == ChromeViewHostMsg_GetCookies::ID ||
message.type() == ViewHostMsg_SetCookie::ID) && message.type() == ChromeViewHostMsg_SetCookie::ID) &&
AutomationResourceMessageFilter::ShouldFilterCookieMessages( AutomationResourceMessageFilter::ShouldFilterCookieMessages(
render_process_id_, message.routing_id())) { render_process_id_, message.routing_id())) {
// ChromeFrame then we need to get/set cookies from the external host. // ChromeFrame then we need to get/set cookies from the external host.
IPC_BEGIN_MESSAGE_MAP_EX(ChromeRenderMessageFilter, message, IPC_BEGIN_MESSAGE_MAP_EX(ChromeRenderMessageFilter, message,
*message_was_ok) *message_was_ok)
IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetCookies, OnGetCookies) IPC_MESSAGE_HANDLER_DELAY_REPLY(ChromeViewHostMsg_GetCookies,
IPC_MESSAGE_HANDLER(ViewHostMsg_SetCookie, OnSetCookie) OnGetCookies)
IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SetCookie, OnSetCookie)
IPC_END_MESSAGE_MAP() IPC_END_MESSAGE_MAP()
handled = true; handled = true;
} }
......
...@@ -532,3 +532,19 @@ IPC_MESSAGE_ROUTED2(ChromeViewHostMsg_InstantSupportDetermined, ...@@ -532,3 +532,19 @@ IPC_MESSAGE_ROUTED2(ChromeViewHostMsg_InstantSupportDetermined,
// The currently displayed PDF has an unsupported feature. // The currently displayed PDF has an unsupported feature.
IPC_MESSAGE_ROUTED0(ChromeViewHostMsg_PDFHasUnsupportedFeature) IPC_MESSAGE_ROUTED0(ChromeViewHostMsg_PDFHasUnsupportedFeature)
// The following messages are used to set and get cookies for ChromeFrame
// processes.
// Used to set a cookie. The cookie is set asynchronously, but will be
// available to a subsequent ChromeViewHostMsg_GetCookies request.
IPC_MESSAGE_ROUTED3(ChromeViewHostMsg_SetCookie,
GURL /* url */,
GURL /* first_party_for_cookies */,
std::string /* cookie */)
// Used to get cookies for the given URL. This may block waiting for a
// previous SetCookie message to be processed.
IPC_SYNC_MESSAGE_ROUTED2_1(ChromeViewHostMsg_GetCookies,
GURL /* url */,
GURL /* first_party_for_cookies */,
std::string /* cookies */)
...@@ -66,6 +66,7 @@ ...@@ -66,6 +66,7 @@
#include "grit/generated_resources.h" #include "grit/generated_resources.h"
#include "grit/locale_settings.h" #include "grit/locale_settings.h"
#include "grit/renderer_resources.h" #include "grit/renderer_resources.h"
#include "ipc/ipc_sync_message.h"
#include "net/base/net_errors.h" #include "net/base/net_errors.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebCache.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebCache.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h"
...@@ -684,6 +685,35 @@ bool ChromeContentRendererClient::ShouldOverridePageVisibilityState( ...@@ -684,6 +685,35 @@ bool ChromeContentRendererClient::ShouldOverridePageVisibilityState(
return true; return true;
} }
bool ChromeContentRendererClient::HandleGetCookieRequest(
RenderView* sender,
const GURL& url,
const GURL& first_party_for_cookies,
std::string* cookies) {
if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kChromeFrame)) {
IPC::SyncMessage* msg = new ChromeViewHostMsg_GetCookies(
MSG_ROUTING_NONE, url, first_party_for_cookies, cookies);
msg->EnableMessagePumping();
sender->Send(msg);
return true;
}
return false;
}
bool ChromeContentRendererClient::HandleSetCookieRequest(
RenderView* sender,
const GURL& url,
const GURL& first_party_for_cookies,
const std::string& value) {
if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kChromeFrame)) {
sender->Send(new ChromeViewHostMsg_SetCookie(
MSG_ROUTING_NONE, url, first_party_for_cookies, value));
return true;
}
return false;
}
void ChromeContentRendererClient::SetExtensionDispatcher( void ChromeContentRendererClient::SetExtensionDispatcher(
ExtensionDispatcher* extension_dispatcher) { ExtensionDispatcher* extension_dispatcher) {
extension_dispatcher_.reset(extension_dispatcher); extension_dispatcher_.reset(extension_dispatcher);
......
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
#define CHROME_RENDERER_CHROME_CONTENT_RENDERER_CLIENT_H_ #define CHROME_RENDERER_CHROME_CONTENT_RENDERER_CLIENT_H_
#pragma once #pragma once
#include <string>
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "content/renderer/content_renderer_client.h" #include "content/renderer/content_renderer_client.h"
...@@ -73,6 +75,14 @@ class ChromeContentRendererClient : public content::ContentRendererClient { ...@@ -73,6 +75,14 @@ class ChromeContentRendererClient : public content::ContentRendererClient {
virtual bool ShouldOverridePageVisibilityState( virtual bool ShouldOverridePageVisibilityState(
const RenderView* render_view, const RenderView* render_view,
WebKit::WebPageVisibilityState* override_state) const OVERRIDE; WebKit::WebPageVisibilityState* override_state) const OVERRIDE;
virtual bool HandleGetCookieRequest(RenderView* sender,
const GURL& url,
const GURL& first_party_for_cookies,
std::string* cookies) OVERRIDE;
virtual bool HandleSetCookieRequest(RenderView* sender,
const GURL& url,
const GURL& first_party_for_cookies,
const std::string& value) OVERRIDE;
// For testing. // For testing.
void SetExtensionDispatcher(ExtensionDispatcher* extension_dispatcher); void SetExtensionDispatcher(ExtensionDispatcher* extension_dispatcher);
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <string> #include <string>
#include "base/string16.h" #include "base/string16.h"
#include "ipc/ipc_message.h"
#include "content/common/content_client.h" #include "content/common/content_client.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebPageVisibilityState.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebPageVisibilityState.h"
...@@ -109,6 +110,20 @@ class ContentRendererClient { ...@@ -109,6 +110,20 @@ class ContentRendererClient {
virtual bool ShouldOverridePageVisibilityState( virtual bool ShouldOverridePageVisibilityState(
const RenderView* render_view, const RenderView* render_view,
WebKit::WebPageVisibilityState* override_state) const = 0; WebKit::WebPageVisibilityState* override_state) const = 0;
// Return true if the GetCookie request will be handled by the embedder.
// Cookies are returned in the cookie parameter.
virtual bool HandleGetCookieRequest(RenderView* sender,
const GURL& url,
const GURL& first_party_for_cookies,
std::string* cookies) = 0;
// Return true if the SetCookie request will be handled by the embedder.
// Cookies to be set are passed in the value parameter.
virtual bool HandleSetCookieRequest(RenderView* sender,
const GURL& url,
const GURL& first_party_for_cookies,
const std::string& value) = 0;
}; };
} // namespace content } // namespace content
......
...@@ -104,4 +104,19 @@ bool MockContentRendererClient::ShouldOverridePageVisibilityState( ...@@ -104,4 +104,19 @@ bool MockContentRendererClient::ShouldOverridePageVisibilityState(
return false; return false;
} }
bool MockContentRendererClient::HandleGetCookieRequest(
RenderView* sender,
const GURL& url,
const GURL& first_party_for_cookies,
std::string* cookies) {
return false;
}
bool MockContentRendererClient::HandleSetCookieRequest(
RenderView* sender,
const GURL& url,
const GURL& first_party_for_cookies,
const std::string& value) {
return false;
}
} // namespace content } // namespace content
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
#define CONTENT_RENDERER_MOCK_CONTENT_RENDERER_CLIENT_H_ #define CONTENT_RENDERER_MOCK_CONTENT_RENDERER_CLIENT_H_
#pragma once #pragma once
#include <string>
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "content/renderer/content_renderer_client.h" #include "content/renderer/content_renderer_client.h"
...@@ -53,6 +55,14 @@ class MockContentRendererClient : public ContentRendererClient { ...@@ -53,6 +55,14 @@ class MockContentRendererClient : public ContentRendererClient {
virtual bool ShouldOverridePageVisibilityState( virtual bool ShouldOverridePageVisibilityState(
const RenderView* render_view, const RenderView* render_view,
WebKit::WebPageVisibilityState* override_state) const OVERRIDE; WebKit::WebPageVisibilityState* override_state) const OVERRIDE;
virtual bool HandleGetCookieRequest(RenderView* sender,
const GURL& url,
const GURL& first_party_for_cookies,
std::string* cookies) OVERRIDE;
virtual bool HandleSetCookieRequest(RenderView* sender,
const GURL& url,
const GURL& first_party_for_cookies,
const std::string& value) OVERRIDE;
}; };
} // namespace content } // namespace content
......
...@@ -6,7 +6,9 @@ ...@@ -6,7 +6,9 @@
#include "base/utf_string_conversions.h" #include "base/utf_string_conversions.h"
#include "content/common/view_messages.h" #include "content/common/view_messages.h"
#include "content/renderer/content_renderer_client.h"
#include "content/renderer/render_thread.h" #include "content/renderer/render_thread.h"
#include "content/renderer/render_view.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebCookie.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebCookie.h"
#include "webkit/glue/webcookie.h" #include "webkit/glue/webcookie.h"
...@@ -20,16 +22,23 @@ void RendererWebCookieJarImpl::setCookie( ...@@ -20,16 +22,23 @@ void RendererWebCookieJarImpl::setCookie(
const WebString& value) { const WebString& value) {
std::string value_utf8; std::string value_utf8;
UTF16ToUTF8(value.data(), value.length(), &value_utf8); UTF16ToUTF8(value.data(), value.length(), &value_utf8);
sender_->Send(new ViewHostMsg_SetCookie( if (!content::GetContentClient()->renderer()->HandleSetCookieRequest(
MSG_ROUTING_NONE, url, first_party_for_cookies, value_utf8)); sender_, url, first_party_for_cookies, value_utf8)) {
sender_->Send(new ViewHostMsg_SetCookie(
MSG_ROUTING_NONE, url, first_party_for_cookies, value_utf8));
}
} }
WebString RendererWebCookieJarImpl::cookies( WebString RendererWebCookieJarImpl::cookies(
const WebURL& url, const WebURL& first_party_for_cookies) { const WebURL& url, const WebURL& first_party_for_cookies) {
std::string value_utf8; std::string value_utf8;
// NOTE: This may pump events (see RenderThread::Send).
sender_->Send(new ViewHostMsg_GetCookies( if (!content::GetContentClient()->renderer()->HandleGetCookieRequest(
MSG_ROUTING_NONE, url, first_party_for_cookies, &value_utf8)); sender_, url, first_party_for_cookies, &value_utf8)) {
// NOTE: This may pump events (see RenderThread::Send).
sender_->Send(new ViewHostMsg_GetCookies(
MSG_ROUTING_NONE, url, first_party_for_cookies, &value_utf8));
}
return WebString::fromUTF8(value_utf8); return WebString::fromUTF8(value_utf8);
} }
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#define CONTENT_RENDERER_RENDERER_WEBCOOKIEJAR_IMPL_H_ #define CONTENT_RENDERER_RENDERER_WEBCOOKIEJAR_IMPL_H_
#pragma once #pragma once
#include "ipc/ipc_message.h"
// TODO(darin): WebCookieJar.h is missing a WebString.h include! // TODO(darin): WebCookieJar.h is missing a WebString.h include!
#include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebCookieJar.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebCookieJar.h"
...@@ -15,9 +14,11 @@ namespace IPC { ...@@ -15,9 +14,11 @@ namespace IPC {
class SyncMessage; class SyncMessage;
} }
class RenderView;
class RendererWebCookieJarImpl : public WebKit::WebCookieJar { class RendererWebCookieJarImpl : public WebKit::WebCookieJar {
public: public:
explicit RendererWebCookieJarImpl(IPC::Message::Sender* sender) explicit RendererWebCookieJarImpl(RenderView* sender)
: sender_(sender) { : sender_(sender) {
} }
virtual ~RendererWebCookieJarImpl() {} virtual ~RendererWebCookieJarImpl() {}
...@@ -39,7 +40,7 @@ class RendererWebCookieJarImpl : public WebKit::WebCookieJar { ...@@ -39,7 +40,7 @@ class RendererWebCookieJarImpl : public WebKit::WebCookieJar {
virtual bool cookiesEnabled( virtual bool cookiesEnabled(
const WebKit::WebURL& url, const WebKit::WebURL& first_party_for_cookies); const WebKit::WebURL& url, const WebKit::WebURL& first_party_for_cookies);
IPC::Message::Sender* sender_; RenderView* sender_;
}; };
#endif // CONTENT_RENDERER_RENDERER_WEBCOOKIEJAR_IMPL_H_ #endif // CONTENT_RENDERER_RENDERER_WEBCOOKIEJAR_IMPL_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment