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/render_widget_host_impl.h" | 5 #include "content/browser/renderer_host/render_widget_host_impl.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 #include <set> | 8 #include <set> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 ignore_input_events_(false), | 177 ignore_input_events_(false), |
178 input_method_active_(false), | 178 input_method_active_(false), |
179 text_direction_updated_(false), | 179 text_direction_updated_(false), |
180 text_direction_(blink::WebTextDirectionLeftToRight), | 180 text_direction_(blink::WebTextDirectionLeftToRight), |
181 text_direction_canceled_(false), | 181 text_direction_canceled_(false), |
182 suppress_next_char_events_(false), | 182 suppress_next_char_events_(false), |
183 pending_mouse_lock_request_(false), | 183 pending_mouse_lock_request_(false), |
184 allow_privileged_mouse_lock_(false), | 184 allow_privileged_mouse_lock_(false), |
185 has_touch_handler_(false), | 185 has_touch_handler_(false), |
186 next_browser_snapshot_id_(1), | 186 next_browser_snapshot_id_(1), |
| 187 owned_by_render_frame_host_(false), |
187 weak_factory_(this) { | 188 weak_factory_(this) { |
188 CHECK(delegate_); | 189 CHECK(delegate_); |
189 if (routing_id_ == MSG_ROUTING_NONE) { | 190 if (routing_id_ == MSG_ROUTING_NONE) { |
190 routing_id_ = process_->GetNextRoutingID(); | 191 routing_id_ = process_->GetNextRoutingID(); |
191 surface_id_ = GpuSurfaceTracker::Get()->AddSurfaceForRenderer( | 192 surface_id_ = GpuSurfaceTracker::Get()->AddSurfaceForRenderer( |
192 process_->GetID(), | 193 process_->GetID(), |
193 routing_id_); | 194 routing_id_); |
194 } else { | 195 } else { |
195 // TODO(piman): This is a O(N) lookup, where we could forward the | 196 // TODO(piman): This is a O(N) lookup, where we could forward the |
196 // information from the RenderWidgetHelper. The problem is that doing so | 197 // information from the RenderWidgetHelper. The problem is that doing so |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 GpuSurfaceTracker::Get()->SetSurfaceHandle( | 408 GpuSurfaceTracker::Get()->SetSurfaceHandle( |
408 surface_id_, GetCompositingSurface()); | 409 surface_id_, GetCompositingSurface()); |
409 | 410 |
410 // Send the ack along with the information on placement. | 411 // Send the ack along with the information on placement. |
411 Send(new ViewMsg_CreatingNew_ACK(routing_id_)); | 412 Send(new ViewMsg_CreatingNew_ACK(routing_id_)); |
412 GetProcess()->ResumeRequestsForView(routing_id_); | 413 GetProcess()->ResumeRequestsForView(routing_id_); |
413 | 414 |
414 WasResized(); | 415 WasResized(); |
415 } | 416 } |
416 | 417 |
| 418 void RenderWidgetHostImpl::InitForFrame() { |
| 419 DCHECK(process_->HasConnection()); |
| 420 renderer_initialized_ = true; |
| 421 } |
| 422 |
417 void RenderWidgetHostImpl::Shutdown() { | 423 void RenderWidgetHostImpl::Shutdown() { |
418 RejectMouseLockOrUnlockIfNecessary(); | 424 RejectMouseLockOrUnlockIfNecessary(); |
419 | 425 |
420 if (process_->HasConnection()) { | 426 if (process_->HasConnection()) { |
421 // Tell the renderer object to close. | 427 // Tell the renderer object to close. |
422 bool rv = Send(new ViewMsg_Close(routing_id_)); | 428 bool rv = Send(new ViewMsg_Close(routing_id_)); |
423 DCHECK(rv); | 429 DCHECK(rv); |
424 } | 430 } |
425 | 431 |
426 Destroy(); | 432 Destroy(); |
(...skipping 884 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1311 } | 1317 } |
1312 | 1318 |
1313 void RenderWidgetHostImpl::SetAutoResize(bool enable, | 1319 void RenderWidgetHostImpl::SetAutoResize(bool enable, |
1314 const gfx::Size& min_size, | 1320 const gfx::Size& min_size, |
1315 const gfx::Size& max_size) { | 1321 const gfx::Size& max_size) { |
1316 auto_resize_enabled_ = enable; | 1322 auto_resize_enabled_ = enable; |
1317 min_size_for_auto_resize_ = min_size; | 1323 min_size_for_auto_resize_ = min_size; |
1318 max_size_for_auto_resize_ = max_size; | 1324 max_size_for_auto_resize_ = max_size; |
1319 } | 1325 } |
1320 | 1326 |
| 1327 void RenderWidgetHostImpl::Cleanup() { |
| 1328 if (view_) { |
| 1329 view_->Destroy(); |
| 1330 view_ = nullptr; |
| 1331 } |
| 1332 } |
| 1333 |
1321 void RenderWidgetHostImpl::Destroy() { | 1334 void RenderWidgetHostImpl::Destroy() { |
1322 NotificationService::current()->Notify( | 1335 NotificationService::current()->Notify( |
1323 NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, | 1336 NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, |
1324 Source<RenderWidgetHost>(this), | 1337 Source<RenderWidgetHost>(this), |
1325 NotificationService::NoDetails()); | 1338 NotificationService::NoDetails()); |
1326 | 1339 |
1327 // Tell the view to die. | 1340 // Tell the view to die. |
1328 // Note that in the process of the view shutting down, it can call a ton | 1341 // Note that in the process of the view shutting down, it can call a ton |
1329 // of other messages on us. So if you do any other deinitialization here, | 1342 // of other messages on us. So if you do any other deinitialization here, |
1330 // do it after this call to view_->Destroy(). | 1343 // do it after this call to view_->Destroy(). |
1331 if (view_) | 1344 if (view_) { |
1332 view_->Destroy(); | 1345 view_->Destroy(); |
| 1346 view_ = nullptr; |
| 1347 } |
1333 | 1348 |
1334 delete this; | 1349 // RenderFrameHost owns a RenderWidgetHost when it needs one, in which case |
| 1350 // it handles destruction. |
| 1351 if (!owned_by_render_frame_host_) |
| 1352 delete this; |
1335 } | 1353 } |
1336 | 1354 |
1337 void RenderWidgetHostImpl::RendererIsUnresponsive() { | 1355 void RenderWidgetHostImpl::RendererIsUnresponsive() { |
1338 NotificationService::current()->Notify( | 1356 NotificationService::current()->Notify( |
1339 NOTIFICATION_RENDER_WIDGET_HOST_HANG, | 1357 NOTIFICATION_RENDER_WIDGET_HOST_HANG, |
1340 Source<RenderWidgetHost>(this), | 1358 Source<RenderWidgetHost>(this), |
1341 NotificationService::NoDetails()); | 1359 NotificationService::NoDetails()); |
1342 is_unresponsive_ = true; | 1360 is_unresponsive_ = true; |
1343 NotifyRendererUnresponsive(); | 1361 NotifyRendererUnresponsive(); |
1344 } | 1362 } |
(...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2164 } | 2182 } |
2165 #endif | 2183 #endif |
2166 | 2184 |
2167 SkColorType RenderWidgetHostImpl::PreferredReadbackFormat() { | 2185 SkColorType RenderWidgetHostImpl::PreferredReadbackFormat() { |
2168 if (view_) | 2186 if (view_) |
2169 return view_->PreferredReadbackFormat(); | 2187 return view_->PreferredReadbackFormat(); |
2170 return kN32_SkColorType; | 2188 return kN32_SkColorType; |
2171 } | 2189 } |
2172 | 2190 |
2173 } // namespace content | 2191 } // namespace content |
OLD | NEW |