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/browser/browser_url_handler.h" | 5 #include "content/browser/browser_url_handler.h" |
6 #include "content/browser/renderer_host/backing_store_skia.h" | 6 #include "content/browser/renderer_host/backing_store_skia.h" |
7 #include "content/browser/renderer_host/test_backing_store.h" | 7 #include "content/browser/renderer_host/test_backing_store.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/tab_contents/navigation_controller_impl.h" | 10 #include "content/browser/tab_contents/navigation_controller_impl.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 TransportDIB::Id bitmap, | 51 TransportDIB::Id bitmap, |
52 const gfx::Rect& rect) { | 52 const gfx::Rect& rect) { |
53 ViewHostMsg_UpdateRect_Params params; | 53 ViewHostMsg_UpdateRect_Params params; |
54 params.bitmap_rect = rect; | 54 params.bitmap_rect = rect; |
55 params.view_size = params.bitmap_rect.size(); | 55 params.view_size = params.bitmap_rect.size(); |
56 params.copy_rects.push_back(params.bitmap_rect); | 56 params.copy_rects.push_back(params.bitmap_rect); |
57 params.flags = 0; | 57 params.flags = 0; |
58 params.bitmap = bitmap; | 58 params.bitmap = bitmap; |
59 | 59 |
60 ViewHostMsg_UpdateRect msg(1, params); | 60 ViewHostMsg_UpdateRect msg(1, params); |
61 static_cast<RenderWidgetHostImpl*>(widget)->OnMessageReceived(msg); | 61 widget->AsRWHImpl()->OnMessageReceived(msg); |
62 } | 62 } |
63 | 63 |
64 TestRenderViewHost* TestRenderViewHost::GetPendingForController( | 64 TestRenderViewHost* TestRenderViewHost::GetPendingForController( |
65 content::NavigationController* controller) { | 65 content::NavigationController* controller) { |
66 TabContents* tab_contents = static_cast<TabContents*>( | 66 TabContents* tab_contents = static_cast<TabContents*>( |
67 controller->GetWebContents()); | 67 controller->GetWebContents()); |
68 return static_cast<TestRenderViewHost*>( | 68 return static_cast<TestRenderViewHost*>( |
69 tab_contents->GetRenderManagerForTesting()->pending_render_view_host()); | 69 tab_contents->GetRenderManagerForTesting()->pending_render_view_host()); |
70 } | 70 } |
71 | 71 |
72 TestRenderViewHost::TestRenderViewHost(SiteInstance* instance, | 72 TestRenderViewHost::TestRenderViewHost(SiteInstance* instance, |
73 RenderViewHostDelegate* delegate, | 73 RenderViewHostDelegate* delegate, |
74 int routing_id) | 74 int routing_id) |
75 : RenderViewHost(instance, delegate, routing_id, | 75 : RenderViewHostImpl(instance, |
76 kInvalidSessionStorageNamespaceId), | 76 delegate, |
| 77 routing_id, |
| 78 kInvalidSessionStorageNamespaceId), |
77 render_view_created_(false), | 79 render_view_created_(false), |
78 delete_counter_(NULL), | 80 delete_counter_(NULL), |
79 simulate_fetch_via_proxy_(false), | 81 simulate_fetch_via_proxy_(false), |
80 contents_mime_type_("text/html") { | 82 contents_mime_type_("text/html") { |
81 // For normal RenderViewHosts, this is freed when |Shutdown()| is called. | 83 // For normal RenderViewHosts, this is freed when |Shutdown()| is called. |
82 // For TestRenderViewHost, the view is explicitly deleted in the destructor | 84 // For TestRenderViewHost, the view is explicitly deleted in the destructor |
83 // below, because TestRenderWidgetHostView::Destroy() doesn't |delete this|. | 85 // below, because TestRenderWidgetHostView::Destroy() doesn't |delete this|. |
84 SetView(new content::TestRenderWidgetHostView(this)); | 86 SetView(new content::TestRenderWidgetHostView(this)); |
85 } | 87 } |
86 | 88 |
87 TestRenderViewHost::~TestRenderViewHost() { | 89 TestRenderViewHost::~TestRenderViewHost() { |
88 if (delete_counter_) | 90 if (delete_counter_) |
89 ++*delete_counter_; | 91 ++*delete_counter_; |
90 | 92 |
91 // Since this isn't a traditional view, we have to delete it. | 93 // Since this isn't a traditional view, we have to delete it. |
92 delete view(); | 94 delete GetView(); |
93 } | 95 } |
94 | 96 |
95 bool TestRenderViewHost::CreateRenderView(const string16& frame_name, | 97 bool TestRenderViewHost::CreateRenderView(const string16& frame_name, |
96 int32 max_page_id) { | 98 int32 max_page_id) { |
97 DCHECK(!render_view_created_); | 99 DCHECK(!render_view_created_); |
98 render_view_created_ = true; | 100 render_view_created_ = true; |
99 return true; | 101 return true; |
100 } | 102 } |
101 | 103 |
102 bool TestRenderViewHost::IsRenderViewLive() const { | 104 bool TestRenderViewHost::IsRenderViewLive() const { |
103 return render_view_created_; | 105 return render_view_created_; |
104 } | 106 } |
105 | 107 |
| 108 // static |
| 109 bool TestRenderViewHost::IsRenderViewHostSwappedOut(RenderViewHost* rwh) { |
| 110 return static_cast<RenderViewHostImpl*>(rwh)->is_swapped_out(); |
| 111 } |
| 112 |
106 bool TestRenderViewHost::TestOnMessageReceived(const IPC::Message& msg) { | 113 bool TestRenderViewHost::TestOnMessageReceived(const IPC::Message& msg) { |
107 return OnMessageReceived(msg); | 114 return OnMessageReceived(msg); |
108 } | 115 } |
109 | 116 |
110 void TestRenderViewHost::SendNavigate(int page_id, const GURL& url) { | 117 void TestRenderViewHost::SendNavigate(int page_id, const GURL& url) { |
111 SendNavigateWithTransition(page_id, url, content::PAGE_TRANSITION_LINK); | 118 SendNavigateWithTransition(page_id, url, content::PAGE_TRANSITION_LINK); |
112 } | 119 } |
113 | 120 |
114 void TestRenderViewHost::SendNavigateWithTransition( | 121 void TestRenderViewHost::SendNavigateWithTransition( |
115 int page_id, const GURL& url, content::PageTransition transition) { | 122 int page_id, const GURL& url, content::PageTransition transition) { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 } | 160 } |
154 | 161 |
155 void TestRenderViewHost::set_contents_mime_type(const std::string& mime_type) { | 162 void TestRenderViewHost::set_contents_mime_type(const std::string& mime_type) { |
156 contents_mime_type_ = mime_type; | 163 contents_mime_type_ = mime_type; |
157 } | 164 } |
158 | 165 |
159 namespace content { | 166 namespace content { |
160 | 167 |
161 TestRenderWidgetHostView::TestRenderWidgetHostView(RenderWidgetHost* rwh) | 168 TestRenderWidgetHostView::TestRenderWidgetHostView(RenderWidgetHost* rwh) |
162 : is_showing_(false) { | 169 : is_showing_(false) { |
163 rwh_ = static_cast<RenderWidgetHostImpl*>(rwh); | 170 rwh_ = rwh->AsRWHImpl(); |
164 } | 171 } |
165 | 172 |
166 TestRenderWidgetHostView::~TestRenderWidgetHostView() { | 173 TestRenderWidgetHostView::~TestRenderWidgetHostView() { |
167 } | 174 } |
168 | 175 |
169 RenderWidgetHost* TestRenderWidgetHostView::GetRenderWidgetHost() const { | 176 RenderWidgetHost* TestRenderWidgetHostView::GetRenderWidgetHost() const { |
170 return NULL; | 177 return NULL; |
171 } | 178 } |
172 | 179 |
173 gfx::NativeView TestRenderWidgetHostView::GetNativeView() const { | 180 gfx::NativeView TestRenderWidgetHostView::GetNativeView() const { |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 TestRenderViewHost* RenderViewHostTestHarness::active_rvh() { | 374 TestRenderViewHost* RenderViewHostTestHarness::active_rvh() { |
368 return pending_rvh() ? pending_rvh() : rvh(); | 375 return pending_rvh() ? pending_rvh() : rvh(); |
369 } | 376 } |
370 | 377 |
371 content::BrowserContext* RenderViewHostTestHarness::browser_context() { | 378 content::BrowserContext* RenderViewHostTestHarness::browser_context() { |
372 return browser_context_.get(); | 379 return browser_context_.get(); |
373 } | 380 } |
374 | 381 |
375 MockRenderProcessHost* RenderViewHostTestHarness::process() { | 382 MockRenderProcessHost* RenderViewHostTestHarness::process() { |
376 if (pending_rvh()) | 383 if (pending_rvh()) |
377 return static_cast<MockRenderProcessHost*>(pending_rvh()->process()); | 384 return static_cast<MockRenderProcessHost*>(pending_rvh()->GetProcess()); |
378 return static_cast<MockRenderProcessHost*>(rvh()->process()); | 385 return static_cast<MockRenderProcessHost*>(rvh()->GetProcess()); |
379 } | 386 } |
380 | 387 |
381 void RenderViewHostTestHarness::DeleteContents() { | 388 void RenderViewHostTestHarness::DeleteContents() { |
382 SetContents(NULL); | 389 SetContents(NULL); |
383 } | 390 } |
384 | 391 |
385 void RenderViewHostTestHarness::SetContents(TestTabContents* contents) { | 392 void RenderViewHostTestHarness::SetContents(TestTabContents* contents) { |
386 contents_.reset(contents); | 393 contents_.reset(contents); |
387 } | 394 } |
388 | 395 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 TestRenderWidgetHostViewWithBackingStoreSkia::Construct( | 451 TestRenderWidgetHostViewWithBackingStoreSkia::Construct( |
445 content::RenderProcessHost* process, | 452 content::RenderProcessHost* process, |
446 int routing_id) { | 453 int routing_id) { |
447 RenderWidgetHostImpl* rwh = new RenderWidgetHostImpl(process, routing_id); | 454 RenderWidgetHostImpl* rwh = new RenderWidgetHostImpl(process, routing_id); |
448 TestRenderWidgetHostViewWithBackingStoreSkia* rwhv = | 455 TestRenderWidgetHostViewWithBackingStoreSkia* rwhv = |
449 new TestRenderWidgetHostViewWithBackingStoreSkia(rwh); | 456 new TestRenderWidgetHostViewWithBackingStoreSkia(rwh); |
450 // Painting will be skipped if there's no view. | 457 // Painting will be skipped if there's no view. |
451 rwh->SetView(rwhv); | 458 rwh->SetView(rwhv); |
452 return rwhv; | 459 return rwhv; |
453 } | 460 } |
OLD | NEW |