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_WEB_DIALOG_OBSERVER_H_ | 5 #ifndef CHROME_TEST_BASE_TEST_WEB_DIALOG_OBSERVER_H_ |
6 #define CHROME_TEST_BASE_TEST_WEB_DIALOG_OBSERVER_H_ | 6 #define CHROME_TEST_BASE_TEST_WEB_DIALOG_OBSERVER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "chrome/browser/ui/webui/web_dialog_observer.h" |
11 #include "content/public/browser/notification_observer.h" | 12 #include "content/public/browser/notification_observer.h" |
12 #include "content/public/browser/notification_registrar.h" | 13 #include "content/public/browser/notification_registrar.h" |
13 | 14 |
14 class JsInjectionReadyObserver; | 15 class JsInjectionReadyObserver; |
15 | 16 |
16 namespace content { | 17 namespace content { |
| 18 class RenderViewHost; |
17 class WebUI; | 19 class WebUI; |
18 } | 20 } |
19 | 21 |
20 // For browser_tests, which run on the UI thread, run a second message | 22 // For browser_tests, which run on the UI thread, run a second message |
21 // MessageLoop to detect WebDialog creation and quit when the constructed | 23 // MessageLoop to detect WebDialog creation and quit when the constructed |
22 // WebUI instance is captured and ready. | 24 // WebUI instance is captured and ready. |
23 class TestWebDialogObserver : public content::NotificationObserver { | 25 class TestWebDialogObserver : public content::NotificationObserver, |
| 26 public WebDialogObserver { |
24 public: | 27 public: |
25 // Create and register a new TestWebDialogObserver. If | 28 // Create and register a new TestWebDialogObserver. If |
26 // |js_injection_ready_observer| is non-NULL, notify it as soon as the RVH is | 29 // |js_injection_ready_observer| is non-NULL, notify it as soon as the RVH is |
27 // available. | 30 // available. |
28 explicit TestWebDialogObserver( | 31 explicit TestWebDialogObserver( |
29 JsInjectionReadyObserver* js_injection_ready_observer); | 32 JsInjectionReadyObserver* js_injection_ready_observer); |
30 virtual ~TestWebDialogObserver(); | 33 virtual ~TestWebDialogObserver(); |
31 | 34 |
| 35 // Overridden from WebDialogObserver: |
| 36 virtual void OnDialogShown( |
| 37 content::WebUI* webui, |
| 38 content::RenderViewHost* render_view_host) OVERRIDE; |
| 39 |
32 // Waits for an WebDialog to be created. The WebUI instance is captured | 40 // Waits for an WebDialog to be created. The WebUI instance is captured |
33 // and the method returns it when the navigation on the dialog is complete. | 41 // and the method returns it when the navigation on the dialog is complete. |
34 content::WebUI* GetWebUI(); | 42 content::WebUI* GetWebUI(); |
35 | 43 |
36 private: | 44 private: |
37 // content::NotificationObserver: | 45 // content::NotificationObserver: |
38 virtual void Observe(int type, | 46 virtual void Observe(int type, |
39 const content::NotificationSource& source, | 47 const content::NotificationSource& source, |
40 const content::NotificationDetails& details) OVERRIDE; | 48 const content::NotificationDetails& details) OVERRIDE; |
41 | 49 |
42 content::NotificationRegistrar registrar_; | 50 content::NotificationRegistrar registrar_; |
43 | 51 |
44 // Observer to take some action when the dialog is ready for JavaScript | 52 // Observer to take some action when the dialog is ready for JavaScript |
45 // injection. | 53 // injection. |
46 JsInjectionReadyObserver* js_injection_ready_observer_; | 54 JsInjectionReadyObserver* js_injection_ready_observer_; |
47 content::WebUI* web_ui_; | 55 content::WebUI* web_ui_; |
48 bool done_; | 56 bool done_; |
49 bool running_; | 57 bool running_; |
50 | 58 |
51 DISALLOW_COPY_AND_ASSIGN(TestWebDialogObserver); | 59 DISALLOW_COPY_AND_ASSIGN(TestWebDialogObserver); |
52 }; | 60 }; |
53 | 61 |
54 #endif // CHROME_TEST_BASE_TEST_WEB_DIALOG_OBSERVER_H_ | 62 #endif // CHROME_TEST_BASE_TEST_WEB_DIALOG_OBSERVER_H_ |
OLD | NEW |