| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_BROWSER_RENDERER_HOST_TEST_RENDER_VIEW_HOST_H_ | 5 #ifndef CHROME_BROWSER_RENDERER_HOST_TEST_RENDER_VIEW_HOST_H_ |
| 6 #define CHROME_BROWSER_RENDERER_HOST_TEST_RENDER_VIEW_HOST_H_ | 6 #define CHROME_BROWSER_RENDERER_HOST_TEST_RENDER_VIEW_HOST_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| 11 #include "chrome/browser/renderer_host/mock_render_process_host.h" | 11 #include "chrome/browser/renderer_host/mock_render_process_host.h" |
| 12 #include "chrome/browser/renderer_host/render_widget_host_view.h" | 12 #include "chrome/browser/renderer_host/render_widget_host_view.h" |
| 13 #include "chrome/browser/renderer_host/render_view_host.h" | 13 #include "chrome/browser/renderer_host/render_view_host.h" |
| 14 #include "chrome/browser/renderer_host/render_view_host_factory.h" |
| 14 #include "chrome/browser/tab_contents/site_instance.h" | 15 #include "chrome/browser/tab_contents/site_instance.h" |
| 15 #include "chrome/browser/tab_contents/test_web_contents.h" | 16 #include "chrome/browser/tab_contents/test_web_contents.h" |
| 16 #include "chrome/test/testing_profile.h" | 17 #include "chrome/test/testing_profile.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 18 | 19 |
| 19 #if defined(OS_WIN) | 20 #if defined(OS_WIN) |
| 20 #include "chrome/browser/tab_contents/navigation_controller.h" | 21 #include "chrome/browser/tab_contents/navigation_controller.h" |
| 21 #elif defined(OS_POSIX) | 22 #elif defined(OS_POSIX) |
| 22 #include "chrome/common/temp_scaffolding_stubs.h" | 23 #include "chrome/common/temp_scaffolding_stubs.h" |
| 23 #endif | 24 #endif |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 bool render_view_created_; | 128 bool render_view_created_; |
| 128 | 129 |
| 129 // See set_delete_counter() above. May be NULL. | 130 // See set_delete_counter() above. May be NULL. |
| 130 int* delete_counter_; | 131 int* delete_counter_; |
| 131 | 132 |
| 132 DISALLOW_COPY_AND_ASSIGN(TestRenderViewHost); | 133 DISALLOW_COPY_AND_ASSIGN(TestRenderViewHost); |
| 133 }; | 134 }; |
| 134 | 135 |
| 135 // TestRenderViewHostFactory --------------------------------------------------- | 136 // TestRenderViewHostFactory --------------------------------------------------- |
| 136 | 137 |
| 138 // Manages creation of the RenderViewHosts using our special subclass. This |
| 139 // automatically registers itself when it goes in scope, and unregisters itself |
| 140 // when it goes out of scope. Since you can't have more than one factory |
| 141 // registered at a time, you can only have one of these objects at a time. |
| 137 class TestRenderViewHostFactory : public RenderViewHostFactory { | 142 class TestRenderViewHostFactory : public RenderViewHostFactory { |
| 138 public: | 143 public: |
| 139 TestRenderViewHostFactory(RenderProcessHostFactory* rph_factory) | 144 TestRenderViewHostFactory(RenderProcessHostFactory* rph_factory) |
| 140 : render_process_host_factory_(rph_factory) { | 145 : render_process_host_factory_(rph_factory) { |
| 146 RenderViewHostFactory::RegisterFactory(this); |
| 141 } | 147 } |
| 142 virtual ~TestRenderViewHostFactory() { | 148 virtual ~TestRenderViewHostFactory() { |
| 149 RenderViewHostFactory::UnregisterFactory(); |
| 143 } | 150 } |
| 144 | 151 |
| 145 virtual RenderViewHost* CreateRenderViewHost( | 152 virtual RenderViewHost* CreateRenderViewHost( |
| 146 SiteInstance* instance, | 153 SiteInstance* instance, |
| 147 RenderViewHostDelegate* delegate, | 154 RenderViewHostDelegate* delegate, |
| 148 int routing_id, | 155 int routing_id, |
| 149 base::WaitableEvent* modal_dialog_event) { | 156 base::WaitableEvent* modal_dialog_event) { |
| 150 // See declaration of render_process_host_factory_ below. | 157 // See declaration of render_process_host_factory_ below. |
| 151 instance->set_render_process_host_factory(render_process_host_factory_); | 158 instance->set_render_process_host_factory(render_process_host_factory_); |
| 152 return new TestRenderViewHost(instance, delegate, routing_id, | 159 return new TestRenderViewHost(instance, delegate, routing_id, |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 | 232 |
| 226 // We clean up the WebContents by calling CloseContents, which deletes itself. | 233 // We clean up the WebContents by calling CloseContents, which deletes itself. |
| 227 // This in turn causes the destruction of these other things. | 234 // This in turn causes the destruction of these other things. |
| 228 TestWebContents* contents_; | 235 TestWebContents* contents_; |
| 229 NavigationController* controller_; | 236 NavigationController* controller_; |
| 230 | 237 |
| 231 DISALLOW_COPY_AND_ASSIGN(RenderViewHostTestHarness); | 238 DISALLOW_COPY_AND_ASSIGN(RenderViewHostTestHarness); |
| 232 }; | 239 }; |
| 233 | 240 |
| 234 #endif // CHROME_BROWSER_RENDERER_HOST_TEST_RENDER_VIEW_HOST_H_ | 241 #endif // CHROME_BROWSER_RENDERER_HOST_TEST_RENDER_VIEW_HOST_H_ |
| OLD | NEW |