| 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 878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1305 } | 1311 } |
| 1306 | 1312 |
| 1307 void RenderWidgetHostImpl::SetAutoResize(bool enable, | 1313 void RenderWidgetHostImpl::SetAutoResize(bool enable, |
| 1308 const gfx::Size& min_size, | 1314 const gfx::Size& min_size, |
| 1309 const gfx::Size& max_size) { | 1315 const gfx::Size& max_size) { |
| 1310 auto_resize_enabled_ = enable; | 1316 auto_resize_enabled_ = enable; |
| 1311 min_size_for_auto_resize_ = min_size; | 1317 min_size_for_auto_resize_ = min_size; |
| 1312 max_size_for_auto_resize_ = max_size; | 1318 max_size_for_auto_resize_ = max_size; |
| 1313 } | 1319 } |
| 1314 | 1320 |
| 1321 void RenderWidgetHostImpl::Cleanup() { |
| 1322 if (view_) { |
| 1323 view_->Destroy(); |
| 1324 view_ = nullptr; |
| 1325 } |
| 1326 } |
| 1327 |
| 1315 void RenderWidgetHostImpl::Destroy() { | 1328 void RenderWidgetHostImpl::Destroy() { |
| 1316 NotificationService::current()->Notify( | 1329 NotificationService::current()->Notify( |
| 1317 NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, | 1330 NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, |
| 1318 Source<RenderWidgetHost>(this), | 1331 Source<RenderWidgetHost>(this), |
| 1319 NotificationService::NoDetails()); | 1332 NotificationService::NoDetails()); |
| 1320 | 1333 |
| 1321 // Tell the view to die. | 1334 // Tell the view to die. |
| 1322 // Note that in the process of the view shutting down, it can call a ton | 1335 // Note that in the process of the view shutting down, it can call a ton |
| 1323 // of other messages on us. So if you do any other deinitialization here, | 1336 // of other messages on us. So if you do any other deinitialization here, |
| 1324 // do it after this call to view_->Destroy(). | 1337 // do it after this call to view_->Destroy(). |
| 1325 if (view_) | 1338 if (view_) { |
| 1326 view_->Destroy(); | 1339 view_->Destroy(); |
| 1340 view_ = nullptr; |
| 1341 } |
| 1327 | 1342 |
| 1328 delete this; | 1343 delete this; |
| 1329 } | 1344 } |
| 1330 | 1345 |
| 1331 void RenderWidgetHostImpl::RendererIsUnresponsive() { | 1346 void RenderWidgetHostImpl::RendererIsUnresponsive() { |
| 1332 NotificationService::current()->Notify( | 1347 NotificationService::current()->Notify( |
| 1333 NOTIFICATION_RENDER_WIDGET_HOST_HANG, | 1348 NOTIFICATION_RENDER_WIDGET_HOST_HANG, |
| 1334 Source<RenderWidgetHost>(this), | 1349 Source<RenderWidgetHost>(this), |
| 1335 NotificationService::NoDetails()); | 1350 NotificationService::NoDetails()); |
| 1336 is_unresponsive_ = true; | 1351 is_unresponsive_ = true; |
| 1337 NotifyRendererUnresponsive(); | 1352 NotifyRendererUnresponsive(); |
| 1338 } | 1353 } |
| 1339 | 1354 |
| 1340 void RenderWidgetHostImpl::RendererIsResponsive() { | 1355 void RenderWidgetHostImpl::RendererIsResponsive() { |
| 1341 if (is_unresponsive_) { | 1356 if (is_unresponsive_) { |
| 1342 is_unresponsive_ = false; | 1357 is_unresponsive_ = false; |
| 1343 NotifyRendererResponsive(); | 1358 NotifyRendererResponsive(); |
| 1344 } | 1359 } |
| 1345 } | 1360 } |
| 1346 | 1361 |
| 1347 void RenderWidgetHostImpl::OnRenderViewReady() { | 1362 void RenderWidgetHostImpl::OnRenderViewReady() { |
| 1348 SendScreenRects(); | 1363 SendScreenRects(); |
| 1349 WasResized(); | 1364 WasResized(); |
| 1350 } | 1365 } |
| 1351 | 1366 |
| 1352 void RenderWidgetHostImpl::OnRenderProcessGone(int status, int exit_code) { | 1367 void RenderWidgetHostImpl::OnRenderProcessGone(int status, int exit_code) { |
| 1353 // TODO(evanm): This synchronously ends up calling "delete this". | 1368 // RenderFrameHost owns a RenderWidgetHost when it needs one, in which case |
| 1354 // Is that really what we want in response to this message? I'm matching | 1369 // it handles destruction. |
| 1355 // previous behavior of the code here. | 1370 if (!owned_by_render_frame_host_) { |
| 1356 Destroy(); | 1371 // TODO(evanm): This synchronously ends up calling "delete this". |
| 1372 // Is that really what we want in response to this message? I'm matching |
| 1373 // previous behavior of the code here. |
| 1374 Destroy(); |
| 1375 } else { |
| 1376 RendererExited(static_cast<base::TerminationStatus>(status), exit_code); |
| 1377 } |
| 1357 } | 1378 } |
| 1358 | 1379 |
| 1359 void RenderWidgetHostImpl::OnClose() { | 1380 void RenderWidgetHostImpl::OnClose() { |
| 1360 Shutdown(); | 1381 Shutdown(); |
| 1361 } | 1382 } |
| 1362 | 1383 |
| 1363 void RenderWidgetHostImpl::OnSetTooltipText( | 1384 void RenderWidgetHostImpl::OnSetTooltipText( |
| 1364 const base::string16& tooltip_text, | 1385 const base::string16& tooltip_text, |
| 1365 WebTextDirection text_direction_hint) { | 1386 WebTextDirection text_direction_hint) { |
| 1366 // First, add directionality marks around tooltip text if necessary. | 1387 // First, add directionality marks around tooltip text if necessary. |
| (...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2163 } | 2184 } |
| 2164 #endif | 2185 #endif |
| 2165 | 2186 |
| 2166 SkColorType RenderWidgetHostImpl::PreferredReadbackFormat() { | 2187 SkColorType RenderWidgetHostImpl::PreferredReadbackFormat() { |
| 2167 if (view_) | 2188 if (view_) |
| 2168 return view_->PreferredReadbackFormat(); | 2189 return view_->PreferredReadbackFormat(); |
| 2169 return kN32_SkColorType; | 2190 return kN32_SkColorType; |
| 2170 } | 2191 } |
| 2171 | 2192 |
| 2172 } // namespace content | 2193 } // namespace content |
| OLD | NEW |