summaryrefslogtreecommitdiffstats
path: root/chrome/browser/tab_contents
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-06 20:29:18 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-06 20:29:18 +0000
commit1ee61486ee0854be7b82d9fca66bb49d563ede4c (patch)
tree6f8ba801a5f19e022a281d622d7eaf467d637214 /chrome/browser/tab_contents
parent0928fb62d472e45d2bd23d97aa43b5f704c00bec (diff)
downloadchromium_src-1ee61486ee0854be7b82d9fca66bb49d563ede4c.zip
chromium_src-1ee61486ee0854be7b82d9fca66bb49d563ede4c.tar.gz
chromium_src-1ee61486ee0854be7b82d9fca66bb49d563ede4c.tar.bz2
Do some refactoring of renderer_host.
This removes the last dependency on tab_contents from the renderer_host code and into the RenderViewHostDelegate. Some of the tests depended on tab_contents, so I moved to a new directory with the tab_contents include allowed via DEPS. Now DEPS can enforce that no additional tab_contents includes are added to renderer_host. RenderViewHost delegate is now pure virtual. After spending a while *again* figuring out why my code didn't work, only to find it was because the default implementation of a function was getting called instead of the real one, I decided to make this pure virtual. It is implemented by TabContents, which implements basically everything, and two other places that implement less. Only two lists of duplicate functions seems not too bad, although long-term it would be nice if this delegate was somehow more succinct. Review URL: http://codereview.chromium.org/155071 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19982 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/tab_contents')
-rw-r--r--chrome/browser/tab_contents/interstitial_page.cc136
-rw-r--r--chrome/browser/tab_contents/interstitial_page.h18
-rw-r--r--chrome/browser/tab_contents/navigation_controller_unittest.cc2
-rw-r--r--chrome/browser/tab_contents/render_view_host_manager_unittest.cc2
-rw-r--r--chrome/browser/tab_contents/tab_contents.cc25
-rw-r--r--chrome/browser/tab_contents/tab_contents.h18
-rw-r--r--chrome/browser/tab_contents/test_web_contents.cc2
-rwxr-xr-xchrome/browser/tab_contents/thumbnail_generator_unittest.cc2
-rw-r--r--chrome/browser/tab_contents/web_contents_unittest.cc2
9 files changed, 112 insertions, 95 deletions
diff --git a/chrome/browser/tab_contents/interstitial_page.cc b/chrome/browser/tab_contents/interstitial_page.cc
index 4683259..1986171 100644
--- a/chrome/browser/tab_contents/interstitial_page.cc
+++ b/chrome/browser/tab_contents/interstitial_page.cc
@@ -281,6 +281,76 @@ void InterstitialPage::Observe(NotificationType type,
}
}
+RenderViewHostDelegate::View* InterstitialPage::GetViewDelegate() const {
+ return rvh_view_delegate_.get();
+}
+
+const GURL& InterstitialPage::GetURL() const {
+ return url_;
+}
+
+void InterstitialPage::RenderViewGone(RenderViewHost* render_view_host) {
+ // Our renderer died. This should not happen in normal cases.
+ // Just dismiss the interstitial.
+ DontProceed();
+}
+
+void InterstitialPage::DidNavigate(
+ RenderViewHost* render_view_host,
+ const ViewHostMsg_FrameNavigate_Params& params) {
+ // A fast user could have navigated away from the page that triggered the
+ // interstitial while the interstitial was loading, that would have disabled
+ // us. In that case we can dismiss ourselves.
+ if (!enabled_){
+ DontProceed();
+ return;
+ }
+
+ // The RenderViewHost has loaded its contents, we can show it now.
+ render_view_host_->view()->Show();
+ tab_->set_interstitial_page(this);
+
+ RenderWidgetHostView* rwh_view = tab_->render_view_host()->view();
+
+ // The RenderViewHost may already have crashed before we even get here.
+ if (rwh_view) {
+ // If the page has focus, focus the interstitial.
+ if (rwh_view->HasFocus())
+ Focus();
+
+ // Hide the original RVH since we're showing the interstitial instead.
+ rwh_view->Hide();
+ }
+
+ // Notify the tab we are not loading so the throbber is stopped. It also
+ // causes a NOTIFY_LOAD_STOP notification, that the AutomationProvider (used
+ // by the UI tests) expects to consider a navigation as complete. Without
+ // this, navigating in a UI test to a URL that triggers an interstitial would
+ // hang.
+ tab_->SetIsLoading(false, NULL);
+}
+
+void InterstitialPage::UpdateTitle(RenderViewHost* render_view_host,
+ int32 page_id,
+ const std::wstring& title) {
+ DCHECK(render_view_host == render_view_host_);
+ NavigationEntry* entry = tab_->controller().GetActiveEntry();
+ // If this interstitial is shown on an existing navigation entry, we'll need
+ // to remember its title so we can revert to it when hidden.
+ if (!new_navigation_ && !should_revert_tab_title_) {
+ original_tab_title_ = UTF16ToWideHack(entry->title());
+ should_revert_tab_title_ = true;
+ }
+ entry->set_title(WideToUTF16Hack(title));
+ tab_->NotifyNavigationStateChanged(TabContents::INVALIDATE_TAB);
+}
+
+void InterstitialPage::DomOperationResponse(const std::string& json_string,
+ int automation_id) {
+ if (enabled_)
+ CommandReceived(json_string);
+}
+
RenderViewHost* InterstitialPage::CreateRenderViewHost() {
RenderViewHost* render_view_host = new RenderViewHost(
SiteInstance::CreateSiteInstance(tab()->profile()),
@@ -380,72 +450,6 @@ void InterstitialPage::FocusThroughTabTraversal(bool reverse) {
render_view_host_->SetInitialFocus(reverse);
}
-void InterstitialPage::DidNavigate(
- RenderViewHost* render_view_host,
- const ViewHostMsg_FrameNavigate_Params& params) {
- // A fast user could have navigated away from the page that triggered the
- // interstitial while the interstitial was loading, that would have disabled
- // us. In that case we can dismiss ourselves.
- if (!enabled_){
- DontProceed();
- return;
- }
-
- // The RenderViewHost has loaded its contents, we can show it now.
- render_view_host_->view()->Show();
- tab_->set_interstitial_page(this);
-
- RenderWidgetHostView* rwh_view = tab_->render_view_host()->view();
-
- // The RenderViewHost may already have crashed before we even get here.
- if (rwh_view) {
- // If the page has focus, focus the interstitial.
- if (rwh_view->HasFocus())
- Focus();
-
- // Hide the original RVH since we're showing the interstitial instead.
- rwh_view->Hide();
- }
-
- // Notify the tab we are not loading so the throbber is stopped. It also
- // causes a NOTIFY_LOAD_STOP notification, that the AutomationProvider (used
- // by the UI tests) expects to consider a navigation as complete. Without
- // this, navigating in a UI test to a URL that triggers an interstitial would
- // hang.
- tab_->SetIsLoading(false, NULL);
-}
-
-void InterstitialPage::RenderViewGone(RenderViewHost* render_view_host) {
- // Our renderer died. This should not happen in normal cases.
- // Just dismiss the interstitial.
- DontProceed();
-}
-
-void InterstitialPage::DomOperationResponse(const std::string& json_string,
- int automation_id) {
- if (enabled_)
- CommandReceived(json_string);
-}
-
-void InterstitialPage::UpdateTitle(RenderViewHost* render_view_host,
- int32 page_id,
- const std::wstring& title) {
- DCHECK(render_view_host == render_view_host_);
- NavigationEntry* entry = tab_->controller().GetActiveEntry();
- // If this interstitial is shown on an existing navigation entry, we'll need
- // to remember its title so we can revert to it when hidden.
- if (!new_navigation_ && !should_revert_tab_title_) {
- original_tab_title_ = UTF16ToWideHack(entry->title());
- should_revert_tab_title_ = true;
- }
- entry->set_title(WideToUTF16Hack(title));
- tab_->NotifyNavigationStateChanged(TabContents::INVALIDATE_TAB);
-}
-
-RenderViewHostDelegate::View* InterstitialPage::GetViewDelegate() const {
- return rvh_view_delegate_.get();
-}
-
void InterstitialPage::Disable() {
enabled_ = false;
}
diff --git a/chrome/browser/tab_contents/interstitial_page.h b/chrome/browser/tab_contents/interstitial_page.h
index 821171d..8ebfb51 100644
--- a/chrome/browser/tab_contents/interstitial_page.h
+++ b/chrome/browser/tab_contents/interstitial_page.h
@@ -5,6 +5,7 @@
#ifndef CHROME_BROWSER_TAB_CONTENTS_INTERSTITIAL_PAGE_H_
#define CHROME_BROWSER_TAB_CONTENTS_INTERSTITIAL_PAGE_H_
+#include <map>
#include <string>
#include "base/gfx/size.h"
@@ -91,29 +92,26 @@ class InterstitialPage : public NotificationObserver,
const NotificationDetails& details);
// RenderViewHostDelegate implementation:
- virtual const GURL& GetURL() const { return url_; }
- virtual WebPreferences GetWebkitPrefs() {
- return WebPreferences();
- }
+ virtual View* GetViewDelegate() const;
+ virtual const GURL& GetURL() const;
+ virtual void RenderViewGone(RenderViewHost* render_view_host);
virtual void DidNavigate(RenderViewHost* render_view_host,
const ViewHostMsg_FrameNavigate_Params& params);
- virtual void RenderViewGone(RenderViewHost* render_view_host);
- virtual void DomOperationResponse(const std::string& json_string,
- int automation_id);
virtual void UpdateTitle(RenderViewHost* render_view_host,
int32 page_id,
const std::wstring& title);
- virtual View* GetViewDelegate() const;
+ virtual void DomOperationResponse(const std::string& json_string,
+ int automation_id);
// Invoked when the page sent a command through DOMAutomation.
- virtual void CommandReceived(const std::string& command) { }
+ virtual void CommandReceived(const std::string& command) {}
// Invoked with the NavigationEntry that is going to be added to the
// navigation controller.
// Gives an opportunity to sub-classes to set states on the |entry|.
// Note that this is only called if the InterstitialPage was constructed with
// |create_navigation_entry| set to true.
- virtual void UpdateEntry(NavigationEntry* entry) { }
+ virtual void UpdateEntry(NavigationEntry* entry) {}
TabContents* tab() const { return tab_; }
const GURL& url() const { return url_; }
diff --git a/chrome/browser/tab_contents/navigation_controller_unittest.cc b/chrome/browser/tab_contents/navigation_controller_unittest.cc
index 50964c7..8047216 100644
--- a/chrome/browser/tab_contents/navigation_controller_unittest.cc
+++ b/chrome/browser/tab_contents/navigation_controller_unittest.cc
@@ -8,7 +8,7 @@
#include "base/string_util.h"
#include "chrome/browser/profile_manager.h"
#include "chrome/browser/history/history.h"
-#include "chrome/browser/renderer_host/test_render_view_host.h"
+#include "chrome/browser/renderer_host/test/test_render_view_host.h"
#include "chrome/browser/sessions/session_service.h"
#include "chrome/browser/sessions/session_service_test_helper.h"
#include "chrome/browser/sessions/session_types.h"
diff --git a/chrome/browser/tab_contents/render_view_host_manager_unittest.cc b/chrome/browser/tab_contents/render_view_host_manager_unittest.cc
index 01fb323..6cf549e 100644
--- a/chrome/browser/tab_contents/render_view_host_manager_unittest.cc
+++ b/chrome/browser/tab_contents/render_view_host_manager_unittest.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/renderer_host/test_render_view_host.h"
+#include "chrome/browser/renderer_host/test/test_render_view_host.h"
#include "chrome/browser/tab_contents/navigation_controller.h"
#include "chrome/browser/tab_contents/navigation_entry.h"
#include "chrome/browser/tab_contents/render_view_host_manager.h"
diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc
index 3b46d99..8141c42 100644
--- a/chrome/browser/tab_contents/tab_contents.cc
+++ b/chrome/browser/tab_contents/tab_contents.cc
@@ -50,6 +50,7 @@
#include "chrome/common/pref_names.h"
#include "chrome/common/pref_service.h"
#include "chrome/common/render_messages.h"
+#include "chrome/common/renderer_preferences.h"
#include "chrome/common/url_constants.h"
#include "grit/generated_resources.h"
#include "grit/locale_settings.h"
@@ -57,6 +58,8 @@
#include "net/base/net_errors.h"
#include "net/base/net_util.h"
#include "net/base/registry_controlled_domain.h"
+#include "webkit/glue/password_form.h"
+#include "webkit/glue/webpreferences.h"
#if defined(OS_WIN)
// For CRect
@@ -1862,6 +1865,10 @@ void TabContents::RequestOpenURL(const GURL& url, const GURL& referrer,
}
}
+void TabContents::DomOperationResponse(const std::string& json_string,
+ int automation_id) {
+}
+
void TabContents::ProcessDOMUIMessage(const std::string& message,
const std::string& content,
int request_id,
@@ -2133,6 +2140,10 @@ void TabContents::OnCrossSiteResponse(int new_render_process_host_id,
new_request_id);
}
+void TabContents::OnCrossSiteNavigationCanceled() {
+ render_manager_.CrossSiteNavigationCanceled();
+}
+
bool TabContents::CanBlur() const {
return delegate() ? delegate()->CanBlur() : true;
}
@@ -2205,6 +2216,13 @@ void TabContents::OnUserGesture() {
controller_.OnUserGesture();
}
+bool TabContents::IsExternalTabContainer() const {
+ if (!delegate())
+ return false;
+
+ return delegate()->IsExternalTabContainer();
+}
+
void TabContents::OnFindReply(int request_id,
int number_of_matches,
const gfx::Rect& selection_rect,
@@ -2236,11 +2254,8 @@ void TabContents::OnFindReply(int request_id,
Details<FindNotificationDetails>(&last_search_result_));
}
-bool TabContents::IsExternalTabContainer() const {
- if (!delegate())
- return false;
-
- return delegate()->IsExternalTabContainer();
+void TabContents::DidInsertCSS() {
+ // This RVHDelegate function is used for extensions and not us.
}
void TabContents::FileSelected(const FilePath& path,
diff --git a/chrome/browser/tab_contents/tab_contents.h b/chrome/browser/tab_contents/tab_contents.h
index f7d8f69..759c70a 100644
--- a/chrome/browser/tab_contents/tab_contents.h
+++ b/chrome/browser/tab_contents/tab_contents.h
@@ -34,7 +34,6 @@
#include "chrome/common/notification_registrar.h"
#include "chrome/common/page_action.h"
#include "chrome/common/property_bag.h"
-#include "chrome/common/renderer_preferences.h"
#include "net/base/load_states.h"
#include "webkit/glue/password_form.h"
#include "webkit/glue/webpreferences.h"
@@ -78,6 +77,7 @@ class PageAction;
class PasswordManager;
class PluginInstaller;
class Profile;
+struct RendererPreferences;
class RenderViewHost;
class TabContentsDelegate;
class TabContentsFactory;
@@ -562,10 +562,6 @@ class TabContents : public PageNavigator,
render_view_host()->SetPageEncoding(encoding);
}
- void CrossSiteNavigationCanceled() {
- render_manager_.CrossSiteNavigationCanceled();
- }
-
void WindowMoveOrResizeStarted() {
render_view_host()->WindowMoveOrResizeStarted();
}
@@ -739,7 +735,6 @@ class TabContents : public PageNavigator,
// RenderViewHostDelegate ----------------------------------------------------
- virtual RendererPreferences GetRendererPrefs() const;
virtual RenderViewHostDelegate::View* GetViewDelegate() const;
virtual RenderViewHostDelegate::Save* GetSaveDelegate() const;
virtual TabContents* GetAsTabContents();
@@ -794,6 +789,8 @@ class TabContents : public PageNavigator,
const SkBitmap& image);
virtual void RequestOpenURL(const GURL& url, const GURL& referrer,
WindowOpenDisposition disposition);
+ virtual void DomOperationResponse(const std::string& json_string,
+ int automation_id);
virtual void ProcessDOMUIMessage(const std::string& message,
const std::string& content,
int request_id,
@@ -831,14 +828,16 @@ class TabContents : public PageNavigator,
virtual void DidGetPrintedPagesCount(int cookie, int number_pages);
virtual void DidPrintPage(const ViewHostMsg_DidPrintPage_Params& params);
virtual GURL GetAlternateErrorPageURL() const;
+ virtual RendererPreferences GetRendererPrefs() const;
virtual WebPreferences GetWebkitPrefs();
virtual void OnMissingPluginStatus(int status);
virtual void OnCrashedPlugin(const FilePath& plugin_path);
virtual void OnCrashedWorker();
virtual void OnJSOutOfMemory();
virtual void ShouldClosePage(bool proceed);
- void OnCrossSiteResponse(int new_render_process_host_id,
- int new_request_id);
+ virtual void OnCrossSiteResponse(int new_render_process_host_id,
+ int new_request_id);
+ virtual void OnCrossSiteNavigationCanceled();
virtual bool CanBlur() const;
virtual gfx::Rect GetRootWindowResizerRect() const;
virtual void RendererUnresponsive(RenderViewHost* render_view_host,
@@ -849,12 +848,13 @@ class TabContents : public PageNavigator,
int32 page_id,
const webkit_glue::WebApplicationInfo& info);
virtual void OnUserGesture();
+ virtual bool IsExternalTabContainer() const;
virtual void OnFindReply(int request_id,
int number_of_matches,
const gfx::Rect& selection_rect,
int active_match_ordinal,
bool final_update);
- virtual bool IsExternalTabContainer() const;
+ virtual void DidInsertCSS();
// SelectFileDialog::Listener ------------------------------------------------
diff --git a/chrome/browser/tab_contents/test_web_contents.cc b/chrome/browser/tab_contents/test_web_contents.cc
index bb5f4d06..f27aa9b 100644
--- a/chrome/browser/tab_contents/test_web_contents.cc
+++ b/chrome/browser/tab_contents/test_web_contents.cc
@@ -4,7 +4,7 @@
#include "chrome/browser/tab_contents/test_web_contents.h"
-#include "chrome/browser/renderer_host/test_render_view_host.h"
+#include "chrome/browser/renderer_host/test/test_render_view_host.h"
TestTabContents::TestTabContents(Profile* profile, SiteInstance* instance)
: TabContents(profile, instance, MSG_ROUTING_NONE, NULL),
diff --git a/chrome/browser/tab_contents/thumbnail_generator_unittest.cc b/chrome/browser/tab_contents/thumbnail_generator_unittest.cc
index 591fdd0..160a377 100755
--- a/chrome/browser/tab_contents/thumbnail_generator_unittest.cc
+++ b/chrome/browser/tab_contents/thumbnail_generator_unittest.cc
@@ -5,7 +5,7 @@
#include "base/basictypes.h"
#include "chrome/browser/renderer_host/backing_store_manager.h"
#include "chrome/browser/renderer_host/mock_render_process_host.h"
-#include "chrome/browser/renderer_host/test_render_view_host.h"
+#include "chrome/browser/renderer_host/test/test_render_view_host.h"
#include "chrome/browser/tab_contents/thumbnail_generator.h"
#include "chrome/common/notification_service.h"
#include "chrome/common/render_messages.h"
diff --git a/chrome/browser/tab_contents/web_contents_unittest.cc b/chrome/browser/tab_contents/web_contents_unittest.cc
index 3b1c43e..bbdc7ef 100644
--- a/chrome/browser/tab_contents/web_contents_unittest.cc
+++ b/chrome/browser/tab_contents/web_contents_unittest.cc
@@ -5,7 +5,7 @@
#include "base/logging.h"
#include "chrome/browser/renderer_host/render_view_host.h"
#include "chrome/browser/renderer_host/render_widget_host_view.h"
-#include "chrome/browser/renderer_host/test_render_view_host.h"
+#include "chrome/browser/renderer_host/test/test_render_view_host.h"
#include "chrome/browser/tab_contents/interstitial_page.h"
#include "chrome/browser/tab_contents/navigation_controller.h"
#include "chrome/browser/tab_contents/navigation_entry.h"