summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/automation/automation_resource_message_filter.cc109
-rw-r--r--chrome/browser/automation/automation_resource_message_filter.h44
-rw-r--r--chrome/browser/renderer_host/chrome_render_message_filter.cc31
-rw-r--r--chrome/browser/renderer_host/chrome_render_message_filter.h7
-rw-r--r--content/browser/DEPS2
-rw-r--r--content/browser/content_browser_client.h4
-rw-r--r--content/browser/renderer_host/browser_render_process_host.cc5
-rw-r--r--content/browser/renderer_host/render_message_filter.cc185
-rw-r--r--content/browser/renderer_host/render_message_filter.h73
-rw-r--r--content/common/view_messages.h18
-rw-r--r--content/renderer/renderer_webcookiejar_impl.cc4
11 files changed, 184 insertions, 298 deletions
diff --git a/chrome/browser/automation/automation_resource_message_filter.cc b/chrome/browser/automation/automation_resource_message_filter.cc
index 288ca41..b8951ef 100644
--- a/chrome/browser/automation/automation_resource_message_filter.cc
+++ b/chrome/browser/automation/automation_resource_message_filter.cc
@@ -15,8 +15,10 @@
#include "chrome/browser/net/url_request_slow_http_job.h"
#include "chrome/common/automation_messages.h"
#include "chrome/common/chrome_paths.h"
+#include "content/browser/browser_message_filter.h"
#include "content/browser/browser_thread.h"
-#include "content/browser/renderer_host/render_message_filter.h"
+#include "content/browser/renderer_host/render_view_host_notification_task.h"
+#include "content/common/view_messages.h"
#include "googleurl/src/gurl.h"
#include "net/base/net_errors.h"
#include "net/url_request/url_request_filter.h"
@@ -99,7 +101,9 @@ AutomationResourceMessageFilter::AutomationDetails::AutomationDetails(
AutomationResourceMessageFilter::AutomationDetails::~AutomationDetails() {}
struct AutomationResourceMessageFilter::CookieCompletionInfo {
- net::CompletionCallback* completion_callback;
+ scoped_refptr<BrowserMessageFilter> filter;
+ int render_process_id;
+ IPC::Message* reply_msg;
scoped_refptr<net::CookieStore> cookie_store;
};
@@ -428,21 +432,25 @@ void AutomationResourceMessageFilter::OnRecordHistograms(
}
}
-bool AutomationResourceMessageFilter::GetCookiesForUrl(
- const GURL& url, net::CompletionCallback* callback) {
- GetCookiesCompletion* get_cookies_callback =
- static_cast<GetCookiesCompletion*>(callback);
+bool AutomationResourceMessageFilter::ShouldFilterCookieMessages(
+ int render_process_id, int render_view_id) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ RendererId renderer_key(render_process_id, render_view_id);
+ RenderViewMap::iterator automation_details_iter(
+ filtered_render_views_.Get().find(renderer_key));
+ return automation_details_iter != filtered_render_views_.Get().end();
+}
- RendererId renderer_key(get_cookies_callback->render_process_id(),
- get_cookies_callback->render_view_id());
+void AutomationResourceMessageFilter::GetCookiesForUrl(
+ BrowserMessageFilter* filter, int render_process_id,
+ IPC::Message* reply_msg, const GURL& url) {
- RenderViewMap::iterator automation_details_iter(
- filtered_render_views_.Get().find(renderer_key));
+ RendererId renderer_key(render_process_id, reply_msg->routing_id());
- if (automation_details_iter == filtered_render_views_.Get().end()) {
- return false;
- }
+ RenderViewMap::iterator automation_details_iter(
+ filtered_render_views_.Get().find(renderer_key));
+ DCHECK(automation_details_iter != filtered_render_views_.Get().end());
DCHECK(automation_details_iter->second.filter != NULL);
DCHECK(automation_details_iter->second.cookie_store_.get() != NULL);
@@ -450,7 +458,9 @@ bool AutomationResourceMessageFilter::GetCookiesForUrl(
DCHECK(!ContainsKey(completion_callback_map_.Get(), completion_callback_id));
CookieCompletionInfo cookie_info;
- cookie_info.completion_callback = callback;
+ cookie_info.filter = filter;
+ cookie_info.render_process_id = render_process_id;
+ cookie_info.reply_msg = reply_msg;
cookie_info.cookie_store = automation_details_iter->second.cookie_store_;
completion_callback_map_.Get()[completion_callback_id] = cookie_info;
@@ -463,7 +473,6 @@ bool AutomationResourceMessageFilter::GetCookiesForUrl(
automation_details_iter->second.tab_handle, url,
completion_callback_id));
}
- return true;
}
void AutomationResourceMessageFilter::OnGetCookiesHostResponse(
@@ -471,62 +480,42 @@ void AutomationResourceMessageFilter::OnGetCookiesHostResponse(
int cookie_id) {
CompletionCallbackMap::iterator index =
completion_callback_map_.Get().find(cookie_id);
- if (index != completion_callback_map_.Get().end()) {
- net::CompletionCallback* callback = index->second.completion_callback;
-
- scoped_refptr<net::CookieStore> cookie_store = index->second.cookie_store;
-
- DCHECK(callback != NULL);
- DCHECK(cookie_store.get() != NULL);
-
- completion_callback_map_.Get().erase(index);
-
- OnGetCookiesHostResponseInternal(tab_handle, success, url, cookies,
- callback, cookie_store.get());
- } else {
+ if (index == completion_callback_map_.Get().end()) {
NOTREACHED() << "Received invalid completion callback id:"
<< cookie_id;
+ return;
}
-}
-
-void AutomationResourceMessageFilter::OnGetCookiesHostResponseInternal(
- int tab_handle, bool success, const GURL& url, const std::string& cookies,
- net::CompletionCallback* callback, net::CookieStore* cookie_store) {
- DCHECK(callback);
- DCHECK(cookie_store);
- GetCookiesCompletion* get_cookies_callback =
- static_cast<GetCookiesCompletion*>(callback);
-
- get_cookies_callback->set_cookie_store(cookie_store);
-
- // Set the cookie in the cookie store so that the callback can read it.
+ scoped_refptr<net::CookieStore> cookie_store = index->second.cookie_store;
+ DCHECK(cookie_store.get() != NULL);
cookie_store->SetCookieWithOptions(url, cookies, net::CookieOptions());
- Tuple1<int> params;
- params.a = success ? net::OK : net::ERR_ACCESS_DENIED;
- callback->RunWithParams(params);
+ int render_view_id = index->second.reply_msg->routing_id();
+ ViewHostMsg_GetCookies::WriteReplyParams(index->second.reply_msg, cookies);
+ index->second.filter->Send(index->second.reply_msg);
+ net::CookieMonster* cookie_monster = cookie_store->GetCookieMonster();
+ net::CookieList cookie_list = cookie_monster->GetAllCookiesForURLWithOptions(
+ url, net::CookieOptions());
+ CallRenderViewHostContentSettingsDelegate(
+ index->second.render_process_id, render_view_id,
+ &RenderViewHostDelegate::ContentSettings::OnCookiesRead,
+ url, cookie_list, !success);
+
// The cookie for this URL is only valid until it is read by the callback.
cookie_store->SetCookieWithOptions(url, "", net::CookieOptions());
+ completion_callback_map_.Get().erase(index);
}
-bool AutomationResourceMessageFilter::SetCookiesForUrl(
- const GURL& url, const std::string& cookie_line,
- net::CompletionCallback* callback) {
- SetCookieCompletion* set_cookies_callback =
- static_cast<SetCookieCompletion*>(callback);
-
+void AutomationResourceMessageFilter::SetCookiesForUrl(
+ int render_process_id,
+ int render_view_id,
+ const GURL& url,
+ const std::string& cookie_line) {
RenderViewMap::iterator automation_details_iter(
- filtered_render_views_.Get().find(RendererId(
- set_cookies_callback->render_process_id(),
- set_cookies_callback->render_view_id())));
-
- if (automation_details_iter == filtered_render_views_.Get().end()) {
- return false;
- }
-
- delete callback;
+ filtered_render_views_.Get().find(RendererId(
+ render_process_id, render_view_id)));
+ DCHECK(automation_details_iter != filtered_render_views_.Get().end());
DCHECK(automation_details_iter->second.filter != NULL);
if (automation_details_iter->second.filter) {
@@ -534,8 +523,6 @@ bool AutomationResourceMessageFilter::SetCookiesForUrl(
new AutomationMsg_SetCookieAsync(
automation_details_iter->second.tab_handle, url, cookie_line));
}
-
- return true;
}
// static
diff --git a/chrome/browser/automation/automation_resource_message_filter.h b/chrome/browser/automation/automation_resource_message_filter.h
index 1d72862..90c13cb 100644
--- a/chrome/browser/automation/automation_resource_message_filter.h
+++ b/chrome/browser/automation/automation_resource_message_filter.h
@@ -14,8 +14,9 @@
#include "net/base/completion_callback.h"
#include "net/base/cookie_store.h"
-class URLRequestAutomationJob;
class GURL;
+class BrowserMessageFilter;
+class URLRequestAutomationJob;
namespace net {
class CookieStore;
@@ -87,16 +88,20 @@ class AutomationResourceMessageFilter
// The pending_view parameter should be true if network requests initiated by
// this render view need to be paused waiting for an acknowledgement from
// the external host.
- static bool RegisterRenderView(int renderer_pid, int renderer_id,
- int tab_handle, AutomationResourceMessageFilter* filter,
- bool pending_view);
+ static bool RegisterRenderView(int renderer_pid,
+ int renderer_id,
+ int tab_handle,
+ AutomationResourceMessageFilter* filter,
+ bool pending_view);
static void UnRegisterRenderView(int renderer_pid, int renderer_id);
// Can be called from the UI thread.
// Resumes pending render views, i.e. network requests issued by this view
// can now be serviced.
- static bool ResumePendingRenderView(int renderer_pid, int renderer_id,
- int tab_handle, AutomationResourceMessageFilter* filter);
+ static bool ResumePendingRenderView(int renderer_pid,
+ int renderer_id,
+ int tab_handle,
+ AutomationResourceMessageFilter* filter);
// Called only on the IO thread.
static bool LookupRegisteredRenderView(
@@ -106,15 +111,23 @@ class AutomationResourceMessageFilter
bool SendDownloadRequestToHost(int routing_id, int tab_handle,
int request_id);
+ // If this returns true, then the get and set cookie IPCs should be sent to
+ // the following two functions.
+ static bool ShouldFilterCookieMessages(int render_process_id,
+ int render_view_id);
+
// Retrieves cookies for the url passed in from the external host. The
// callback passed in is notified on success or failure asynchronously.
- // Returns true on success.
- static bool GetCookiesForUrl(const GURL& url,
- net::CompletionCallback* callback);
+ static void GetCookiesForUrl(BrowserMessageFilter* filter,
+ int render_process_id,
+ IPC::Message* reply_msg,
+ const GURL& url);
- // Sets cookies on the URL in the external host. Returns true on success.
- static bool SetCookiesForUrl(const GURL& url, const std::string& cookie_line,
- net::CompletionCallback* callback);
+ // Sets cookies on the URL in the external host.
+ static void SetCookiesForUrl(int render_process_id,
+ int render_view_id,
+ const GURL& url,
+ const std::string& cookie_line);
// This function gets invoked when we receive a response from the external
// host for the cookie request sent in GetCookiesForUrl above. It sets the
@@ -139,13 +152,6 @@ class AutomationResourceMessageFilter
int renderer_pid, int renderer_id, int tab_handle,
AutomationResourceMessageFilter* filter);
- // Helper function to execute the GetCookies completion callback with the
- // response for the GetCookies request from the renderer.
- static void OnGetCookiesHostResponseInternal(
- int tab_handle, bool success, const GURL& url,
- const std::string& cookies, net::CompletionCallback* callback,
- net::CookieStore* cookie_store);
-
private:
void OnSetFilteredInet(bool enable);
void OnGetFilteredInetHitCount(int* hit_count);
diff --git a/chrome/browser/renderer_host/chrome_render_message_filter.cc b/chrome/browser/renderer_host/chrome_render_message_filter.cc
index 7f12e45..9f55701 100644
--- a/chrome/browser/renderer_host/chrome_render_message_filter.cc
+++ b/chrome/browser/renderer_host/chrome_render_message_filter.cc
@@ -6,6 +6,7 @@
#include "base/file_path.h"
#include "base/metrics/histogram.h"
+#include "chrome/browser/automation/automation_resource_message_filter.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/content_settings/host_content_settings_map.h"
#include "chrome/browser/content_settings/tab_specific_content_settings.h"
@@ -26,6 +27,7 @@
#include "content/browser/renderer_host/render_process_host.h"
#include "content/browser/renderer_host/resource_dispatcher_host.h"
#include "content/common/url_constants.h"
+#include "content/common/view_messages.h"
#include "googleurl/src/gurl.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h"
@@ -88,6 +90,19 @@ bool ChromeRenderMessageFilter::OnMessageReceived(const IPC::Message& message,
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
+ if ((message.type() == ViewHostMsg_GetCookies::ID ||
+ message.type() == ViewHostMsg_SetCookie::ID) &&
+ AutomationResourceMessageFilter::ShouldFilterCookieMessages(
+ render_process_id_, message.routing_id())) {
+ // ChromeFrame then we need to get/set cookies from the external host.
+ IPC_BEGIN_MESSAGE_MAP_EX(ChromeRenderMessageFilter, message,
+ *message_was_ok)
+ IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetCookies, OnGetCookies)
+ IPC_MESSAGE_HANDLER(ViewHostMsg_SetCookie, OnSetCookie)
+ IPC_END_MESSAGE_MAP()
+ handled = true;
+ }
+
return handled;
}
@@ -384,3 +399,19 @@ void ChromeRenderMessageFilter::OnCanTriggerClipboardWrite(const GURL& url,
context->extension_info_map()->CheckURLAccessToExtensionPermission(
url, Extension::kClipboardWritePermission);
}
+
+void ChromeRenderMessageFilter::OnGetCookies(
+ const GURL& url,
+ const GURL& first_party_for_cookies,
+ IPC::Message* reply_msg) {
+ AutomationResourceMessageFilter::GetCookiesForUrl(
+ this, render_process_id_, reply_msg, url);
+}
+
+void ChromeRenderMessageFilter::OnSetCookie(const IPC::Message& message,
+ const GURL& url,
+ const GURL& first_party_for_cookies,
+ const std::string& cookie) {
+ AutomationResourceMessageFilter::SetCookiesForUrl(
+ render_process_id_, message.routing_id(), url, cookie);
+}
diff --git a/chrome/browser/renderer_host/chrome_render_message_filter.h b/chrome/browser/renderer_host/chrome_render_message_filter.h
index bafb82f..5ff7bb1 100644
--- a/chrome/browser/renderer_host/chrome_render_message_filter.h
+++ b/chrome/browser/renderer_host/chrome_render_message_filter.h
@@ -99,6 +99,13 @@ class ChromeRenderMessageFilter : public BrowserMessageFilter {
bool* allowed);
void OnCanTriggerClipboardRead(const GURL& url, bool* allowed);
void OnCanTriggerClipboardWrite(const GURL& url, bool* allowed);
+ void OnGetCookies(const GURL& url,
+ const GURL& first_party_for_cookies,
+ IPC::Message* reply_msg);
+ void OnSetCookie(const IPC::Message& message,
+ const GURL& url,
+ const GURL& first_party_for_cookies,
+ const std::string& cookie);
int render_process_id_;
diff --git a/content/browser/DEPS b/content/browser/DEPS
index 22c8153..8515ee5 100644
--- a/content/browser/DEPS
+++ b/content/browser/DEPS
@@ -6,8 +6,6 @@ include_rules = [
"+chrome/browser/accessibility/browser_accessibility_state.h",
- "+chrome/browser/automation/automation_resource_message_filter.h",
-
"+chrome/browser/browser_about_handler.h",
"+chrome/browser/browser_process.h",
diff --git a/content/browser/content_browser_client.h b/content/browser/content_browser_client.h
index c41027e..2de7751 100644
--- a/content/browser/content_browser_client.h
+++ b/content/browser/content_browser_client.h
@@ -39,7 +39,9 @@ class ContentBrowserClient {
Profile* profile,
const GURL& url);
- // Notifies that a BrowserRenderProcessHost has been created.
+ // Notifies that a BrowserRenderProcessHost has been created. This is called
+ // before the content layer adds its own BrowserMessageFilters, so that the
+ // embedder's IPC filters have priority.
virtual void BrowserRenderProcessHostCreated(BrowserRenderProcessHost* host);
// Notifies that a WorkerProcessHost has been created.
diff --git a/content/browser/renderer_host/browser_render_process_host.cc b/content/browser/renderer_host/browser_render_process_host.cc
index 7222b09..5874e57 100644
--- a/content/browser/renderer_host/browser_render_process_host.cc
+++ b/content/browser/renderer_host/browser_render_process_host.cc
@@ -280,10 +280,11 @@ bool BrowserRenderProcessHost::Init(
// be doing.
channel_->set_sync_messages_with_no_timeout_allowed(false);
- CreateMessageFilters();
-
+ // Call the embedder first so that their IPC filters have priority.
content::GetContentClient()->browser()->BrowserRenderProcessHostCreated(this);
+ CreateMessageFilters();
+
if (run_renderer_in_process()) {
// Crank up a thread and run the initialization there. With the way that
// messages flow between the browser and renderer, this thread is required
diff --git a/content/browser/renderer_host/render_message_filter.cc b/content/browser/renderer_host/render_message_filter.cc
index 0f88b99..4444a6b 100644
--- a/content/browser/renderer_host/render_message_filter.cc
+++ b/content/browser/renderer_host/render_message_filter.cc
@@ -12,7 +12,6 @@
#include "base/threading/thread.h"
#include "base/threading/worker_pool.h"
#include "base/utf_string_conversions.h"
-#include "chrome/browser/automation/automation_resource_message_filter.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/content_settings/host_content_settings_map.h"
#include "chrome/browser/download/download_types.h"
@@ -345,7 +344,7 @@ bool RenderMessageFilter::OnMessageReceived(const IPC::Message& message,
OnMsgCreateFullscreenWidget)
IPC_MESSAGE_HANDLER(ViewHostMsg_SetCookie, OnSetCookie)
IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetCookies, OnGetCookies)
- IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_GetRawCookies, OnGetRawCookies)
+ IPC_MESSAGE_HANDLER(ViewHostMsg_GetRawCookies, OnGetRawCookies)
IPC_MESSAGE_HANDLER(ViewHostMsg_DeleteCookie, OnDeleteCookie)
IPC_MESSAGE_HANDLER(ViewHostMsg_CookiesEnabled, OnCookiesEnabled)
#if defined(OS_MACOSX)
@@ -457,49 +456,59 @@ void RenderMessageFilter::OnSetCookie(const IPC::Message& message,
const std::string& cookie) {
net::URLRequestContext* context = GetRequestContextForURL(url);
- SetCookieCompletion* callback = new SetCookieCompletion(
- render_process_id_, message.routing_id(), url, cookie, context);
-
- // If this render view is associated with an automation channel, aka
- // ChromeFrame then we need to set cookies in the external host.
- if (!AutomationResourceMessageFilter::SetCookiesForUrl(url,
- cookie,
- callback)) {
- int policy = net::OK;
- if (context->cookie_policy()) {
- policy = context->cookie_policy()->CanSetCookie(
- url, first_party_for_cookies, cookie);
- }
- callback->Run(policy);
+ int policy = net::OK;
+ if (context->cookie_policy()) {
+ policy = context->cookie_policy()->CanSetCookie(
+ url, first_party_for_cookies, cookie);
}
+
+ bool blocked_by_policy = true;
+ net::CookieOptions options;
+ if (policy == net::OK || policy == net::OK_FOR_SESSION_ONLY) {
+ blocked_by_policy = false;
+ if (policy == net::OK_FOR_SESSION_ONLY)
+ options.set_force_session();
+ context->cookie_store()->SetCookieWithOptions(url, cookie, options);
+ }
+ CallRenderViewHostContentSettingsDelegate(
+ render_process_id_, message.routing_id(),
+ &RenderViewHostDelegate::ContentSettings::OnCookieChanged,
+ url, cookie, options, blocked_by_policy);
}
+// We use DELAY_REPLY even though we have the result here because we want the
+// message's routing_id, and there's no (current) way to get it.
void RenderMessageFilter::OnGetCookies(const GURL& url,
const GURL& first_party_for_cookies,
IPC::Message* reply_msg) {
net::URLRequestContext* context = GetRequestContextForURL(url);
- GetCookiesCompletion* callback = new GetCookiesCompletion(
- render_process_id_, reply_msg->routing_id(), url, reply_msg, this,
- context, false);
-
- // If this render view is associated with an automation channel, aka
- // ChromeFrame then we need to retrieve cookies from the external host.
- if (!AutomationResourceMessageFilter::GetCookiesForUrl(url, callback)) {
- int policy = net::OK;
- if (context->cookie_policy()) {
- policy = context->cookie_policy()->CanGetCookies(
- url, first_party_for_cookies);
- }
- callback->Run(policy);
+ int policy = net::OK;
+ if (context->cookie_policy()) {
+ policy = context->cookie_policy()->CanGetCookies(
+ url, first_party_for_cookies);
}
+ std::string cookies;
+ if (policy == net::OK)
+ cookies = context->cookie_store()->GetCookies(url);
+ net::CookieMonster* cookie_monster =
+ context->cookie_store()->GetCookieMonster();
+ net::CookieList cookie_list = cookie_monster->GetAllCookiesForURLWithOptions(
+ url, net::CookieOptions());
+ CallRenderViewHostContentSettingsDelegate(
+ render_process_id_, reply_msg->routing_id(),
+ &RenderViewHostDelegate::ContentSettings::OnCookiesRead,
+ url, cookie_list, policy != net::OK);
+
+ ViewHostMsg_GetCookies::WriteReplyParams(reply_msg, cookies);
+ Send(reply_msg);
}
void RenderMessageFilter::OnGetRawCookies(
const GURL& url,
const GURL& first_party_for_cookies,
- IPC::Message* reply_msg) {
-
+ std::vector<webkit_glue::WebCookie>* cookies) {
+ cookies->clear();
net::URLRequestContext* context = GetRequestContextForURL(url);
// Only return raw cookies to trusted renderers or if this request is
@@ -508,17 +517,9 @@ void RenderMessageFilter::OnGetRawCookies(
// hosts.
if (!ChildProcessSecurityPolicy::GetInstance()->CanReadRawCookies(
render_process_id_)) {
- ViewHostMsg_GetRawCookies::WriteReplyParams(
- reply_msg,
- std::vector<webkit_glue::WebCookie>());
- Send(reply_msg);
return;
}
- GetCookiesCompletion* callback = new GetCookiesCompletion(
- render_process_id_, reply_msg->routing_id(), url, reply_msg, this,
- context, true);
-
// We check policy here to avoid sending back cookies that would not normally
// be applied to outbound requests for the given URL. Since this cookie info
// is visible in the developer tools, it is helpful to make it match reality.
@@ -527,7 +528,17 @@ void RenderMessageFilter::OnGetRawCookies(
policy = context->cookie_policy()->CanGetCookies(
url, first_party_for_cookies);
}
- callback->Run(policy);
+
+ // Ignore the policy result. We only waited on the policy result so that
+ // any pending 'set-cookie' requests could be flushed. The intent of
+ // querying the raw cookies is to reveal the contents of the cookie DB, so
+ // it important that we don't read the cookie db ahead of pending writes.
+ net::CookieMonster* cookie_monster =
+ context->cookie_store()->GetCookieMonster();
+ net::CookieList cookie_list = cookie_monster->GetAllCookiesForURL(url);
+
+ for (size_t i = 0; i < cookie_list.size(); ++i)
+ cookies->push_back(webkit_glue::WebCookie(cookie_list[i]));
}
void RenderMessageFilter::OnDeleteCookie(const GURL& url,
@@ -981,97 +992,3 @@ void RenderMessageFilter::AsyncOpenFileOnFileThread(const FilePath& path,
BrowserThread::IO, FROM_HERE, NewRunnableMethod(
this, &RenderMessageFilter::Send, reply));
}
-
-SetCookieCompletion::SetCookieCompletion(int render_process_id,
- int render_view_id,
- const GURL& url,
- const std::string& cookie_line,
- net::URLRequestContext* context)
- : render_process_id_(render_process_id),
- render_view_id_(render_view_id),
- url_(url),
- cookie_line_(cookie_line),
- context_(context) {
-}
-
-SetCookieCompletion::~SetCookieCompletion() {}
-
-void SetCookieCompletion::RunWithParams(const Tuple1<int>& params) {
- int result = params.a;
- bool blocked_by_policy = true;
- net::CookieOptions options;
- if (result == net::OK ||
- result == net::OK_FOR_SESSION_ONLY) {
- blocked_by_policy = false;
- if (result == net::OK_FOR_SESSION_ONLY)
- options.set_force_session();
- context_->cookie_store()->SetCookieWithOptions(url_, cookie_line_,
- options);
- }
- CallRenderViewHostContentSettingsDelegate(
- render_process_id_, render_view_id_,
- &RenderViewHostDelegate::ContentSettings::OnCookieChanged,
- url_, cookie_line_, options, blocked_by_policy);
- delete this;
-}
-
-GetCookiesCompletion::GetCookiesCompletion(int render_process_id,
- int render_view_id,
- const GURL& url,
- IPC::Message* reply_msg,
- RenderMessageFilter* filter,
- net::URLRequestContext* context,
- bool raw_cookies)
- : url_(url),
- reply_msg_(reply_msg),
- filter_(filter),
- context_(context),
- render_process_id_(render_process_id),
- render_view_id_(render_view_id),
- raw_cookies_(raw_cookies) {
- set_cookie_store(context_->cookie_store());
-}
-
-GetCookiesCompletion::~GetCookiesCompletion() {}
-
-void GetCookiesCompletion::RunWithParams(const Tuple1<int>& params) {
- if (!raw_cookies_) {
- int result = params.a;
- std::string cookies;
- if (result == net::OK)
- cookies = cookie_store()->GetCookies(url_);
- ViewHostMsg_GetCookies::WriteReplyParams(reply_msg_, cookies);
- filter_->Send(reply_msg_);
- net::CookieMonster* cookie_monster =
- context_->cookie_store()->GetCookieMonster();
- net::CookieList cookie_list =
- cookie_monster->GetAllCookiesForURLWithOptions(
- url_, net::CookieOptions());
- CallRenderViewHostContentSettingsDelegate(
- render_process_id_, render_view_id_,
- &RenderViewHostDelegate::ContentSettings::OnCookiesRead,
- url_, cookie_list, result != net::OK);
- delete this;
- } else {
- // Ignore the policy result. We only waited on the policy result so that
- // any pending 'set-cookie' requests could be flushed. The intent of
- // querying the raw cookies is to reveal the contents of the cookie DB, so
- // it important that we don't read the cookie db ahead of pending writes.
- net::CookieMonster* cookie_monster =
- context_->cookie_store()->GetCookieMonster();
- net::CookieList cookie_list = cookie_monster->GetAllCookiesForURL(url_);
-
- std::vector<webkit_glue::WebCookie> cookies;
- for (size_t i = 0; i < cookie_list.size(); ++i) {
- cookies.push_back(webkit_glue::WebCookie(cookie_list[i]));
- }
-
- ViewHostMsg_GetRawCookies::WriteReplyParams(reply_msg_, cookies);
- filter_->Send(reply_msg_);
- delete this;
- }
-}
-
-void GetCookiesCompletion::set_cookie_store(CookieStore* cookie_store) {
- cookie_store_ = cookie_store;
-}
diff --git a/content/browser/renderer_host/render_message_filter.h b/content/browser/renderer_host/render_message_filter.h
index 420d9a8..efd471c 100644
--- a/content/browser/renderer_host/render_message_filter.h
+++ b/content/browser/renderer_host/render_message_filter.h
@@ -54,7 +54,6 @@ class Rect;
}
namespace net {
-class CookieStore;
class URLRequestContextGetter;
}
@@ -64,6 +63,10 @@ struct WebPluginInfo;
}
}
+namespace webkit_glue {
+struct WebCookie;
+}
+
// This class filters out incoming IPC messages for the renderer process on the
// IPC thread.
class RenderMessageFilter : public BrowserMessageFilter {
@@ -115,7 +118,7 @@ class RenderMessageFilter : public BrowserMessageFilter {
IPC::Message* reply_msg);
void OnGetRawCookies(const GURL& url,
const GURL& first_party_for_cookies,
- IPC::Message* reply_msg);
+ std::vector<webkit_glue::WebCookie>* cookies);
void OnDeleteCookie(const GURL& url,
const std::string& cookieName);
void OnCookiesEnabled(const GURL& url,
@@ -273,70 +276,4 @@ class RenderMessageFilter : public BrowserMessageFilter {
DISALLOW_COPY_AND_ASSIGN(RenderMessageFilter);
};
-// These classes implement completion callbacks for getting and setting
-// cookies.
-class SetCookieCompletion : public net::CompletionCallback {
- public:
- SetCookieCompletion(int render_process_id,
- int render_view_id,
- const GURL& url,
- const std::string& cookie_line,
- net::URLRequestContext* context);
- virtual ~SetCookieCompletion();
-
- virtual void RunWithParams(const Tuple1<int>& params);
-
- int render_process_id() const {
- return render_process_id_;
- }
-
- int render_view_id() const {
- return render_view_id_;
- }
-
- private:
- int render_process_id_;
- int render_view_id_;
- GURL url_;
- std::string cookie_line_;
- scoped_refptr<net::URLRequestContext> context_;
-};
-
-class GetCookiesCompletion : public net::CompletionCallback {
- public:
- GetCookiesCompletion(int render_process_id,
- int render_view_id,
- const GURL& url, IPC::Message* reply_msg,
- RenderMessageFilter* filter,
- net::URLRequestContext* context,
- bool raw_cookies);
- virtual ~GetCookiesCompletion();
-
- virtual void RunWithParams(const Tuple1<int>& params);
-
- int render_process_id() const {
- return render_process_id_;
- }
-
- int render_view_id() const {
- return render_view_id_;
- }
-
- void set_cookie_store(net::CookieStore* cookie_store);
-
- net::CookieStore* cookie_store() {
- return cookie_store_.get();
- }
-
- private:
- GURL url_;
- IPC::Message* reply_msg_;
- scoped_refptr<RenderMessageFilter> filter_;
- scoped_refptr<net::URLRequestContext> context_;
- int render_process_id_;
- int render_view_id_;
- bool raw_cookies_;
- scoped_refptr<net::CookieStore> cookie_store_;
-};
-
#endif // CONTENT_BROWSER_RENDERER_HOST_RENDER_MESSAGE_FILTER_H_
diff --git a/content/common/view_messages.h b/content/common/view_messages.h
index ba5780c..9ed984c 100644
--- a/content/common/view_messages.h
+++ b/content/common/view_messages.h
@@ -1459,11 +1459,11 @@ IPC_SYNC_MESSAGE_ROUTED2_1(ViewHostMsg_GetCookies,
// Used to get raw cookie information for the given URL. This may block
// waiting for a previous SetCookie message to be processed.
-IPC_SYNC_MESSAGE_ROUTED2_1(ViewHostMsg_GetRawCookies,
- GURL /* url */,
- GURL /* first_party_for_cookies */,
- std::vector<webkit_glue::WebCookie>
- /* raw_cookies */)
+IPC_SYNC_MESSAGE_CONTROL2_1(ViewHostMsg_GetRawCookies,
+ GURL /* url */,
+ GURL /* first_party_for_cookies */,
+ std::vector<webkit_glue::WebCookie>
+ /* raw_cookies */)
// Used to delete cookie for the given URL and name
IPC_SYNC_MESSAGE_CONTROL2_0(ViewHostMsg_DeleteCookie,
@@ -1472,10 +1472,10 @@ IPC_SYNC_MESSAGE_CONTROL2_0(ViewHostMsg_DeleteCookie,
// Used to check if cookies are enabled for the given URL. This may block
// waiting for a previous SetCookie message to be processed.
-IPC_SYNC_MESSAGE_ROUTED2_1(ViewHostMsg_CookiesEnabled,
- GURL /* url */,
- GURL /* first_party_for_cookies */,
- bool /* cookies_enabled */)
+IPC_SYNC_MESSAGE_CONTROL2_1(ViewHostMsg_CookiesEnabled,
+ GURL /* url */,
+ GURL /* first_party_for_cookies */,
+ bool /* cookies_enabled */)
// Used to get the list of plugins
IPC_SYNC_MESSAGE_CONTROL1_1(ViewHostMsg_GetPlugins,
diff --git a/content/renderer/renderer_webcookiejar_impl.cc b/content/renderer/renderer_webcookiejar_impl.cc
index 1fd573b..75f1e30 100644
--- a/content/renderer/renderer_webcookiejar_impl.cc
+++ b/content/renderer/renderer_webcookiejar_impl.cc
@@ -44,7 +44,7 @@ void RendererWebCookieJarImpl::rawCookies(
std::vector<webkit_glue::WebCookie> cookies;
// NOTE: This may pump events (see RenderThread::Send).
sender_->Send(new ViewHostMsg_GetRawCookies(
- MSG_ROUTING_NONE, url, first_party_for_cookies, &cookies));
+ url, first_party_for_cookies, &cookies));
WebVector<WebCookie> result(cookies.size());
int i = 0;
@@ -74,6 +74,6 @@ bool RendererWebCookieJarImpl::cookiesEnabled(
bool cookies_enabled;
// NOTE: This may pump events (see RenderThread::Send).
sender_->Send(new ViewHostMsg_CookiesEnabled(
- MSG_ROUTING_NONE, url, first_party_for_cookies, &cookies_enabled));
+ url, first_party_for_cookies, &cookies_enabled));
return cookies_enabled;
}