Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(112)

Side by Side Diff: content/browser/renderer_host/render_widget_host_impl.cc

Issue 2475443003: Drag-and-drop: Move startDrag out of WebView/RenderView. (Closed)
Patch Set: Removed unneeded declarations. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
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 = RenderViewHost::From(this);
1367 if (!rvh)
1368 return;
1369
1370 RenderViewHostDelegateView* view = delegate_->GetDelegateView();
1371 if (!view) {
1372 // Need to clear drag and drop state in blink.
1373 rvh->DragSourceSystemDragEnded();
1374 return;
1375 }
1376
1377 DropData filtered_data(drop_data);
1378 RenderProcessHost* process = GetProcess();
1379 ChildProcessSecurityPolicyImpl* policy =
1380 ChildProcessSecurityPolicyImpl::GetInstance();
1381
1382 // Allow drag of Javascript URLs to enable bookmarklet drag to bookmark bar.
1383 if (!filtered_data.url.SchemeIs(url::kJavaScriptScheme))
1384 process->FilterURL(true, &filtered_data.url);
1385 process->FilterURL(false, &filtered_data.html_base_url);
1386 // Filter out any paths that the renderer didn't have access to. This prevents
1387 // the following attack on a malicious renderer:
1388 // 1. StartDragging IPC sent with renderer-specified filesystem paths that it
1389 // doesn't have read permissions for.
1390 // 2. We initiate a native DnD operation.
1391 // 3. DnD operation immediately ends since mouse is not held down. DnD events
1392 // still fire though, which causes read permissions to be granted to the
1393 // renderer for any file paths in the drop.
1394 filtered_data.filenames.clear();
1395 for (const auto& file_info : drop_data.filenames) {
1396 if (policy->CanReadFile(GetProcess()->GetID(), file_info.path))
1397 filtered_data.filenames.push_back(file_info);
1398 }
1399
1400 storage::FileSystemContext* file_system_context =
1401 BrowserContext::GetStoragePartition(GetProcess()->GetBrowserContext(),
1402 rvh->GetSiteInstance())
1403 ->GetFileSystemContext();
1404 filtered_data.file_system_files.clear();
1405 for (size_t i = 0; i < drop_data.file_system_files.size(); ++i) {
1406 storage::FileSystemURL file_system_url =
1407 file_system_context->CrackURL(drop_data.file_system_files[i].url);
1408 if (policy->CanReadFileSystemFile(GetProcess()->GetID(), file_system_url))
1409 filtered_data.file_system_files.push_back(drop_data.file_system_files[i]);
1410 }
1411
1412 float scale = GetScaleFactorForView(GetView());
1413 gfx::ImageSkia image(gfx::ImageSkiaRep(bitmap, scale));
1414 view->StartDragging(filtered_data, drag_operations_mask, image,
1415 bitmap_offset_in_dip, event_info);
1416 }
1417
1353 void RenderWidgetHostImpl::RendererExited(base::TerminationStatus status, 1418 void RenderWidgetHostImpl::RendererExited(base::TerminationStatus status,
1354 int exit_code) { 1419 int exit_code) {
1355 if (!renderer_initialized_) 1420 if (!renderer_initialized_)
1356 return; 1421 return;
1357 1422
1358 // Clearing this flag causes us to re-create the renderer when recovering 1423 // Clearing this flag causes us to re-create the renderer when recovering
1359 // from a crashed renderer. 1424 // from a crashed renderer.
1360 renderer_initialized_ = false; 1425 renderer_initialized_ = false;
1361 1426
1362 waiting_for_screen_rects_ack_ = false; 1427 waiting_for_screen_rects_ack_ = false;
(...skipping 852 matching lines...) Expand 10 before | Expand all | Expand 10 after
2215 return delegate_ ? delegate_->GetRootBrowserAccessibilityManager() : NULL; 2280 return delegate_ ? delegate_->GetRootBrowserAccessibilityManager() : NULL;
2216 } 2281 }
2217 2282
2218 BrowserAccessibilityManager* 2283 BrowserAccessibilityManager*
2219 RenderWidgetHostImpl::GetOrCreateRootBrowserAccessibilityManager() { 2284 RenderWidgetHostImpl::GetOrCreateRootBrowserAccessibilityManager() {
2220 return delegate_ ? 2285 return delegate_ ?
2221 delegate_->GetOrCreateRootBrowserAccessibilityManager() : NULL; 2286 delegate_->GetOrCreateRootBrowserAccessibilityManager() : NULL;
2222 } 2287 }
2223 2288
2224 } // namespace content 2289 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_impl.h ('k') | content/public/browser/render_widget_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698