summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-18 21:50:51 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-18 21:50:51 +0000
commitfacf11efd060d2abcb1d7c296f31d552eab496c8 (patch)
tree06f5c9a10b303d940ecbae4fa423672391bf075b
parentb0a95726b8532c4c858b9de019f9f9e2cb573041 (diff)
downloadchromium_src-facf11efd060d2abcb1d7c296f31d552eab496c8.zip
chromium_src-facf11efd060d2abcb1d7c296f31d552eab496c8.tar.gz
chromium_src-facf11efd060d2abcb1d7c296f31d552eab496c8.tar.bz2
content: Move all listeners of NOTIFICATION_RENDER_VIEW_HOST_CREATED out of content.
This is a prerequisite of converting NOTIFICATION_RENDER_VIEW_HOST_CREATED to listeners of RenderViewCreated callback propagated through ContentBrowserClient in chrome. BUG=170921 Review URL: https://codereview.chromium.org/12832004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@188840 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/download/download_browsertest.cc1
-rw-r--r--chrome/browser/errorpage_browsertest.cc1
-rw-r--r--chrome/browser/extensions/app_process_apitest.cc1
-rw-r--r--chrome/browser/history/redirect_browsertest.cc2
-rw-r--r--chrome/browser/managed_mode/managed_mode_resource_throttle_browsertest.cc2
-rw-r--r--chrome/browser/performance_monitor/performance_monitor_browsertest.cc2
-rw-r--r--chrome/browser/prerender/prerender_browsertest.cc2
-rw-r--r--chrome/browser/sessions/session_restore_browsertest.cc2
-rw-r--r--chrome/browser/ui/browser_browsertest.cc1
-rw-r--r--chrome/browser/ui/fullscreen/fullscreen_controller_test.cc4
-rw-r--r--chrome/browser/ui/webui/bookmarks_ui_browsertest.cc2
-rw-r--r--chrome/test/base/in_process_browser_test.cc2
-rw-r--r--chrome/test/base/test_tab_strip_model_observer.cc46
-rw-r--r--chrome/test/base/test_tab_strip_model_observer.h20
-rw-r--r--chrome/test/base/ui_test_utils.cc5
-rw-r--r--chrome/test/base/web_ui_browsertest.cc58
-rw-r--r--content/public/test/test_navigation_observer.cc47
-rw-r--r--content/public/test/test_navigation_observer.h33
-rw-r--r--content/test/content_browser_test_utils.cc1
19 files changed, 136 insertions, 96 deletions
diff --git a/chrome/browser/download/download_browsertest.cc b/chrome/browser/download/download_browsertest.cc
index 35354a4..20823dc 100644
--- a/chrome/browser/download/download_browsertest.cc
+++ b/chrome/browser/download/download_browsertest.cc
@@ -1177,7 +1177,6 @@ IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadResourceThrottleCancels) {
content::TestNavigationObserver observer(
content::Source<content::NavigationController>(
&web_contents->GetController()),
- NULL,
1);
bool download_assempted;
ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
diff --git a/chrome/browser/errorpage_browsertest.cc b/chrome/browser/errorpage_browsertest.cc
index 76d9c02..1513006 100644
--- a/chrome/browser/errorpage_browsertest.cc
+++ b/chrome/browser/errorpage_browsertest.cc
@@ -94,7 +94,6 @@ class ErrorPageTest : public InProcessBrowserTest {
content::Source<NavigationController>(
&browser()->tab_strip_model()->GetActiveWebContents()->
GetController()),
- NULL,
num_navigations);
if (direction == HISTORY_NAVIGATE_BACK) {
chrome::GoBack(browser(), CURRENT_TAB);
diff --git a/chrome/browser/extensions/app_process_apitest.cc b/chrome/browser/extensions/app_process_apitest.cc
index 70034c1..53c1455 100644
--- a/chrome/browser/extensions/app_process_apitest.cc
+++ b/chrome/browser/extensions/app_process_apitest.cc
@@ -612,7 +612,6 @@ IN_PROC_BROWSER_TEST_F(AppApiTest, OpenAppFromExtension) {
// 3. The app's URL.
content::TestNavigationObserver test_navigation_observer(
content::NotificationService::AllSources(),
- NULL,
3);
// Load the launcher extension, which should launch the app.
diff --git a/chrome/browser/history/redirect_browsertest.cc b/chrome/browser/history/redirect_browsertest.cc
index 039af8f..b0547de 100644
--- a/chrome/browser/history/redirect_browsertest.cc
+++ b/chrome/browser/history/redirect_browsertest.cc
@@ -281,7 +281,7 @@ IN_PROC_BROWSER_TEST_F(RedirectTest,
content::TestNavigationObserver observer(
content::Source<content::NavigationController>(
&web_contents->GetController()),
- NULL, 2);
+ 2);
ui_test_utils::NavigateToURLWithDisposition(
browser(), first_url, CURRENT_TAB, ui_test_utils::BROWSER_TEST_NONE);
diff --git a/chrome/browser/managed_mode/managed_mode_resource_throttle_browsertest.cc b/chrome/browser/managed_mode/managed_mode_resource_throttle_browsertest.cc
index 9aa0828..4d5a842 100644
--- a/chrome/browser/managed_mode/managed_mode_resource_throttle_browsertest.cc
+++ b/chrome/browser/managed_mode/managed_mode_resource_throttle_browsertest.cc
@@ -48,7 +48,7 @@ IN_PROC_BROWSER_TEST_F(ManagedModeResourceThrottleTest, NoNavigationObserver) {
WebContents::Create(WebContents::CreateParams(browser()->profile())));
NavigationController& controller = web_contents->GetController();
content::TestNavigationObserver observer(
- content::Source<NavigationController>(&controller), NULL, 1);
+ content::Source<NavigationController>(&controller), 1);
controller.LoadURL(GURL("http://www.example.com"), content::Referrer(),
content::PAGE_TRANSITION_TYPED, std::string());
observer.Wait();
diff --git a/chrome/browser/performance_monitor/performance_monitor_browsertest.cc b/chrome/browser/performance_monitor/performance_monitor_browsertest.cc
index 9382169..75bd3cd 100644
--- a/chrome/browser/performance_monitor/performance_monitor_browsertest.cc
+++ b/chrome/browser/performance_monitor/performance_monitor_browsertest.cc
@@ -369,7 +369,7 @@ class PerformanceMonitorSessionRestoreBrowserTest
// Create a new window, which should trigger session restore.
ui_test_utils::BrowserAddedObserver window_observer;
content::TestNavigationObserver navigation_observer(
- content::NotificationService::AllSources(), NULL, expected_tab_count);
+ content::NotificationService::AllSources(), expected_tab_count);
chrome::NewEmptyWindow(profile, chrome::HOST_DESKTOP_TYPE_NATIVE);
Browser* new_browser = window_observer.WaitForSingleNewBrowser();
navigation_observer.Wait();
diff --git a/chrome/browser/prerender/prerender_browsertest.cc b/chrome/browser/prerender/prerender_browsertest.cc
index ece0d38..78439db 100644
--- a/chrome/browser/prerender/prerender_browsertest.cc
+++ b/chrome/browser/prerender/prerender_browsertest.cc
@@ -1154,7 +1154,7 @@ class PrerenderBrowserTest : virtual public InProcessBrowserTest {
// We don't expect to pick up a running prerender, so instead
// observe one navigation.
content::TestNavigationObserver observer(
- content::NotificationService::AllSources(), NULL, 1);
+ content::NotificationService::AllSources(), 1);
base::RunLoop run_loop;
observer.WaitForObservation(
base::Bind(&content::RunThisRunLoop,
diff --git a/chrome/browser/sessions/session_restore_browsertest.cc b/chrome/browser/sessions/session_restore_browsertest.cc
index 5eae0aa..d410a55 100644
--- a/chrome/browser/sessions/session_restore_browsertest.cc
+++ b/chrome/browser/sessions/session_restore_browsertest.cc
@@ -124,7 +124,7 @@ class SessionRestoreTest : public InProcessBrowserTest {
// Create a new window, which should trigger session restore.
ui_test_utils::BrowserAddedObserver window_observer;
content::TestNavigationObserver navigation_observer(
- content::NotificationService::AllSources(), NULL, expected_tab_count);
+ content::NotificationService::AllSources(), expected_tab_count);
chrome::NewEmptyWindow(profile, chrome::HOST_DESKTOP_TYPE_NATIVE);
Browser* new_browser = window_observer.WaitForSingleNewBrowser();
navigation_observer.Wait();
diff --git a/chrome/browser/ui/browser_browsertest.cc b/chrome/browser/ui/browser_browsertest.cc
index 8338f68..5c18389 100644
--- a/chrome/browser/ui/browser_browsertest.cc
+++ b/chrome/browser/ui/browser_browsertest.cc
@@ -1930,7 +1930,6 @@ class ClickModifierTest : public InProcessBrowserTest {
web_contents ? &web_contents->GetController() : NULL;
content::TestNavigationObserver same_tab_observer(
content::Source<NavigationController>(controller),
- NULL,
1);
SimulateMouseClick(web_contents, modifiers, button);
base::RunLoop run_loop;
diff --git a/chrome/browser/ui/fullscreen/fullscreen_controller_test.cc b/chrome/browser/ui/fullscreen/fullscreen_controller_test.cc
index ea26d7b..1880eee 100644
--- a/chrome/browser/ui/fullscreen/fullscreen_controller_test.cc
+++ b/chrome/browser/ui/fullscreen/fullscreen_controller_test.cc
@@ -86,7 +86,7 @@ void FullscreenControllerTest::DenyCurrentFullscreenOrMouseLockRequest() {
void FullscreenControllerTest::GoBack() {
content::TestNavigationObserver observer(
- content::NotificationService::AllSources(), NULL, 1);
+ content::NotificationService::AllSources(), 1);
chrome::GoBack(browser(), CURRENT_TAB);
@@ -95,7 +95,7 @@ void FullscreenControllerTest::GoBack() {
void FullscreenControllerTest::Reload() {
content::TestNavigationObserver observer(
- content::NotificationService::AllSources(), NULL, 1);
+ content::NotificationService::AllSources(), 1);
chrome::Reload(browser(), CURRENT_TAB);
diff --git a/chrome/browser/ui/webui/bookmarks_ui_browsertest.cc b/chrome/browser/ui/webui/bookmarks_ui_browsertest.cc
index 80c8dfc..2053948 100644
--- a/chrome/browser/ui/webui/bookmarks_ui_browsertest.cc
+++ b/chrome/browser/ui/webui/bookmarks_ui_browsertest.cc
@@ -22,7 +22,7 @@ class BookmarksTest : public InProcessBrowserTest {
void OpenBookmarksManager() {
content::TestNavigationObserver navigation_observer(
- content::NotificationService::AllSources(), NULL, 2);
+ content::NotificationService::AllSources(), 2);
// Bring up the bookmarks manager tab.
chrome::ShowBookmarkManager(browser());
diff --git a/chrome/test/base/in_process_browser_test.cc b/chrome/test/base/in_process_browser_test.cc
index 18f439e..53aad1c 100644
--- a/chrome/test/base/in_process_browser_test.cc
+++ b/chrome/test/base/in_process_browser_test.cc
@@ -219,7 +219,7 @@ void InProcessBrowserTest::AddTabAtIndexToBrowser(
const GURL& url,
content::PageTransition transition) {
content::TestNavigationObserver observer(
- content::NotificationService::AllSources(), NULL, 1);
+ content::NotificationService::AllSources(), 1);
chrome::NavigateParams params(browser, url, transition);
params.tabstrip_index = index;
diff --git a/chrome/test/base/test_tab_strip_model_observer.cc b/chrome/test/base/test_tab_strip_model_observer.cc
index e613116..53917b1 100644
--- a/chrome/test/base/test_tab_strip_model_observer.cc
+++ b/chrome/test/base/test_tab_strip_model_observer.cc
@@ -8,14 +8,42 @@
#include "base/message_loop.h"
#include "chrome/browser/printing/print_preview_dialog_controller.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
+#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_source.h"
+#include "content/public/browser/notification_types.h"
+#include "content/public/browser/render_view_host_observer.h"
#include "content/public/browser/web_contents.h"
+#include "content/public/test/js_injection_ready_observer.h"
+
+class TestTabStripModelObserver::RenderViewHostInitializedObserver
+ : public content::RenderViewHostObserver {
+ public:
+ RenderViewHostInitializedObserver(content::RenderViewHost* render_view_host,
+ content::JsInjectionReadyObserver* observer)
+ : content::RenderViewHostObserver(render_view_host),
+ injection_observer_(observer) {
+ }
+
+ // content::RenderViewHostObserver:
+ virtual void RenderViewHostInitialized() OVERRIDE {
+ injection_observer_->OnJsInjectionReady(render_view_host());
+ }
+
+ private:
+ content::JsInjectionReadyObserver* injection_observer_;
+
+ DISALLOW_COPY_AND_ASSIGN(RenderViewHostInitializedObserver);
+};
TestTabStripModelObserver::TestTabStripModelObserver(
TabStripModel* tab_strip_model,
content::JsInjectionReadyObserver* js_injection_ready_observer)
- : TestNavigationObserver(js_injection_ready_observer, 1),
- tab_strip_model_(tab_strip_model) {
+ : TestNavigationObserver(1),
+ tab_strip_model_(tab_strip_model),
+ injection_observer_(js_injection_ready_observer) {
+ registrar_.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_CREATED,
+ content::NotificationService::AllSources());
+
tab_strip_model_->AddObserver(this);
}
@@ -23,6 +51,20 @@ TestTabStripModelObserver::~TestTabStripModelObserver() {
tab_strip_model_->RemoveObserver(this);
}
+void TestTabStripModelObserver::Observe(
+ int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) {
+ if (type == content::NOTIFICATION_RENDER_VIEW_HOST_CREATED) {
+ rvh_observer_.reset(
+ new RenderViewHostInitializedObserver(
+ content::Source<content::RenderViewHost>(source).ptr(),
+ injection_observer_));
+ } else {
+ content::TestNavigationObserver::Observe(type, source, details);
+ }
+}
+
void TestTabStripModelObserver::TabBlockedStateChanged(
content::WebContents* contents, int index) {
// Need to do this later - the print preview dialog has not been created yet.
diff --git a/chrome/test/base/test_tab_strip_model_observer.h b/chrome/test/base/test_tab_strip_model_observer.h
index 22a8ad5..f038f25 100644
--- a/chrome/test/base/test_tab_strip_model_observer.h
+++ b/chrome/test/base/test_tab_strip_model_observer.h
@@ -7,10 +7,16 @@
#include "base/compiler_specific.h"
#include "chrome/browser/ui/tabs/tab_strip_model_observer.h"
+#include "content/public/browser/notification_observer.h"
+#include "content/public/browser/notification_registrar.h"
#include "content/public/test/test_navigation_observer.h"
class TabStripModel;
+namespace content {
+class JsInjectionReadyObserver;
+}
+
// In order to support testing of print preview, we need to wait for the
// constrained window to block the current tab, and then observe notifications
// on the newly added tab's controller to wait for it to be loaded.
@@ -29,6 +35,13 @@ class TestTabStripModelObserver : public content::TestNavigationObserver,
virtual ~TestTabStripModelObserver();
private:
+ class RenderViewHostInitializedObserver;
+
+ // content::NotificationObserver:
+ virtual void Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) OVERRIDE;
+
// Callback to observer the print preview dialog associated with |contents|.
void ObservePrintPreviewDialog(content::WebContents* contents);
@@ -40,6 +53,13 @@ class TestTabStripModelObserver : public content::TestNavigationObserver,
// register this as an observer, and the destructor will remove the observer.
TabStripModel* tab_strip_model_;
+ // RenderViewHost watched for JS injection.
+ scoped_ptr<RenderViewHostInitializedObserver> rvh_observer_;
+
+ content::JsInjectionReadyObserver* injection_observer_;
+
+ content::NotificationRegistrar registrar_;
+
DISALLOW_COPY_AND_ASSIGN(TestTabStripModelObserver);
};
diff --git a/chrome/test/base/ui_test_utils.cc b/chrome/test/base/ui_test_utils.cc
index 884de82..0a2b555 100644
--- a/chrome/test/base/ui_test_utils.cc
+++ b/chrome/test/base/ui_test_utils.cc
@@ -193,7 +193,7 @@ bool GetCurrentTabTitle(const Browser* browser, string16* title) {
void WaitForNavigations(NavigationController* controller,
int number_of_navigations) {
content::TestNavigationObserver observer(
- content::Source<NavigationController>(controller), NULL,
+ content::Source<NavigationController>(controller),
number_of_navigations);
base::RunLoop run_loop;
observer.WaitForObservation(
@@ -226,7 +226,7 @@ Browser* OpenURLOffTheRecord(Profile* profile, const GURL& url) {
void NavigateToURL(chrome::NavigateParams* params) {
content::TestNavigationObserver observer(
- content::NotificationService::AllSources(), NULL, 1);
+ content::NotificationService::AllSources(), 1);
chrome::Navigate(params);
base::RunLoop run_loop;
observer.WaitForObservation(
@@ -257,7 +257,6 @@ static void NavigateToURLWithDispositionBlockUntilNavigationsComplete(
&tab_strip->GetActiveWebContents()->GetController() : NULL;
content::TestNavigationObserver same_tab_observer(
content::Source<NavigationController>(controller),
- NULL,
number_of_navigations);
std::set<Browser*> initial_browsers;
diff --git a/chrome/test/base/web_ui_browsertest.cc b/chrome/test/base/web_ui_browsertest.cc
index d868a429..544bf84 100644
--- a/chrome/test/base/web_ui_browsertest.cc
+++ b/chrome/test/base/web_ui_browsertest.cc
@@ -27,6 +27,11 @@
#include "chrome/test/base/test_tab_strip_model_observer.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/browser/navigation_controller.h"
+#include "content/public/browser/notification_observer.h"
+#include "content/public/browser/notification_registrar.h"
+#include "content/public/browser/notification_service.h"
+#include "content/public/browser/notification_types.h"
+#include "content/public/browser/render_view_host_observer.h"
#include "content/public/browser/url_data_source.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui_controller.h"
@@ -70,6 +75,56 @@ bool LogHandler(int severity,
return false;
}
+class RenderViewHostInitializedObserver
+ : public content::RenderViewHostObserver {
+ public:
+ RenderViewHostInitializedObserver(content::RenderViewHost* render_view_host,
+ content::JsInjectionReadyObserver* observer)
+ : content::RenderViewHostObserver(render_view_host),
+ injection_observer_(observer) {
+ }
+
+ // content::RenderViewHostObserver:
+ virtual void RenderViewHostInitialized() OVERRIDE {
+ injection_observer_->OnJsInjectionReady(render_view_host());
+ }
+
+ private:
+ content::JsInjectionReadyObserver* injection_observer_;
+
+ DISALLOW_COPY_AND_ASSIGN(RenderViewHostInitializedObserver);
+};
+
+class WebUIJsInjectionReadyObserver : public content::NotificationObserver {
+ public:
+ explicit WebUIJsInjectionReadyObserver(
+ content::JsInjectionReadyObserver* observer)
+ : injection_observer_(observer) {
+ registrar_.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_CREATED,
+ content::NotificationService::AllSources());
+ }
+
+ // content::NotificationObserver:
+ virtual void Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) OVERRIDE {
+ DCHECK_EQ(content::NOTIFICATION_RENDER_VIEW_HOST_CREATED, type);
+
+ rvh_observer_.reset(new RenderViewHostInitializedObserver(
+ content::Source<content::RenderViewHost>(source).ptr(),
+ injection_observer_));
+ }
+
+ private:
+ content::JsInjectionReadyObserver* injection_observer_;
+
+ scoped_ptr<RenderViewHostInitializedObserver> rvh_observer_;
+
+ content::NotificationRegistrar registrar_;
+
+ DISALLOW_COPY_AND_ASSIGN(WebUIJsInjectionReadyObserver);
+};
+
} // namespace
WebUIBrowserTest::~WebUIBrowserTest() {}
@@ -210,11 +265,12 @@ void WebUIBrowserTest::PreLoadJavascriptLibraries(
}
void WebUIBrowserTest::BrowsePreload(const GURL& browse_to) {
+ WebUIJsInjectionReadyObserver injection_observer(this);
content::TestNavigationObserver navigation_observer(
content::Source<NavigationController>(
&browser()->tab_strip_model()->
GetActiveWebContents()->GetController()),
- this, 1);
+ 1);
chrome::NavigateParams params(browser(), GURL(browse_to),
content::PAGE_TRANSITION_TYPED);
params.disposition = CURRENT_TAB;
diff --git a/content/public/test/test_navigation_observer.cc b/content/public/test/test_navigation_observer.cc
index 590d8a7..970d82d 100644
--- a/content/public/test/test_navigation_observer.cc
+++ b/content/public/test/test_navigation_observer.cc
@@ -9,52 +9,19 @@
#include "base/run_loop.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h"
-#include "content/public/browser/render_view_host_observer.h"
-#include "content/public/test/js_injection_ready_observer.h"
#include "content/public/test/test_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace content {
-// This class observes |render_view_host| and calls OnJsInjectionReady() of
-// |js_injection_ready_observer| when the time is right to inject JavaScript
-// into the page.
-class TestNavigationObserver::RVHOSendJS : public RenderViewHostObserver {
- public:
- RVHOSendJS(RenderViewHost* render_view_host,
- JsInjectionReadyObserver* js_injection_ready_observer)
- : RenderViewHostObserver(render_view_host),
- js_injection_ready_observer_(js_injection_ready_observer) {
- }
-
- private:
- // RenderViewHostObserver implementation.
- virtual void RenderViewHostInitialized() OVERRIDE {
- if (js_injection_ready_observer_)
- js_injection_ready_observer_->OnJsInjectionReady(render_view_host());
- }
-
- JsInjectionReadyObserver* js_injection_ready_observer_;
-
- DISALLOW_COPY_AND_ASSIGN(RVHOSendJS);
-};
-
TestNavigationObserver::TestNavigationObserver(
const NotificationSource& source,
- JsInjectionReadyObserver* js_injection_ready_observer,
int number_of_navigations)
: navigation_started_(false),
navigations_completed_(0),
number_of_navigations_(number_of_navigations),
- js_injection_ready_observer_(js_injection_ready_observer),
done_(false),
running_(false) {
- // When javascript injection is requested, register for RenderViewHost
- // creation.
- if (js_injection_ready_observer_) {
- registrar_.Add(this, NOTIFICATION_RENDER_VIEW_HOST_CREATED,
- NotificationService::AllSources());
- }
RegisterAsObserver(source);
}
@@ -63,7 +30,6 @@ TestNavigationObserver::TestNavigationObserver(
: navigation_started_(false),
navigations_completed_(0),
number_of_navigations_(1),
- js_injection_ready_observer_(NULL),
done_(false),
running_(false) {
RegisterAsObserver(source);
@@ -93,20 +59,12 @@ void TestNavigationObserver::Wait() {
}
TestNavigationObserver::TestNavigationObserver(
- JsInjectionReadyObserver* js_injection_ready_observer,
int number_of_navigations)
: navigation_started_(false),
navigations_completed_(0),
number_of_navigations_(number_of_navigations),
- js_injection_ready_observer_(js_injection_ready_observer),
done_(false),
running_(false) {
- // When javascript injection is requested, register for RenderViewHost
- // creation.
- if (js_injection_ready_observer_) {
- registrar_.Add(this, NOTIFICATION_RENDER_VIEW_HOST_CREATED,
- NotificationService::AllSources());
- }
}
void TestNavigationObserver::RegisterAsObserver(
@@ -138,11 +96,6 @@ void TestNavigationObserver::Observe(
}
}
break;
- case NOTIFICATION_RENDER_VIEW_HOST_CREATED:
- rvho_send_js_.reset(new RVHOSendJS(
- Source<RenderViewHost>(source).ptr(),
- js_injection_ready_observer_));
- break;
default:
NOTREACHED();
}
diff --git a/content/public/test/test_navigation_observer.h b/content/public/test/test_navigation_observer.h
index 70cda33..e7c2f86 100644
--- a/content/public/test/test_navigation_observer.h
+++ b/content/public/test/test_navigation_observer.h
@@ -13,24 +13,12 @@
namespace content {
-class JsInjectionReadyObserver;
-
// For browser_tests, which run on the UI thread, run a second
-// MessageLoop and quit when the navigation completes loading. For
-// WebUI tests that need to inject javascript, construct with a
-// JsInjectionReadyObserver and this class will call its
-// OnJsInjectionReady() at the appropriate time.
+// MessageLoop and quit when the navigation completes loading.
class TestNavigationObserver : public NotificationObserver {
public:
- class RVHOSendJS;
-
- // Create and register a new TestNavigationObserver against the
- // |controller|. When |js_injection_ready_observer| is non-null, notify with
- // OnEntryCommitted() after |number_of_navigations| navigations.
- // Note: |js_injection_ready_observer| is owned by the caller and should be
- // valid until this class is destroyed.
+ // Create and register a new TestNavigationObserver against the |source|.
TestNavigationObserver(const NotificationSource& source,
- JsInjectionReadyObserver* js_injection_ready_observer,
int number_of_navigations);
// Like above but waits for one navigation.
explicit TestNavigationObserver(const NotificationSource& source);
@@ -44,21 +32,16 @@ class TestNavigationObserver : public NotificationObserver {
void Wait();
protected:
- // Note: |js_injection_ready_observer| is owned by the caller and should be
- // valid until this class is destroyed. Subclasses using this constructor MUST
- // call RegisterAsObserver when a NavigationController becomes available.
- explicit TestNavigationObserver(
- JsInjectionReadyObserver* js_injection_ready_observer,
- int number_of_navigations);
+ explicit TestNavigationObserver(int number_of_navigations);
// Register this TestNavigationObserver as an observer of the |source|.
void RegisterAsObserver(const NotificationSource& source);
- private:
// NotificationObserver:
virtual void Observe(int type, const NotificationSource& source,
const NotificationDetails& details) OVERRIDE;
+ private:
NotificationRegistrar registrar_;
// If true the navigation has started.
@@ -70,10 +53,6 @@ class TestNavigationObserver : public NotificationObserver {
// The number of navigations to wait for.
int number_of_navigations_;
- // Observer to take some action when the page is ready for JavaScript
- // injection.
- JsInjectionReadyObserver* js_injection_ready_observer_;
-
// |done_| will get set when this object observes a TabStripModel event.
bool done_;
@@ -84,10 +63,6 @@ class TestNavigationObserver : public NotificationObserver {
// |running_| will be true during WaitForObservation until |done_| is true.
bool running_;
- // |rvho_send_js_| will hold a RenderViewHostObserver subclass to allow
- // JavaScript injection at the appropriate time.
- scoped_ptr<RVHOSendJS> rvho_send_js_;
-
DISALLOW_COPY_AND_ASSIGN(TestNavigationObserver);
};
diff --git a/content/test/content_browser_test_utils.cc b/content/test/content_browser_test_utils.cc
index c67050c..32d2597 100644
--- a/content/test/content_browser_test_utils.cc
+++ b/content/test/content_browser_test_utils.cc
@@ -39,7 +39,6 @@ void NavigateToURLBlockUntilNavigationsComplete(Shell* window,
NavigationController* controller = &window->web_contents()->GetController();
TestNavigationObserver same_tab_observer(
Source<NavigationController>(controller),
- NULL,
number_of_navigations);
window->LoadURL(url);