OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_TEST_BASE_TEST_TAB_STRIP_MODEL_OBSERVER_H_ | 5 #ifndef CHROME_TEST_BASE_TEST_TAB_STRIP_MODEL_OBSERVER_H_ |
6 #define CHROME_TEST_BASE_TEST_TAB_STRIP_MODEL_OBSERVER_H_ | 6 #define CHROME_TEST_BASE_TEST_TAB_STRIP_MODEL_OBSERVER_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" | 9 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" |
| 10 #include "content/public/browser/notification_observer.h" |
| 11 #include "content/public/browser/notification_registrar.h" |
10 #include "content/public/test/test_navigation_observer.h" | 12 #include "content/public/test/test_navigation_observer.h" |
11 | 13 |
12 class TabStripModel; | 14 class TabStripModel; |
13 | 15 |
| 16 namespace content { |
| 17 class JsInjectionReadyObserver; |
| 18 } |
| 19 |
14 // In order to support testing of print preview, we need to wait for the | 20 // In order to support testing of print preview, we need to wait for the |
15 // constrained window to block the current tab, and then observe notifications | 21 // constrained window to block the current tab, and then observe notifications |
16 // on the newly added tab's controller to wait for it to be loaded. | 22 // on the newly added tab's controller to wait for it to be loaded. |
17 // To support tests registering javascript WebUI handlers, we need to inject | 23 // To support tests registering javascript WebUI handlers, we need to inject |
18 // the framework & registration javascript before the webui page loads by | 24 // the framework & registration javascript before the webui page loads by |
19 // calling back through the TestTabStripModelObserver::LoadStartObserver when | 25 // calling back through the TestTabStripModelObserver::LoadStartObserver when |
20 // the new page starts loading. | 26 // the new page starts loading. |
21 class TestTabStripModelObserver : public content::TestNavigationObserver, | 27 class TestTabStripModelObserver : public content::TestNavigationObserver, |
22 public TabStripModelObserver { | 28 public TabStripModelObserver { |
23 public: | 29 public: |
24 // Observe the |tab_strip_model|, which may not be NULL. If | 30 // Observe the |tab_strip_model|, which may not be NULL. If |
25 // |load_start_observer| is non-NULL, notify when the page load starts. | 31 // |load_start_observer| is non-NULL, notify when the page load starts. |
26 TestTabStripModelObserver( | 32 TestTabStripModelObserver( |
27 TabStripModel* tab_strip_model, | 33 TabStripModel* tab_strip_model, |
28 content::JsInjectionReadyObserver* js_injection_ready_observer); | 34 content::JsInjectionReadyObserver* js_injection_ready_observer); |
29 virtual ~TestTabStripModelObserver(); | 35 virtual ~TestTabStripModelObserver(); |
30 | 36 |
31 private: | 37 private: |
| 38 class RenderViewHostInitializedObserver; |
| 39 |
| 40 // content::NotificationObserver: |
| 41 virtual void Observe(int type, |
| 42 const content::NotificationSource& source, |
| 43 const content::NotificationDetails& details) OVERRIDE; |
| 44 |
32 // Callback to observer the print preview dialog associated with |contents|. | 45 // Callback to observer the print preview dialog associated with |contents|. |
33 void ObservePrintPreviewDialog(content::WebContents* contents); | 46 void ObservePrintPreviewDialog(content::WebContents* contents); |
34 | 47 |
35 // TabStripModelObserver: | 48 // TabStripModelObserver: |
36 virtual void TabBlockedStateChanged(content::WebContents* contents, | 49 virtual void TabBlockedStateChanged(content::WebContents* contents, |
37 int index) OVERRIDE; | 50 int index) OVERRIDE; |
38 | 51 |
39 // |tab_strip_model_| is the object this observes. The constructor will | 52 // |tab_strip_model_| is the object this observes. The constructor will |
40 // register this as an observer, and the destructor will remove the observer. | 53 // register this as an observer, and the destructor will remove the observer. |
41 TabStripModel* tab_strip_model_; | 54 TabStripModel* tab_strip_model_; |
42 | 55 |
| 56 // RenderViewHost watched for JS injection. |
| 57 scoped_ptr<RenderViewHostInitializedObserver> rvh_observer_; |
| 58 |
| 59 content::JsInjectionReadyObserver* injection_observer_; |
| 60 |
| 61 content::NotificationRegistrar registrar_; |
| 62 |
43 DISALLOW_COPY_AND_ASSIGN(TestTabStripModelObserver); | 63 DISALLOW_COPY_AND_ASSIGN(TestTabStripModelObserver); |
44 }; | 64 }; |
45 | 65 |
46 #endif // CHROME_TEST_BASE_TEST_TAB_STRIP_MODEL_OBSERVER_H_ | 66 #endif // CHROME_TEST_BASE_TEST_TAB_STRIP_MODEL_OBSERVER_H_ |
OLD | NEW |