| 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 "content/test/test_navigation_observer.h" | 5 #include "content/test/test_navigation_observer.h" |
| 6 | 6 |
| 7 #include "content/public/browser/notification_service.h" | 7 #include "content/public/browser/notification_service.h" |
| 8 #include "content/public/browser/notification_types.h" | 8 #include "content/public/browser/notification_types.h" |
| 9 #include "content/public/browser/render_view_host_observer.h" | 9 #include "content/public/browser/render_view_host_observer.h" |
| 10 #include "content/test/js_injection_ready_observer.h" | 10 #include "content/test/js_injection_ready_observer.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 12 |
| 13 // This class observes |render_view_host| and calls OnJsInjectionReady() of | 13 // This class observes |render_view_host| and calls OnJsInjectionReady() of |
| 14 // |js_injection_ready_observer| when the time is right to inject JavaScript | 14 // |js_injection_ready_observer| when the time is right to inject JavaScript |
| 15 // into the page. | 15 // into the page. |
| 16 class TestNavigationObserver::RVHOSendJS | 16 class TestNavigationObserver::RVHOSendJS |
| 17 : public content::RenderViewHostObserver { | 17 : public content::RenderViewHostObserver { |
| 18 public: | 18 public: |
| 19 RVHOSendJS(RenderViewHost* render_view_host, | 19 RVHOSendJS(content::RenderViewHost* render_view_host, |
| 20 JsInjectionReadyObserver* js_injection_ready_observer) | 20 JsInjectionReadyObserver* js_injection_ready_observer) |
| 21 : content::RenderViewHostObserver(render_view_host), | 21 : content::RenderViewHostObserver(render_view_host), |
| 22 js_injection_ready_observer_(js_injection_ready_observer) { | 22 js_injection_ready_observer_(js_injection_ready_observer) { |
| 23 } | 23 } |
| 24 | 24 |
| 25 private: | 25 private: |
| 26 // content::RenderViewHostObserver implementation. | 26 // content::RenderViewHostObserver implementation. |
| 27 virtual void RenderViewHostInitialized() OVERRIDE { | 27 virtual void RenderViewHostInitialized() OVERRIDE { |
| 28 if (js_injection_ready_observer_) | 28 if (js_injection_ready_observer_) |
| 29 js_injection_ready_observer_->OnJsInjectionReady(render_view_host()); | 29 js_injection_ready_observer_->OnJsInjectionReady(render_view_host()); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 if (navigation_started_ && | 106 if (navigation_started_ && |
| 107 ++navigations_completed_ == number_of_navigations_) { | 107 ++navigations_completed_ == number_of_navigations_) { |
| 108 navigation_started_ = false; | 108 navigation_started_ = false; |
| 109 done_ = true; | 109 done_ = true; |
| 110 if (running_) | 110 if (running_) |
| 111 done_callback_.Run(); | 111 done_callback_.Run(); |
| 112 } | 112 } |
| 113 break; | 113 break; |
| 114 case content::NOTIFICATION_RENDER_VIEW_HOST_CREATED: | 114 case content::NOTIFICATION_RENDER_VIEW_HOST_CREATED: |
| 115 rvho_send_js_.reset(new RVHOSendJS( | 115 rvho_send_js_.reset(new RVHOSendJS( |
| 116 content::Source<RenderViewHost>(source).ptr(), | 116 content::Source<content::RenderViewHost>(source).ptr(), |
| 117 js_injection_ready_observer_)); | 117 js_injection_ready_observer_)); |
| 118 break; | 118 break; |
| 119 default: | 119 default: |
| 120 NOTREACHED(); | 120 NOTREACHED(); |
| 121 } | 121 } |
| 122 } | 122 } |
| OLD | NEW |