Chromium Code Reviews| 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 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <tuple> | 10 #include <tuple> |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 #include "base/strings/utf_string_conversions.h" | 26 #include "base/strings/utf_string_conversions.h" |
| 27 #include "base/threading/thread_task_runner_handle.h" | 27 #include "base/threading/thread_task_runner_handle.h" |
| 28 #include "base/trace_event/trace_event.h" | 28 #include "base/trace_event/trace_event.h" |
| 29 #include "build/build_config.h" | 29 #include "build/build_config.h" |
| 30 #include "cc/base/switches.h" | 30 #include "cc/base/switches.h" |
| 31 #include "cc/output/compositor_frame.h" | 31 #include "cc/output/compositor_frame.h" |
| 32 #include "content/browser/accessibility/accessibility_mode_helper.h" | 32 #include "content/browser/accessibility/accessibility_mode_helper.h" |
| 33 #include "content/browser/accessibility/browser_accessibility_state_impl.h" | 33 #include "content/browser/accessibility/browser_accessibility_state_impl.h" |
| 34 #include "content/browser/bad_message.h" | 34 #include "content/browser/bad_message.h" |
| 35 #include "content/browser/browser_plugin/browser_plugin_guest.h" | 35 #include "content/browser/browser_plugin/browser_plugin_guest.h" |
| 36 #include "content/browser/child_process_security_policy_impl.h" | |
| 36 #include "content/browser/gpu/compositor_util.h" | 37 #include "content/browser/gpu/compositor_util.h" |
| 37 #include "content/browser/renderer_host/dip_util.h" | 38 #include "content/browser/renderer_host/dip_util.h" |
| 38 #include "content/browser/renderer_host/frame_metadata_util.h" | 39 #include "content/browser/renderer_host/frame_metadata_util.h" |
| 39 #include "content/browser/renderer_host/input/input_router_config_helper.h" | 40 #include "content/browser/renderer_host/input/input_router_config_helper.h" |
| 40 #include "content/browser/renderer_host/input/input_router_impl.h" | 41 #include "content/browser/renderer_host/input/input_router_impl.h" |
| 41 #include "content/browser/renderer_host/input/synthetic_gesture.h" | 42 #include "content/browser/renderer_host/input/synthetic_gesture.h" |
| 42 #include "content/browser/renderer_host/input/synthetic_gesture_controller.h" | 43 #include "content/browser/renderer_host/input/synthetic_gesture_controller.h" |
| 43 #include "content/browser/renderer_host/input/synthetic_gesture_target.h" | 44 #include "content/browser/renderer_host/input/synthetic_gesture_target.h" |
| 44 #include "content/browser/renderer_host/input/timeout_monitor.h" | 45 #include "content/browser/renderer_host/input/timeout_monitor.h" |
| 45 #include "content/browser/renderer_host/input/touch_emulator.h" | 46 #include "content/browser/renderer_host/input/touch_emulator.h" |
| 46 #include "content/browser/renderer_host/render_process_host_impl.h" | 47 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 48 #include "content/browser/renderer_host/render_view_host_delegate.h" | |
| 49 #include "content/browser/renderer_host/render_view_host_delegate_view.h" | |
| 47 #include "content/browser/renderer_host/render_view_host_impl.h" | 50 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 48 #include "content/browser/renderer_host/render_widget_helper.h" | 51 #include "content/browser/renderer_host/render_widget_helper.h" |
| 49 #include "content/browser/renderer_host/render_widget_host_input_event_router.h" | 52 #include "content/browser/renderer_host/render_widget_host_input_event_router.h" |
| 50 #include "content/browser/renderer_host/render_widget_host_owner_delegate.h" | 53 #include "content/browser/renderer_host/render_widget_host_owner_delegate.h" |
| 51 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 54 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
| 52 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 55 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
| 53 #include "content/common/content_constants_internal.h" | 56 #include "content/common/content_constants_internal.h" |
| 54 #include "content/common/content_switches_internal.h" | 57 #include "content/common/content_switches_internal.h" |
| 55 #include "content/common/cursors/webcursor.h" | 58 #include "content/common/cursors/webcursor.h" |
| 59 #include "content/common/drag_messages.h" | |
| 56 #include "content/common/frame_messages.h" | 60 #include "content/common/frame_messages.h" |
| 57 #include "content/common/host_shared_bitmap_manager.h" | 61 #include "content/common/host_shared_bitmap_manager.h" |
| 58 #include "content/common/input_messages.h" | 62 #include "content/common/input_messages.h" |
| 59 #include "content/common/resize_params.h" | 63 #include "content/common/resize_params.h" |
| 60 #include "content/common/text_input_state.h" | 64 #include "content/common/text_input_state.h" |
| 61 #include "content/common/view_messages.h" | 65 #include "content/common/view_messages.h" |
| 66 #include "content/public/browser/browser_context.h" | |
| 62 #include "content/public/browser/native_web_keyboard_event.h" | 67 #include "content/public/browser/native_web_keyboard_event.h" |
| 63 #include "content/public/browser/notification_service.h" | 68 #include "content/public/browser/notification_service.h" |
| 64 #include "content/public/browser/notification_types.h" | 69 #include "content/public/browser/notification_types.h" |
| 65 #include "content/public/browser/render_widget_host_iterator.h" | 70 #include "content/public/browser/render_widget_host_iterator.h" |
| 66 #include "content/public/browser/storage_partition.h" | 71 #include "content/public/browser/storage_partition.h" |
| 67 #include "content/public/common/content_constants.h" | 72 #include "content/public/common/content_constants.h" |
| 68 #include "content/public/common/content_switches.h" | 73 #include "content/public/common/content_switches.h" |
| 69 #include "content/public/common/result_codes.h" | 74 #include "content/public/common/result_codes.h" |
| 70 #include "content/public/common/web_preferences.h" | 75 #include "content/public/common/web_preferences.h" |
| 71 #include "gpu/GLES2/gl2extchromium.h" | 76 #include "gpu/GLES2/gl2extchromium.h" |
| 72 #include "gpu/command_buffer/service/gpu_switches.h" | 77 #include "gpu/command_buffer/service/gpu_switches.h" |
| 73 #include "gpu/ipc/common/gpu_messages.h" | 78 #include "gpu/ipc/common/gpu_messages.h" |
| 74 #include "skia/ext/image_operations.h" | 79 #include "skia/ext/image_operations.h" |
| 75 #include "skia/ext/platform_canvas.h" | 80 #include "skia/ext/platform_canvas.h" |
| 76 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" | 81 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" |
| 77 #include "ui/events/blink/web_input_event_traits.h" | 82 #include "ui/events/blink/web_input_event_traits.h" |
| 78 #include "ui/events/event.h" | 83 #include "ui/events/event.h" |
| 79 #include "ui/events/keycodes/keyboard_codes.h" | 84 #include "ui/events/keycodes/keyboard_codes.h" |
| 80 #include "ui/gfx/color_space.h" | 85 #include "ui/gfx/color_space.h" |
| 81 #include "ui/gfx/geometry/size_conversions.h" | 86 #include "ui/gfx/geometry/size_conversions.h" |
| 82 #include "ui/gfx/geometry/vector2d_conversions.h" | 87 #include "ui/gfx/geometry/vector2d_conversions.h" |
| 88 #include "ui/gfx/image/image_skia.h" | |
| 83 #include "ui/gfx/skbitmap_operations.h" | 89 #include "ui/gfx/skbitmap_operations.h" |
| 84 #include "ui/snapshot/snapshot.h" | 90 #include "ui/snapshot/snapshot.h" |
| 85 | 91 |
| 86 #if defined(OS_MACOSX) | 92 #if defined(OS_MACOSX) |
| 87 #include "device/power_save_blocker/power_save_blocker.h" | 93 #include "device/power_save_blocker/power_save_blocker.h" |
| 88 #include "ui/accelerated_widget_mac/window_resize_helper_mac.h" | 94 #include "ui/accelerated_widget_mac/window_resize_helper_mac.h" |
| 89 #endif | 95 #endif |
| 90 | 96 |
| 91 using base::Time; | 97 using base::Time; |
| 92 using base::TimeDelta; | 98 using base::TimeDelta; |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 489 OnShowDisambiguationPopup) | 495 OnShowDisambiguationPopup) |
| 490 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionBoundsChanged, | 496 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionBoundsChanged, |
| 491 OnSelectionBoundsChanged) | 497 OnSelectionBoundsChanged) |
| 492 IPC_MESSAGE_HANDLER(InputHostMsg_ImeCompositionRangeChanged, | 498 IPC_MESSAGE_HANDLER(InputHostMsg_ImeCompositionRangeChanged, |
| 493 OnImeCompositionRangeChanged) | 499 OnImeCompositionRangeChanged) |
| 494 IPC_MESSAGE_HANDLER(ViewHostMsg_DidFirstPaintAfterLoad, | 500 IPC_MESSAGE_HANDLER(ViewHostMsg_DidFirstPaintAfterLoad, |
| 495 OnFirstPaintAfterLoad) | 501 OnFirstPaintAfterLoad) |
| 496 IPC_MESSAGE_HANDLER(ViewHostMsg_ForwardCompositorProto, | 502 IPC_MESSAGE_HANDLER(ViewHostMsg_ForwardCompositorProto, |
| 497 OnForwardCompositorProto) | 503 OnForwardCompositorProto) |
| 498 IPC_MESSAGE_HANDLER(ViewHostMsg_SetNeedsBeginFrames, OnSetNeedsBeginFrames) | 504 IPC_MESSAGE_HANDLER(ViewHostMsg_SetNeedsBeginFrames, OnSetNeedsBeginFrames) |
| 505 IPC_MESSAGE_HANDLER(DragHostMsg_StartDragging, OnStartDragging) | |
| 499 IPC_MESSAGE_UNHANDLED(handled = false) | 506 IPC_MESSAGE_UNHANDLED(handled = false) |
| 500 IPC_END_MESSAGE_MAP() | 507 IPC_END_MESSAGE_MAP() |
| 501 | 508 |
| 502 if (!handled && input_router_ && input_router_->OnMessageReceived(msg)) | 509 if (!handled && input_router_ && input_router_->OnMessageReceived(msg)) |
| 503 return true; | 510 return true; |
| 504 | 511 |
| 505 if (!handled && view_ && view_->OnMessageReceived(msg)) | 512 if (!handled && view_ && view_->OnMessageReceived(msg)) |
| 506 return true; | 513 return true; |
| 507 | 514 |
| 508 return handled; | 515 return handled; |
| (...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1343 | 1350 |
| 1344 void RenderWidgetHostImpl::OnSetNeedsBeginFrames(bool needs_begin_frames) { | 1351 void RenderWidgetHostImpl::OnSetNeedsBeginFrames(bool needs_begin_frames) { |
| 1345 if (needs_begin_frames_ == needs_begin_frames) | 1352 if (needs_begin_frames_ == needs_begin_frames) |
| 1346 return; | 1353 return; |
| 1347 | 1354 |
| 1348 needs_begin_frames_ = needs_begin_frames; | 1355 needs_begin_frames_ = needs_begin_frames; |
| 1349 if (view_) | 1356 if (view_) |
| 1350 view_->SetNeedsBeginFrames(needs_begin_frames); | 1357 view_->SetNeedsBeginFrames(needs_begin_frames); |
| 1351 } | 1358 } |
| 1352 | 1359 |
| 1360 void RenderWidgetHostImpl::OnStartDragging( | |
| 1361 const DropData& drop_data, | |
| 1362 blink::WebDragOperationsMask drag_operations_mask, | |
| 1363 const SkBitmap& bitmap, | |
| 1364 const gfx::Vector2d& bitmap_offset_in_dip, | |
| 1365 const DragEventSourceInfo& event_info) { | |
| 1366 RenderViewHost* rvh = delegate_->GetRenderViewHost(); | |
| 1367 if (!rvh) | |
| 1368 return; | |
| 1369 RenderViewHostDelegateView* view = rvh->GetDelegate()->GetDelegateView(); | |
| 1370 if (!view) { | |
| 1371 // Need to clear drag and drop state in blink. | |
| 1372 rvh->DragSourceSystemDragEnded(); | |
| 1373 return; | |
| 1374 } | |
| 1375 | |
| 1376 DropData filtered_data(drop_data); | |
| 1377 RenderProcessHost* process = GetProcess(); | |
| 1378 ChildProcessSecurityPolicyImpl* policy = | |
| 1379 ChildProcessSecurityPolicyImpl::GetInstance(); | |
| 1380 | |
| 1381 // Allow drag of Javascript URLs to enable bookmarklet drag to bookmark bar. | |
| 1382 if (!filtered_data.url.SchemeIs(url::kJavaScriptScheme)) | |
| 1383 process->FilterURL(true, &filtered_data.url); | |
| 1384 process->FilterURL(false, &filtered_data.html_base_url); | |
| 1385 // Filter out any paths that the renderer didn't have access to. This prevents | |
| 1386 // the following attack on a malicious renderer: | |
| 1387 // 1. StartDragging IPC sent with renderer-specified filesystem paths that it | |
| 1388 // doesn't have read permissions for. | |
| 1389 // 2. We initiate a native DnD operation. | |
| 1390 // 3. DnD operation immediately ends since mouse is not held down. DnD events | |
| 1391 // still fire though, which causes read permissions to be granted to the | |
| 1392 // renderer for any file paths in the drop. | |
| 1393 filtered_data.filenames.clear(); | |
| 1394 for (std::vector<ui::FileInfo>::const_iterator it = | |
|
dcheng
2016/11/07 21:11:00
Nit: mind changing this to a range-based for loop
paulmeyer
2016/11/07 22:18:13
Done.
| |
| 1395 drop_data.filenames.begin(); | |
| 1396 it != drop_data.filenames.end(); | |
| 1397 ++it) { | |
| 1398 if (policy->CanReadFile(GetProcess()->GetID(), it->path)) | |
| 1399 filtered_data.filenames.push_back(*it); | |
| 1400 } | |
| 1401 | |
| 1402 storage::FileSystemContext* file_system_context = | |
| 1403 BrowserContext::GetStoragePartition(GetProcess()->GetBrowserContext(), | |
| 1404 rvh->GetSiteInstance()) | |
| 1405 ->GetFileSystemContext(); | |
| 1406 filtered_data.file_system_files.clear(); | |
| 1407 for (size_t i = 0; i < drop_data.file_system_files.size(); ++i) { | |
| 1408 storage::FileSystemURL file_system_url = | |
| 1409 file_system_context->CrackURL(drop_data.file_system_files[i].url); | |
| 1410 if (policy->CanReadFileSystemFile(GetProcess()->GetID(), file_system_url)) | |
| 1411 filtered_data.file_system_files.push_back(drop_data.file_system_files[i]); | |
| 1412 } | |
| 1413 | |
| 1414 float scale = GetScaleFactorForView(GetView()); | |
| 1415 gfx::ImageSkia image(gfx::ImageSkiaRep(bitmap, scale)); | |
| 1416 view->StartDragging(filtered_data, drag_operations_mask, image, | |
| 1417 bitmap_offset_in_dip, event_info); | |
| 1418 } | |
| 1419 | |
| 1353 void RenderWidgetHostImpl::RendererExited(base::TerminationStatus status, | 1420 void RenderWidgetHostImpl::RendererExited(base::TerminationStatus status, |
| 1354 int exit_code) { | 1421 int exit_code) { |
| 1355 if (!renderer_initialized_) | 1422 if (!renderer_initialized_) |
| 1356 return; | 1423 return; |
| 1357 | 1424 |
| 1358 // Clearing this flag causes us to re-create the renderer when recovering | 1425 // Clearing this flag causes us to re-create the renderer when recovering |
| 1359 // from a crashed renderer. | 1426 // from a crashed renderer. |
| 1360 renderer_initialized_ = false; | 1427 renderer_initialized_ = false; |
| 1361 | 1428 |
| 1362 waiting_for_screen_rects_ack_ = false; | 1429 waiting_for_screen_rects_ack_ = false; |
| (...skipping 852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2215 return delegate_ ? delegate_->GetRootBrowserAccessibilityManager() : NULL; | 2282 return delegate_ ? delegate_->GetRootBrowserAccessibilityManager() : NULL; |
| 2216 } | 2283 } |
| 2217 | 2284 |
| 2218 BrowserAccessibilityManager* | 2285 BrowserAccessibilityManager* |
| 2219 RenderWidgetHostImpl::GetOrCreateRootBrowserAccessibilityManager() { | 2286 RenderWidgetHostImpl::GetOrCreateRootBrowserAccessibilityManager() { |
| 2220 return delegate_ ? | 2287 return delegate_ ? |
| 2221 delegate_->GetOrCreateRootBrowserAccessibilityManager() : NULL; | 2288 delegate_->GetOrCreateRootBrowserAccessibilityManager() : NULL; |
| 2222 } | 2289 } |
| 2223 | 2290 |
| 2224 } // namespace content | 2291 } // namespace content |
| OLD | NEW |