OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_TEST_NAVIGATION_OBSERVER_H_ | 5 #ifndef CHROME_TEST_BASE_TEST_NAVIGATION_OBSERVER_H_ |
Paweł Hajdan Jr.
2011/11/17 09:47:10
If you're moving this, could you rather move it to
Sheridan Rawlins
2011/11/17 16:46:25
I don't feel comfortable adding that to this scope
Paweł Hajdan Jr.
2011/11/17 17:11:42
You're moving this anyway, so it really makes sens
Sheridan Rawlins
2011/11/17 23:20:35
Thanks for the suggestion. Filed http://crbug.com
Sheridan Rawlins
2011/11/18 05:17:34
Argh... Now I'm hitting check_deps because of the
Paweł Hajdan Jr.
2011/11/21 08:57:25
Okay, feel free to commit without this move (LGTM)
Sheridan Rawlins
2011/11/23 20:10:07
FYI, filed http://crbug.com/105213 for followup.
| |
6 #define CHROME_TEST_TEST_NAVIGATION_OBSERVER_H_ | 6 #define CHROME_TEST_BASE_TEST_NAVIGATION_OBSERVER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "content/public/browser/notification_observer.h" | 11 #include "content/public/browser/notification_observer.h" |
12 #include "content/public/browser/notification_registrar.h" | 12 #include "content/public/browser/notification_registrar.h" |
13 | 13 |
14 class JsInjectionReadyObserver; | |
14 class NavigationController; | 15 class NavigationController; |
15 class RenderViewHost; | 16 class RenderViewHost; |
16 | 17 |
17 // For browser_tests, which run on the UI thread, run a second | 18 // For browser_tests, which run on the UI thread, run a second |
18 // MessageLoop and quit when the navigation completes loading. For | 19 // MessageLoop and quit when the navigation completes loading. For |
19 // WebUI tests that need to inject javascript, construct with a | 20 // WebUI tests that need to inject javascript, construct with a |
20 // JsInjectionReadyObserver and this class will call its | 21 // JsInjectionReadyObserver and this class will call its |
21 // OnJsInjectionReady() at the appropriate time. | 22 // OnJsInjectionReady() at the appropriate time. |
22 class TestNavigationObserver : public content::NotificationObserver { | 23 class TestNavigationObserver : public content::NotificationObserver { |
23 public: | 24 public: |
24 class RVHOSendJS; | 25 class RVHOSendJS; |
25 | 26 |
26 // Interface to notify when JavaScript injection is possible. | |
27 class JsInjectionReadyObserver { | |
28 public: | |
29 JsInjectionReadyObserver(); | |
30 virtual ~JsInjectionReadyObserver(); | |
31 | |
32 // Called to indicate page entry committed and ready for JavaScript | |
33 // injection. | |
34 virtual void OnJsInjectionReady(RenderViewHost* render_view_host) = 0; | |
35 }; | |
36 | |
37 // Create and register a new TestNavigationObserver against the | 27 // Create and register a new TestNavigationObserver against the |
38 // |controller|. When |js_injection_ready_observer| is non-null, notify with | 28 // |controller|. When |js_injection_ready_observer| is non-null, notify with |
39 // OnEntryCommitted() after |number_of_navigations| navigations. | 29 // OnEntryCommitted() after |number_of_navigations| navigations. |
40 // Note: |js_injection_ready_observer| is owned by the caller and should be | 30 // Note: |js_injection_ready_observer| is owned by the caller and should be |
41 // valid until this class is destroyed. | 31 // valid until this class is destroyed. |
42 TestNavigationObserver(const content::NotificationSource& source, | 32 TestNavigationObserver(const content::NotificationSource& source, |
43 JsInjectionReadyObserver* js_injection_ready_observer, | 33 JsInjectionReadyObserver* js_injection_ready_observer, |
44 int number_of_navigations); | 34 int number_of_navigations); |
45 | 35 |
46 virtual ~TestNavigationObserver(); | 36 virtual ~TestNavigationObserver(); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
85 // |running_| will be true during WaitForObservation until |done_| is true. | 75 // |running_| will be true during WaitForObservation until |done_| is true. |
86 bool running_; | 76 bool running_; |
87 | 77 |
88 // |rvho_send_js_| will hold a RenderViewHostObserver subclass to allow | 78 // |rvho_send_js_| will hold a RenderViewHostObserver subclass to allow |
89 // JavaScript injection at the appropriate time. | 79 // JavaScript injection at the appropriate time. |
90 scoped_ptr<RVHOSendJS> rvho_send_js_; | 80 scoped_ptr<RVHOSendJS> rvho_send_js_; |
91 | 81 |
92 DISALLOW_COPY_AND_ASSIGN(TestNavigationObserver); | 82 DISALLOW_COPY_AND_ASSIGN(TestNavigationObserver); |
93 }; | 83 }; |
94 | 84 |
95 #endif // CHROME_TEST_TEST_NAVIGATION_OBSERVER_H_ | 85 #endif // CHROME_TEST_BASE_TEST_NAVIGATION_OBSERVER_H_ |
OLD | NEW |