Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(501)

Unified Diff: chrome/test/base/test_tab_strip_model_observer.cc

Issue 12832004: content: Move all listeners of NOTIFICATION_RENDER_VIEW_HOST_CREATED out of content. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/base/test_tab_strip_model_observer.h ('k') | chrome/test/base/ui_test_utils.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/base/test_tab_strip_model_observer.cc
diff --git a/chrome/test/base/test_tab_strip_model_observer.cc b/chrome/test/base/test_tab_strip_model_observer.cc
index e61311688b57f15a11d50750a56bd8c69bb70f04..53917b14a8989091f79adb66aa86827533ee4970 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.
« no previous file with comments | « chrome/test/base/test_tab_strip_model_observer.h ('k') | chrome/test/base/ui_test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698