summaryrefslogtreecommitdiffstats
path: root/chrome/browser/renderer_host
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-30 01:11:18 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-30 01:11:18 +0000
commit724159ade73d3b63a41778a8dbb0a39751561ee3 (patch)
treef9314b1ef2256bc246f7d541546cf062a6d470e1 /chrome/browser/renderer_host
parent64c754589b76670e3e1ad64fe358c25a1cd2839c (diff)
downloadchromium_src-724159ade73d3b63a41778a8dbb0a39751561ee3.zip
chromium_src-724159ade73d3b63a41778a8dbb0a39751561ee3.tar.gz
chromium_src-724159ade73d3b63a41778a8dbb0a39751561ee3.tar.bz2
Get rid of RenderViewHostDelegate::Resource and dispatch the IPC messages directly in TabContents.
Review URL: http://codereview.chromium.org/6025009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70292 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/renderer_host')
-rw-r--r--chrome/browser/renderer_host/render_view_host.cc196
-rw-r--r--chrome/browser/renderer_host/render_view_host.h26
-rw-r--r--chrome/browser/renderer_host/render_view_host_delegate.cc8
-rw-r--r--chrome/browser/renderer_host/render_view_host_delegate.h73
-rw-r--r--chrome/browser/renderer_host/render_view_host_notification_task.h61
-rw-r--r--chrome/browser/renderer_host/resource_dispatcher_host.cc40
-rw-r--r--chrome/browser/renderer_host/resource_dispatcher_host.h10
-rw-r--r--chrome/browser/renderer_host/resource_request_details.cc2
-rw-r--r--chrome/browser/renderer_host/resource_request_details.h4
9 files changed, 105 insertions, 315 deletions
diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc
index 950c60e..12eb0c5 100644
--- a/chrome/browser/renderer_host/render_view_host.cc
+++ b/chrome/browser/renderer_host/render_view_host.cc
@@ -11,7 +11,6 @@
#include "base/command_line.h"
#include "base/i18n/rtl.h"
#include "base/json/json_reader.h"
-#include "base/metrics/stats_counters.h"
#include "base/string_util.h"
#include "base/time.h"
#include "base/utf_string_conversions.h"
@@ -81,25 +80,6 @@ using WebKit::WebTextDirection;
namespace {
-void FilterURL(ChildProcessSecurityPolicy* policy, int renderer_id, GURL* url) {
- if (!url->is_valid())
- return; // We don't need to block invalid URLs.
-
- if (url->SchemeIs(chrome::kAboutScheme)) {
- // The renderer treats all URLs in the about: scheme as being about:blank.
- // Canonicalize about: URLs to about:blank.
- *url = GURL(chrome::kAboutBlankURL);
- }
-
- if (!policy->CanRequestURL(renderer_id, *url)) {
- // If this renderer is not permitted to request this URL, we invalidate the
- // URL. This prevents us from storing the blocked URL and becoming confused
- // later.
- VLOG(1) << "Blocked URL " << url->spec();
- *url = GURL();
- }
-}
-
// Delay to wait on closing the tab for a beforeunload/unload handler to fire.
const int kUnloadTimeoutMS = 1000;
@@ -760,6 +740,9 @@ bool RenderViewHost::OnMessageReceived(const IPC::Message& msg) {
}
#endif
+ if (delegate_->OnMessageReceived(msg))
+ return true;
+
bool handled = true;
bool msg_is_ok = true;
IPC_BEGIN_MESSAGE_MAP_EX(RenderViewHost, msg, msg_is_ok)
@@ -778,7 +761,7 @@ bool RenderViewHost::OnMessageReceived(const IPC::Message& msg) {
IPC_MESSAGE_HANDLER(ViewHostMsg_Thumbnail, OnMsgThumbnail)
IPC_MESSAGE_HANDLER(ViewHostMsg_Snapshot, OnMsgScreenshot)
IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateInspectorSetting,
- OnUpdateInspectorSetting);
+ OnUpdateInspectorSetting)
IPC_MESSAGE_HANDLER(ViewHostMsg_Close, OnMsgClose)
IPC_MESSAGE_HANDLER(ViewHostMsg_RequestMove, OnMsgRequestMove)
IPC_MESSAGE_HANDLER(ViewHostMsg_DidStartLoading, OnMsgDidStartLoading)
@@ -789,18 +772,6 @@ bool RenderViewHost::OnMessageReceived(const IPC::Message& msg) {
OnMsgDocumentAvailableInMainFrame)
IPC_MESSAGE_HANDLER(ViewHostMsg_DocumentOnLoadCompletedInMainFrame,
OnMsgDocumentOnLoadCompletedInMainFrame)
- IPC_MESSAGE_HANDLER(ViewHostMsg_DidLoadResourceFromMemoryCache,
- OnMsgDidLoadResourceFromMemoryCache)
- IPC_MESSAGE_HANDLER(ViewHostMsg_DidDisplayInsecureContent,
- OnMsgDidDisplayInsecureContent)
- IPC_MESSAGE_HANDLER(ViewHostMsg_DidRunInsecureContent,
- OnMsgDidRunInsecureContent)
- IPC_MESSAGE_HANDLER(ViewHostMsg_DidRedirectProvisionalLoad,
- OnMsgDidRedirectProvisionalLoad)
- IPC_MESSAGE_HANDLER(ViewHostMsg_DidStartProvisionalLoadForFrame,
- OnMsgDidStartProvisionalLoadForFrame)
- IPC_MESSAGE_HANDLER(ViewHostMsg_DidFailProvisionalLoadWithError,
- OnMsgDidFailProvisionalLoadWithError)
IPC_MESSAGE_HANDLER(ViewHostMsg_Find_Reply, OnMsgFindReply)
IPC_MESSAGE_HANDLER(ViewMsg_ExecuteCodeFinished,
OnExecuteCodeFinished)
@@ -812,16 +783,10 @@ bool RenderViewHost::OnMessageReceived(const IPC::Message& msg) {
OnMsgDidContentsPreferredSizeChange)
IPC_MESSAGE_HANDLER(ViewHostMsg_DomOperationResponse,
OnMsgDomOperationResponse)
- IPC_MESSAGE_HANDLER(ViewHostMsg_DOMUISend,
- OnMsgDOMUISend)
+ IPC_MESSAGE_HANDLER(ViewHostMsg_DOMUISend, OnMsgDOMUISend)
IPC_MESSAGE_HANDLER(ViewHostMsg_ForwardMessageToExternalHost,
OnMsgForwardMessageToExternalHost)
- IPC_MESSAGE_HANDLER(ViewHostMsg_DocumentLoadedInFrame,
- OnMsgDocumentLoadedInFrame)
- IPC_MESSAGE_HANDLER(ViewHostMsg_DidFinishLoad,
- OnMsgDidFinishLoad)
- IPC_MESSAGE_HANDLER(ViewHostMsg_GoToEntryAtOffset,
- OnMsgGoToEntryAtOffset)
+ IPC_MESSAGE_HANDLER(ViewHostMsg_GoToEntryAtOffset, OnMsgGoToEntryAtOffset)
IPC_MESSAGE_HANDLER(ViewHostMsg_SetTooltipText, OnMsgSetTooltipText)
IPC_MESSAGE_HANDLER(ViewHostMsg_RunFileChooser, OnMsgRunFileChooser)
IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_RunJavaScriptMessage,
@@ -844,34 +809,34 @@ bool RenderViewHost::OnMessageReceived(const IPC::Message& msg) {
IPC_MESSAGE_HANDLER(ViewHostMsg_DidPrintPage, DidPrintPage)
IPC_MESSAGE_HANDLER(ViewHostMsg_AddMessageToConsole, OnAddMessageToConsole)
IPC_MESSAGE_HANDLER(ViewHostMsg_ForwardToDevToolsAgent,
- OnForwardToDevToolsAgent);
+ OnForwardToDevToolsAgent)
IPC_MESSAGE_HANDLER(ViewHostMsg_ForwardToDevToolsClient,
- OnForwardToDevToolsClient);
+ OnForwardToDevToolsClient)
IPC_MESSAGE_HANDLER(ViewHostMsg_ActivateDevToolsWindow,
- OnActivateDevToolsWindow);
+ OnActivateDevToolsWindow)
IPC_MESSAGE_HANDLER(ViewHostMsg_CloseDevToolsWindow,
- OnCloseDevToolsWindow);
+ OnCloseDevToolsWindow)
IPC_MESSAGE_HANDLER(ViewHostMsg_RequestDockDevToolsWindow,
- OnRequestDockDevToolsWindow);
+ OnRequestDockDevToolsWindow)
IPC_MESSAGE_HANDLER(ViewHostMsg_RequestUndockDevToolsWindow,
- OnRequestUndockDevToolsWindow);
+ OnRequestUndockDevToolsWindow)
IPC_MESSAGE_HANDLER(ViewHostMsg_DevToolsRuntimePropertyChanged,
- OnDevToolsRuntimePropertyChanged);
- IPC_MESSAGE_HANDLER(ViewHostMsg_MissingPluginStatus, OnMissingPluginStatus);
- IPC_MESSAGE_HANDLER(ViewHostMsg_CrashedPlugin, OnCrashedPlugin);
+ OnDevToolsRuntimePropertyChanged)
+ IPC_MESSAGE_HANDLER(ViewHostMsg_MissingPluginStatus, OnMissingPluginStatus)
+ IPC_MESSAGE_HANDLER(ViewHostMsg_CrashedPlugin, OnCrashedPlugin)
IPC_MESSAGE_HANDLER(ViewHostMsg_BlockedOutdatedPlugin,
- OnBlockedOutdatedPlugin);
+ OnBlockedOutdatedPlugin)
IPC_MESSAGE_HANDLER(ViewHostMsg_SendCurrentPageAllSavableResourceLinks,
- OnReceivedSavableResourceLinksForCurrentPage);
+ OnReceivedSavableResourceLinksForCurrentPage)
IPC_MESSAGE_HANDLER(ViewHostMsg_SendSerializedHtmlData,
- OnReceivedSerializedHtmlData);
+ OnReceivedSerializedHtmlData)
IPC_MESSAGE_HANDLER(ViewHostMsg_DidGetApplicationInfo,
- OnDidGetApplicationInfo);
+ OnDidGetApplicationInfo)
IPC_MESSAGE_HANDLER(ViewHostMsg_InstallApplication,
- OnInstallApplication);
+ OnInstallApplication)
IPC_MESSAGE_FORWARD(ViewHostMsg_JSOutOfMemory, delegate_,
- RenderViewHostDelegate::OnJSOutOfMemory);
- IPC_MESSAGE_HANDLER(ViewHostMsg_ShouldClose_ACK, OnMsgShouldCloseACK);
+ RenderViewHostDelegate::OnJSOutOfMemory)
+ IPC_MESSAGE_HANDLER(ViewHostMsg_ShouldClose_ACK, OnMsgShouldCloseACK)
IPC_MESSAGE_HANDLER(ViewHostMsg_QueryFormFieldAutoFill,
OnQueryFormFieldAutoFill)
IPC_MESSAGE_HANDLER(ViewHostMsg_DidShowAutoFillSuggestions,
@@ -1155,17 +1120,6 @@ void RenderViewHost::OnMsgRequestMove(const gfx::Rect& pos) {
Send(new ViewMsg_Move_ACK(routing_id()));
}
-void RenderViewHost::OnMsgDidRedirectProvisionalLoad(int32 page_id,
- const GURL& source_url,
- const GURL& target_url) {
- RenderViewHostDelegate::Resource* resource_delegate =
- delegate_->GetResourceDelegate();
- if (resource_delegate) {
- resource_delegate->DidRedirectProvisionalLoad(page_id,
- source_url, target_url);
- }
-}
-
void RenderViewHost::OnMsgDidStartLoading() {
delegate_->DidStartLoading();
}
@@ -1186,77 +1140,6 @@ void RenderViewHost::OnMsgDocumentOnLoadCompletedInMainFrame(int32 page_id) {
delegate_->DocumentOnLoadCompletedInMainFrame(this, page_id);
}
-void RenderViewHost::OnMsgDidLoadResourceFromMemoryCache(
- const GURL& url,
- const std::string& frame_origin,
- const std::string& main_frame_origin,
- const std::string& security_info) {
- static base::StatsCounter cache("WebKit.CacheHit");
- cache.Increment();
-
- RenderViewHostDelegate::Resource* resource_delegate =
- delegate_->GetResourceDelegate();
- if (resource_delegate) {
- resource_delegate->DidLoadResourceFromMemoryCache(
- url, frame_origin, main_frame_origin, security_info);
- }
-}
-
-void RenderViewHost::OnMsgDidDisplayInsecureContent() {
- RenderViewHostDelegate::Resource* resource_delegate =
- delegate_->GetResourceDelegate();
- if (resource_delegate)
- resource_delegate->DidDisplayInsecureContent();
-}
-
-void RenderViewHost::OnMsgDidRunInsecureContent(
- const std::string& security_origin) {
- RenderViewHostDelegate::Resource* resource_delegate =
- delegate_->GetResourceDelegate();
- if (resource_delegate)
- resource_delegate->DidRunInsecureContent(security_origin);
-}
-
-void RenderViewHost::OnMsgDidStartProvisionalLoadForFrame(int64 frame_id,
- bool is_main_frame,
- const GURL& url) {
- bool is_error_page = (url.spec() == chrome::kUnreachableWebDataURL);
- GURL validated_url(url);
- FilterURL(ChildProcessSecurityPolicy::GetInstance(),
- process()->id(), &validated_url);
-
- RenderViewHostDelegate::Resource* resource_delegate =
- delegate_->GetResourceDelegate();
- if (resource_delegate) {
- resource_delegate->DidStartProvisionalLoadForFrame(
- this, frame_id, is_main_frame, is_error_page, validated_url);
- }
-}
-
-void RenderViewHost::OnMsgDidFailProvisionalLoadWithError(
- int64 frame_id,
- bool is_main_frame,
- int error_code,
- const GURL& url,
- bool showing_repost_interstitial) {
- VLOG(1) << "Failed Provisional Load: " << url.possibly_invalid_spec()
- << ", error_code: " << error_code
- << " is_main_frame: " << is_main_frame
- << " showing_repost_interstitial: " << showing_repost_interstitial
- << " frame_id: " << frame_id;
- GURL validated_url(url);
- FilterURL(ChildProcessSecurityPolicy::GetInstance(),
- process()->id(), &validated_url);
-
- RenderViewHostDelegate::Resource* resource_delegate =
- delegate_->GetResourceDelegate();
- if (resource_delegate) {
- resource_delegate->DidFailProvisionalLoadWithError(
- this, frame_id, is_main_frame, error_code, validated_url,
- showing_repost_interstitial);
- }
-}
-
void RenderViewHost::OnMsgFindReply(int request_id,
int number_of_matches,
const gfx::Rect& selection_rect,
@@ -1396,20 +1279,6 @@ void RenderViewHost::OnMsgForwardMessageToExternalHost(
delegate_->ProcessExternalHostMessage(message, origin, target);
}
-void RenderViewHost::OnMsgDocumentLoadedInFrame(int64 frame_id) {
- RenderViewHostDelegate::Resource* resource_delegate =
- delegate_->GetResourceDelegate();
- if (resource_delegate)
- resource_delegate->DocumentLoadedInFrame(frame_id);
-}
-
-void RenderViewHost::OnMsgDidFinishLoad(int64 frame_id) {
- RenderViewHostDelegate::Resource* resource_delegate =
- delegate_->GetResourceDelegate();
- if (resource_delegate)
- resource_delegate->DidFinishLoad(frame_id);
-}
-
void RenderViewHost::DisassociateFromPopupCount() {
Send(new ViewMsg_DisassociateFromPopupCount(routing_id()));
}
@@ -2093,6 +1962,27 @@ void RenderViewHost::DetermineIfPageSupportsInstant(const string16& value,
verbatim));
}
+void RenderViewHost::FilterURL(ChildProcessSecurityPolicy* policy,
+ int renderer_id,
+ GURL* url) {
+ if (!url->is_valid())
+ return; // We don't need to block invalid URLs.
+
+ if (url->SchemeIs(chrome::kAboutScheme)) {
+ // The renderer treats all URLs in the about: scheme as being about:blank.
+ // Canonicalize about: URLs to about:blank.
+ *url = GURL(chrome::kAboutBlankURL);
+ }
+
+ if (!policy->CanRequestURL(renderer_id, *url)) {
+ // If this renderer is not permitted to request this URL, we invalidate the
+ // URL. This prevents us from storing the blocked URL and becoming confused
+ // later.
+ VLOG(1) << "Blocked URL " << url->spec();
+ *url = GURL();
+ }
+}
+
void RenderViewHost::OnExtensionPostMessage(
int port_id, const std::string& message) {
if (process()->profile()->GetExtensionMessageService()) {
diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h
index 697b67d..2174f2f 100644
--- a/chrome/browser/renderer_host/render_view_host.h
+++ b/chrome/browser/renderer_host/render_view_host.h
@@ -26,6 +26,7 @@
#include "webkit/glue/webaccessibility.h"
#include "webkit/glue/window_open_disposition.h"
+class ChildProcessSecurityPolicy;
class FilePath;
class GURL;
class ListValue;
@@ -538,6 +539,12 @@ class RenderViewHost : public RenderWidgetHost {
bool is_waiting_for_unload_ack() { return is_waiting_for_unload_ack_; }
#endif
+ // Checks that the given renderer can request |url|, if not it sets it to an
+ // empty url.
+ static void FilterURL(ChildProcessSecurityPolicy* policy,
+ int renderer_id,
+ GURL* url);
+
protected:
// RenderWidgetHost protected overrides.
virtual bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event,
@@ -572,28 +579,11 @@ class RenderViewHost : public RenderWidgetHost {
void OnMsgScreenshot(const SkBitmap& bitmap);
void OnMsgClose();
void OnMsgRequestMove(const gfx::Rect& pos);
- void OnMsgDidRedirectProvisionalLoad(int32 page_id,
- const GURL& source_url,
- const GURL& target_url);
void OnMsgDidStartLoading();
void OnMsgDidStopLoading();
void OnMsgDidChangeLoadProgress(double load_progress);
void OnMsgDocumentAvailableInMainFrame();
void OnMsgDocumentOnLoadCompletedInMainFrame(int32 page_id);
- void OnMsgDidLoadResourceFromMemoryCache(const GURL& url,
- const std::string& frame_origin,
- const std::string& main_frame_origin,
- const std::string& security_info);
- void OnMsgDidDisplayInsecureContent();
- void OnMsgDidRunInsecureContent(const std::string& security_origin);
- void OnMsgDidStartProvisionalLoadForFrame(int64 frame_id,
- bool main_frame,
- const GURL& url);
- void OnMsgDidFailProvisionalLoadWithError(int64 frame_id,
- bool main_frame,
- int error_code,
- const GURL& url,
- bool showing_repost_interstitial);
void OnMsgFindReply(int request_id,
int number_of_matches,
const gfx::Rect& selection_rect,
@@ -617,8 +607,6 @@ class RenderViewHost : public RenderWidgetHost {
void OnMsgForwardMessageToExternalHost(const std::string& message,
const std::string& origin,
const std::string& target);
- void OnMsgDocumentLoadedInFrame(int64 frame_id);
- void OnMsgDidFinishLoad(int64 frame_id);
void OnMsgGoToEntryAtOffset(int offset);
void OnMsgSetTooltipText(const std::wstring& tooltip_text,
WebKit::WebTextDirection text_direction_hint);
diff --git a/chrome/browser/renderer_host/render_view_host_delegate.cc b/chrome/browser/renderer_host/render_view_host_delegate.cc
index 738a1ec..a58eea5 100644
--- a/chrome/browser/renderer_host/render_view_host_delegate.cc
+++ b/chrome/browser/renderer_host/render_view_host_delegate.cc
@@ -30,10 +30,6 @@ RenderViewHostDelegate::GetBrowserIntegrationDelegate() {
return NULL;
}
-RenderViewHostDelegate::Resource*
-RenderViewHostDelegate::GetResourceDelegate() {
- return NULL;
-}
RenderViewHostDelegate::ContentSettings*
RenderViewHostDelegate::GetContentSettingsDelegate() {
@@ -84,6 +80,10 @@ RenderViewHostDelegate::GetAutomationResourceRoutingDelegate() {
return NULL;
}
+bool RenderViewHostDelegate::OnMessageReceived(const IPC::Message& message) {
+ return false;
+}
+
const GURL& RenderViewHostDelegate::GetURL() const {
return GURL::EmptyGURL();
}
diff --git a/chrome/browser/renderer_host/render_view_host_delegate.h b/chrome/browser/renderer_host/render_view_host_delegate.h
index d769d05..34c206bec 100644
--- a/chrome/browser/renderer_host/render_view_host_delegate.h
+++ b/chrome/browser/renderer_host/render_view_host_delegate.h
@@ -18,6 +18,7 @@
#include "chrome/common/translate_errors.h"
#include "chrome/common/view_types.h"
#include "chrome/common/window_container_type.h"
+#include "ipc/ipc_channel.h"
#include "net/base/load_states.h"
#include "third_party/WebKit/WebKit/chromium/public/WebDragOperation.h"
#include "third_party/WebKit/WebKit/chromium/public/WebPopupType.h"
@@ -94,7 +95,7 @@ struct PasswordForm;
// exposing a more generic Send function on RenderViewHost and a response
// listener here to serve that need.
//
-class RenderViewHostDelegate {
+class RenderViewHostDelegate : public IPC::Channel::Listener {
public:
// View ----------------------------------------------------------------------
// Functions that can be routed directly to a view-specific class.
@@ -322,71 +323,6 @@ class RenderViewHostDelegate {
virtual ~BrowserIntegration() {}
};
- // Resource ------------------------------------------------------------------
- // Notifications of resource loading events.
-
- class Resource {
- public:
- // The RenderView is starting a provisional load.
- virtual void DidStartProvisionalLoadForFrame(
- RenderViewHost* render_view_host,
- int64 frame_id,
- bool is_main_frame,
- bool is_error_page,
- const GURL& url) = 0;
-
- // Notification by the resource loading system (not the renderer) that it
- // has started receiving a resource response. This is different than
- // DidStartProvisionalLoadForFrame above because this is called for every
- // resource (images, automatically loaded subframes, etc.) and provisional
- // loads are only for user-initiated navigations.
- virtual void DidStartReceivingResourceResponse(
- const ResourceRequestDetails& details) = 0;
-
- // Sent when a provisional load is redirected.
- virtual void DidRedirectProvisionalLoad(int32 page_id,
- const GURL& source_url,
- const GURL& target_url) = 0;
-
- // Notification by the resource loading system (not the renderer) that a
- // resource was redirected. This is different than
- // DidRedirectProvisionalLoad above because this is called for every
- // resource (images, automatically loaded subframes, etc.) and provisional
- // loads are only for user-initiated navigations.
- virtual void DidRedirectResource(
- const ResourceRedirectDetails& details) = 0;
-
- // The RenderView loaded a resource from an in-memory cache.
- // |security_info| contains the security info if this resource was
- // originally loaded over a secure connection.
- virtual void DidLoadResourceFromMemoryCache(
- const GURL& url,
- const std::string& frame_origin,
- const std::string& main_frame_origin,
- const std::string& security_info) = 0;
-
- virtual void DidDisplayInsecureContent() = 0;
- virtual void DidRunInsecureContent(const std::string& security_origin) = 0;
-
- // The RenderView failed a provisional load with an error.
- virtual void DidFailProvisionalLoadWithError(
- RenderViewHost* render_view_host,
- int64 frame_id,
- bool is_main_frame,
- int error_code,
- const GURL& url,
- bool showing_repost_interstitial) = 0;
-
- // Notification that a document has been loaded in a frame.
- virtual void DocumentLoadedInFrame(int64 frame_id) = 0;
-
- // Notification that a frame finished loading.
- virtual void DidFinishLoad(int64 frame_id) = 0;
-
- protected:
- virtual ~Resource() {}
- };
-
// ContentSettings------------------------------------------------------------
// Interface for content settings related events.
@@ -672,7 +608,6 @@ class RenderViewHostDelegate {
virtual View* GetViewDelegate();
virtual RendererManagement* GetRendererManagementDelegate();
virtual BrowserIntegration* GetBrowserIntegrationDelegate();
- virtual Resource* GetResourceDelegate();
virtual ContentSettings* GetContentSettingsDelegate();
virtual Save* GetSaveDelegate();
virtual Printing* GetPrintingDelegate();
@@ -688,6 +623,10 @@ class RenderViewHostDelegate {
virtual AutomationResourceRoutingDelegate*
GetAutomationResourceRoutingDelegate();
+ // IPC::Channel::Listener implementation.
+ // This is used to give the delegate a chance to filter IPC messages.
+ virtual bool OnMessageReceived(const IPC::Message& message);
+
// Gets the URL that is currently being displayed, if there is one.
virtual const GURL& GetURL() const;
diff --git a/chrome/browser/renderer_host/render_view_host_notification_task.h b/chrome/browser/renderer_host/render_view_host_notification_task.h
index 1aab02b..fb06112 100644
--- a/chrome/browser/renderer_host/render_view_host_notification_task.h
+++ b/chrome/browser/renderer_host/render_view_host_notification_task.h
@@ -70,31 +70,6 @@ inline void CallRenderViewHostHelper(int render_process_id, int render_view_id,
params));
}
-// For proxying calls to RenderViewHostDelegate::Resource
-
-class RenderViewHostToResourceDelegate {
- public:
- typedef RenderViewHostDelegate::Resource MappedType;
- static MappedType* Map(RenderViewHost* rvh) {
- return rvh ? rvh->delegate()->GetResourceDelegate() : NULL;
- }
-};
-
-template <typename Method, typename Params>
-inline void CallRenderViewHostResourceDelegateHelper(int render_process_id,
- int render_view_id,
- Method method,
- const Params& params) {
-
- BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE,
- new RenderViewHostNotificationTask<
- Method, Params, RenderViewHostToResourceDelegate>(render_process_id,
- render_view_id,
- method,
- params));
-}
-
// For proxying calls to RenderViewHostDelegate::ContentSettings
class RenderViewHostToContentSettingsDelegate {
@@ -213,42 +188,6 @@ inline void CallRenderViewHost(int render_process_id,
}
// ----------------------------------------------------------------------------
-// Proxy calls to the specified RenderViewHost's Resource delegate.
-
-template <typename Method>
-inline void CallRenderViewHostResourceDelegate(int render_process_id,
- int render_view_id,
- Method method) {
- internal::CallRenderViewHostResourceDelegateHelper(render_process_id,
- render_view_id,
- method,
- MakeTuple());
-}
-
-template <typename Method, typename A>
-inline void CallRenderViewHostResourceDelegate(int render_process_id,
- int render_view_id,
- Method method,
- const A& a) {
- internal::CallRenderViewHostResourceDelegateHelper(render_process_id,
- render_view_id,
- method,
- MakeTuple(a));
-}
-
-template <typename Method, typename A, typename B>
-inline void CallRenderViewHostResourceDelegate(int render_process_id,
- int render_view_id,
- Method method,
- const A& a,
- const B& b) {
- internal::CallRenderViewHostResourceDelegateHelper(render_process_id,
- render_view_id,
- method,
- MakeTuple(a, b));
-}
-
-// ----------------------------------------------------------------------------
// Proxy calls to the specified RenderViewHost's ContentSettings delegate.
template <typename Method>
diff --git a/chrome/browser/renderer_host/resource_dispatcher_host.cc b/chrome/browser/renderer_host/resource_dispatcher_host.cc
index cad4560..93749f3 100644
--- a/chrome/browser/renderer_host/resource_dispatcher_host.cc
+++ b/chrome/browser/renderer_host/resource_dispatcher_host.cc
@@ -54,6 +54,7 @@
#include "chrome/browser/ui/login/login_prompt.h"
#include "chrome/browser/worker_host/worker_service.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/common/notification_service.h"
#include "chrome/common/render_messages.h"
#include "chrome/common/render_messages_params.h"
#include "chrome/common/url_constants.h"
@@ -1571,10 +1572,14 @@ void ResourceDispatcherHost::NotifyResponseStarted(net::URLRequest* request,
return;
// Notify the observers on the UI thread.
- CallRenderViewHostResourceDelegate(
- render_process_id, render_view_id,
- &RenderViewHostDelegate::Resource::DidStartReceivingResourceResponse,
- ResourceRequestDetails(request, GetCertID(request, child_id)));
+ ResourceRequestDetails* detail = new ResourceRequestDetails(
+ request, GetCertID(request, child_id));
+ BrowserThread::PostTask(
+ BrowserThread::UI, FROM_HERE,
+ NewRunnableFunction(
+ &ResourceDispatcherHost::NotifyOnUI<ResourceRequestDetails>,
+ NotificationType::RESOURCE_RESPONSE_STARTED,
+ render_process_id, render_view_id, detail));
}
void ResourceDispatcherHost::NotifyResponseCompleted(net::URLRequest* request,
@@ -1596,10 +1601,29 @@ void ResourceDispatcherHost::NotifyReceivedRedirect(net::URLRequest* request,
return;
// Notify the observers on the UI thread.
- CallRenderViewHostResourceDelegate(
- render_process_id, render_view_id,
- &RenderViewHostDelegate::Resource::DidRedirectResource,
- ResourceRedirectDetails(request, GetCertID(request, child_id), new_url));
+ ResourceRedirectDetails* detail = new ResourceRedirectDetails(
+ request, GetCertID(request, child_id), new_url);
+ BrowserThread::PostTask(
+ BrowserThread::UI, FROM_HERE,
+ NewRunnableFunction(
+ &ResourceDispatcherHost::NotifyOnUI<ResourceRedirectDetails>,
+ NotificationType::RESOURCE_RECEIVED_REDIRECT,
+ render_process_id, render_view_id, detail));
+}
+
+template <class T>
+void ResourceDispatcherHost::NotifyOnUI(NotificationType type,
+ int render_process_id,
+ int render_view_id,
+ T* detail) {
+ RenderViewHost* rvh =
+ RenderViewHost::FromID(render_process_id, render_view_id);
+ if (!rvh)
+ return;
+ RenderViewHostDelegate* rvhd = rvh->delegate();
+ NotificationService::current()->Notify(
+ type, Source<RenderViewHostDelegate>(rvhd), Details<T>(detail));
+ delete detail;
}
namespace {
diff --git a/chrome/browser/renderer_host/resource_dispatcher_host.h b/chrome/browser/renderer_host/resource_dispatcher_host.h
index 9d1924d..b48d906 100644
--- a/chrome/browser/renderer_host/resource_dispatcher_host.h
+++ b/chrome/browser/renderer_host/resource_dispatcher_host.h
@@ -23,6 +23,7 @@
#include "base/scoped_ptr.h"
#include "base/timer.h"
#include "chrome/common/child_process_info.h"
+#include "chrome/common/notification_type.h"
#include "chrome/browser/renderer_host/resource_queue.h"
#include "ipc/ipc_message.h"
#include "net/url_request/url_request.h"
@@ -32,6 +33,7 @@ class CrossSiteResourceHandler;
class DownloadFileManager;
class DownloadRequestLimiter;
class LoginHandler;
+class NotificationDetails;
class PluginService;
class ResourceDispatcherHostRequestInfo;
class ResourceHandler;
@@ -420,6 +422,14 @@ class ResourceDispatcherHost : public net::URLRequest::Delegate {
// is to user-perceived page load performance.
static net::RequestPriority DetermineRequestPriority(ResourceType::Type type);
+ // Sends the given notification on the UI thread. The RenderViewHost's
+ // controller is used as the source.
+ template <class T>
+ static void NotifyOnUI(NotificationType type,
+ int render_process_id,
+ int render_view_id,
+ T* detail);
+
PendingRequestList pending_requests_;
// Collection of temp files downloaded for child processes via
diff --git a/chrome/browser/renderer_host/resource_request_details.cc b/chrome/browser/renderer_host/resource_request_details.cc
index 07183d4..75da0d9 100644
--- a/chrome/browser/renderer_host/resource_request_details.cc
+++ b/chrome/browser/renderer_host/resource_request_details.cc
@@ -4,6 +4,8 @@
#include "chrome/browser/renderer_host/resource_request_details.h"
+#include "chrome/browser/renderer_host/resource_dispatcher_host.h"
+#include "chrome/browser/renderer_host/resource_dispatcher_host_request_info.h"
#include "chrome/browser/worker_host/worker_service.h"
ResourceRequestDetails::ResourceRequestDetails(const net::URLRequest* request,
diff --git a/chrome/browser/renderer_host/resource_request_details.h b/chrome/browser/renderer_host/resource_request_details.h
index 6f53de3..49f716d 100644
--- a/chrome/browser/renderer_host/resource_request_details.h
+++ b/chrome/browser/renderer_host/resource_request_details.h
@@ -12,11 +12,9 @@
#include <string>
-#include "chrome/browser/renderer_host/resource_dispatcher_host.h"
-#include "chrome/browser/renderer_host/resource_dispatcher_host_request_info.h"
-#include "chrome/browser/worker_host/worker_service.h"
#include "googleurl/src/gurl.h"
#include "net/url_request/url_request_status.h"
+#include "webkit/glue/resource_type.h"
namespace net {
class URLRequest;