summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-16 18:04:36 +0000
committeraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-16 18:04:36 +0000
commitcf430e2ea4fb5a3e65cb4ca16061ac6663d0ab1c (patch)
tree3e93a4cf6b79d02a8d7382482c0503f1947d65d0
parent86cf1066d2361c94f5d56f51188e10f5b4e90b02 (diff)
downloadchromium_src-cf430e2ea4fb5a3e65cb4ca16061ac6663d0ab1c.zip
chromium_src-cf430e2ea4fb5a3e65cb4ca16061ac6663d0ab1c.tar.gz
chromium_src-cf430e2ea4fb5a3e65cb4ca16061ac6663d0ab1c.tar.bz2
Fix for bug where we would not create ExtensionFunctionDispatcher
instances for ExtensionDOMUI if RenderView was reused. BUG=16853 TEST=Added browser test Review URL: http://codereview.chromium.org/155592 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20880 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/dom_ui/dom_ui.h8
-rw-r--r--chrome/browser/extensions/extension_browsertests_misc.cc12
-rw-r--r--chrome/browser/extensions/extension_dom_ui.cc6
-rw-r--r--chrome/browser/extensions/extension_dom_ui.h1
-rw-r--r--chrome/browser/tab_contents/render_view_host_manager.cc3
5 files changed, 30 insertions, 0 deletions
diff --git a/chrome/browser/dom_ui/dom_ui.h b/chrome/browser/dom_ui/dom_ui.h
index fad04e5..d5204b1 100644
--- a/chrome/browser/dom_ui/dom_ui.h
+++ b/chrome/browser/dom_ui/dom_ui.h
@@ -29,8 +29,16 @@ class DOMUI {
explicit DOMUI(TabContents* contents);
virtual ~DOMUI();
+ // Called by RenderViewHost when the RenderView is first created. This is
+ // *not* called for every page load because in some cases
+ // RenderViewHostManager will reuse RenderView instances. In those cases,
+ // RenderViewReused will be called instead.
virtual void RenderViewCreated(RenderViewHost* render_view_host) {}
+ // Called by RenderViewHostManager when a RenderView is reused to display a
+ // page.
+ virtual void RenderViewReused(RenderViewHost* render_view_host) {}
+
// Called from DOMUIContents.
virtual void ProcessDOMUIMessage(const std::string& message,
const std::string& content,
diff --git a/chrome/browser/extensions/extension_browsertests_misc.cc b/chrome/browser/extensions/extension_browsertests_misc.cc
index 99c8b19..48fb0ca 100644
--- a/chrome/browser/extensions/extension_browsertests_misc.cc
+++ b/chrome/browser/extensions/extension_browsertests_misc.cc
@@ -131,6 +131,18 @@ IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, TabContents) {
browser()->GetSelectedTabContents()->render_view_host(), L"",
L"testTabsAPI()", &result);
EXPECT_TRUE(result);
+
+ // There was a bug where we would crash if we navigated to a page in the same
+ // extension because no new render view was getting created, so we would not
+ // do some setup.
+ ui_test_utils::NavigateToURL(
+ browser(),
+ GURL("chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/page.html"));
+ result = false;
+ ui_test_utils::ExecuteJavaScriptAndExtractBool(
+ browser()->GetSelectedTabContents()->render_view_host(), L"",
+ L"testTabsAPI()", &result);
+ EXPECT_TRUE(result);
}
// Tests that we can load page actions in the Omnibox.
diff --git a/chrome/browser/extensions/extension_dom_ui.cc b/chrome/browser/extensions/extension_dom_ui.cc
index 0d24345..2fa4eb3 100644
--- a/chrome/browser/extensions/extension_dom_ui.cc
+++ b/chrome/browser/extensions/extension_dom_ui.cc
@@ -18,6 +18,12 @@ void ExtensionDOMUI::RenderViewCreated(RenderViewHost* render_view_host) {
tab_contents()->GetURL()));
}
+void ExtensionDOMUI::RenderViewReused(RenderViewHost* render_view_host) {
+ extension_function_dispatcher_.reset(
+ new ExtensionFunctionDispatcher(render_view_host, this,
+ tab_contents()->GetURL()));
+}
+
void ExtensionDOMUI::ProcessDOMUIMessage(const std::string& message,
const std::string& content,
int request_id,
diff --git a/chrome/browser/extensions/extension_dom_ui.h b/chrome/browser/extensions/extension_dom_ui.h
index 2de94cf..d80c503 100644
--- a/chrome/browser/extensions/extension_dom_ui.h
+++ b/chrome/browser/extensions/extension_dom_ui.h
@@ -18,6 +18,7 @@ class ExtensionDOMUI
// DOMUI
virtual void RenderViewCreated(RenderViewHost* render_view_host);
+ virtual void RenderViewReused(RenderViewHost* render_view_host);
virtual void ProcessDOMUIMessage(const std::string& message,
const std::string& content,
int request_id,
diff --git a/chrome/browser/tab_contents/render_view_host_manager.cc b/chrome/browser/tab_contents/render_view_host_manager.cc
index a34668c..e5b3645 100644
--- a/chrome/browser/tab_contents/render_view_host_manager.cc
+++ b/chrome/browser/tab_contents/render_view_host_manager.cc
@@ -564,6 +564,9 @@ RenderViewHost* RenderViewHostManager::UpdateRendererStateForNavigate(
return pending_render_view_host_;
} else {
+ if (pending_dom_ui_.get() && render_view_host_->IsRenderViewLive())
+ pending_dom_ui_->RenderViewReused(render_view_host_);
+
// The renderer can exit view source mode when any error or cancellation
// happen. We must overwrite to recover the mode.
if (entry.IsViewSourceMode()) {