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 #include "chrome/test/test_navigation_observer.h" | 5 #include "chrome/test/test_navigation_observer.h" |
6 | 6 |
7 #include "chrome/test/base/ui_test_utils.h" | 7 #include "chrome/test/base/ui_test_utils.h" |
8 #include "content/browser/renderer_host/render_view_host_observer.h" | |
9 #include "content/public/browser/notification_service.h" | 8 #include "content/public/browser/notification_service.h" |
10 #include "content/public/browser/notification_types.h" | 9 #include "content/public/browser/notification_types.h" |
| 10 #include "content/public/browser/render_view_host_observer.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
12 | 12 |
13 // This class observes |rvh| and calls OnJsInjectionReady() of | 13 // This class observes |rvh| and calls OnJsInjectionReady() of |
14 // |js_injection_ready_observer| when the time is right to inject | 14 // |js_injection_ready_observer| when the time is right to inject |
15 // JavaScript into the page. | 15 // JavaScript into the page. |
16 class TestNavigationObserver::RVHOSendJS : public RenderViewHostObserver { | 16 class TestNavigationObserver::RVHOSendJS |
| 17 : public content::RenderViewHostObserver { |
17 public: | 18 public: |
18 RVHOSendJS(RenderViewHost* rvh, | 19 RVHOSendJS(RenderViewHost* rvh, |
19 JsInjectionReadyObserver* js_injection_ready_observer) | 20 JsInjectionReadyObserver* js_injection_ready_observer) |
20 : RenderViewHostObserver(rvh), | 21 : content::RenderViewHostObserver(rvh), |
21 js_injection_ready_observer_(js_injection_ready_observer) { | 22 js_injection_ready_observer_(js_injection_ready_observer) { |
22 } | 23 } |
23 | 24 |
24 private: | 25 private: |
25 // RenderViewHostObserver implementation. | 26 // content::RenderViewHostObserver implementation. |
26 virtual void RenderViewHostInitialized() OVERRIDE { | 27 virtual void RenderViewHostInitialized() OVERRIDE { |
27 if (js_injection_ready_observer_) | 28 if (js_injection_ready_observer_) |
28 js_injection_ready_observer_->OnJsInjectionReady(render_view_host()); | 29 js_injection_ready_observer_->OnJsInjectionReady(render_view_host()); |
29 } | 30 } |
30 | 31 |
31 JsInjectionReadyObserver* js_injection_ready_observer_; | 32 JsInjectionReadyObserver* js_injection_ready_observer_; |
32 | 33 |
33 DISALLOW_COPY_AND_ASSIGN(RVHOSendJS); | 34 DISALLOW_COPY_AND_ASSIGN(RVHOSendJS); |
34 }; | 35 }; |
35 | 36 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 break; | 116 break; |
116 case content::NOTIFICATION_RENDER_VIEW_HOST_CREATED: | 117 case content::NOTIFICATION_RENDER_VIEW_HOST_CREATED: |
117 rvho_send_js_.reset(new RVHOSendJS( | 118 rvho_send_js_.reset(new RVHOSendJS( |
118 content::Source<RenderViewHost>(source).ptr(), | 119 content::Source<RenderViewHost>(source).ptr(), |
119 js_injection_ready_observer_)); | 120 js_injection_ready_observer_)); |
120 break; | 121 break; |
121 default: | 122 default: |
122 NOTREACHED(); | 123 NOTREACHED(); |
123 } | 124 } |
124 } | 125 } |
OLD | NEW |