diff options
-rw-r--r-- | chrome/browser/renderer_host/render_view_host.cc | 196 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_view_host.h | 26 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_view_host_delegate.cc | 8 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_view_host_delegate.h | 73 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_view_host_notification_task.h | 61 | ||||
-rw-r--r-- | chrome/browser/renderer_host/resource_dispatcher_host.cc | 40 | ||||
-rw-r--r-- | chrome/browser/renderer_host/resource_dispatcher_host.h | 10 | ||||
-rw-r--r-- | chrome/browser/renderer_host/resource_request_details.cc | 2 | ||||
-rw-r--r-- | chrome/browser/renderer_host/resource_request_details.h | 4 | ||||
-rw-r--r-- | chrome/browser/ssl/ssl_manager.cc | 11 | ||||
-rw-r--r-- | chrome/browser/tab_contents/tab_contents.cc | 345 | ||||
-rw-r--r-- | chrome/browser/tab_contents/tab_contents.h | 58 | ||||
-rw-r--r-- | chrome/common/notification_type.h | 4 |
13 files changed, 320 insertions, 518 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; diff --git a/chrome/browser/ssl/ssl_manager.cc b/chrome/browser/ssl/ssl_manager.cc index 597d3ca..7c9cd8f 100644 --- a/chrome/browser/ssl/ssl_manager.cc +++ b/chrome/browser/ssl/ssl_manager.cc @@ -11,12 +11,15 @@ #include "chrome/browser/net/url_request_tracking.h" #include "chrome/browser/prefs/pref_service.h" #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/ssl/ssl_cert_error_handler.h" #include "chrome/browser/ssl/ssl_policy.h" #include "chrome/browser/ssl/ssl_request_info.h" #include "chrome/browser/tab_contents/navigation_controller.h" #include "chrome/browser/tab_contents/navigation_entry.h" #include "chrome/browser/tab_contents/provisional_load_details.h" +#include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/common/notification_service.h" #include "chrome/common/pref_names.h" #include "grit/generated_resources.h" @@ -119,9 +122,9 @@ SSLManager::SSLManager(NavigationController* controller) registrar_.Add(this, NotificationType::FAIL_PROVISIONAL_LOAD_WITH_ERROR, Source<NavigationController>(controller_)); registrar_.Add(this, NotificationType::RESOURCE_RESPONSE_STARTED, - Source<NavigationController>(controller_)); + Source<RenderViewHostDelegate>(controller_->tab_contents())); registrar_.Add(this, NotificationType::RESOURCE_RECEIVED_REDIRECT, - Source<NavigationController>(controller_)); + Source<RenderViewHostDelegate>(controller_->tab_contents())); registrar_.Add(this, NotificationType::LOAD_FROM_MEMORY_CACHE, Source<NavigationController>(controller_)); registrar_.Add(this, NotificationType::SSL_INTERNAL_STATE_CHANGED, @@ -205,8 +208,6 @@ void SSLManager::Observe(NotificationType type, } void SSLManager::DidLoadFromMemoryCache(LoadFromMemoryCacheDetails* details) { - DCHECK(details); - // Simulate loading this resource through the usual path. // Note that we specify SUB_RESOURCE as the resource type as WebCore only // caches sub-resources. @@ -226,8 +227,6 @@ void SSLManager::DidLoadFromMemoryCache(LoadFromMemoryCacheDetails* details) { } void SSLManager::DidStartResourceResponse(ResourceRequestDetails* details) { - DCHECK(details); - scoped_refptr<SSLRequestInfo> info(new SSLRequestInfo( details->url(), details->resource_type(), diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc index 65e24e2..6ab990b 100644 --- a/chrome/browser/tab_contents/tab_contents.cc +++ b/chrome/browser/tab_contents/tab_contents.cc @@ -10,6 +10,7 @@ #include "app/resource_bundle.h" #include "base/auto_reset.h" #include "base/metrics/histogram.h" +#include "base/metrics/stats_counters.h" #include "base/string16.h" #include "base/string_util.h" #include "base/time.h" @@ -21,6 +22,7 @@ #include "chrome/browser/browser_process.h" #include "chrome/browser/browser_shutdown.h" #include "chrome/browser/character_encoding.h" +#include "chrome/browser/child_process_security_policy.h" #include "chrome/browser/content_settings/content_settings_details.h" #include "chrome/browser/content_settings/host_content_settings_map.h" #include "chrome/browser/debugger/devtools_manager.h" @@ -44,6 +46,7 @@ #include "chrome/browser/load_from_memory_cache_details.h" #include "chrome/browser/load_notification_details.h" #include "chrome/browser/metrics/metric_event_duration_details.h" +#include "chrome/browser/metrics/user_metrics.h" #include "chrome/browser/modal_html_dialog_delegate.h" #include "chrome/browser/omnibox_search_hint.h" #include "chrome/browser/platform_util.h" @@ -548,6 +551,36 @@ void TabContents::RegisterUserPrefs(PrefService* prefs) { IDS_STATIC_ENCODING_LIST); } +bool TabContents::OnMessageReceived(const IPC::Message& message) { + bool handled = true; + bool message_is_ok = true; + IPC_BEGIN_MESSAGE_MAP_EX(TabContents, message, message_is_ok) + IPC_MESSAGE_HANDLER(ViewHostMsg_DidStartProvisionalLoadForFrame, + OnDidStartProvisionalLoadForFrame) + IPC_MESSAGE_HANDLER(ViewHostMsg_DidRedirectProvisionalLoad, + OnDidRedirectProvisionalLoad) + IPC_MESSAGE_HANDLER(ViewHostMsg_DidFailProvisionalLoadWithError, + OnDidFailProvisionalLoadWithError) + IPC_MESSAGE_HANDLER(ViewHostMsg_DidLoadResourceFromMemoryCache, + OnDidLoadResourceFromMemoryCache) + IPC_MESSAGE_HANDLER(ViewHostMsg_DidDisplayInsecureContent, + OnDidDisplayInsecureContent) + IPC_MESSAGE_HANDLER(ViewHostMsg_DidRunInsecureContent, + OnDidRunInsecureContent) + IPC_MESSAGE_HANDLER(ViewHostMsg_DocumentLoadedInFrame, + OnDocumentLoadedInFrame) + IPC_MESSAGE_HANDLER(ViewHostMsg_DidFinishLoad, OnDidFinishLoad) + IPC_MESSAGE_UNHANDLED(handled = false) + IPC_END_MESSAGE_MAP_EX() + + if (!message_is_ok) { + UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_RVD")); + GetRenderProcessHost()->ReceivedBadMessage(); + } + + return handled; +} + // Returns true if contains content rendered by an extension. bool TabContents::HostsExtension() const { return GetURL().SchemeIs(chrome::kExtensionScheme); @@ -1556,6 +1589,159 @@ void TabContents::ViewSource() { delegate_->ViewSourceForTab(this, active_entry->url()); } +void TabContents::OnDidStartProvisionalLoadForFrame(int64 frame_id, + bool is_main_frame, + const GURL& url) { + bool is_error_page = (url.spec() == chrome::kUnreachableWebDataURL); + GURL validated_url(url); + render_view_host()->FilterURL(ChildProcessSecurityPolicy::GetInstance(), + GetRenderProcessHost()->id(), &validated_url); + + ProvisionalLoadDetails details( + is_main_frame, + controller_.IsURLInPageNavigation(validated_url), + validated_url, std::string(), false, is_error_page, frame_id); + NotificationService::current()->Notify( + NotificationType::FRAME_PROVISIONAL_LOAD_START, + Source<NavigationController>(&controller_), + Details<ProvisionalLoadDetails>(&details)); + if (is_main_frame) { + // If we're displaying a network error page do not reset the content + // settings delegate's cookies so the user has a chance to modify cookie + // settings. + if (!is_error_page) + content_settings_delegate_->ClearCookieSpecificContentSettings(); + content_settings_delegate_->ClearGeolocationContentSettings(); + } +} + +void TabContents::OnDidRedirectProvisionalLoad(int32 page_id, + const GURL& source_url, + const GURL& target_url) { + NavigationEntry* entry; + if (page_id == -1) + entry = controller_.pending_entry(); + else + entry = controller_.GetEntryWithPageID(GetSiteInstance(), page_id); + if (!entry || entry->url() != source_url) + return; + entry->set_url(target_url); +} + +void TabContents::OnDidFailProvisionalLoadWithError( + 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); + render_view_host()->FilterURL(ChildProcessSecurityPolicy::GetInstance(), + GetRenderProcessHost()->id(), &validated_url); + + if (net::ERR_ABORTED == error_code) { + // EVIL HACK ALERT! Ignore failed loads when we're showing interstitials. + // This means that the interstitial won't be torn down properly, which is + // bad. But if we have an interstitial, go back to another tab type, and + // then load the same interstitial again, we could end up getting the first + // interstitial's "failed" message (as a result of the cancel) when we're on + // the second one. + // + // We can't tell this apart, so we think we're tearing down the current page + // which will cause a crash later one. There is also some code in + // RenderViewHostManager::RendererAbortedProvisionalLoad that is commented + // out because of this problem. + // + // http://code.google.com/p/chromium/issues/detail?id=2855 + // Because this will not tear down the interstitial properly, if "back" is + // back to another tab type, the interstitial will still be somewhat alive + // in the previous tab type. If you navigate somewhere that activates the + // tab with the interstitial again, you'll see a flash before the new load + // commits of the interstitial page. + if (showing_interstitial_page()) { + LOG(WARNING) << "Discarding message during interstitial."; + return; + } + + // This will discard our pending entry if we cancelled the load (e.g., if we + // decided to download the file instead of load it). Only discard the + // pending entry if the URLs match, otherwise the user initiated a navigate + // before the page loaded so that the discard would discard the wrong entry. + NavigationEntry* pending_entry = controller_.pending_entry(); + if (pending_entry && pending_entry->url() == validated_url) { + controller_.DiscardNonCommittedEntries(); + // Update the URL display. + NotifyNavigationStateChanged(TabContents::INVALIDATE_URL); + } + + render_manager_.RendererAbortedProvisionalLoad(render_view_host()); + } + + // Send out a notification that we failed a provisional load with an error. + ProvisionalLoadDetails details( + is_main_frame, controller_.IsURLInPageNavigation(validated_url), + validated_url, std::string(), false, false, frame_id); + details.set_error_code(error_code); + + NotificationService::current()->Notify( + NotificationType::FAIL_PROVISIONAL_LOAD_WITH_ERROR, + Source<NavigationController>(&controller_), + Details<ProvisionalLoadDetails>(&details)); +} + +void TabContents::OnDidLoadResourceFromMemoryCache( + 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(); + + // Send out a notification that we loaded a resource from our memory cache. + int cert_id = 0, cert_status = 0, security_bits = -1, connection_status = 0; + SSLManager::DeserializeSecurityInfo(security_info, + &cert_id, &cert_status, + &security_bits, + &connection_status); + LoadFromMemoryCacheDetails details(url, frame_origin, main_frame_origin, + GetRenderProcessHost()->id(), cert_id, + cert_status); + + NotificationService::current()->Notify( + NotificationType::LOAD_FROM_MEMORY_CACHE, + Source<NavigationController>(&controller_), + Details<LoadFromMemoryCacheDetails>(&details)); +} + +void TabContents::OnDidDisplayInsecureContent() { + displayed_insecure_content_ = true; + SSLManager::NotifySSLInternalStateChanged(); +} + +void TabContents::OnDidRunInsecureContent( + const std::string& security_origin) { + controller_.ssl_manager()->DidRunInsecureContent(security_origin); +} + +void TabContents::OnDocumentLoadedInFrame(int64 frame_id) { + controller_.DocumentLoadedInFrame(); + NotificationService::current()->Notify( + NotificationType::FRAME_DOM_CONTENT_LOADED, + Source<NavigationController>(&controller_), + Details<int64>(&frame_id)); +} + +void TabContents::OnDidFinishLoad(int64 frame_id) { + NotificationService::current()->Notify( + NotificationType::FRAME_DID_FINISH_LOAD, + Source<NavigationController>(&controller_), + Details<int64>(&frame_id)); +} + // Notifies the RenderWidgetHost instance about the fact that the page is // loading, or done loading and calls the base implementation. void TabContents::SetIsLoading(bool is_loading, @@ -2190,148 +2376,6 @@ void TabContents::OnInstantSupportDetermined(int32 page_id, bool result) { delegate()->OnInstantSupportDetermined(page_id, result); } -void TabContents::DidStartProvisionalLoadForFrame( - RenderViewHost* render_view_host, - int64 frame_id, - bool is_main_frame, - bool is_error_page, - const GURL& url) { - ProvisionalLoadDetails details(is_main_frame, - controller_.IsURLInPageNavigation(url), - url, std::string(), false, - is_error_page, frame_id); - NotificationService::current()->Notify( - NotificationType::FRAME_PROVISIONAL_LOAD_START, - Source<NavigationController>(&controller_), - Details<ProvisionalLoadDetails>(&details)); - if (is_main_frame) { - // If we're displaying a network error page do not reset the content - // settings delegate's cookies so the user has a chance to modify cookie - // settings. - if (!is_error_page) - content_settings_delegate_->ClearCookieSpecificContentSettings(); - content_settings_delegate_->ClearGeolocationContentSettings(); - } -} - -void TabContents::DidStartReceivingResourceResponse( - const ResourceRequestDetails& details) { - NotificationService::current()->Notify( - NotificationType::RESOURCE_RESPONSE_STARTED, - Source<NavigationController>(&controller()), - Details<const ResourceRequestDetails>(&details)); -} - -void TabContents::DidRedirectResource( - const ResourceRedirectDetails& details) { - NotificationService::current()->Notify( - NotificationType::RESOURCE_RECEIVED_REDIRECT, - Source<NavigationController>(&controller()), - Details<const ResourceRequestDetails>(&details)); -} - -void TabContents::DidLoadResourceFromMemoryCache( - const GURL& url, - const std::string& frame_origin, - const std::string& main_frame_origin, - const std::string& security_info) { - // Send out a notification that we loaded a resource from our memory cache. - int cert_id = 0, cert_status = 0, security_bits = -1, connection_status = 0; - SSLManager::DeserializeSecurityInfo(security_info, - &cert_id, &cert_status, - &security_bits, - &connection_status); - LoadFromMemoryCacheDetails details(url, frame_origin, main_frame_origin, - GetRenderProcessHost()->id(), cert_id, - cert_status); - - NotificationService::current()->Notify( - NotificationType::LOAD_FROM_MEMORY_CACHE, - Source<NavigationController>(&controller_), - Details<LoadFromMemoryCacheDetails>(&details)); -} - -void TabContents::DidDisplayInsecureContent() { - displayed_insecure_content_ = true; - SSLManager::NotifySSLInternalStateChanged(); -} - -void TabContents::DidRunInsecureContent(const std::string& security_origin) { - controller_.ssl_manager()->DidRunInsecureContent(security_origin); -} - -void TabContents::DidFailProvisionalLoadWithError( - RenderViewHost* render_view_host, - int64 frame_id, - bool is_main_frame, - int error_code, - const GURL& url, - bool showing_repost_interstitial) { - if (net::ERR_ABORTED == error_code) { - // EVIL HACK ALERT! Ignore failed loads when we're showing interstitials. - // This means that the interstitial won't be torn down properly, which is - // bad. But if we have an interstitial, go back to another tab type, and - // then load the same interstitial again, we could end up getting the first - // interstitial's "failed" message (as a result of the cancel) when we're on - // the second one. - // - // We can't tell this apart, so we think we're tearing down the current page - // which will cause a crash later one. There is also some code in - // RenderViewHostManager::RendererAbortedProvisionalLoad that is commented - // out because of this problem. - // - // http://code.google.com/p/chromium/issues/detail?id=2855 - // Because this will not tear down the interstitial properly, if "back" is - // back to another tab type, the interstitial will still be somewhat alive - // in the previous tab type. If you navigate somewhere that activates the - // tab with the interstitial again, you'll see a flash before the new load - // commits of the interstitial page. - if (showing_interstitial_page()) { - LOG(WARNING) << "Discarding message during interstitial."; - return; - } - - // This will discard our pending entry if we cancelled the load (e.g., if we - // decided to download the file instead of load it). Only discard the - // pending entry if the URLs match, otherwise the user initiated a navigate - // before the page loaded so that the discard would discard the wrong entry. - NavigationEntry* pending_entry = controller_.pending_entry(); - if (pending_entry && pending_entry->url() == url) { - controller_.DiscardNonCommittedEntries(); - // Update the URL display. - NotifyNavigationStateChanged(TabContents::INVALIDATE_URL); - } - - render_manager_.RendererAbortedProvisionalLoad(render_view_host); - } - - // Send out a notification that we failed a provisional load with an error. - ProvisionalLoadDetails details(is_main_frame, - controller_.IsURLInPageNavigation(url), - url, std::string(), false, false, frame_id); - details.set_error_code(error_code); - - NotificationService::current()->Notify( - NotificationType::FAIL_PROVISIONAL_LOAD_WITH_ERROR, - Source<NavigationController>(&controller_), - Details<ProvisionalLoadDetails>(&details)); -} - -void TabContents::DocumentLoadedInFrame(int64 frame_id) { - controller_.DocumentLoadedInFrame(); - NotificationService::current()->Notify( - NotificationType::FRAME_DOM_CONTENT_LOADED, - Source<NavigationController>(&controller_), - Details<int64>(&frame_id)); -} - -void TabContents::DidFinishLoad(int64 frame_id) { - NotificationService::current()->Notify( - NotificationType::FRAME_DID_FINISH_LOAD, - Source<NavigationController>(&controller_), - Details<int64>(&frame_id)); -} - void TabContents::OnContentSettingsAccessed(bool content_was_blocked) { if (delegate_) delegate_->OnContentSettingsChange(this); @@ -2351,10 +2395,6 @@ RenderViewHostDelegate::BrowserIntegration* return this; } -RenderViewHostDelegate::Resource* TabContents::GetResourceDelegate() { - return this; -} - RenderViewHostDelegate::ContentSettings* TabContents::GetContentSettingsDelegate() { return content_settings_delegate_.get(); @@ -2774,19 +2814,6 @@ void TabContents::DocumentOnLoadCompletedInMainFrame( Details<int>(&page_id)); } -void TabContents::DidRedirectProvisionalLoad(int32 page_id, - const GURL& source_url, - const GURL& target_url) { - NavigationEntry* entry; - if (page_id == -1) - entry = controller_.pending_entry(); - else - entry = controller_.GetEntryWithPageID(GetSiteInstance(), page_id); - if (!entry || entry->url() != source_url) - return; - entry->set_url(target_url); -} - void TabContents::RequestOpenURL(const GURL& url, const GURL& referrer, WindowOpenDisposition disposition) { if (render_manager_.dom_ui()) { diff --git a/chrome/browser/tab_contents/tab_contents.h b/chrome/browser/tab_contents/tab_contents.h index a791cc1..79ab5f7 100644 --- a/chrome/browser/tab_contents/tab_contents.h +++ b/chrome/browser/tab_contents/tab_contents.h @@ -51,10 +51,6 @@ namespace printing { class PrintViewManager; } -namespace IPC { -class Message; -} - namespace webkit_glue { struct PasswordForm; } @@ -94,7 +90,6 @@ class TabContents : public PageNavigator, public NotificationObserver, public RenderViewHostDelegate, public RenderViewHostDelegate::BrowserIntegration, - public RenderViewHostDelegate::Resource, public RenderViewHostManager::Delegate, public JavaScriptAppModalDialogDelegate, public ImageLoadingTracker::Observer, @@ -785,6 +780,27 @@ class TabContents : public PageNavigator, // Used to access RVH Delegates. friend class PrerenderManager; + // Message handlers. + void OnDidStartProvisionalLoadForFrame(int64 frame_id, + bool main_frame, + const GURL& url); + void OnDidRedirectProvisionalLoad(int32 page_id, + const GURL& source_url, + const GURL& target_url); + void OnDidFailProvisionalLoadWithError(int64 frame_id, + bool main_frame, + int error_code, + const GURL& url, + bool showing_repost_interstitial); + void OnDidLoadResourceFromMemoryCache(const GURL& url, + const std::string& frame_origin, + const std::string& main_frame_origin, + const std::string& security_info); + void OnDidDisplayInsecureContent(); + void OnDidRunInsecureContent(const std::string& security_origin); + void OnDocumentLoadedInFrame(int64 frame_id); + void OnDidFinishLoad(int64 frame_id); + // Changes the IsLoading state and notifies delegate as needed // |details| is used to provide details on the load that just finished // (but can be null if not applicable). Can be overridden. @@ -920,43 +936,12 @@ class TabContents : public PageNavigator, const std::vector<std::string>& suggestions); virtual void OnInstantSupportDetermined(int32 page_id, bool result); - // RenderViewHostDelegate::Resource implementation. - virtual void DidStartProvisionalLoadForFrame(RenderViewHost* render_view_host, - int64 frame_id, - bool is_main_frame, - bool is_error_page, - const GURL& url); - virtual void DidStartReceivingResourceResponse( - const ResourceRequestDetails& details); - virtual void DidRedirectProvisionalLoad(int32 page_id, - const GURL& source_url, - const GURL& target_url); - virtual void DidRedirectResource( - const ResourceRedirectDetails& details); - virtual void DidLoadResourceFromMemoryCache( - const GURL& url, - const std::string& frame_origin, - const std::string& main_frame_origin, - const std::string& security_info); - virtual void DidDisplayInsecureContent(); - virtual void DidRunInsecureContent(const std::string& security_origin); - virtual void DidFailProvisionalLoadWithError( - RenderViewHost* render_view_host, - int64 frame_id, - bool is_main_frame, - int error_code, - const GURL& url, - bool showing_repost_interstitial); - virtual void DocumentLoadedInFrame(int64 frame_id); - virtual void DidFinishLoad(int64 frame_id); - // RenderViewHostDelegate implementation. virtual RenderViewHostDelegate::View* GetViewDelegate(); virtual RenderViewHostDelegate::RendererManagement* GetRendererManagementDelegate(); virtual RenderViewHostDelegate::BrowserIntegration* GetBrowserIntegrationDelegate(); - virtual RenderViewHostDelegate::Resource* GetResourceDelegate(); virtual RenderViewHostDelegate::ContentSettings* GetContentSettingsDelegate(); virtual RenderViewHostDelegate::Save* GetSaveDelegate(); virtual RenderViewHostDelegate::Printing* GetPrintingDelegate(); @@ -968,6 +953,7 @@ class TabContents : public PageNavigator, virtual AutomationResourceRoutingDelegate* GetAutomationResourceRoutingDelegate(); virtual TabContents* GetAsTabContents(); + virtual bool OnMessageReceived(const IPC::Message& message); virtual ViewType::Type GetRenderViewType() const; virtual int GetBrowserWindowID() const; virtual void RenderViewCreated(RenderViewHost* render_view_host); diff --git a/chrome/common/notification_type.h b/chrome/common/notification_type.h index e7484aa..8dbc2a3 100644 --- a/chrome/common/notification_type.h +++ b/chrome/common/notification_type.h @@ -138,13 +138,13 @@ class NotificationType { FAIL_PROVISIONAL_LOAD_WITH_ERROR, // A response has been received for a resource request. The source will be - // a Source<NavigationController> corresponding to the tab in which the + // a Source<RenderViewHostDelegate> corresponding to the tab in which the // request was issued. Details in the form of a ResourceRequestDetails // object are provided. RESOURCE_RESPONSE_STARTED, // A redirect was received while requesting a resource. The source will be - // a Source<NavigationController> corresponding to the tab in which the + // a Source<RenderViewHostDelegate> corresponding to the tab in which the // request was issued. Details in the form of a ResourceRedirectDetails // are provided. RESOURCE_RECEIVED_REDIRECT, |