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 CONTENT_BROWSER_RENDERER_HOST_TEST_RENDER_VIEW_HOST_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_TEST_RENDER_VIEW_HOST_H_ |
6 #define CONTENT_BROWSER_RENDERER_HOST_TEST_RENDER_VIEW_HOST_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_TEST_RENDER_VIEW_HOST_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
13 #include "content/browser/renderer_host/mock_render_process_host.h" | 13 #include "content/browser/renderer_host/mock_render_process_host.h" |
14 #include "content/browser/renderer_host/render_view_host.h" | 14 #include "content/browser/renderer_host/render_view_host.h" |
15 #include "content/browser/renderer_host/render_view_host_factory.h" | 15 #include "content/browser/renderer_host/render_view_host_factory.h" |
16 #include "content/browser/renderer_host/render_widget_host_view.h" | 16 #include "content/browser/renderer_host/render_widget_host_view.h" |
17 #include "content/public/common/page_transition_types.h" | 17 #include "content/public/common/page_transition_types.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
19 | 19 |
20 namespace content { | 20 namespace content { |
21 class BrowserContext; | 21 class BrowserContext; |
| 22 class RenderProcessHostFactory; |
22 } | 23 } |
23 | 24 |
24 namespace gfx { | 25 namespace gfx { |
25 class Rect; | 26 class Rect; |
26 } | 27 } |
27 | 28 |
28 class NavigationController; | 29 class NavigationController; |
29 class SiteInstance; | 30 class SiteInstance; |
30 class TestTabContents; | 31 class TestTabContents; |
31 struct ViewHostMsg_FrameNavigate_Params; | 32 struct ViewHostMsg_FrameNavigate_Params; |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 }; | 256 }; |
256 | 257 |
257 // TestRenderViewHostFactory --------------------------------------------------- | 258 // TestRenderViewHostFactory --------------------------------------------------- |
258 | 259 |
259 // Manages creation of the RenderViewHosts using our special subclass. This | 260 // Manages creation of the RenderViewHosts using our special subclass. This |
260 // automatically registers itself when it goes in scope, and unregisters itself | 261 // automatically registers itself when it goes in scope, and unregisters itself |
261 // when it goes out of scope. Since you can't have more than one factory | 262 // when it goes out of scope. Since you can't have more than one factory |
262 // registered at a time, you can only have one of these objects at a time. | 263 // registered at a time, you can only have one of these objects at a time. |
263 class TestRenderViewHostFactory : public RenderViewHostFactory { | 264 class TestRenderViewHostFactory : public RenderViewHostFactory { |
264 public: | 265 public: |
265 explicit TestRenderViewHostFactory(RenderProcessHostFactory* rph_factory); | 266 explicit TestRenderViewHostFactory( |
| 267 content::RenderProcessHostFactory* rph_factory); |
266 virtual ~TestRenderViewHostFactory(); | 268 virtual ~TestRenderViewHostFactory(); |
267 | 269 |
268 virtual void set_render_process_host_factory( | 270 virtual void set_render_process_host_factory( |
269 RenderProcessHostFactory* rph_factory); | 271 content::RenderProcessHostFactory* rph_factory); |
270 virtual RenderViewHost* CreateRenderViewHost( | 272 virtual RenderViewHost* CreateRenderViewHost( |
271 SiteInstance* instance, | 273 SiteInstance* instance, |
272 RenderViewHostDelegate* delegate, | 274 RenderViewHostDelegate* delegate, |
273 int routing_id, | 275 int routing_id, |
274 SessionStorageNamespace* session_storage) OVERRIDE; | 276 SessionStorageNamespace* session_storage) OVERRIDE; |
275 | 277 |
276 private: | 278 private: |
277 // This is a bit of a hack. With the current design of the site instances / | 279 // This is a bit of a hack. With the current design of the site instances / |
278 // browsing instances, it's difficult to pass a RenderProcessHostFactory | 280 // browsing instances, it's difficult to pass a RenderProcessHostFactory |
279 // around properly. | 281 // around properly. |
280 // | 282 // |
281 // Instead, we set it right before we create a new RenderViewHost, which | 283 // Instead, we set it right before we create a new RenderViewHost, which |
282 // happens before the RenderProcessHost is created. This way, the instance | 284 // happens before the RenderProcessHost is created. This way, the instance |
283 // has the correct factory and creates our special RenderProcessHosts. | 285 // has the correct factory and creates our special RenderProcessHosts. |
284 RenderProcessHostFactory* render_process_host_factory_; | 286 content::RenderProcessHostFactory* render_process_host_factory_; |
285 | 287 |
286 DISALLOW_COPY_AND_ASSIGN(TestRenderViewHostFactory); | 288 DISALLOW_COPY_AND_ASSIGN(TestRenderViewHostFactory); |
287 }; | 289 }; |
288 | 290 |
289 // RenderViewHostTestHarness --------------------------------------------------- | 291 // RenderViewHostTestHarness --------------------------------------------------- |
290 | 292 |
291 class RenderViewHostTestHarness : public testing::Test { | 293 class RenderViewHostTestHarness : public testing::Test { |
292 public: | 294 public: |
293 RenderViewHostTestHarness(); | 295 RenderViewHostTestHarness(); |
294 virtual ~RenderViewHostTestHarness(); | 296 virtual ~RenderViewHostTestHarness(); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 MockRenderProcessHostFactory rph_factory_; | 336 MockRenderProcessHostFactory rph_factory_; |
335 TestRenderViewHostFactory rvh_factory_; | 337 TestRenderViewHostFactory rvh_factory_; |
336 | 338 |
337 private: | 339 private: |
338 scoped_ptr<TestTabContents> contents_; | 340 scoped_ptr<TestTabContents> contents_; |
339 | 341 |
340 DISALLOW_COPY_AND_ASSIGN(RenderViewHostTestHarness); | 342 DISALLOW_COPY_AND_ASSIGN(RenderViewHostTestHarness); |
341 }; | 343 }; |
342 | 344 |
343 #endif // CONTENT_BROWSER_RENDERER_HOST_TEST_RENDER_VIEW_HOST_H_ | 345 #endif // CONTENT_BROWSER_RENDERER_HOST_TEST_RENDER_VIEW_HOST_H_ |
OLD | NEW |