diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-08 16:24:33 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-08 16:24:33 +0000 |
commit | bf5c2ff3931c43b98095d33f8bc1b98379afe16f (patch) | |
tree | 7c87f5a7f693ac8b5a43cf5f2eebe0ac462b1853 /chrome/browser/renderer_host | |
parent | e9d7b6cf453475ad269785f3775700339c8a03fb (diff) | |
download | chromium_src-bf5c2ff3931c43b98095d33f8bc1b98379afe16f.zip chromium_src-bf5c2ff3931c43b98095d33f8bc1b98379afe16f.tar.gz chromium_src-bf5c2ff3931c43b98095d33f8bc1b98379afe16f.tar.bz2 |
Split out some of the RVHDelegate functions into separate sub-classes. To limit
the scope, this patch just contains those delegate functions implemented only
by TabContents, plus the favicon functions implemented by the FavIconHelper.
The only changes are re-ordering and moving the functions, and changes in the
way that the functions are called through the new optional delegate.
Review URL: http://codereview.chromium.org/149239
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20152 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/renderer_host')
-rw-r--r-- | chrome/browser/renderer_host/render_view_host.cc | 115 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_view_host.h | 16 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_view_host_delegate.cc | 15 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_view_host_delegate.h | 232 | ||||
-rw-r--r-- | chrome/browser/renderer_host/resource_dispatcher_host.cc | 28 |
5 files changed, 260 insertions, 146 deletions
diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc index 4aa5de0..4445099 100644 --- a/chrome/browser/renderer_host/render_view_host.cc +++ b/chrome/browser/renderer_host/render_view_host.cc @@ -522,14 +522,14 @@ void RenderViewHost::SelectAll() { Send(new ViewMsg_SelectAll(routing_id())); } -int RenderViewHost::DownloadImage(const GURL& url, int image_size) { +int RenderViewHost::DownloadFavIcon(const GURL& url, int image_size) { if (!url.is_valid()) { NOTREACHED(); return 0; } static int next_id = 1; int id = next_id++; - Send(new ViewMsg_DownloadImage(routing_id(), id, url, image_size)); + Send(new ViewMsg_DownloadFavIcon(routing_id(), id, url, image_size)); return id; } @@ -725,7 +725,7 @@ void RenderViewHost::OnMessageReceived(const IPC::Message& msg) { OnMsgDidFailProvisionalLoadWithError) IPC_MESSAGE_HANDLER(ViewHostMsg_Find_Reply, OnMsgFindReply) IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateFavIconURL, OnMsgUpdateFavIconURL) - IPC_MESSAGE_HANDLER(ViewHostMsg_DidDownloadImage, OnMsgDidDownloadImage) + IPC_MESSAGE_HANDLER(ViewHostMsg_DidDownloadFavIcon, OnMsgDidDownloadFavIcon) IPC_MESSAGE_HANDLER(ViewHostMsg_ContextMenu, OnMsgContextMenu) IPC_MESSAGE_HANDLER(ViewHostMsg_OpenURL, OnMsgOpenURL) IPC_MESSAGE_HANDLER(ViewHostMsg_DidContentsPreferredWidthChange, @@ -775,8 +775,7 @@ void RenderViewHost::OnMessageReceived(const IPC::Message& msg) { IPC_MESSAGE_HANDLER(ViewHostMsg_UserMetricsRecordAction, OnUserMetricsRecordAction) IPC_MESSAGE_HANDLER(ViewHostMsg_MissingPluginStatus, OnMissingPluginStatus); - IPC_MESSAGE_FORWARD(ViewHostMsg_CrashedPlugin, delegate_, - RenderViewHostDelegate::OnCrashedPlugin); + IPC_MESSAGE_HANDLER(ViewHostMsg_CrashedPlugin, OnCrashedPlugin); IPC_MESSAGE_HANDLER(ViewHostMsg_SendCurrentPageAllSavableResourceLinks, OnReceivedSavableResourceLinksForCurrentPage); IPC_MESSAGE_HANDLER(ViewHostMsg_SendSerializedHtmlData, @@ -977,7 +976,12 @@ void RenderViewHost::OnMsgRequestMove(const gfx::Rect& pos) { void RenderViewHost::OnMsgDidRedirectProvisionalLoad(int32 page_id, const GURL& source_url, const GURL& target_url) { - delegate_->DidRedirectProvisionalLoad(page_id, source_url, target_url); + RenderViewHostDelegate::Resource* resource_delegate = + delegate_->GetResourceDelegate(); + if (resource_delegate) { + resource_delegate->DidRedirectProvisionalLoad(page_id, + source_url, target_url); + } } void RenderViewHost::OnMsgDidStartLoading() { @@ -993,8 +997,12 @@ void RenderViewHost::OnMsgDidLoadResourceFromMemoryCache( const std::string& frame_origin, const std::string& main_frame_origin, const std::string& security_info) { - delegate_->DidLoadResourceFromMemoryCache( - url, frame_origin, main_frame_origin, security_info); + RenderViewHostDelegate::Resource* resource_delegate = + delegate_->GetResourceDelegate(); + if (resource_delegate) { + resource_delegate->DidLoadResourceFromMemoryCache( + url, frame_origin, main_frame_origin, security_info); + } } void RenderViewHost::OnMsgDidStartProvisionalLoadForFrame(bool is_main_frame, @@ -1003,8 +1011,12 @@ void RenderViewHost::OnMsgDidStartProvisionalLoadForFrame(bool is_main_frame, FilterURL(ChildProcessSecurityPolicy::GetInstance(), process()->pid(), &validated_url); - delegate_->DidStartProvisionalLoadForFrame(this, is_main_frame, - validated_url); + RenderViewHostDelegate::Resource* resource_delegate = + delegate_->GetResourceDelegate(); + if (resource_delegate) { + resource_delegate->DidStartProvisionalLoadForFrame(this, is_main_frame, + validated_url); + } } void RenderViewHost::OnMsgDidFailProvisionalLoadWithError( @@ -1016,9 +1028,13 @@ void RenderViewHost::OnMsgDidFailProvisionalLoadWithError( FilterURL(ChildProcessSecurityPolicy::GetInstance(), process()->pid(), &validated_url); - delegate_->DidFailProvisionalLoadWithError(this, is_main_frame, - error_code, validated_url, - showing_repost_interstitial); + RenderViewHostDelegate::Resource* resource_delegate = + delegate_->GetResourceDelegate(); + if (resource_delegate) { + resource_delegate->DidFailProvisionalLoadWithError( + this, is_main_frame, error_code, validated_url, + showing_repost_interstitial); + } } void RenderViewHost::OnMsgFindReply(int request_id, @@ -1026,8 +1042,13 @@ void RenderViewHost::OnMsgFindReply(int request_id, const gfx::Rect& selection_rect, int active_match_ordinal, bool final_update) { - delegate_->OnFindReply(request_id, number_of_matches, selection_rect, - active_match_ordinal, final_update); + RenderViewHostDelegate::BrowserIntegration* integration_delegate = + delegate_->GetBrowserIntegrationDelegate(); + if (integration_delegate) { + integration_delegate->OnFindReply(request_id, number_of_matches, + selection_rect, + active_match_ordinal, final_update); + } // Send a notification to the renderer that we are ready to receive more // results from the scoping effort of the Find operation. The FindInPage @@ -1040,15 +1061,20 @@ void RenderViewHost::OnMsgFindReply(int request_id, void RenderViewHost::OnMsgUpdateFavIconURL(int32 page_id, const GURL& icon_url) { - delegate_->UpdateFavIconURL(this, page_id, icon_url); + RenderViewHostDelegate::FavIcon* favicon_delegate = + delegate_->GetFavIconDelegate(); + if (favicon_delegate) + favicon_delegate->UpdateFavIconURL(this, page_id, icon_url); } -void RenderViewHost::OnMsgDidDownloadImage( - int id, - const GURL& image_url, - bool errored, - const SkBitmap& image) { - delegate_->DidDownloadImage(this, id, image_url, errored, image); +void RenderViewHost::OnMsgDidDownloadFavIcon(int id, + const GURL& image_url, + bool errored, + const SkBitmap& image) { + RenderViewHostDelegate::FavIcon* favicon_delegate = + delegate_->GetFavIconDelegate(); + if (favicon_delegate) + favicon_delegate->DidDownloadFavIcon(this, id, image_url, errored, image); } void RenderViewHost::OnMsgContextMenu(const ContextMenuParams& params) { @@ -1060,7 +1086,8 @@ void RenderViewHost::OnMsgContextMenu(const ContextMenuParams& params) { // directly, don't show them in the context menu. ContextMenuParams validated_params(params); const int renderer_id = process()->pid(); - ChildProcessSecurityPolicy* policy = ChildProcessSecurityPolicy::GetInstance(); + ChildProcessSecurityPolicy* policy = + ChildProcessSecurityPolicy::GetInstance(); // We don't validate |unfiltered_link_url| so that this field can be used // when users want to copy the original link URL. @@ -1124,7 +1151,10 @@ void RenderViewHost::OnMsgForwardMessageToExternalHost( } void RenderViewHost::OnMsgDocumentLoadedInFrame() { - delegate_->DocumentLoadedInFrame(); + RenderViewHostDelegate::Resource* resource_delegate = + delegate_->GetResourceDelegate(); + if (resource_delegate) + resource_delegate->DocumentLoadedInFrame(); } void RenderViewHost::DisassociateFromPopupCount() { @@ -1136,7 +1166,10 @@ void RenderViewHost::PopupNotificationVisibilityChanged(bool visible) { } void RenderViewHost::OnMsgGoToEntryAtOffset(int offset) { - delegate_->GoToEntryAtOffset(offset); + RenderViewHostDelegate::BrowserIntegration* integration_delegate = + delegate_->GetBrowserIntegrationDelegate(); + if (integration_delegate) + integration_delegate->GoToEntryAtOffset(offset); } void RenderViewHost::OnMsgSetTooltipText(const std::wstring& tooltip_text) { @@ -1283,18 +1316,35 @@ void RenderViewHost::UnhandledKeyboardEvent( } void RenderViewHost::OnUserGesture() { - delegate_->OnUserGesture(); + RenderViewHostDelegate::BrowserIntegration* integration_delegate = + delegate_->GetBrowserIntegrationDelegate(); + if (integration_delegate) + integration_delegate->OnUserGesture(); } void RenderViewHost::OnMissingPluginStatus(int status) { - delegate_->OnMissingPluginStatus(status); + RenderViewHostDelegate::BrowserIntegration* integration_delegate = + delegate_->GetBrowserIntegrationDelegate(); + if (integration_delegate) + integration_delegate->OnMissingPluginStatus(status); +} + +void RenderViewHost::OnCrashedPlugin(const FilePath& plugin_path) { + RenderViewHostDelegate::BrowserIntegration* integration_delegate = + delegate_->GetBrowserIntegrationDelegate(); + if (integration_delegate) + integration_delegate->OnCrashedPlugin(plugin_path); } void RenderViewHost::UpdateBackForwardListCount() { int back_list_count = 0, forward_list_count = 0; - delegate_->GetHistoryListCount(&back_list_count, &forward_list_count); - Send(new ViewMsg_UpdateBackForwardListCount( - routing_id(), back_list_count, forward_list_count)); + RenderViewHostDelegate::BrowserIntegration* integration_delegate = + delegate_->GetBrowserIntegrationDelegate(); + if (integration_delegate) { + integration_delegate->GetHistoryListCount(&back_list_count, &forward_list_count); + Send(new ViewMsg_UpdateBackForwardListCount( + routing_id(), back_list_count, forward_list_count)); + } } void RenderViewHost::GetAllSavableResourceLinksForCurrentPage( @@ -1317,7 +1367,10 @@ void RenderViewHost::OnReceivedSavableResourceLinksForCurrentPage( void RenderViewHost::OnDidGetApplicationInfo( int32 page_id, const webkit_glue::WebApplicationInfo& info) { - delegate_->OnDidGetApplicationInfo(page_id, info); + RenderViewHostDelegate::BrowserIntegration* integration_delegate = + delegate_->GetBrowserIntegrationDelegate(); + if (integration_delegate) + integration_delegate->OnDidGetApplicationInfo(page_id, info); } void RenderViewHost::GetSerializedHtmlDataForCurrentPageWithLocalLinks( diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h index e7e6a81..6d39844 100644 --- a/chrome/browser/renderer_host/render_view_host.h +++ b/chrome/browser/renderer_host/render_view_host.h @@ -262,9 +262,10 @@ class RenderViewHost : public RenderWidgetHost, void Delete(); void SelectAll(); - // Downloads an image notifying the delegate appropriately. The returned - // integer uniquely identifies the download for the lifetime of the browser. - int DownloadImage(const GURL& url, int image_size); + // Downloads an image notifying the FavIcon delegate appropriately. The + // returned integer uniquely identifies the download for the lifetime of the + // browser. + int DownloadFavIcon(const GURL& url, int image_size); // Requests application info for the specified page. This is an asynchronous // request. The delegate is notified by way of OnDidGetApplicationInfo when @@ -457,10 +458,10 @@ class RenderViewHost : public RenderWidgetHost, int active_match_ordinal, bool final_update); void OnMsgUpdateFavIconURL(int32 page_id, const GURL& icon_url); - void OnMsgDidDownloadImage(int id, - const GURL& image_url, - bool errored, - const SkBitmap& image_data); + void OnMsgDidDownloadFavIcon(int id, + const GURL& image_url, + bool errored, + const SkBitmap& image_data); void OnMsgContextMenu(const ContextMenuParams& params); void OnMsgOpenURL(const GURL& url, const GURL& referrer, WindowOpenDisposition disposition); @@ -513,6 +514,7 @@ class RenderViewHost : public RenderWidgetHost, void OnUserMetricsRecordAction(const std::wstring& action); void OnMissingPluginStatus(int status); + void OnCrashedPlugin(const FilePath& plugin_path); void OnMessageReceived(IPC::Message* msg) { } void OnReceivedSavableResourceLinksForCurrentPage( diff --git a/chrome/browser/renderer_host/render_view_host_delegate.cc b/chrome/browser/renderer_host/render_view_host_delegate.cc index 4e05a60..b976176 100644 --- a/chrome/browser/renderer_host/render_view_host_delegate.cc +++ b/chrome/browser/renderer_host/render_view_host_delegate.cc @@ -13,10 +13,25 @@ RenderViewHostDelegate::View* RenderViewHostDelegate::GetViewDelegate() const { return NULL; } +RenderViewHostDelegate::BrowserIntegration* +RenderViewHostDelegate::GetBrowserIntegrationDelegate() const { + return NULL; +} + +RenderViewHostDelegate::Resource* +RenderViewHostDelegate::GetResourceDelegate() const { + return NULL; +} + RenderViewHostDelegate::Save* RenderViewHostDelegate::GetSaveDelegate() const { return NULL; } +RenderViewHostDelegate::FavIcon* +RenderViewHostDelegate::GetFavIconDelegate() const { + return NULL; +} + 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 e3fe34a..b1992e8 100644 --- a/chrome/browser/renderer_host/render_view_host_delegate.h +++ b/chrome/browser/renderer_host/render_view_host_delegate.h @@ -65,6 +65,9 @@ struct WebApplicationInfo; // class RenderViewHostDelegate { public: + // View ---------------------------------------------------------------------- + // Functions that can be routed directly to a view-specific class. + class View { public: // The page is trying to open a new page (e.g. a popup window). The @@ -134,7 +137,111 @@ class RenderViewHostDelegate { virtual void UpdatePreferredWidth(int pref_width) = 0; }; + // BrowserIntegration -------------------------------------------------------- + // Functions that integrate with other browser services. + + class BrowserIntegration { + public: + // Notification the user has made a gesture while focus was on the + // page. This is used to avoid uninitiated user downloads (aka carpet + // bombing), see DownloadRequestManager for details. + virtual void OnUserGesture() = 0; + + // A find operation in the current page completed. + virtual void OnFindReply(int request_id, + int number_of_matches, + const gfx::Rect& selection_rect, + int active_match_ordinal, + bool final_update) = 0; + + // Navigate to the history entry for the given offset from the current + // position within the NavigationController. Makes no change if offset is + // not valid. + virtual void GoToEntryAtOffset(int offset) = 0; + + // The page requests the size of the back and forward lists + // within the NavigationController. + virtual void GetHistoryListCount(int* back_list_count, + int* forward_list_count) = 0; + + // Notification when default plugin updates status of the missing plugin. + virtual void OnMissingPluginStatus(int status) = 0; + + // Notification from the renderer that a plugin instance has crashed. + // + // BrowserIntegration isn't necessarily the best place for this, if you + // need to implement this function somewhere that doesn't need any other + // BrowserIntegration callbacks, feel free to move it elsewhere. + virtual void OnCrashedPlugin(const FilePath& plugin_path) = 0; + + // Notification that a worker process has crashed. + virtual void OnCrashedWorker() = 0; + + // Notification that a request for install info has completed. + virtual void OnDidGetApplicationInfo( + int32 page_id, + const webkit_glue::WebApplicationInfo& app_info) = 0; + }; + + // Resource ------------------------------------------------------------------ + // Notifications of resource loading events. + + class Resource { + public: + // The RenderView is starting a provisional load. + virtual void DidStartProvisionalLoadForFrame( + RenderViewHost* render_view_host, + bool is_main_frame, + 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. + // + // The pointer ownership is NOT transferred. + virtual void DidStartReceivingResourceResponse( + 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. + // + // The pointer ownership is NOT transferred. + virtual void DidRedirectResource(ResourceRequestDetails* 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; + + // The RenderView failed a provisional load with an error. + virtual void DidFailProvisionalLoadWithError( + RenderViewHost* render_view_host, + 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() = 0; + }; + + // Save ---------------------------------------------------------------------- // Interface for saving web pages. + class Save { public: // Notification that we get when we receive all savable links of @@ -157,10 +264,38 @@ class RenderViewHostDelegate { int32 status) = 0; }; + // FavIcon ------------------------------------------------------------------- + // Interface for the renderer to supply favicon information. + + class FavIcon { + public: + // An image that was requested to be downloaded by DownloadImage has + // completed. + // + // TODO(brettw) this should be renamed DidDownloadFavIcon, and the RVH + // function, IPC message, and the RenderView function DownloadImage should + // all be named DownloadFavIcon. + virtual void DidDownloadFavIcon(RenderViewHost* render_view_host, + int id, + const GURL& image_url, + bool errored, + const SkBitmap& image) = 0; + + // The URL for the FavIcon of a page has changed. + virtual void UpdateFavIconURL(RenderViewHost* render_view_host, + int32 page_id, + const GURL& icon_url) = 0; + }; + + // --------------------------------------------------------------------------- + // Returns the current delegate associated with a feature. May return NULL if // there is no corresponding delegate. virtual View* GetViewDelegate() const; + virtual BrowserIntegration* GetBrowserIntegrationDelegate() const; + virtual Resource* GetResourceDelegate() const; virtual Save* GetSaveDelegate() const; + virtual FavIcon* GetFavIconDelegate() const; // Gets the URL that is currently being displayed, if there is one. virtual const GURL& GetURL() const; @@ -223,64 +358,6 @@ class RenderViewHostDelegate { // notion of the throbber stopping. virtual void DidStopLoading(RenderViewHost* render_view_host) {} - // The RenderView is starting a provisional load. - virtual void DidStartProvisionalLoadForFrame(RenderViewHost* render_view_host, - bool is_main_frame, - const GURL& url) {} - - // 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. - // - // The pointer ownership is NOT transferred. - virtual void DidStartReceivingResourceResponse( - ResourceRequestDetails* details) {} - - // Sent when a provisional load is redirected. - virtual void DidRedirectProvisionalLoad(int32 page_id, - const GURL& source_url, - const GURL& target_url) {} - - // 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. - // - // The pointer ownership is NOT transferred. - virtual void DidRedirectResource(ResourceRequestDetails* details) {} - - // 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) {} - - // The RenderView failed a provisional load with an error. - virtual void DidFailProvisionalLoadWithError( - RenderViewHost* render_view_host, - bool is_main_frame, - int error_code, - const GURL& url, - bool showing_repost_interstitial) {} - - // The URL for the FavIcon of a page has changed. - virtual void UpdateFavIconURL(RenderViewHost* render_view_host, - int32 page_id, const GURL& icon_url) {} - - // An image that was requested to be downloaded by DownloadImage has - // completed. - virtual void DidDownloadImage(RenderViewHost* render_view_host, - int id, - const GURL& image_url, - bool errored, - const SkBitmap& image) {} - // The page wants to open a URL with the specified disposition. virtual void RequestOpenURL(const GURL& url, const GURL& referrer, @@ -305,19 +382,6 @@ class RenderViewHostDelegate { const std::string& origin, const std::string& target) {} - // Notification that a document has been loaded in a frame. - virtual void DocumentLoadedInFrame() {} - - // Navigate to the history entry for the given offset from the current - // position within the NavigationController. Makes no change if offset is - // not valid. - virtual void GoToEntryAtOffset(int offset) {} - - // The page requests the size of the back and forward lists - // within the NavigationController. - virtual void GetHistoryListCount(int* back_list_count, - int* forward_list_count) {} - // A file chooser should be shown. virtual void RunFileChooser(bool multiple_files, const string16& title, @@ -388,15 +452,6 @@ class RenderViewHostDelegate { // associated with the owning render view host. virtual WebPreferences GetWebkitPrefs(); - // Notification when default plugin updates status of the missing plugin. - virtual void OnMissingPluginStatus(int status) {} - - // Notification from the renderer that a plugin instance has crashed. - virtual void OnCrashedPlugin(const FilePath& plugin_path) {} - - // Notification that a worker process has crashed. - virtual void OnCrashedWorker() {} - // Notification from the renderer that JS runs out of memory. virtual void OnJSOutOfMemory() {} @@ -438,26 +493,9 @@ class RenderViewHostDelegate { // Notification that the RenderViewHost's load state changed. virtual void LoadStateChanged(const GURL& url, net::LoadState load_state) {} - // Notification that a request for install info has completed. - virtual void OnDidGetApplicationInfo( - int32 page_id, - const webkit_glue::WebApplicationInfo& app_info) {} - - // Notification the user has made a gesture while focus was on the - // page. This is used to avoid uninitiated user downloads (aka carpet - // bombing), see DownloadRequestManager for details. - virtual void OnUserGesture() {} - // Returns true if this view is used to host an external tab container. virtual bool IsExternalTabContainer() const; - // A find operation in the current page completed. - virtual void OnFindReply(int request_id, - int number_of_matches, - const gfx::Rect& selection_rect, - int active_match_ordinal, - bool final_update) {} - // The RenderView has inserted one css file into page. virtual void DidInsertCSS() {} }; diff --git a/chrome/browser/renderer_host/resource_dispatcher_host.cc b/chrome/browser/renderer_host/resource_dispatcher_host.cc index 28a64a3..16d8a62 100644 --- a/chrome/browser/renderer_host/resource_dispatcher_host.cc +++ b/chrome/browser/renderer_host/resource_dispatcher_host.cc @@ -114,6 +114,9 @@ const int kMaxOutstandingRequestsCostPerProcess = 26214400; // constructed on the IO thread and run in the UI thread. class NotificationTask : public Task { public: + typedef void (RenderViewHostDelegate::Resource::* ResourceFunction) + (ResourceRequestDetails*); + // Supply the originating URLRequest, a function on RenderViewHostDelegate // to call, and the details to use as the parameter to the given function. // @@ -121,29 +124,34 @@ class NotificationTask : public Task { // allocated on the heap. NotificationTask( URLRequest* request, - void (RenderViewHostDelegate::* function)(ResourceRequestDetails*), + ResourceFunction function, ResourceRequestDetails* details) : function_(function), details_(details) { if (!ResourceDispatcherHost::RenderViewForRequest(request, &render_process_host_id_, - &render_view_host_id_)) + &render_view_host_id_)) { NOTREACHED(); + } } virtual void Run() { RenderViewHost* rvh = RenderViewHost::FromID(render_process_host_id_, render_view_host_id_); - if (rvh) - (rvh->delegate()->*function_)(details_.get()); + if (rvh) { + RenderViewHostDelegate::Resource* resource_delegate = + rvh->delegate()->GetResourceDelegate(); + if (resource_delegate) + (resource_delegate->*function_)(details_.get()); + } } private: int render_process_host_id_; int render_view_host_id_; - // The function to call on RenderViewHostDelegate on the UI thread. - void (RenderViewHostDelegate::* function_)(ResourceRequestDetails*); + // The function to call on RenderViewHostDelegate::Resource on the UI thread. + ResourceFunction function_; // The details for the notification. scoped_ptr<ResourceRequestDetails> details_; @@ -1392,7 +1400,7 @@ void ResourceDispatcherHost::NotifyResponseStarted(URLRequest* request, // Notify the observers on the UI thread. ui_loop_->PostTask(FROM_HERE, new NotificationTask(request, - &RenderViewHostDelegate::DidStartReceivingResourceResponse, + &RenderViewHostDelegate::Resource::DidStartReceivingResourceResponse, new ResourceRequestDetails(request, GetCertID(request, process_id)))); } @@ -1417,10 +1425,8 @@ void ResourceDispatcherHost::NotifyReceivedRedirect(URLRequest* request, // Notify the observers on the UI thread. ui_loop_->PostTask(FROM_HERE, new NotificationTask(request, - &RenderViewHostDelegate::DidRedirectResource, - new ResourceRedirectDetails(request, - cert_id, - new_url))); + &RenderViewHostDelegate::Resource::DidRedirectResource, + new ResourceRedirectDetails(request, cert_id, new_url))); } namespace { |