summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-07 16:48:07 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-07 16:48:07 +0000
commit3ff3493b8904ee4db7b41cd1676ccdcb127ecbd8 (patch)
tree6d3dcf4bf6a0f19d553a3e1a2c2eba0a81e72ce3 /chrome
parenta64691f2882ea7403dc2fcd39f026583e12429fe (diff)
downloadchromium_src-3ff3493b8904ee4db7b41cd1676ccdcb127ecbd8.zip
chromium_src-3ff3493b8904ee4db7b41cd1676ccdcb127ecbd8.tar.gz
chromium_src-3ff3493b8904ee4db7b41cd1676ccdcb127ecbd8.tar.bz2
Make the RenderViewHostFactory a global. This prevents us from having to pass
a factory pointer around all the time. Removing TestTabContents will require making the Browser object keep track of the Factory pointer as well, so I think the global is the best approach and cleans some things up. Review URL: http://codereview.chromium.org/62044 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13255 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/browser.cc6
-rw-r--r--chrome/browser/browser.vcproj8
-rw-r--r--chrome/browser/debugger/debugger_view.cc2
-rw-r--r--chrome/browser/debugger/devtools_view.cc4
-rw-r--r--chrome/browser/dom_ui/dom_ui_host.cc1
-rw-r--r--chrome/browser/dom_ui/dom_ui_unittest.cc3
-rw-r--r--chrome/browser/external_tab_container.cc15
-rw-r--r--chrome/browser/external_tab_container.h9
-rw-r--r--chrome/browser/navigation_controller_unittest.cc8
-rw-r--r--chrome/browser/renderer_host/render_view_host.h12
-rw-r--r--chrome/browser/renderer_host/render_view_host_factory.cc36
-rw-r--r--chrome/browser/renderer_host/render_view_host_factory.h66
-rw-r--r--chrome/browser/renderer_host/test_render_view_host.cc2
-rw-r--r--chrome/browser/renderer_host/test_render_view_host.h7
-rw-r--r--chrome/browser/site_instance_unittest.cc2
-rw-r--r--chrome/browser/tab_contents/navigation_controller.cc7
-rw-r--r--chrome/browser/tab_contents/navigation_controller.h11
-rw-r--r--chrome/browser/tab_contents/render_view_host_manager.cc24
-rw-r--r--chrome/browser/tab_contents/render_view_host_manager.h18
-rw-r--r--chrome/browser/tab_contents/tab_contents.h3
-rw-r--r--chrome/browser/tab_contents/tab_contents_factory.cc6
-rw-r--r--chrome/browser/tab_contents/test_web_contents.cc5
-rw-r--r--chrome/browser/tab_contents/test_web_contents.h3
-rw-r--r--chrome/browser/tab_contents/web_contents.cc5
-rw-r--r--chrome/browser/tab_contents/web_contents.h7
-rw-r--r--chrome/browser/tab_contents/web_contents_unittest.cc6
-rw-r--r--chrome/browser/tab_contents/web_contents_view.cc1
-rw-r--r--chrome/browser/tab_contents/web_contents_view_gtk.cc3
-rw-r--r--chrome/browser/tab_contents/web_contents_view_win.cc3
-rw-r--r--chrome/browser/tabs/tab_strip_model_unittest.cc2
-rw-r--r--chrome/browser/views/dom_view.cc3
-rw-r--r--chrome/chrome.gyp2
32 files changed, 165 insertions, 125 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index ab5037a..374ca34 100644
--- a/chrome/browser/browser.cc
+++ b/chrome/browser/browser.cc
@@ -1346,8 +1346,7 @@ TabContents* Browser::CreateTabContentsForURL(
TabContentsType type = TabContents::TypeForURL(&real_url);
DCHECK(type != TAB_CONTENTS_UNKNOWN_TYPE);
- TabContents* contents = TabContents::CreateWithType(type, profile, instance,
- NULL);
+ TabContents* contents = TabContents::CreateWithType(type, profile, instance);
contents->SetupController(profile);
if (!defer_load) {
@@ -2382,8 +2381,7 @@ NavigationController* Browser::BuildRestoredNavigationController(
selected_navigation < static_cast<int>(navigations.size()));
// Create a NavigationController. This constructor creates the appropriate
// set of TabContents.
- return new NavigationController(profile_, navigations, selected_navigation,
- NULL);
+ return new NavigationController(profile_, navigations, selected_navigation);
} else {
// No navigations. Create a tab with about:blank.
TabContents* contents =
diff --git a/chrome/browser/browser.vcproj b/chrome/browser/browser.vcproj
index 9292222..8a876db 100644
--- a/chrome/browser/browser.vcproj
+++ b/chrome/browser/browser.vcproj
@@ -2086,6 +2086,14 @@
>
</File>
<File
+ RelativePath=".\renderer_host\render_view_host_factory.cc"
+ >
+ </File>
+ <File
+ RelativePath=".\renderer_host\render_view_host_factory.h"
+ >
+ </File>
+ <File
RelativePath=".\renderer_host\render_widget_helper.cc"
>
</File>
diff --git a/chrome/browser/debugger/debugger_view.cc b/chrome/browser/debugger/debugger_view.cc
index 19ea1f4..3a72171 100644
--- a/chrome/browser/debugger/debugger_view.cc
+++ b/chrome/browser/debugger/debugger_view.cc
@@ -97,7 +97,7 @@ void DebuggerView::OnInit() {
// We can't create the WebContents until we've actually been put into a real
// view hierarchy somewhere.
Profile* profile = BrowserList::GetLastActive()->profile();
- web_contents_ = new WebContents(profile, NULL, NULL, MSG_ROUTING_NONE, NULL);
+ web_contents_ = new WebContents(profile, NULL, MSG_ROUTING_NONE, NULL);
web_contents_->SetupController(profile);
web_contents_->set_delegate(this);
diff --git a/chrome/browser/debugger/devtools_view.cc b/chrome/browser/debugger/devtools_view.cc
index df4258e..483f87f 100644
--- a/chrome/browser/debugger/devtools_view.cc
+++ b/chrome/browser/debugger/devtools_view.cc
@@ -49,9 +49,7 @@ void DevToolsView::Init() {
// view hierarchy somewhere.
Profile* profile = BrowserList::GetLastActive()->profile();
- TabContents* tc = TabContents::CreateWithType(TAB_CONTENTS_WEB, profile,
- NULL, NULL);
- web_contents_ = tc->AsWebContents();
+ web_contents_ = new WebContents(profile, NULL, MSG_ROUTING_NONE, NULL);
web_contents_->SetupController(profile);
web_contents_->set_delegate(this);
web_container_->SetTabContents(web_contents_);
diff --git a/chrome/browser/dom_ui/dom_ui_host.cc b/chrome/browser/dom_ui/dom_ui_host.cc
index ae7bcc40..ffeda1b 100644
--- a/chrome/browser/dom_ui/dom_ui_host.cc
+++ b/chrome/browser/dom_ui/dom_ui_host.cc
@@ -16,7 +16,6 @@ DOMUIHost::DOMUIHost(Profile* profile,
RenderViewHostFactory* render_view_factory)
: WebContents(profile,
instance,
- render_view_factory,
MSG_ROUTING_NONE,
NULL) {
// Implementors of this class will have a specific tab contents type.
diff --git a/chrome/browser/dom_ui/dom_ui_unittest.cc b/chrome/browser/dom_ui/dom_ui_unittest.cc
index 3371acf..c1a554e 100644
--- a/chrome/browser/dom_ui/dom_ui_unittest.cc
+++ b/chrome/browser/dom_ui/dom_ui_unittest.cc
@@ -88,8 +88,7 @@ TEST_F(DOMUITest, DOMUIToStandard) {
// slightly different than the very-first-navigation case since the
// SiteInstance will be the same (the original WebContents must still be
// alive), which will trigger different behavior in RenderViewHostManager.
- WebContents* contents2 = new TestWebContents(profile_.get(), NULL,
- &rvh_factory_);
+ WebContents* contents2 = new TestWebContents(profile_.get(), NULL);
NavigationController* controller2 =
new NavigationController(contents2, profile_.get());
contents2->set_controller(controller2);
diff --git a/chrome/browser/external_tab_container.cc b/chrome/browser/external_tab_container.cc
index da38c7e..3ec28a89 100644
--- a/chrome/browser/external_tab_container.cc
+++ b/chrome/browser/external_tab_container.cc
@@ -64,20 +64,11 @@ bool ExternalTabContainer::Init(Profile* profile, HWND parent,
DCHECK(focus_manager);
focus_manager->AddKeystrokeListener(this);
- tab_contents_ = TabContents::CreateWithType(TAB_CONTENTS_WEB, profile,
- NULL, NULL);
- if (!tab_contents_) {
- NOTREACHED();
- DestroyWindow();
- return false;
- }
+ tab_contents_ = new WebContents(profile, NULL, MSG_ROUTING_NONE, NULL);
tab_contents_->SetupController(profile);
tab_contents_->set_delegate(this);
-
- WebContents* web_conents = tab_contents_->AsWebContents();
- if (web_conents)
- web_conents->render_view_host()->AllowExternalHostBindings();
+ tab_contents_->render_view_host()->AllowExternalHostBindings();
// Create a TabContentsContainerView to handle focus cycling using Tab and
// Shift-Tab.
@@ -402,7 +393,7 @@ void ExternalTabContainer::ProcessUnhandledAccelerator(const MSG& msg) {
void ExternalTabContainer::SetInitialFocus(bool reverse) {
DCHECK(tab_contents_);
if (tab_contents_) {
- tab_contents_->SetInitialFocus(reverse);
+ static_cast<TabContents*>(tab_contents_)->SetInitialFocus(reverse);
}
}
diff --git a/chrome/browser/external_tab_container.h b/chrome/browser/external_tab_container.h
index a72cea0..afbbfc4 100644
--- a/chrome/browser/external_tab_container.h
+++ b/chrome/browser/external_tab_container.h
@@ -21,7 +21,7 @@
#include "chrome/views/widget/widget.h"
class AutomationProvider;
-class TabContents;
+class WebContents;
class Profile;
class TabContentsContainerView;
// This class serves as the container window for an external tab.
@@ -48,7 +48,7 @@ class ExternalTabContainer : public TabContentsDelegate,
ExternalTabContainer(AutomationProvider* automation);
~ExternalTabContainer();
- TabContents* tab_contents() const {
+ WebContents* tab_contents() const {
return tab_contents_;
}
@@ -141,7 +141,7 @@ class ExternalTabContainer : public TabContentsDelegate,
void OnFinalMessage(HWND window);
protected:
- TabContents *tab_contents_;
+ WebContents* tab_contents_;
scoped_refptr<AutomationProvider> automation_;
NotificationRegistrar registrar_;
@@ -153,6 +153,7 @@ class ExternalTabContainer : public TabContentsDelegate,
unsigned int external_accel_entry_count_;
// A view to handle focus cycling
TabContentsContainerView* tab_contents_container_;
+
private:
// A failed navigation like a 404 is followed in chrome with a success
// navigation for the 404 page. We need to ignore the next navigation
@@ -163,4 +164,4 @@ class ExternalTabContainer : public TabContentsDelegate,
DISALLOW_COPY_AND_ASSIGN(ExternalTabContainer);
};
-#endif // CHROME_BROWSER_EXTERNAL_TAB_CONTAINER_H__
+#endif // CHROME_BROWSER_EXTERNAL_TAB_CONTAINER_H_
diff --git a/chrome/browser/navigation_controller_unittest.cc b/chrome/browser/navigation_controller_unittest.cc
index 6a11b3f..a9def34 100644
--- a/chrome/browser/navigation_controller_unittest.cc
+++ b/chrome/browser/navigation_controller_unittest.cc
@@ -1063,7 +1063,7 @@ TEST_F(NavigationControllerTest, RestoreNavigate) {
ASCIIToUTF16("Title"), "state",
PageTransition::LINK));
NavigationController* our_controller =
- new NavigationController(profile(), navigations, 0, &rvh_factory_);
+ new NavigationController(profile(), navigations, 0);
our_controller->GoToIndex(0);
// We should now have one entry, and it should be "pending".
@@ -1355,9 +1355,6 @@ TEST_F(NavigationControllerTest, SameSubframe) {
EXPECT_EQ(controller()->GetLastCommittedEntryIndex(), 0);
}
-/* TODO(brettw) These test pass on my local machine but fail on the buildbot
- cleaning up the directory after they run. This should be fixed.
-
// A basic test case. Navigates to a single url, and make sure the history
// db matches.
TEST_F(NavigationControllerHistoryTest, Basic) {
@@ -1374,6 +1371,9 @@ TEST_F(NavigationControllerHistoryTest, Basic) {
session_helper_.AssertNavigationEquals(nav1, windows_[0]->tabs[0]->navigations[0]);
}
+/* TODO(brettw) These test pass on my local machine but fail on the buildbot
+ cleaning up the directory after they run. This should be fixed.
+
// Navigates to three urls, then goes back and make sure the history database
// is in sync.
TEST_F(NavigationControllerHistoryTest, NavigationThenBack) {
diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h
index 8813a2c..f70d449 100644
--- a/chrome/browser/renderer_host/render_view_host.h
+++ b/chrome/browser/renderer_host/render_view_host.h
@@ -651,16 +651,4 @@ class RenderViewHost : public RenderWidgetHost {
DISALLOW_EVIL_CONSTRUCTORS(RenderViewHost);
};
-// Factory for creating RenderViewHosts. Useful for unit tests.
-class RenderViewHostFactory {
- public:
- virtual ~RenderViewHostFactory() {}
-
- virtual RenderViewHost* CreateRenderViewHost(
- SiteInstance* instance,
- RenderViewHostDelegate* delegate,
- int routing_id,
- base::WaitableEvent* modal_dialog_event) = 0;
-};
-
#endif // CHROME_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_H_
diff --git a/chrome/browser/renderer_host/render_view_host_factory.cc b/chrome/browser/renderer_host/render_view_host_factory.cc
new file mode 100644
index 0000000..38af233
--- /dev/null
+++ b/chrome/browser/renderer_host/render_view_host_factory.cc
@@ -0,0 +1,36 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// 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/render_view_host_factory.h"
+
+#include "base/logging.h"
+#include "chrome/browser/renderer_host/render_view_host.h"
+
+// static
+RenderViewHostFactory* RenderViewHostFactory::factory_ = NULL;
+
+// static
+RenderViewHost* RenderViewHostFactory::Create(
+ SiteInstance* instance,
+ RenderViewHostDelegate* delegate,
+ int routing_id,
+ base::WaitableEvent* modal_dialog_event) {
+ if (factory_) {
+ return factory_->CreateRenderViewHost(instance, delegate,
+ routing_id, modal_dialog_event);
+ }
+ return new RenderViewHost(instance, delegate, routing_id, modal_dialog_event);
+}
+
+// static
+void RenderViewHostFactory::RegisterFactory(RenderViewHostFactory* factory) {
+ DCHECK(!factory_) << "Can't register two factories at once.";
+ factory_ = factory;
+}
+
+// static
+void RenderViewHostFactory::UnregisterFactory() {
+ DCHECK(factory_) << "No factory to unregister.";
+ factory_ = NULL;
+}
diff --git a/chrome/browser/renderer_host/render_view_host_factory.h b/chrome/browser/renderer_host/render_view_host_factory.h
new file mode 100644
index 0000000..9bbfa56
--- /dev/null
+++ b/chrome/browser/renderer_host/render_view_host_factory.h
@@ -0,0 +1,66 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_FACTORY_H_
+#define CHROME_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_FACTORY_H_
+
+#include "base/basictypes.h"
+
+class RenderViewHost;
+class RenderViewHostDelegate;
+class SiteInstance;
+
+namespace base {
+class WaitableEvent;
+} // namespace base
+
+// A factory for creating RenderViewHosts. There is a global factory function
+// that can be installed for the purposes of testing to provide a specialized
+// RenderViewHost class.
+class RenderViewHostFactory {
+ public:
+ // Creates a RenderViewHost using the currently registered factory, or the
+ // default one if no factory is registered. Ownership of the returned
+ // pointer will be passed to the caller.
+ static RenderViewHost* Create(SiteInstance* instance,
+ RenderViewHostDelegate* delegate,
+ int routing_id,
+ base::WaitableEvent* modal_dialog_event);
+
+ // Returns true if there is currently a globally-registered factory.
+ static bool has_factory() {
+ return !!factory_;
+ }
+
+ protected:
+ RenderViewHostFactory() {}
+ virtual ~RenderViewHostFactory() {}
+
+ // You can derive from this class and specify an implementation for this
+ // function to create a different kind of RenderViewHost for testing.
+ virtual RenderViewHost* CreateRenderViewHost(
+ SiteInstance* instance,
+ RenderViewHostDelegate* delegate,
+ int routing_id,
+ base::WaitableEvent* modal_dialog_event) = 0;
+
+ // Registers your factory to be called when new RenderViewHosts are created.
+ // We have only one global factory, so there must be no factory registered
+ // before the call. This class does NOT take ownership of the pointer.
+ static void RegisterFactory(RenderViewHostFactory* factory);
+
+ // Unregister the previously registered factory. With no factory registered,
+ // the default RenderViewHosts will be created.
+ static void UnregisterFactory();
+
+ private:
+ // The current globally registered factory. This is NULL when we should
+ // create the default RenderViewHosts.
+ static RenderViewHostFactory* factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(RenderViewHostFactory);
+};
+
+
+#endif // CHROME_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_FACTORY_H_
diff --git a/chrome/browser/renderer_host/test_render_view_host.cc b/chrome/browser/renderer_host/test_render_view_host.cc
index 1d54449..abc5699 100644
--- a/chrome/browser/renderer_host/test_render_view_host.cc
+++ b/chrome/browser/renderer_host/test_render_view_host.cc
@@ -82,7 +82,7 @@ void RenderViewHostTestHarness::SetUp() {
// This will be deleted when the WebContents goes away.
SiteInstance* instance = SiteInstance::CreateSiteInstance(profile_.get());
- contents_ = new TestWebContents(profile_.get(), instance, &rvh_factory_);
+ contents_ = new TestWebContents(profile_.get(), instance);
controller_ = new NavigationController(contents_, profile_.get());
}
diff --git a/chrome/browser/renderer_host/test_render_view_host.h b/chrome/browser/renderer_host/test_render_view_host.h
index 69d836e..63e6da6 100644
--- a/chrome/browser/renderer_host/test_render_view_host.h
+++ b/chrome/browser/renderer_host/test_render_view_host.h
@@ -11,6 +11,7 @@
#include "chrome/browser/renderer_host/mock_render_process_host.h"
#include "chrome/browser/renderer_host/render_widget_host_view.h"
#include "chrome/browser/renderer_host/render_view_host.h"
+#include "chrome/browser/renderer_host/render_view_host_factory.h"
#include "chrome/browser/tab_contents/site_instance.h"
#include "chrome/browser/tab_contents/test_web_contents.h"
#include "chrome/test/testing_profile.h"
@@ -134,12 +135,18 @@ class TestRenderViewHost : public RenderViewHost {
// TestRenderViewHostFactory ---------------------------------------------------
+// Manages creation of the RenderViewHosts using our special subclass. This
+// automatically registers itself when it goes in scope, and unregisters itself
+// when it goes out of scope. Since you can't have more than one factory
+// registered at a time, you can only have one of these objects at a time.
class TestRenderViewHostFactory : public RenderViewHostFactory {
public:
TestRenderViewHostFactory(RenderProcessHostFactory* rph_factory)
: render_process_host_factory_(rph_factory) {
+ RenderViewHostFactory::RegisterFactory(this);
}
virtual ~TestRenderViewHostFactory() {
+ RenderViewHostFactory::UnregisterFactory();
}
virtual RenderViewHost* CreateRenderViewHost(
diff --git a/chrome/browser/site_instance_unittest.cc b/chrome/browser/site_instance_unittest.cc
index d9e64ee..2e8a3a1 100644
--- a/chrome/browser/site_instance_unittest.cc
+++ b/chrome/browser/site_instance_unittest.cc
@@ -109,7 +109,7 @@ TEST_F(SiteInstanceTest, SiteInstanceDestructor) {
&siteDeleteCounter,
&browsingDeleteCounter);
WebContents* contents = new WebContents(
- profile.get(), instance, NULL, MSG_ROUTING_NONE, NULL);
+ profile.get(), instance, MSG_ROUTING_NONE, NULL);
contents->SetupController(profile.get());
EXPECT_EQ(1, siteDeleteCounter);
EXPECT_EQ(1, browsingDeleteCounter);
diff --git a/chrome/browser/tab_contents/navigation_controller.cc b/chrome/browser/tab_contents/navigation_controller.cc
index 88bc154..444c41d 100644
--- a/chrome/browser/tab_contents/navigation_controller.cc
+++ b/chrome/browser/tab_contents/navigation_controller.cc
@@ -148,7 +148,6 @@ static void CreateNavigationEntriesFromTabNavigations(
NavigationController::NavigationController(TabContents* contents,
Profile* profile)
: profile_(profile),
- rvh_factory_(NULL),
pending_entry_(NULL),
last_committed_entry_index_(-1),
pending_entry_index_(-1),
@@ -166,10 +165,8 @@ NavigationController::NavigationController(TabContents* contents,
NavigationController::NavigationController(
Profile* profile,
const std::vector<TabNavigation>& navigations,
- int selected_navigation,
- RenderViewHostFactory* rvh_factory)
+ int selected_navigation)
: profile_(profile),
- rvh_factory_(rvh_factory),
pending_entry_(NULL),
last_committed_entry_index_(-1),
pending_entry_index_(-1),
@@ -1047,7 +1044,7 @@ TabContents* NavigationController::GetTabContentsCreateIfNecessary(
TabContents* contents = GetTabContents(entry.tab_type());
if (!contents) {
contents = TabContents::CreateWithType(entry.tab_type(), profile_,
- entry.site_instance(), rvh_factory_);
+ entry.site_instance());
if (!contents->AsWebContents()) {
// Update the max page id, otherwise the newly created TabContents may
// have reset its max page id resulting in all new navigations. We only
diff --git a/chrome/browser/tab_contents/navigation_controller.h b/chrome/browser/tab_contents/navigation_controller.h
index 2d1364f..04160dc 100644
--- a/chrome/browser/tab_contents/navigation_controller.h
+++ b/chrome/browser/tab_contents/navigation_controller.h
@@ -21,7 +21,6 @@
class NavigationEntry;
class GURL;
class Profile;
-class RenderViewHostFactory;
class TabContents;
class SiteInstance;
class SkBitmap;
@@ -129,13 +128,11 @@ class NavigationController {
// Creates a NavigationController from the specified history. Processing
// for this is asynchronous and handled via the RestoreHelper (in
- // navigation_controller.cc). The RenderViewHostFactory will be passed to
- // new TabContentses, it is non-NULL only for testing.
+ // navigation_controller.cc).
NavigationController(
Profile* profile,
const std::vector<TabNavigation>& navigations,
- int selected_navigation,
- RenderViewHostFactory* rvh_factory);
+ int selected_navigation);
~NavigationController();
// Begin the destruction sequence for this NavigationController and all its
@@ -494,10 +491,6 @@ class NavigationController {
// The user profile associated with this controller
Profile* profile_;
- // Non-owning pointer to the factory to pass to new TabContentes. This will be
- // NULL except in testing, where it is used to create mock RVH's.
- RenderViewHostFactory* rvh_factory_;
-
// List of NavigationEntry for this tab
typedef std::vector<linked_ptr<NavigationEntry> > NavigationEntries;
NavigationEntries entries_;
diff --git a/chrome/browser/tab_contents/render_view_host_manager.cc b/chrome/browser/tab_contents/render_view_host_manager.cc
index 7bc23f8..b9fa344 100644
--- a/chrome/browser/tab_contents/render_view_host_manager.cc
+++ b/chrome/browser/tab_contents/render_view_host_manager.cc
@@ -10,6 +10,7 @@
#include "chrome/browser/dom_ui/dom_ui_factory.h"
#include "chrome/browser/renderer_host/render_view_host.h"
#include "chrome/browser/renderer_host/render_view_host_delegate.h"
+#include "chrome/browser/renderer_host/render_view_host_factory.h"
#include "chrome/browser/renderer_host/render_widget_host_view.h"
#include "chrome/browser/tab_contents/navigation_controller.h"
#include "chrome/browser/tab_contents/navigation_entry.h"
@@ -23,12 +24,10 @@ class WaitableEvent;
}
RenderViewHostManager::RenderViewHostManager(
- RenderViewHostFactory* render_view_factory,
RenderViewHostDelegate* render_view_delegate,
Delegate* delegate)
: delegate_(delegate),
cross_navigation_pending_(false),
- render_view_factory_(render_view_factory),
render_view_delegate_(render_view_delegate),
render_view_host_(NULL),
pending_render_view_host_(NULL),
@@ -52,8 +51,8 @@ void RenderViewHostManager::Init(Profile* profile,
// ref counted.
if (!site_instance)
site_instance = SiteInstance::CreateSiteInstance(profile);
- render_view_host_ = CreateRenderViewHost(
- site_instance, routing_id, modal_dialog_event);
+ render_view_host_ = RenderViewHostFactory::Create(
+ site_instance, render_view_delegate_, routing_id, modal_dialog_event);
}
void RenderViewHostManager::Shutdown() {
@@ -399,8 +398,8 @@ bool RenderViewHostManager::CreatePendingRenderView(SiteInstance* instance) {
// we're about to switch away, so that it sends an UpdateState message.
}
- pending_render_view_host_ =
- CreateRenderViewHost(instance, MSG_ROUTING_NONE, NULL);
+ pending_render_view_host_ = RenderViewHostFactory::Create(
+ instance, render_view_delegate_, MSG_ROUTING_NONE, NULL);
bool success = delegate_->CreateRenderViewForRenderManager(
pending_render_view_host_);
@@ -413,19 +412,6 @@ bool RenderViewHostManager::CreatePendingRenderView(SiteInstance* instance) {
return success;
}
-RenderViewHost* RenderViewHostManager::CreateRenderViewHost(
- SiteInstance* instance,
- int routing_id,
- base::WaitableEvent* modal_dialog_event) {
- if (render_view_factory_) {
- return render_view_factory_->CreateRenderViewHost(
- instance, render_view_delegate_, routing_id, modal_dialog_event);
- } else {
- return new RenderViewHost(instance, render_view_delegate_, routing_id,
- modal_dialog_event);
- }
-}
-
void RenderViewHostManager::CommitPending() {
// First commit the DOM UI, if any.
dom_ui_.swap(pending_dom_ui_);
diff --git a/chrome/browser/tab_contents/render_view_host_manager.h b/chrome/browser/tab_contents/render_view_host_manager.h
index 3754be8..dcd2c48 100644
--- a/chrome/browser/tab_contents/render_view_host_manager.h
+++ b/chrome/browser/tab_contents/render_view_host_manager.h
@@ -61,17 +61,13 @@ class RenderViewHostManager : public NotificationObserver {
GetLastCommittedNavigationEntryForRenderManager() = 0;
};
- // The factory is optional. It is used by unit tests to supply custom render
- // view hosts. When NULL, the regular RenderViewHost will be created.
- //
// Both delegate pointers must be non-NULL and are not owned by this class.
// They must outlive this class. The RenderViewHostDelegate is what will be
// installed into all RenderViewHosts that are created.
//
// You must call Init() before using this class and Shutdown() before
// deleting it.
- RenderViewHostManager(RenderViewHostFactory* render_view_factory,
- RenderViewHostDelegate* render_view_delegate,
+ RenderViewHostManager(RenderViewHostDelegate* render_view_delegate,
Delegate* delegate);
~RenderViewHostManager();
@@ -84,12 +80,6 @@ class RenderViewHostManager : public NotificationObserver {
// Schedules all RenderViewHosts for destruction.
void Shutdown();
- // Returns true if there is a RenderViewHostFactory that will generate
- // non-standard RenderViewHosts.
- bool has_render_view_host_factory() const {
- return !!render_view_factory_;
- }
-
// Returns the currently actuive RenderViewHost.
//
// This will be non-NULL between Init() and Shutdown(). You may want to NULL
@@ -213,12 +203,6 @@ class RenderViewHostManager : public NotificationObserver {
// navigation.
bool CreatePendingRenderView(SiteInstance* instance);
- // Creates a RenderViewHost using render_view_factory_ (or directly, if the
- // factory is NULL).
- RenderViewHost* CreateRenderViewHost(SiteInstance* instance,
- int routing_id,
- base::WaitableEvent* modal_dialog_event);
-
// Sets the pending RenderViewHost/DOMUI to be the active one. Note that this
// doesn't require the pending render_view_host_ pointer to be non-NULL, since
// there could be DOM UI switching as well. Call this for every commit.
diff --git a/chrome/browser/tab_contents/tab_contents.h b/chrome/browser/tab_contents/tab_contents.h
index 566aab7..a8b8883 100644
--- a/chrome/browser/tab_contents/tab_contents.h
+++ b/chrome/browser/tab_contents/tab_contents.h
@@ -89,8 +89,7 @@ class TabContents : public PageNavigator,
// will be passed to the new TabContents (it may be NULL).
static TabContents* CreateWithType(TabContentsType type,
Profile* profile,
- SiteInstance* instance,
- RenderViewHostFactory* rvh_factory);
+ SiteInstance* instance);
// Returns the type of TabContents needed to handle the URL. |url| may
// end up being modified to contain the _real_ url being loaded if the
diff --git a/chrome/browser/tab_contents/tab_contents_factory.cc b/chrome/browser/tab_contents/tab_contents_factory.cc
index 8ed5d27..8cc721f 100644
--- a/chrome/browser/tab_contents/tab_contents_factory.cc
+++ b/chrome/browser/tab_contents/tab_contents_factory.cc
@@ -39,14 +39,12 @@ TabContentsType TabContentsFactory::NextUnusedType() {
// static
TabContents* TabContents::CreateWithType(TabContentsType type,
Profile* profile,
- SiteInstance* instance,
- RenderViewHostFactory* rvh_factory) {
+ SiteInstance* instance) {
TabContents* contents = NULL;
switch (type) {
case TAB_CONTENTS_WEB:
- contents = new WebContents(profile, instance, rvh_factory,
- MSG_ROUTING_NONE, NULL);
+ contents = new WebContents(profile, instance, MSG_ROUTING_NONE, NULL);
break;
default:
if (g_extra_types) {
diff --git a/chrome/browser/tab_contents/test_web_contents.cc b/chrome/browser/tab_contents/test_web_contents.cc
index 2977423..6aa4c6a 100644
--- a/chrome/browser/tab_contents/test_web_contents.cc
+++ b/chrome/browser/tab_contents/test_web_contents.cc
@@ -6,9 +6,8 @@
#include "chrome/browser/renderer_host/test_render_view_host.h"
-TestWebContents::TestWebContents(Profile* profile, SiteInstance* instance,
- RenderViewHostFactory* rvh_factory)
- : WebContents(profile, instance, rvh_factory, MSG_ROUTING_NONE, NULL),
+TestWebContents::TestWebContents(Profile* profile, SiteInstance* instance)
+ : WebContents(profile, instance, MSG_ROUTING_NONE, NULL),
transition_cross_site(false) {
}
diff --git a/chrome/browser/tab_contents/test_web_contents.h b/chrome/browser/tab_contents/test_web_contents.h
index 42ba35e..dea7d6d 100644
--- a/chrome/browser/tab_contents/test_web_contents.h
+++ b/chrome/browser/tab_contents/test_web_contents.h
@@ -15,8 +15,7 @@ class TestRenderViewHost;
class TestWebContents : public WebContents {
public:
// The render view host factory will be passed on to the
- TestWebContents(Profile* profile, SiteInstance* instance,
- RenderViewHostFactory* rvh_factory);
+ TestWebContents(Profile* profile, SiteInstance* instance);
TestRenderViewHost* pending_rvh();
diff --git a/chrome/browser/tab_contents/web_contents.cc b/chrome/browser/tab_contents/web_contents.cc
index 7f3164a..ee734d4 100644
--- a/chrome/browser/tab_contents/web_contents.cc
+++ b/chrome/browser/tab_contents/web_contents.cc
@@ -192,14 +192,11 @@ int WebContents::find_request_id_counter_ = -1;
WebContents::WebContents(Profile* profile,
SiteInstance* site_instance,
- RenderViewHostFactory* render_view_factory,
int routing_id,
base::WaitableEvent* modal_dialog_event)
: TabContents(TAB_CONTENTS_WEB),
view_(WebContentsView::Create(this)),
- ALLOW_THIS_IN_INITIALIZER_LIST(
- render_manager_(render_view_factory, this, this)),
- render_view_factory_(render_view_factory),
+ ALLOW_THIS_IN_INITIALIZER_LIST(render_manager_(this, this)),
printing_(*this),
notify_disconnection_(false),
received_page_title_(false),
diff --git a/chrome/browser/tab_contents/web_contents.h b/chrome/browser/tab_contents/web_contents.h
index 7663712..07e0db3 100644
--- a/chrome/browser/tab_contents/web_contents.h
+++ b/chrome/browser/tab_contents/web_contents.h
@@ -42,7 +42,6 @@ class PasswordManager;
class PluginInstaller;
class RenderProcessHost;
class RenderViewHost;
-class RenderViewHostFactory;
class RenderWidgetHost;
struct ThumbnailScore;
struct ViewHostMsg_FrameNavigate_Params;
@@ -75,7 +74,6 @@ class WebContents : public TabContents,
// directly.
WebContents(Profile* profile,
SiteInstance* instance,
- RenderViewHostFactory* render_view_factory,
int routing_id,
base::WaitableEvent* modal_dialog_event);
@@ -109,8 +107,10 @@ class WebContents : public TabContents,
return view_.get();
}
+#ifdef UNIT_TEST
// Expose the render manager for testing.
RenderViewHostManager* render_manager() { return &render_manager_; }
+#endif
// Page state getters & setters ----------------------------------------------
@@ -597,9 +597,6 @@ class WebContents : public TabContents,
// Manages creation and swapping of render views.
RenderViewHostManager render_manager_;
- // For testing, passed to new RenderViewHost managers.
- RenderViewHostFactory* render_view_factory_;
-
// Handles print preview and print job for this contents.
printing::PrintViewManager printing_;
diff --git a/chrome/browser/tab_contents/web_contents_unittest.cc b/chrome/browser/tab_contents/web_contents_unittest.cc
index 2f069e9..4245cab 100644
--- a/chrome/browser/tab_contents/web_contents_unittest.cc
+++ b/chrome/browser/tab_contents/web_contents_unittest.cc
@@ -351,8 +351,7 @@ TEST_F(WebContentsTest, NavigateTwoTabsCrossSite) {
contents()->TestDidNavigate(orig_rvh, params1);
// Open a new tab with the same SiteInstance, navigated to the same site.
- TestWebContents* contents2 = new TestWebContents(profile(), instance1,
- &rvh_factory_);
+ TestWebContents* contents2 = new TestWebContents(profile(), instance1);
params1.page_id = 2; // Need this since the site instance is the same (which
// is the scope of page IDs) and we want to consider
// this a new page.
@@ -409,8 +408,7 @@ TEST_F(WebContentsTest, CrossSiteComparesAgainstCurrentPage) {
contents()->TestDidNavigate(orig_rvh, params1);
// Open a related tab to a second site.
- TestWebContents* contents2 = new TestWebContents(profile(), instance1,
- &rvh_factory_);
+ TestWebContents* contents2 = new TestWebContents(profile(), instance1);
contents2->transition_cross_site = true;
contents2->SetupController(profile());
const GURL url2("http://www.yahoo.com");
diff --git a/chrome/browser/tab_contents/web_contents_view.cc b/chrome/browser/tab_contents/web_contents_view.cc
index 14cb744..689ce7e 100644
--- a/chrome/browser/tab_contents/web_contents_view.cc
+++ b/chrome/browser/tab_contents/web_contents_view.cc
@@ -31,7 +31,6 @@ void WebContentsView::CreateNewWindow(int route_id,
WebContents* new_contents =
new WebContents(web_contents()->profile(),
web_contents()->GetSiteInstance(),
- web_contents()->render_view_factory_,
route_id,
modal_dialog_event);
new_contents->SetupController(web_contents()->profile());
diff --git a/chrome/browser/tab_contents/web_contents_view_gtk.cc b/chrome/browser/tab_contents/web_contents_view_gtk.cc
index a013d0b..809c6c9 100644
--- a/chrome/browser/tab_contents/web_contents_view_gtk.cc
+++ b/chrome/browser/tab_contents/web_contents_view_gtk.cc
@@ -13,6 +13,7 @@
#include "base/gfx/rect.h"
#include "chrome/browser/gtk/browser_window_gtk.h"
#include "chrome/browser/renderer_host/render_view_host.h"
+#include "chrome/browser/renderer_host/render_view_host_factory.h"
#include "chrome/browser/renderer_host/render_widget_host_view_gtk.h"
#include "chrome/browser/tab_contents/render_view_context_menu_gtk.h"
#include "chrome/browser/tab_contents/tab_contents_delegate.h"
@@ -81,7 +82,7 @@ RenderWidgetHostView* WebContentsViewGtk::CreateViewForWidget(
// this actually is happening (and somebody isn't accidentally creating the
// view twice), we check for the RVH Factory, which will be set when we're
// making special ones (which go along with the special views).
- DCHECK(web_contents()->render_manager()->has_render_view_host_factory());
+ DCHECK(RenderViewHostFactory::has_factory());
return render_widget_host->view();
}
diff --git a/chrome/browser/tab_contents/web_contents_view_win.cc b/chrome/browser/tab_contents/web_contents_view_win.cc
index 6ad4d4f..3fd45b9 100644
--- a/chrome/browser/tab_contents/web_contents_view_win.cc
+++ b/chrome/browser/tab_contents/web_contents_view_win.cc
@@ -13,6 +13,7 @@
#include "chrome/browser/download/download_request_manager.h"
#include "chrome/browser/renderer_host/render_process_host.h"
#include "chrome/browser/renderer_host/render_view_host.h"
+#include "chrome/browser/renderer_host/render_view_host_factory.h"
#include "chrome/browser/renderer_host/render_widget_host_view_win.h"
#include "chrome/browser/tab_contents/render_view_context_menu_win.h"
#include "chrome/browser/tab_contents/interstitial_page.h"
@@ -88,7 +89,7 @@ RenderWidgetHostView* WebContentsViewWin::CreateViewForWidget(
// this actually is happening (and somebody isn't accidentally creating the
// view twice), we check for the RVH Factory, which will be set when we're
// making special ones (which go along with the special views).
- DCHECK(web_contents()->render_manager()->has_render_view_host_factory());
+ DCHECK(RenderViewHostFactory::has_factory());
return render_widget_host->view();
}
diff --git a/chrome/browser/tabs/tab_strip_model_unittest.cc b/chrome/browser/tabs/tab_strip_model_unittest.cc
index 72f9af0..9c5e646 100644
--- a/chrome/browser/tabs/tab_strip_model_unittest.cc
+++ b/chrome/browser/tabs/tab_strip_model_unittest.cc
@@ -65,7 +65,7 @@ class TabStripDummyDelegate : public TabStripModelDelegate {
class TabStripModelTest : public RenderViewHostTestHarness {
public:
TabContents* CreateTabContents() {
- WebContents* con = new WebContents(profile(), NULL, &rvh_factory_, 0, NULL);
+ WebContents* con = new WebContents(profile(), NULL, 0, NULL);
con->SetupController(profile());
return con;
}
diff --git a/chrome/browser/views/dom_view.cc b/chrome/browser/views/dom_view.cc
index 9af3b66..c915e39 100644
--- a/chrome/browser/views/dom_view.cc
+++ b/chrome/browser/views/dom_view.cc
@@ -23,8 +23,7 @@ bool DOMView::Init(Profile* profile, SiteInstance* instance) {
return true;
initialized_ = true;
- web_contents_ = new WebContents(profile, instance, NULL,
- MSG_ROUTING_NONE, NULL);
+ web_contents_ = new WebContents(profile, instance, MSG_ROUTING_NONE, NULL);
views::HWNDView::Attach(web_contents_->GetNativeView());
web_contents_->SetupController(profile);
return true;
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index 8a1dfb4..da52d1c 100644
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -910,6 +910,8 @@
'browser/renderer_host/render_view_host.cc',
'browser/renderer_host/render_view_host.h',
'browser/renderer_host/render_view_host_delegate.h',
+ 'browser/renderer_host/render_view_host_factory.cc',
+ 'browser/renderer_host/render_view_host_factory.h',
'browser/renderer_host/render_widget_helper.cc',
'browser/renderer_host/render_widget_helper.h',
'browser/renderer_host/render_widget_host.cc',