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/renderer/render_view_impl.h" | 5 #include "content/renderer/render_view_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
419 | 419 |
420 bool HandleMouseLockedInputEvent(const blink::WebMouseEvent& event) override { | 420 bool HandleMouseLockedInputEvent(const blink::WebMouseEvent& event) override { |
421 // The WebWidget handles mouse lock in WebKit's handleInputEvent(). | 421 // The WebWidget handles mouse lock in WebKit's handleInputEvent(). |
422 return false; | 422 return false; |
423 } | 423 } |
424 | 424 |
425 private: | 425 private: |
426 blink::WebWidget* webwidget_; | 426 blink::WebWidget* webwidget_; |
427 }; | 427 }; |
428 | 428 |
429 WebDragData DropMetaDataToWebDragData( | |
430 const std::vector<DropData::MetaData>& drop_meta_data) { | |
431 std::vector<WebDragData::Item> item_list; | |
432 for (const auto& meta_data_item : drop_meta_data) { | |
433 if (meta_data_item.kind == DropData::Kind::STRING) { | |
434 WebDragData::Item item; | |
435 item.storageType = WebDragData::Item::StorageTypeString; | |
436 item.stringType = meta_data_item.mime_type; | |
437 item_list.push_back(item); | |
438 continue; | |
439 } | |
440 | |
441 // TODO(hush): crbug.com/584789. Blink needs to support creating a file with | |
442 // just the mimetype. This is needed to drag files to WebView on Android | |
443 // platform. | |
dcheng
2016/05/11 01:19:15
We should probably skip adding an item if it has n
hush (inactive)
2016/05/20 00:01:59
Done.
| |
444 if (meta_data_item.kind == DropData::Kind::FILENAME) { | |
445 WebDragData::Item item; | |
446 item.storageType = WebDragData::Item::StorageTypeFilename; | |
447 item.filenameData = meta_data_item.filename.AsUTF16Unsafe(); | |
448 item_list.push_back(item); | |
449 continue; | |
450 } | |
451 | |
452 if (meta_data_item.kind == DropData::Kind::FILESYSTEMFILE) { | |
453 WebDragData::Item item; | |
454 item.storageType = WebDragData::Item::StorageTypeFileSystemFile; | |
455 item.fileSystemURL = meta_data_item.file_system_url; | |
456 item_list.push_back(item); | |
457 continue; | |
458 } | |
459 } | |
460 | |
461 WebDragData result; | |
462 result.initialize(); | |
463 result.setItems(item_list); | |
464 return result; | |
465 } | |
466 | |
429 WebDragData DropDataToWebDragData(const DropData& drop_data) { | 467 WebDragData DropDataToWebDragData(const DropData& drop_data) { |
430 std::vector<WebDragData::Item> item_list; | 468 std::vector<WebDragData::Item> item_list; |
431 | 469 |
432 // These fields are currently unused when dragging into WebKit. | 470 // These fields are currently unused when dragging into WebKit. |
433 DCHECK(drop_data.download_metadata.empty()); | 471 DCHECK(drop_data.download_metadata.empty()); |
434 DCHECK(drop_data.file_contents.empty()); | 472 DCHECK(drop_data.file_contents.empty()); |
435 DCHECK(drop_data.file_description_filename.empty()); | 473 DCHECK(drop_data.file_description_filename.empty()); |
436 | 474 |
437 if (!drop_data.text.is_null()) { | 475 if (!drop_data.text.is_null()) { |
438 WebDragData::Item item; | 476 WebDragData::Item item; |
(...skipping 2003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2442 | 2480 |
2443 enabled_bindings_ |= enabled_bindings_flags; | 2481 enabled_bindings_ |= enabled_bindings_flags; |
2444 | 2482 |
2445 // Keep track of the total bindings accumulated in this process. | 2483 // Keep track of the total bindings accumulated in this process. |
2446 RenderProcess::current()->AddBindings(enabled_bindings_flags); | 2484 RenderProcess::current()->AddBindings(enabled_bindings_flags); |
2447 | 2485 |
2448 if (main_render_frame_) | 2486 if (main_render_frame_) |
2449 main_render_frame_->MaybeEnableMojoBindings(); | 2487 main_render_frame_->MaybeEnableMojoBindings(); |
2450 } | 2488 } |
2451 | 2489 |
2452 void RenderViewImpl::OnDragTargetDragEnter(const DropData& drop_data, | 2490 void RenderViewImpl::OnDragTargetDragEnter( |
2453 const gfx::Point& client_point, | 2491 const std::vector<DropData::MetaData>& drop_meta_data, |
2454 const gfx::Point& screen_point, | 2492 const gfx::Point& client_point, |
2455 WebDragOperationsMask ops, | 2493 const gfx::Point& screen_point, |
2456 int key_modifiers) { | 2494 WebDragOperationsMask ops, |
2495 int key_modifiers) { | |
2457 WebDragOperation operation = webview()->dragTargetDragEnter( | 2496 WebDragOperation operation = webview()->dragTargetDragEnter( |
2458 DropDataToWebDragData(drop_data), | 2497 DropMetaDataToWebDragData(drop_meta_data), client_point, screen_point, |
2459 ConvertWindowPointToViewport(client_point), | 2498 ops, key_modifiers); |
2460 screen_point, | |
2461 ops, | |
2462 key_modifiers); | |
2463 | 2499 |
2464 Send(new DragHostMsg_UpdateDragCursor(GetRoutingID(), operation)); | 2500 Send(new DragHostMsg_UpdateDragCursor(GetRoutingID(), operation)); |
2465 } | 2501 } |
2466 | 2502 |
2467 void RenderViewImpl::OnDragTargetDragOver(const gfx::Point& client_point, | 2503 void RenderViewImpl::OnDragTargetDragOver(const gfx::Point& client_point, |
2468 const gfx::Point& screen_point, | 2504 const gfx::Point& screen_point, |
2469 WebDragOperationsMask ops, | 2505 WebDragOperationsMask ops, |
2470 int key_modifiers) { | 2506 int key_modifiers) { |
2471 WebDragOperation operation = webview()->dragTargetDragOver( | 2507 WebDragOperation operation = webview()->dragTargetDragOver( |
2472 ConvertWindowPointToViewport(client_point), | 2508 ConvertWindowPointToViewport(client_point), |
2473 screen_point, | 2509 screen_point, |
2474 ops, | 2510 ops, |
2475 key_modifiers); | 2511 key_modifiers); |
2476 | 2512 |
2477 Send(new DragHostMsg_UpdateDragCursor(GetRoutingID(), operation)); | 2513 Send(new DragHostMsg_UpdateDragCursor(GetRoutingID(), operation)); |
2478 } | 2514 } |
2479 | 2515 |
2480 void RenderViewImpl::OnDragTargetDragLeave() { | 2516 void RenderViewImpl::OnDragTargetDragLeave() { |
2481 webview()->dragTargetDragLeave(); | 2517 webview()->dragTargetDragLeave(); |
2482 } | 2518 } |
2483 | 2519 |
2484 void RenderViewImpl::OnDragTargetDrop(const gfx::Point& client_point, | 2520 void RenderViewImpl::OnDragTargetDrop(const DropData& drop_data, |
2521 const gfx::Point& client_point, | |
2485 const gfx::Point& screen_point, | 2522 const gfx::Point& screen_point, |
2486 int key_modifiers) { | 2523 int key_modifiers) { |
2487 webview()->dragTargetDrop( | 2524 webview()->dragTargetDrop(DropDataToWebDragData(drop_data), client_point, |
2488 ConvertWindowPointToViewport(client_point), screen_point, key_modifiers); | 2525 screen_point, key_modifiers); |
2489 } | 2526 } |
2490 | 2527 |
2491 void RenderViewImpl::OnDragSourceEnded(const gfx::Point& client_point, | 2528 void RenderViewImpl::OnDragSourceEnded(const gfx::Point& client_point, |
2492 const gfx::Point& screen_point, | 2529 const gfx::Point& screen_point, |
2493 WebDragOperation op) { | 2530 WebDragOperation op) { |
2494 webview()->dragSourceEndedAt( | 2531 webview()->dragSourceEndedAt( |
2495 ConvertWindowPointToViewport(client_point), screen_point, op); | 2532 ConvertWindowPointToViewport(client_point), screen_point, op); |
2496 } | 2533 } |
2497 | 2534 |
2498 void RenderViewImpl::OnDragSourceSystemDragEnded() { | 2535 void RenderViewImpl::OnDragSourceSystemDragEnded() { |
(...skipping 925 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3424 if (IsUseZoomForDSFEnabled()) { | 3461 if (IsUseZoomForDSFEnabled()) { |
3425 webview()->setZoomFactorForDeviceScaleFactor(device_scale_factor_); | 3462 webview()->setZoomFactorForDeviceScaleFactor(device_scale_factor_); |
3426 } else { | 3463 } else { |
3427 webview()->setDeviceScaleFactor(device_scale_factor_); | 3464 webview()->setDeviceScaleFactor(device_scale_factor_); |
3428 } | 3465 } |
3429 webview()->settings()->setPreferCompositingToLCDTextEnabled( | 3466 webview()->settings()->setPreferCompositingToLCDTextEnabled( |
3430 PreferCompositingToLCDText(compositor_deps_, device_scale_factor_)); | 3467 PreferCompositingToLCDText(compositor_deps_, device_scale_factor_)); |
3431 } | 3468 } |
3432 | 3469 |
3433 } // namespace content | 3470 } // namespace content |
OLD | NEW |