| 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 <utility> | 8 #include <utility> | 
| 9 | 9 | 
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" | 
| 11 #include "base/bind.h" | 11 #include "base/bind.h" | 
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" | 
| 13 #include "base/debug/trace_event.h" | 13 #include "base/debug/trace_event.h" | 
| 14 #include "base/i18n/rtl.h" | 14 #include "base/i18n/rtl.h" | 
| 15 #include "base/message_loop.h" | 15 #include "base/message_loop.h" | 
| 16 #include "base/metrics/field_trial.h" | 16 #include "base/metrics/field_trial.h" | 
| 17 #include "base/metrics/histogram.h" | 17 #include "base/metrics/histogram.h" | 
| 18 #include "base/string_number_conversions.h" | 18 #include "base/string_number_conversions.h" | 
| 19 #include "base/utf_string_conversions.h" | 19 #include "base/utf_string_conversions.h" | 
| 20 #include "cc/output/compositor_frame.h" | 20 #include "cc/output/compositor_frame.h" | 
| 21 #include "cc/output/compositor_frame_ack.h" | 21 #include "cc/output/compositor_frame_ack.h" | 
| 22 #include "content/browser/accessibility/browser_accessibility_state_impl.h" | 22 #include "content/browser/accessibility/browser_accessibility_state_impl.h" | 
| 23 #include "content/browser/gpu/gpu_process_host.h" | 23 #include "content/browser/gpu/gpu_process_host.h" | 
| 24 #include "content/browser/gpu/gpu_process_host_ui_shim.h" | 24 #include "content/browser/gpu/gpu_process_host_ui_shim.h" | 
| 25 #include "content/browser/gpu/gpu_surface_tracker.h" | 25 #include "content/browser/gpu/gpu_surface_tracker.h" | 
| 26 #include "content/browser/renderer_host/backing_store.h" | 26 #include "content/browser/renderer_host/backing_store.h" | 
| 27 #include "content/browser/renderer_host/backing_store_manager.h" | 27 #include "content/browser/renderer_host/backing_store_manager.h" | 
|  | 28 #include "content/browser/renderer_host/dip_util.h" | 
| 28 #include "content/browser/renderer_host/gesture_event_filter.h" | 29 #include "content/browser/renderer_host/gesture_event_filter.h" | 
| 29 #include "content/browser/renderer_host/overscroll_controller.h" | 30 #include "content/browser/renderer_host/overscroll_controller.h" | 
| 30 #include "content/browser/renderer_host/render_process_host_impl.h" | 31 #include "content/browser/renderer_host/render_process_host_impl.h" | 
| 31 #include "content/browser/renderer_host/render_view_host_impl.h" | 32 #include "content/browser/renderer_host/render_view_host_impl.h" | 
| 32 #include "content/browser/renderer_host/render_widget_helper.h" | 33 #include "content/browser/renderer_host/render_widget_helper.h" | 
| 33 #include "content/browser/renderer_host/render_widget_host_delegate.h" | 34 #include "content/browser/renderer_host/render_widget_host_delegate.h" | 
| 34 #include "content/browser/renderer_host/touch_event_queue.h" | 35 #include "content/browser/renderer_host/touch_event_queue.h" | 
| 35 #include "content/browser/renderer_host/touchpad_tap_suppression_controller.h" | 36 #include "content/browser/renderer_host/touchpad_tap_suppression_controller.h" | 
| 36 #include "content/common/accessibility_messages.h" | 37 #include "content/common/accessibility_messages.h" | 
| 37 #include "content/common/content_constants_internal.h" | 38 #include "content/common/content_constants_internal.h" | 
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 384     IPC_MESSAGE_HANDLER(ViewHostMsg_LockMouse, OnLockMouse) | 385     IPC_MESSAGE_HANDLER(ViewHostMsg_LockMouse, OnLockMouse) | 
| 385     IPC_MESSAGE_HANDLER(ViewHostMsg_UnlockMouse, OnUnlockMouse) | 386     IPC_MESSAGE_HANDLER(ViewHostMsg_UnlockMouse, OnUnlockMouse) | 
| 386     IPC_MESSAGE_HANDLER(ViewHostMsg_ShowDisambiguationPopup, | 387     IPC_MESSAGE_HANDLER(ViewHostMsg_ShowDisambiguationPopup, | 
| 387                         OnShowDisambiguationPopup) | 388                         OnShowDisambiguationPopup) | 
| 388 #if defined(OS_WIN) | 389 #if defined(OS_WIN) | 
| 389     IPC_MESSAGE_HANDLER(ViewHostMsg_WindowlessPluginDummyWindowCreated, | 390     IPC_MESSAGE_HANDLER(ViewHostMsg_WindowlessPluginDummyWindowCreated, | 
| 390                         OnWindowlessPluginDummyWindowCreated) | 391                         OnWindowlessPluginDummyWindowCreated) | 
| 391     IPC_MESSAGE_HANDLER(ViewHostMsg_WindowlessPluginDummyWindowDestroyed, | 392     IPC_MESSAGE_HANDLER(ViewHostMsg_WindowlessPluginDummyWindowDestroyed, | 
| 392                         OnWindowlessPluginDummyWindowDestroyed) | 393                         OnWindowlessPluginDummyWindowDestroyed) | 
| 393 #endif | 394 #endif | 
|  | 395     IPC_MESSAGE_HANDLER(ViewHostMsg_Snapshot, OnSnapshot) | 
| 394     IPC_MESSAGE_UNHANDLED(handled = false) | 396     IPC_MESSAGE_UNHANDLED(handled = false) | 
| 395   IPC_END_MESSAGE_MAP_EX() | 397   IPC_END_MESSAGE_MAP_EX() | 
| 396 | 398 | 
| 397   if (!handled && view_ && view_->OnMessageReceived(msg)) | 399   if (!handled && view_ && view_->OnMessageReceived(msg)) | 
| 398     return true; | 400     return true; | 
| 399 | 401 | 
| 400   if (!msg_is_ok) { | 402   if (!msg_is_ok) { | 
| 401     // The message de-serialization failed. Kill the renderer process. | 403     // The message de-serialization failed. Kill the renderer process. | 
| 402     RecordAction(UserMetricsAction("BadMessageTerminate_RWH")); | 404     RecordAction(UserMetricsAction("BadMessageTerminate_RWH")); | 
| 403     GetProcess()->ReceivedBadMessage(); | 405     GetProcess()->ReceivedBadMessage(); | 
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 566   view_->SetIsLoading(is_loading); | 568   view_->SetIsLoading(is_loading); | 
| 567 } | 569 } | 
| 568 | 570 | 
| 569 void RenderWidgetHostImpl::CopyFromBackingStore( | 571 void RenderWidgetHostImpl::CopyFromBackingStore( | 
| 570     const gfx::Rect& src_subrect, | 572     const gfx::Rect& src_subrect, | 
| 571     const gfx::Size& accelerated_dst_size, | 573     const gfx::Size& accelerated_dst_size, | 
| 572     const base::Callback<void(bool, const SkBitmap&)>& callback) { | 574     const base::Callback<void(bool, const SkBitmap&)>& callback) { | 
| 573   if (view_ && is_accelerated_compositing_active_) { | 575   if (view_ && is_accelerated_compositing_active_) { | 
| 574     TRACE_EVENT0("browser", | 576     TRACE_EVENT0("browser", | 
| 575         "RenderWidgetHostImpl::CopyFromBackingStore::FromCompositingSurface"); | 577         "RenderWidgetHostImpl::CopyFromBackingStore::FromCompositingSurface"); | 
| 576     gfx::Rect copy_rect = src_subrect.IsEmpty() ? | 578     gfx::Rect accelerated_copy_rect = src_subrect.IsEmpty() ? | 
| 577         gfx::Rect(view_->GetViewBounds().size()) : src_subrect; | 579         gfx::Rect(view_->GetViewBounds().size()) : src_subrect; | 
| 578     view_->CopyFromCompositingSurface(copy_rect, | 580     view_->CopyFromCompositingSurface(accelerated_copy_rect, | 
| 579                                       accelerated_dst_size, | 581                                       accelerated_dst_size, | 
| 580                                       callback); | 582                                       callback); | 
| 581     return; | 583     return; | 
| 582   } | 584   } | 
| 583 | 585 | 
| 584   BackingStore* backing_store = GetBackingStore(false); | 586   BackingStore* backing_store = GetBackingStore(false); | 
| 585   if (!backing_store) { | 587   if (!backing_store) { | 
| 586     callback.Run(false, SkBitmap()); | 588     callback.Run(false, SkBitmap()); | 
| 587     return; | 589     return; | 
| 588   } | 590   } | 
| (...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1242   else | 1244   else | 
| 1243     RenderWidgetHostViewPort::GetDefaultScreenInfo(result); | 1245     RenderWidgetHostViewPort::GetDefaultScreenInfo(result); | 
| 1244 } | 1246 } | 
| 1245 | 1247 | 
| 1246 void RenderWidgetHostImpl::NotifyScreenInfoChanged() { | 1248 void RenderWidgetHostImpl::NotifyScreenInfoChanged() { | 
| 1247   WebKit::WebScreenInfo screen_info; | 1249   WebKit::WebScreenInfo screen_info; | 
| 1248   GetWebScreenInfo(&screen_info); | 1250   GetWebScreenInfo(&screen_info); | 
| 1249   Send(new ViewMsg_ScreenInfoChanged(GetRoutingID(), screen_info)); | 1251   Send(new ViewMsg_ScreenInfoChanged(GetRoutingID(), screen_info)); | 
| 1250 } | 1252 } | 
| 1251 | 1253 | 
|  | 1254 void RenderWidgetHostImpl::GetSnapshotFromRenderer( | 
|  | 1255     const gfx::Rect& src_subrect, | 
|  | 1256     const base::Callback<void(bool, const SkBitmap&)>& callback) { | 
|  | 1257   TRACE_EVENT0("browser", "RenderWidgetHostImpl::GetSnapshotFromRenderer"); | 
|  | 1258   pending_snapshots_.push(callback); | 
|  | 1259 | 
|  | 1260   gfx::Rect copy_rect = src_subrect.IsEmpty() ? | 
|  | 1261       gfx::Rect(view_->GetViewBounds().size()) : src_subrect; | 
|  | 1262 | 
|  | 1263   gfx::Rect copy_rect_in_pixel = ConvertRectToPixel(view_, copy_rect); | 
|  | 1264   Send(new ViewMsg_Snapshot(GetRoutingID(), copy_rect_in_pixel)); | 
|  | 1265 } | 
|  | 1266 | 
|  | 1267 void RenderWidgetHostImpl::OnSnapshot(bool success, | 
|  | 1268                                     const SkBitmap& bitmap) { | 
|  | 1269   if (pending_snapshots_.size() == 0) { | 
|  | 1270     LOG(ERROR) << "RenderWidgetHostImpl::OnSnapshot: " | 
|  | 1271                   "Received a snapshot that was not requested."; | 
|  | 1272     return; | 
|  | 1273   } | 
|  | 1274 | 
|  | 1275   base::Callback<void(bool, const SkBitmap&)> callback = | 
|  | 1276       pending_snapshots_.front(); | 
|  | 1277   pending_snapshots_.pop(); | 
|  | 1278 | 
|  | 1279   if (!success) { | 
|  | 1280     callback.Run(success, SkBitmap()); | 
|  | 1281     return; | 
|  | 1282   } | 
|  | 1283 | 
|  | 1284   callback.Run(success, bitmap); | 
|  | 1285 } | 
|  | 1286 | 
| 1252 void RenderWidgetHostImpl::UpdateVSyncParameters(base::TimeTicks timebase, | 1287 void RenderWidgetHostImpl::UpdateVSyncParameters(base::TimeTicks timebase, | 
| 1253                                                  base::TimeDelta interval) { | 1288                                                  base::TimeDelta interval) { | 
| 1254   Send(new ViewMsg_UpdateVSyncParameters(GetRoutingID(), timebase, interval)); | 1289   Send(new ViewMsg_UpdateVSyncParameters(GetRoutingID(), timebase, interval)); | 
| 1255 } | 1290 } | 
| 1256 | 1291 | 
| 1257 void RenderWidgetHostImpl::RendererExited(base::TerminationStatus status, | 1292 void RenderWidgetHostImpl::RendererExited(base::TerminationStatus status, | 
| 1258                                           int exit_code) { | 1293                                           int exit_code) { | 
| 1259   // Clearing this flag causes us to re-create the renderer when recovering | 1294   // Clearing this flag causes us to re-create the renderer when recovering | 
| 1260   // from a crashed renderer. | 1295   // from a crashed renderer. | 
| 1261   renderer_initialized_ = false; | 1296   renderer_initialized_ = false; | 
| (...skipping 1162 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2424     return; | 2459     return; | 
| 2425 | 2460 | 
| 2426   OnRenderAutoResized(new_size); | 2461   OnRenderAutoResized(new_size); | 
| 2427 } | 2462 } | 
| 2428 | 2463 | 
| 2429 void RenderWidgetHostImpl::DetachDelegate() { | 2464 void RenderWidgetHostImpl::DetachDelegate() { | 
| 2430   delegate_ = NULL; | 2465   delegate_ = NULL; | 
| 2431 } | 2466 } | 
| 2432 | 2467 | 
| 2433 }  // namespace content | 2468 }  // namespace content | 
| OLD | NEW | 
|---|