diff options
author | jorlow@chromium.org <jorlow@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-09 12:53:54 +0000 |
---|---|---|
committer | jorlow@chromium.org <jorlow@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-09 12:53:54 +0000 |
commit | 7b1e41c71f55f4b18f80ab713c104957cc9d80e2 (patch) | |
tree | 6a6622049fc590d7ac858a2b7d9e37f350f0e653 | |
parent | 5ec40cfbe054961db55591c94e46979c4c4d53d7 (diff) | |
download | chromium_src-7b1e41c71f55f4b18f80ab713c104957cc9d80e2.zip chromium_src-7b1e41c71f55f4b18f80ab713c104957cc9d80e2.tar.gz chromium_src-7b1e41c71f55f4b18f80ab713c104957cc9d80e2.tar.bz2 |
Use the WebViewClient* passed in from the StorageAreaProxy instead of using
RenderThread::RoutingIDForCurrentContext() whenever possible. In addition,
call OnContentBlocked directly from within the browser instead of sending
another IPC message. Lastly, make sure that we don't crash in the event
that we can't determine the routing id.
WebKit side: https://bugs.webkit.org/show_bug.cgi?id=35758
(Landing again after reverting in 40922)
TEST=none
BUG=none
Review URL: http://codereview.chromium.org/671001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41024 0039d316-1c4b-4281-b951-d872f2087c98
5 files changed, 36 insertions, 19 deletions
diff --git a/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.cc b/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.cc index ddd9439..bb28bff 100644 --- a/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.cc +++ b/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.cc @@ -1,6 +1,6 @@ -// 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. +// 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/browser/in_process_webkit/dom_storage_dispatcher_host.h" @@ -12,6 +12,7 @@ #include "chrome/browser/in_process_webkit/webkit_thread.h" #include "chrome/browser/net/chrome_url_request_context.h" #include "chrome/browser/renderer_host/browser_render_process_host.h" +#include "chrome/browser/renderer_host/render_view_host_notification_task.h" #include "chrome/browser/renderer_host/resource_message_filter.h" #include "chrome/common/render_messages.h" #include "googleurl/src/gurl.h" @@ -58,13 +59,14 @@ DOMStorageDispatcherHost::DOMStorageDispatcherHost( DOMStorageDispatcherHost::~DOMStorageDispatcherHost() { } -void DOMStorageDispatcherHost::Init( - base::ProcessHandle process_handle) { +void DOMStorageDispatcherHost::Init(int process_id, + base::ProcessHandle process_handle) { DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); DCHECK(resource_message_filter_); // Ensure Shutdown() has not been called. DCHECK(!process_handle_); // Make sure Init() has not yet been called. DCHECK(process_handle); Context()->RegisterDispatcherHost(this); + process_id_ = process_id; process_handle_ = process_handle; } @@ -271,6 +273,17 @@ void DOMStorageDispatcherHost::OnSetItem( ScopedStorageEventContext scope(this, &url); WebStorageArea::Result result; NullableString16 old_value = storage_area->SetItem(key, value, &result, this); + + // If content was blocked, tell the UI to display the blocked content icon. + if (reply_msg->routing_id() == MSG_ROUTING_CONTROL) { + DLOG(WARNING) << "setItem was not given a proper routing id"; + } else if (result == WebKit::WebStorageArea::ResultBlockedByPolicy) { + CallRenderViewHostResourceDelegate( + process_id_, reply_msg->routing_id(), + &RenderViewHostDelegate::Resource::OnContentBlocked, + CONTENT_SETTINGS_TYPE_COOKIES); + } + ViewHostMsg_DOMStorageSetItem::WriteReplyParams(reply_msg, result, old_value); Send(reply_msg); } diff --git a/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.h b/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.h index 30176d7..fea147a 100644 --- a/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.h +++ b/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.h @@ -33,7 +33,7 @@ class DOMStorageDispatcherHost WebKitContext* webkit_context, WebKitThread* webkit_thread); // Only call from ResourceMessageFilter on the IO thread. - void Init(base::ProcessHandle process_handle); + void Init(int process_id, base::ProcessHandle process_handle); // Only call from ResourceMessageFilter on the IO thread. Calls self on the // WebKit thread in some cases. @@ -111,6 +111,9 @@ class DOMStorageDispatcherHost // handle. base::ProcessHandle process_handle_; + // Used to dispatch messages to the correct view host. + int process_id_; + DISALLOW_IMPLICIT_CONSTRUCTORS(DOMStorageDispatcherHost); }; diff --git a/chrome/browser/renderer_host/resource_message_filter.cc b/chrome/browser/renderer_host/resource_message_filter.cc index 5506ffd..c288713 100644 --- a/chrome/browser/renderer_host/resource_message_filter.cc +++ b/chrome/browser/renderer_host/resource_message_filter.cc @@ -361,7 +361,7 @@ void ResourceMessageFilter::OnChannelConnected(int32 peer_pid) { WorkerService::GetInstance()->Initialize(resource_dispatcher_host_); appcache_dispatcher_host_->Initialize(this, id(), handle()); - dom_storage_dispatcher_host_->Init(handle()); + dom_storage_dispatcher_host_->Init(id(), handle()); db_dispatcher_host_->Init(handle()); } diff --git a/chrome/renderer/renderer_webstoragearea_impl.cc b/chrome/renderer/renderer_webstoragearea_impl.cc index d2d13dc..d466952 100644 --- a/chrome/renderer/renderer_webstoragearea_impl.cc +++ b/chrome/renderer/renderer_webstoragearea_impl.cc @@ -49,9 +49,15 @@ WebString RendererWebStorageAreaImpl::getItem(const WebString& key) { void RendererWebStorageAreaImpl::setItem( const WebString& key, const WebString& value, const WebURL& url, - WebStorageArea::Result& result, WebString& old_value_webkit) { - int32 routing_id = RenderThread::RoutingIDForCurrentContext(); - CHECK(routing_id != MSG_ROUTING_CONTROL); + WebStorageArea::Result& result, WebString& old_value_webkit, + WebFrame* web_frame) { + int32 routing_id = MSG_ROUTING_CONTROL; + if (web_frame) { + RenderView* render_view = RenderView::FromWebView(web_frame->view()); + if (render_view) + routing_id = render_view->routing_id(); + } + DCHECK(routing_id != MSG_ROUTING_CONTROL); NullableString16 old_value; IPC::SyncMessage* message = @@ -60,11 +66,6 @@ void RendererWebStorageAreaImpl::setItem( // NOTE: This may pump events (see RenderThread::Send). RenderThread::current()->Send(message); old_value_webkit = old_value; - - if (result == WebStorageArea::ResultBlockedByPolicy) { - RenderThread::current()->Send(new ViewHostMsg_ContentBlocked( - routing_id, CONTENT_SETTINGS_TYPE_COOKIES)); - } } void RendererWebStorageAreaImpl::removeItem( diff --git a/chrome/renderer/renderer_webstoragearea_impl.h b/chrome/renderer/renderer_webstoragearea_impl.h index 7bd6ff1..8a324c2 100644 --- a/chrome/renderer/renderer_webstoragearea_impl.h +++ b/chrome/renderer/renderer_webstoragearea_impl.h @@ -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. #ifndef CHROME_RENDERER_RENDERER_WEBSTORAGEAREA_IMPL_H_ #define CHROME_RENDERER_RENDERER_WEBSTORAGEAREA_IMPL_H_ @@ -23,7 +23,7 @@ class RendererWebStorageAreaImpl : public WebKit::WebStorageArea { virtual void setItem( const WebKit::WebString& key, const WebKit::WebString& value, const WebKit::WebURL& url, WebStorageArea::Result& result, - WebKit::WebString& old_value); + WebKit::WebString& old_value, WebKit::WebFrame* web_view); virtual void removeItem( const WebKit::WebString& key, const WebKit::WebURL& url, WebKit::WebString& old_value); |