diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-26 16:41:34 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-26 16:41:34 +0000 |
commit | 056de2d024b7fe311b6ad5924e831e7c44816e68 (patch) | |
tree | aedf3f5320fab373add37a3e4b4ce2d927e73d20 /chrome | |
parent | 41da4799559e2e8c2b8434dc74bee5f1fa030dc1 (diff) | |
download | chromium_src-056de2d024b7fe311b6ad5924e831e7c44816e68.zip chromium_src-056de2d024b7fe311b6ad5924e831e7c44816e68.tar.gz chromium_src-056de2d024b7fe311b6ad5924e831e7c44816e68.tar.bz2 |
Remove dependency on NavigationEntry from RenderViewHost. The code for
converting a NavigationEntry to a Navigate message is now in TabContents and
it will send the params rather than the NavigationEntry to the RenderViewHost.
I also removed "virtual" fron a bunch of functions that were never overridden.
Review URL: http://codereview.chromium.org/147128
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19369 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/renderer_host/render_view_host.cc | 50 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_view_host.h | 48 | ||||
-rw-r--r-- | chrome/browser/tab_contents/tab_contents.cc | 15 |
3 files changed, 47 insertions, 66 deletions
diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc index 8833c41..0d3d2f9 100644 --- a/chrome/browser/renderer_host/render_view_host.cc +++ b/chrome/browser/renderer_host/render_view_host.cc @@ -22,9 +22,7 @@ #include "chrome/browser/renderer_host/render_view_host_delegate.h" #include "chrome/browser/renderer_host/render_widget_host.h" #include "chrome/browser/renderer_host/render_widget_host_view.h" -#include "chrome/browser/tab_contents/navigation_entry.h" #include "chrome/browser/tab_contents/site_instance.h" -#include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/common/bindings_policy.h" #include "chrome/common/notification_service.h" #include "chrome/common/notification_type.h" @@ -207,32 +205,12 @@ void RenderViewHost::SetRendererPrefs( Send(new ViewMsg_SetRendererPrefs(routing_id(), renderer_prefs)); } -void RenderViewHost::NavigateToEntry(const NavigationEntry& entry, - bool is_reload) { - ViewMsg_Navigate_Params params; - MakeNavigateParams(entry, is_reload, ¶ms); - - ChildProcessSecurityPolicy::GetInstance()->GrantRequestURL( - process()->pid(), params.url); - - DoNavigate(entry.url(), new ViewMsg_Navigate(routing_id(), params)); -} - -void RenderViewHost::NavigateToURL(const GURL& url) { - ViewMsg_Navigate_Params params; - params.page_id = -1; - params.url = url; - params.transition = PageTransition::LINK; - params.reload = false; - +void RenderViewHost::Navigate(const ViewMsg_Navigate_Params& params) { ChildProcessSecurityPolicy::GetInstance()->GrantRequestURL( process()->pid(), params.url); - DoNavigate(url, new ViewMsg_Navigate(routing_id(), params)); -} + ViewMsg_Navigate* nav_message = new ViewMsg_Navigate(routing_id(), params); -void RenderViewHost::DoNavigate(const GURL& url, - ViewMsg_Navigate* nav_message) { // Only send the message if we aren't suspended at the start of a cross-site // request. if (navigations_suspended_) { @@ -256,11 +234,20 @@ void RenderViewHost::DoNavigate(const GURL& url, // // WebKit doesn't send throb notifications for JavaScript URLs, so we // don't want to either. - if (!url.SchemeIs(chrome::kJavaScriptScheme)) + if (!params.url.SchemeIs(chrome::kJavaScriptScheme)) delegate_->DidStartLoading(this); } } +void RenderViewHost::NavigateToURL(const GURL& url) { + ViewMsg_Navigate_Params params; + params.page_id = -1; + params.url = url; + params.transition = PageTransition::LINK; + params.reload = false; + Navigate(params); +} + void RenderViewHost::LoadAlternateHTMLString(const std::string& html_text, bool new_navigation, const GURL& display_url, @@ -609,19 +596,6 @@ void RenderViewHost::SetDOMUIProperty(const std::string& name, Send(new ViewMsg_SetDOMUIProperty(routing_id(), name, value)); } -// static -void RenderViewHost::MakeNavigateParams(const NavigationEntry& entry, - bool reload, - ViewMsg_Navigate_Params* params) { - params->page_id = entry.page_id(); - params->url = entry.url(); - params->referrer = entry.referrer(); - params->transition = entry.transition_type(); - params->state = entry.content_state(); - params->reload = reload; - params->request_time = base::Time::Now(); -} - void RenderViewHost::GotFocus() { RenderWidgetHost::GotFocus(); // Notifies the renderer it got focus. diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h index 16e0acc..0e783a5 100644 --- a/chrome/browser/renderer_host/render_view_host.h +++ b/chrome/browser/renderer_host/render_view_host.h @@ -19,7 +19,6 @@ #include "webkit/glue/password_form_dom_manager.h" #include "webkit/glue/window_open_disposition.h" -class NavigationEntry; class RenderViewHostDelegate; class SiteInstance; class SkBitmap; @@ -97,17 +96,26 @@ class RenderViewHost : public RenderWidgetHost { return extension_function_dispatcher_.get(); } - // Set up the RenderView child process. + // Set up the RenderView child process. Virtual because it is overridden by + // TestRenderViewHost. virtual bool CreateRenderView(); - // Returns true if the RenderView is active and has not crashed. + + // Returns true if the RenderView is active and has not crashed. Virtual + // because it is overridden by TestRenderViewHost. virtual bool IsRenderViewLive() const; - virtual void SetRendererPrefs(const RendererPreferences& renderer_prefs); + void SetRendererPrefs(const RendererPreferences& renderer_prefs); - // Load the specified entry, optionally reloading. - virtual void NavigateToEntry(const NavigationEntry& entry, bool is_reload); + // Sends the given navigation message. Use this rather than sending it + // yourself since this does the internal bookkeeping described below. This + // function takes ownership of the provided message pointer. + // + // If a cross-site request is in progress, we may be suspended while waiting + // for the onbeforeunload handler, so this function might buffer the message + // rather than sending it. + void Navigate(const ViewMsg_Navigate_Params& message); - // Load the specified URL. + // Load the specified URL, this is a shortcut for Navigate(). void NavigateToURL(const GURL& url); // Loads the specified html (must be UTF8) in the main frame. If @@ -117,10 +125,10 @@ class RenderViewHost : public RenderWidgetHost { // string if no secure connection state should be simulated. // Note that if |new_navigation| is false, |display_url| and |security_info| // are not used. - virtual void LoadAlternateHTMLString(const std::string& html_text, - bool new_navigation, - const GURL& display_url, - const std::string& security_info); + void LoadAlternateHTMLString(const std::string& html_text, + bool new_navigation, + const GURL& display_url, + const std::string& security_info); // Returns whether navigation messages are currently suspended for this // RenderViewHost. Only true during a cross-site navigation, while waiting @@ -140,7 +148,7 @@ class RenderViewHost : public RenderWidgetHost { // Causes the renderer to invoke the onbeforeunload event handler. The // result will be returned via ViewMsg_ShouldClose. - virtual void FirePageBeforeUnload(); + void FirePageBeforeUnload(); // Close the page after the page has responded that it can be closed via // ViewMsg_ShouldClose. This is where the page itself is closed. The @@ -159,8 +167,7 @@ class RenderViewHost : public RenderWidgetHost { // ResourceDispatcherHost when it is finished. |new_render_process_host_id| // and |new_request_id| will help the ResourceDispatcherHost identify which // response is associated with this event. - virtual void ClosePage(int new_render_process_host_id, - int new_request_id); + void ClosePage(int new_render_process_host_id, int new_request_id); // Sets whether this RenderViewHost has an outstanding cross-site request, // for which another renderer will need to run an onunload event handler. @@ -324,11 +331,6 @@ class RenderViewHost : public RenderWidgetHost { // Must call AllowDOMUIBindings() on this renderer first. void SetDOMUIProperty(const std::string& name, const std::string& value); - // Fill in a ViewMsg_Navigate_Params struct from a NavigationEntry. - static void MakeNavigateParams(const NavigationEntry& entry, - bool reload, - ViewMsg_Navigate_Params* params); - // Tells the renderer view to focus the first (last if reverse is true) node. void SetInitialFocus(bool reverse); @@ -545,14 +547,6 @@ class RenderViewHost : public RenderWidgetHost { void OnAccessibilityFocusChange(int acc_obj_id); void OnCSSInserted(); - // Helper function to send a navigation message. If a cross-site request is - // in progress, we may be suspended while waiting for the onbeforeunload - // handler, so this function might buffer the message rather than sending it. - // - // The URL parameter should match the one in the message. It's provided so - // that we don't have to decode the message to check it. - void DoNavigate(const GURL& url, ViewMsg_Navigate* nav_message); - private: friend class TestRenderViewHost; diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc index 7aecca5..f8434f9 100644 --- a/chrome/browser/tab_contents/tab_contents.cc +++ b/chrome/browser/tab_contents/tab_contents.cc @@ -164,6 +164,17 @@ BOOL CALLBACK InvalidateWindow(HWND hwnd, LPARAM lparam) { } #endif +void MakeNavigateParams(const NavigationEntry& entry, bool reload, + ViewMsg_Navigate_Params* params) { + params->page_id = entry.page_id(); + params->url = entry.url(); + params->referrer = entry.referrer(); + params->transition = entry.transition_type(); + params->state = entry.content_state(); + params->reload = reload; + params->request_time = base::Time::Now(); +} + } // namespace // ----------------------------------------------------------------------------- @@ -656,7 +667,9 @@ bool TabContents::NavigateToPendingEntry(bool reload) { current_load_start_ = base::TimeTicks::Now(); // Navigate in the desired RenderViewHost. - dest_render_view_host->NavigateToEntry(entry, reload); + ViewMsg_Navigate_Params navigate_params; + MakeNavigateParams(entry, reload, &navigate_params); + dest_render_view_host->Navigate(navigate_params); if (entry.page_id() == -1) { // HACK!! This code suppresses javascript: URLs from being added to |