OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_render_view_host_factory.h" | 5 #include "content/test/test_render_view_host_factory.h" |
6 | 6 |
7 #include "content/browser/renderer_host/test_render_view_host.h" | 7 #include "content/browser/renderer_host/test_render_view_host.h" |
8 #include "content/browser/site_instance_impl.h" | 8 #include "content/browser/site_instance_impl.h" |
9 #include "content/public/browser/render_process_host_factory.h" | 9 #include "content/public/browser/render_process_host_factory.h" |
10 | 10 |
11 namespace content { | 11 namespace content { |
12 | 12 |
13 TestRenderViewHostFactory::TestRenderViewHostFactory( | 13 TestRenderViewHostFactory::TestRenderViewHostFactory( |
14 RenderProcessHostFactory* rph_factory) | 14 RenderProcessHostFactory* rph_factory) { |
15 : render_process_host_factory_(rph_factory) { | 15 SiteInstanceImpl::set_render_process_host_factory(rph_factory); |
16 RenderViewHostFactory::RegisterFactory(this); | 16 RenderViewHostFactory::RegisterFactory(this); |
17 } | 17 } |
18 | 18 |
19 TestRenderViewHostFactory::~TestRenderViewHostFactory() { | 19 TestRenderViewHostFactory::~TestRenderViewHostFactory() { |
20 RenderViewHostFactory::UnregisterFactory(); | 20 RenderViewHostFactory::UnregisterFactory(); |
| 21 SiteInstanceImpl::set_render_process_host_factory(NULL); |
21 } | 22 } |
22 | 23 |
23 void TestRenderViewHostFactory::set_render_process_host_factory( | 24 void TestRenderViewHostFactory::set_render_process_host_factory( |
24 RenderProcessHostFactory* rph_factory) { | 25 RenderProcessHostFactory* rph_factory) { |
25 render_process_host_factory_ = rph_factory; | 26 SiteInstanceImpl::set_render_process_host_factory(rph_factory); |
26 } | 27 } |
27 | 28 |
28 RenderViewHost* TestRenderViewHostFactory::CreateRenderViewHost( | 29 RenderViewHost* TestRenderViewHostFactory::CreateRenderViewHost( |
29 SiteInstance* instance, | 30 SiteInstance* instance, |
30 RenderViewHostDelegate* delegate, | 31 RenderViewHostDelegate* delegate, |
31 RenderWidgetHostDelegate* widget_delegate, | 32 RenderWidgetHostDelegate* widget_delegate, |
32 int routing_id, | 33 int routing_id, |
33 int main_frame_routing_id, | 34 int main_frame_routing_id, |
34 bool swapped_out, | 35 bool swapped_out, |
35 SessionStorageNamespace* session_storage) { | 36 SessionStorageNamespace* session_storage) { |
36 // See declaration of render_process_host_factory_ below. | |
37 static_cast<SiteInstanceImpl*>(instance)-> | |
38 set_render_process_host_factory(render_process_host_factory_); | |
39 return new TestRenderViewHost( | 37 return new TestRenderViewHost( |
40 instance, delegate, widget_delegate, routing_id, main_frame_routing_id, | 38 instance, delegate, widget_delegate, routing_id, main_frame_routing_id, |
41 swapped_out); | 39 swapped_out); |
42 } | 40 } |
43 | 41 |
44 } // namespace content | 42 } // namespace content |
OLD | NEW |