Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(473)

Side by Side Diff: content/test/test_renderer_host.cc

Issue 10191010: Re-implement the screensaver to use WebView instead of ExtensionDialogHost. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ut fix. Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/test/test_render_view_host_factory.cc ('k') | ui/views/controls/webview/webview.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_renderer_host.h" 5 #include "content/test/test_renderer_host.h"
6 6
7 #include "content/browser/renderer_host/render_view_host_factory.h" 7 #include "content/browser/renderer_host/render_view_host_factory.h"
8 #include "content/browser/renderer_host/test_render_view_host.h" 8 #include "content/browser/renderer_host/test_render_view_host.h"
9 #include "content/browser/site_instance_impl.h" 9 #include "content/browser/site_instance_impl.h"
10 #include "content/browser/web_contents/navigation_entry_impl.h" 10 #include "content/browser/web_contents/navigation_entry_impl.h"
11 #include "content/browser/web_contents/test_web_contents.h" 11 #include "content/browser/web_contents/test_web_contents.h"
12 #include "content/public/browser/web_contents.h" 12 #include "content/public/browser/web_contents.h"
13 #include "content/test/mock_render_process_host.h" 13 #include "content/test/mock_render_process_host.h"
14 #include "content/test/test_browser_context.h" 14 #include "content/test/test_browser_context.h"
15 #include "content/test/test_render_view_host_factory.h"
15 16
16 #if defined(USE_AURA) 17 #if defined(USE_AURA)
17 #include "ui/aura/env.h" 18 #include "ui/aura/env.h"
18 #include "ui/aura/monitor_manager.h" 19 #include "ui/aura/monitor_manager.h"
19 #include "ui/aura/root_window.h" 20 #include "ui/aura/root_window.h"
20 #include "ui/aura/single_monitor_manager.h" 21 #include "ui/aura/single_monitor_manager.h"
21 #include "ui/aura/test/test_screen.h" 22 #include "ui/aura/test/test_screen.h"
22 #include "ui/aura/test/test_stacking_client.h" 23 #include "ui/aura/test/test_stacking_client.h"
23 #include "ui/gfx/screen.h" 24 #include "ui/gfx/screen.h"
24 #endif 25 #endif
25 26
26 namespace content { 27 namespace content {
27 28
28 // Manages creation of the RenderViewHosts using our special subclass. This
29 // automatically registers itself when it goes in scope, and unregisters itself
30 // when it goes out of scope. Since you can't have more than one factory
31 // registered at a time, you can only have one of these objects at a time.
32 //
33 // This is an implementation detail of this file and used only via
34 // RenderViewHostTestEnabler.
35 class TestRenderViewHostFactory : public RenderViewHostFactory {
36 public:
37 explicit TestRenderViewHostFactory(
38 content::RenderProcessHostFactory* rph_factory);
39 virtual ~TestRenderViewHostFactory();
40
41 virtual void set_render_process_host_factory(
42 content::RenderProcessHostFactory* rph_factory);
43 virtual content::RenderViewHost* CreateRenderViewHost(
44 content::SiteInstance* instance,
45 content::RenderViewHostDelegate* delegate,
46 int routing_id,
47 bool swapped_out,
48 content::SessionStorageNamespace* session_storage) OVERRIDE;
49
50 private:
51 // This is a bit of a hack. With the current design of the site instances /
52 // browsing instances, it's difficult to pass a RenderProcessHostFactory
53 // around properly.
54 //
55 // Instead, we set it right before we create a new RenderViewHost, which
56 // happens before the RenderProcessHost is created. This way, the instance
57 // has the correct factory and creates our special RenderProcessHosts.
58 content::RenderProcessHostFactory* render_process_host_factory_;
59
60 DISALLOW_COPY_AND_ASSIGN(TestRenderViewHostFactory);
61 };
62
63 TestRenderViewHostFactory::TestRenderViewHostFactory(
64 content::RenderProcessHostFactory* rph_factory)
65 : render_process_host_factory_(rph_factory) {
66 RenderViewHostFactory::RegisterFactory(this);
67 }
68
69 TestRenderViewHostFactory::~TestRenderViewHostFactory() {
70 RenderViewHostFactory::UnregisterFactory();
71 }
72
73 void TestRenderViewHostFactory::set_render_process_host_factory(
74 content::RenderProcessHostFactory* rph_factory) {
75 render_process_host_factory_ = rph_factory;
76 }
77
78 content::RenderViewHost* TestRenderViewHostFactory::CreateRenderViewHost(
79 SiteInstance* instance,
80 RenderViewHostDelegate* delegate,
81 int routing_id,
82 bool swapped_out,
83 SessionStorageNamespace* session_storage) {
84 // See declaration of render_process_host_factory_ below.
85 static_cast<SiteInstanceImpl*>(instance)->
86 set_render_process_host_factory(render_process_host_factory_);
87 return new TestRenderViewHost(instance, delegate, routing_id, swapped_out);
88 }
89
90 // static 29 // static
91 RenderViewHostTester* RenderViewHostTester::For(RenderViewHost* host) { 30 RenderViewHostTester* RenderViewHostTester::For(RenderViewHost* host) {
92 return static_cast<TestRenderViewHost*>(host); 31 return static_cast<TestRenderViewHost*>(host);
93 } 32 }
94 33
95 // static 34 // static
96 void RenderViewHostTester::EnableAccessibilityUpdatedNotifications( 35 void RenderViewHostTester::EnableAccessibilityUpdatedNotifications(
97 RenderViewHost* host) { 36 RenderViewHost* host) {
98 static_cast<RenderViewHostImpl*>( 37 static_cast<RenderViewHostImpl*>(
99 host)->set_send_accessibility_updated_notifications(true); 38 host)->set_send_accessibility_updated_notifications(true);
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 message_loop_.DeleteSoon(FROM_HERE, browser_context_.release()); 158 message_loop_.DeleteSoon(FROM_HERE, browser_context_.release());
220 message_loop_.RunAllPending(); 159 message_loop_.RunAllPending();
221 } 160 }
222 161
223 void RenderViewHostTestHarness::SetRenderProcessHostFactory( 162 void RenderViewHostTestHarness::SetRenderProcessHostFactory(
224 RenderProcessHostFactory* factory) { 163 RenderProcessHostFactory* factory) {
225 rvh_test_enabler_.rvh_factory_->set_render_process_host_factory(factory); 164 rvh_test_enabler_.rvh_factory_->set_render_process_host_factory(factory);
226 } 165 }
227 166
228 } // namespace content 167 } // namespace content
OLDNEW
« no previous file with comments | « content/test/test_render_view_host_factory.cc ('k') | ui/views/controls/webview/webview.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698