| 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/renderer_host/test_render_view_host.h" | 5 #include "content/browser/renderer_host/test_render_view_host.h" |
| 6 | 6 |
| 7 #include "content/browser/dom_storage/dom_storage_context_impl.h" | 7 #include "content/browser/dom_storage/dom_storage_context_impl.h" |
| 8 #include "content/browser/dom_storage/session_storage_namespace_impl.h" | 8 #include "content/browser/dom_storage/session_storage_namespace_impl.h" |
| 9 #include "content/browser/renderer_host/test_backing_store.h" | 9 #include "content/browser/renderer_host/test_backing_store.h" |
| 10 #include "content/browser/site_instance_impl.h" | 10 #include "content/browser/site_instance_impl.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 params->security_info = std::string(); | 57 params->security_info = std::string(); |
| 58 params->gesture = NavigationGestureUser; | 58 params->gesture = NavigationGestureUser; |
| 59 params->was_within_same_page = false; | 59 params->was_within_same_page = false; |
| 60 params->is_post = false; | 60 params->is_post = false; |
| 61 params->page_state = PageState::CreateFromURL(url); | 61 params->page_state = PageState::CreateFromURL(url); |
| 62 } | 62 } |
| 63 | 63 |
| 64 TestRenderWidgetHostView::TestRenderWidgetHostView(RenderWidgetHost* rwh) | 64 TestRenderWidgetHostView::TestRenderWidgetHostView(RenderWidgetHost* rwh) |
| 65 : rwh_(RenderWidgetHostImpl::From(rwh)), | 65 : rwh_(RenderWidgetHostImpl::From(rwh)), |
| 66 is_showing_(false) { | 66 is_showing_(false) { |
| 67 rwh_->SetView(this); |
| 67 } | 68 } |
| 68 | 69 |
| 69 TestRenderWidgetHostView::~TestRenderWidgetHostView() { | 70 TestRenderWidgetHostView::~TestRenderWidgetHostView() { |
| 70 } | 71 } |
| 71 | 72 |
| 72 RenderWidgetHost* TestRenderWidgetHostView::GetRenderWidgetHost() const { | 73 RenderWidgetHost* TestRenderWidgetHostView::GetRenderWidgetHost() const { |
| 73 return NULL; | 74 return NULL; |
| 74 } | 75 } |
| 75 | 76 |
| 76 gfx::NativeView TestRenderWidgetHostView::GetNativeView() const { | 77 gfx::NativeView TestRenderWidgetHostView::GetNativeView() const { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 103 | 104 |
| 104 bool TestRenderWidgetHostView::IsShowing() { | 105 bool TestRenderWidgetHostView::IsShowing() { |
| 105 return is_showing_; | 106 return is_showing_; |
| 106 } | 107 } |
| 107 | 108 |
| 108 void TestRenderWidgetHostView::RenderViewGone(base::TerminationStatus status, | 109 void TestRenderWidgetHostView::RenderViewGone(base::TerminationStatus status, |
| 109 int error_code) { | 110 int error_code) { |
| 110 delete this; | 111 delete this; |
| 111 } | 112 } |
| 112 | 113 |
| 114 void TestRenderWidgetHostView::Destroy() { delete this; } |
| 115 |
| 113 gfx::Rect TestRenderWidgetHostView::GetViewBounds() const { | 116 gfx::Rect TestRenderWidgetHostView::GetViewBounds() const { |
| 114 return gfx::Rect(); | 117 return gfx::Rect(); |
| 115 } | 118 } |
| 116 | 119 |
| 117 BackingStore* TestRenderWidgetHostView::AllocBackingStore( | 120 BackingStore* TestRenderWidgetHostView::AllocBackingStore( |
| 118 const gfx::Size& size) { | 121 const gfx::Size& size) { |
| 119 return new TestBackingStore(rwh_, size); | 122 return new TestBackingStore(rwh_, size); |
| 120 } | 123 } |
| 121 | 124 |
| 122 void TestRenderWidgetHostView::CopyFromCompositingSurface( | 125 void TestRenderWidgetHostView::CopyFromCompositingSurface( |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 widget_delegate, | 250 widget_delegate, |
| 248 routing_id, | 251 routing_id, |
| 249 main_frame_routing_id, | 252 main_frame_routing_id, |
| 250 swapped_out, | 253 swapped_out, |
| 251 CreateSessionStorageNamespace(instance)), | 254 CreateSessionStorageNamespace(instance)), |
| 252 render_view_created_(false), | 255 render_view_created_(false), |
| 253 delete_counter_(NULL), | 256 delete_counter_(NULL), |
| 254 simulate_fetch_via_proxy_(false), | 257 simulate_fetch_via_proxy_(false), |
| 255 simulate_history_list_was_cleared_(false), | 258 simulate_history_list_was_cleared_(false), |
| 256 contents_mime_type_("text/html") { | 259 contents_mime_type_("text/html") { |
| 257 // For normal RenderViewHosts, this is freed when |Shutdown()| is | 260 // TestRenderWidgetHostView installs itself into this->view_ in its |
| 258 // called. For TestRenderViewHost, the view is explicitly | 261 // constructor, and deletes itself when TestRenderWidgetHostView::Destroy() is |
| 259 // deleted in the destructor below, because | 262 // called. |
| 260 // TestRenderWidgetHostView::Destroy() doesn't |delete this|. | 263 new TestRenderWidgetHostView(this); |
| 261 SetView(new TestRenderWidgetHostView(this)); | |
| 262 | 264 |
| 263 main_frame_id_ = kFrameId; | 265 main_frame_id_ = kFrameId; |
| 264 } | 266 } |
| 265 | 267 |
| 266 TestRenderViewHost::~TestRenderViewHost() { | 268 TestRenderViewHost::~TestRenderViewHost() { |
| 267 if (delete_counter_) | 269 if (delete_counter_) |
| 268 ++*delete_counter_; | 270 ++*delete_counter_; |
| 269 | |
| 270 // Since this isn't a traditional view, we have to delete it. | |
| 271 delete GetView(); | |
| 272 } | 271 } |
| 273 | 272 |
| 274 bool TestRenderViewHost::CreateRenderView( | 273 bool TestRenderViewHost::CreateRenderView( |
| 275 const string16& frame_name, | 274 const string16& frame_name, |
| 276 int opener_route_id, | 275 int opener_route_id, |
| 277 int32 max_page_id) { | 276 int32 max_page_id) { |
| 278 DCHECK(!render_view_created_); | 277 DCHECK(!render_view_created_); |
| 279 render_view_created_ = true; | 278 render_view_created_ = true; |
| 280 return true; | 279 return true; |
| 281 } | 280 } |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 | 417 |
| 419 TestRenderViewHost* RenderViewHostImplTestHarness::active_test_rvh() { | 418 TestRenderViewHost* RenderViewHostImplTestHarness::active_test_rvh() { |
| 420 return static_cast<TestRenderViewHost*>(active_rvh()); | 419 return static_cast<TestRenderViewHost*>(active_rvh()); |
| 421 } | 420 } |
| 422 | 421 |
| 423 TestWebContents* RenderViewHostImplTestHarness::contents() { | 422 TestWebContents* RenderViewHostImplTestHarness::contents() { |
| 424 return static_cast<TestWebContents*>(web_contents()); | 423 return static_cast<TestWebContents*>(web_contents()); |
| 425 } | 424 } |
| 426 | 425 |
| 427 } // namespace content | 426 } // namespace content |
| OLD | NEW |