summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authordarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-11 16:41:57 +0000
committerdarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-11 16:41:57 +0000
commit3c231c59e0a76b0325bcb7285fffeb8c59ad169c (patch)
treeb1d5de3733aa549a5abf6080d0e4b1faa17f3889 /chrome
parent1bc5ec5d6fca5de3d3604e21b4717a210221f305 (diff)
downloadchromium_src-3c231c59e0a76b0325bcb7285fffeb8c59ad169c.zip
chromium_src-3c231c59e0a76b0325bcb7285fffeb8c59ad169c.tar.gz
chromium_src-3c231c59e0a76b0325bcb7285fffeb8c59ad169c.tar.bz2
Change ViewHostMsg_SetCookie to be routed so we can show the blocked cookie
notification. We get the RenderView identifier by looking at the current WebFrame. R=jorlow BUG=34573 TEST=none Review URL: http://codereview.chromium.org/596050 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38777 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/renderer_host/resource_message_filter.cc26
-rw-r--r--chrome/browser/renderer_host/resource_message_filter.h3
-rw-r--r--chrome/common/render_messages_internal.h8
-rw-r--r--chrome/renderer/renderer_webkitclient_impl.cc19
4 files changed, 42 insertions, 14 deletions
diff --git a/chrome/browser/renderer_host/resource_message_filter.cc b/chrome/browser/renderer_host/resource_message_filter.cc
index 6f427c3..f35859e 100644
--- a/chrome/browser/renderer_host/resource_message_filter.cc
+++ b/chrome/browser/renderer_host/resource_message_filter.cc
@@ -35,6 +35,7 @@
#include "chrome/browser/renderer_host/browser_render_process_host.h"
#include "chrome/browser/renderer_host/database_dispatcher_host.h"
#include "chrome/browser/renderer_host/render_widget_helper.h"
+#include "chrome/browser/renderer_host/render_view_host_notification_task.h"
#include "chrome/browser/spellchecker_platform_engine.h"
#include "chrome/browser/task_manager.h"
#include "chrome/browser/worker_host/message_port_dispatcher.h"
@@ -150,26 +151,39 @@ Blacklist::Match* GetPrivacyBlacklistMatchForURL(
class SetCookieCompletion : public net::CompletionCallback {
public:
- SetCookieCompletion(const GURL& url, const std::string& cookie_line,
+ SetCookieCompletion(int render_process_id,
+ int render_view_id,
+ const GURL& url,
+ const std::string& cookie_line,
URLRequestContext* context)
- : url_(url),
+ : render_process_id_(render_process_id),
+ render_view_id_(render_view_id),
+ url_(url),
cookie_line_(cookie_line),
context_(context) {
}
virtual void RunWithParams(const Tuple1<int>& params) {
int result = params.a;
- if (result >= 0) {
+ if (result == net::OK ||
+ result == net::OK_FOR_SESSION_ONLY) {
net::CookieOptions options;
if (result == net::OK_FOR_SESSION_ONLY)
options.set_force_session();
context_->cookie_store()->SetCookieWithOptions(url_, cookie_line_,
options);
+ } else {
+ CallRenderViewHostResourceDelegate(
+ render_process_id_, render_view_id_,
+ &RenderViewHostDelegate::Resource::OnContentBlocked,
+ CONTENT_SETTINGS_TYPE_COOKIES);
}
delete this;
}
private:
+ int render_process_id_;
+ int render_view_id_;
GURL url_;
std::string cookie_line_;
scoped_refptr<URLRequestContext> context_;
@@ -572,7 +586,8 @@ void ResourceMessageFilter::OnMsgCreateWidget(int opener_id,
render_widget_helper_->CreateNewWidget(opener_id, activatable, route_id);
}
-void ResourceMessageFilter::OnSetCookie(const GURL& url,
+void ResourceMessageFilter::OnSetCookie(const IPC::Message& message,
+ const GURL& url,
const GURL& first_party_for_cookies,
const std::string& cookie) {
ChromeURLRequestContext* context = GetRequestContextForURL(url);
@@ -582,7 +597,8 @@ void ResourceMessageFilter::OnSetCookie(const GURL& url,
if (match.get() && (match->attributes() & Blacklist::kBlockCookies))
return;
- SetCookieCompletion* callback = new SetCookieCompletion(url, cookie, context);
+ SetCookieCompletion* callback =
+ new SetCookieCompletion(id(), message.routing_id(), url, cookie, context);
int policy = net::OK;
if (context->cookie_policy()) {
diff --git a/chrome/browser/renderer_host/resource_message_filter.h b/chrome/browser/renderer_host/resource_message_filter.h
index 2467645..240227e 100644
--- a/chrome/browser/renderer_host/resource_message_filter.h
+++ b/chrome/browser/renderer_host/resource_message_filter.h
@@ -127,7 +127,8 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter,
int64 session_storage_namespace_id, int* route_id,
int64* cloned_session_storage_namespace_id);
void OnMsgCreateWidget(int opener_id, bool activatable, int* route_id);
- void OnSetCookie(const GURL& url,
+ void OnSetCookie(const IPC::Message& message,
+ const GURL& url,
const GURL& first_party_for_cookies,
const std::string& cookie);
void OnGetCookies(const GURL& url,
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index 591dbb1..b985c96 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -1088,10 +1088,10 @@ IPC_BEGIN_MESSAGES(ViewHost)
// Used to set a cookie. The cookie is set asynchronously, but will be
// available to a subsequent ViewHostMsg_GetCookies request.
- IPC_MESSAGE_CONTROL3(ViewHostMsg_SetCookie,
- GURL /* url */,
- GURL /* first_party_for_cookies */,
- std::string /* cookie */)
+ IPC_MESSAGE_ROUTED3(ViewHostMsg_SetCookie,
+ GURL /* url */,
+ GURL /* first_party_for_cookies */,
+ std::string /* cookie */)
// Used to get cookies for the given URL
IPC_SYNC_MESSAGE_CONTROL2_1(ViewHostMsg_GetCookies,
diff --git a/chrome/renderer/renderer_webkitclient_impl.cc b/chrome/renderer/renderer_webkitclient_impl.cc
index 5580ab9..c9e3da7 100644
--- a/chrome/renderer/renderer_webkitclient_impl.cc
+++ b/chrome/renderer/renderer_webkitclient_impl.cc
@@ -1,6 +1,6 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
-// source code is governed by a BSD-style license that can be found in the
-// LICENSE file.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
#include "chrome/renderer/renderer_webkitclient_impl.h"
@@ -21,10 +21,12 @@
#include "chrome/plugin/npobject_util.h"
#include "chrome/renderer/net/render_dns_master.h"
#include "chrome/renderer/render_thread.h"
+#include "chrome/renderer/render_view.h"
#include "chrome/renderer/renderer_webstoragenamespace_impl.h"
#include "chrome/renderer/visitedlink_slave.h"
#include "googleurl/src/gurl.h"
#include "third_party/WebKit/WebKit/chromium/public/WebCookie.h"
+#include "third_party/WebKit/WebKit/chromium/public/WebFrame.h"
#include "third_party/WebKit/WebKit/chromium/public/WebStorageEventDispatcher.h"
#include "third_party/WebKit/WebKit/chromium/public/WebString.h"
#include "third_party/WebKit/WebKit/chromium/public/WebURL.h"
@@ -43,6 +45,7 @@
using WebKit::WebApplicationCacheHost;
using WebKit::WebApplicationCacheHostClient;
using WebKit::WebCookie;
+using WebKit::WebFrame;
using WebKit::WebKitClient;
using WebKit::WebStorageArea;
using WebKit::WebStorageEventDispatcher;
@@ -111,10 +114,18 @@ RendererWebKitClientImpl::createMessagePortChannel() {
void RendererWebKitClientImpl::setCookies(const WebURL& url,
const WebURL& first_party_for_cookies,
const WebString& value) {
+ // TODO(darin): Modify WebKit to pass the WebFrame.
+ RenderView* view =
+ RenderView::FromWebView(WebFrame::frameForCurrentContext()->view());
+ DCHECK(view);
+
std::string value_utf8;
UTF16ToUTF8(value.data(), value.length(), &value_utf8);
RenderThread::current()->Send(
- new ViewHostMsg_SetCookie(url, first_party_for_cookies, value_utf8));
+ new ViewHostMsg_SetCookie(view->routing_id(),
+ url,
+ first_party_for_cookies,
+ value_utf8));
}
WebString RendererWebKitClientImpl::cookies(