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. |
| 444 if ((meta_data_item.kind == DropData::Kind::FILENAME) && |
| 445 !meta_data_item.filename.empty()) { |
| 446 WebDragData::Item item; |
| 447 item.storageType = WebDragData::Item::StorageTypeFilename; |
| 448 item.filenameData = meta_data_item.filename.AsUTF16Unsafe(); |
| 449 item_list.push_back(item); |
| 450 continue; |
| 451 } |
| 452 |
| 453 if (meta_data_item.kind == DropData::Kind::FILESYSTEMFILE) { |
| 454 WebDragData::Item item; |
| 455 item.storageType = WebDragData::Item::StorageTypeFileSystemFile; |
| 456 item.fileSystemURL = meta_data_item.file_system_url; |
| 457 item_list.push_back(item); |
| 458 continue; |
| 459 } |
| 460 } |
| 461 |
| 462 WebDragData result; |
| 463 result.initialize(); |
| 464 result.setItems(item_list); |
| 465 return result; |
| 466 } |
| 467 |
429 WebDragData DropDataToWebDragData(const DropData& drop_data) { | 468 WebDragData DropDataToWebDragData(const DropData& drop_data) { |
430 std::vector<WebDragData::Item> item_list; | 469 std::vector<WebDragData::Item> item_list; |
431 | 470 |
432 // These fields are currently unused when dragging into WebKit. | 471 // These fields are currently unused when dragging into WebKit. |
433 DCHECK(drop_data.download_metadata.empty()); | 472 DCHECK(drop_data.download_metadata.empty()); |
434 DCHECK(drop_data.file_contents.empty()); | 473 DCHECK(drop_data.file_contents.empty()); |
435 DCHECK(drop_data.file_description_filename.empty()); | 474 DCHECK(drop_data.file_description_filename.empty()); |
436 | 475 |
437 if (!drop_data.text.is_null()) { | 476 if (!drop_data.text.is_null()) { |
438 WebDragData::Item item; | 477 WebDragData::Item item; |
(...skipping 1958 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2397 | 2436 |
2398 enabled_bindings_ |= enabled_bindings_flags; | 2437 enabled_bindings_ |= enabled_bindings_flags; |
2399 | 2438 |
2400 // Keep track of the total bindings accumulated in this process. | 2439 // Keep track of the total bindings accumulated in this process. |
2401 RenderProcess::current()->AddBindings(enabled_bindings_flags); | 2440 RenderProcess::current()->AddBindings(enabled_bindings_flags); |
2402 | 2441 |
2403 if (main_render_frame_) | 2442 if (main_render_frame_) |
2404 main_render_frame_->MaybeEnableMojoBindings(); | 2443 main_render_frame_->MaybeEnableMojoBindings(); |
2405 } | 2444 } |
2406 | 2445 |
2407 void RenderViewImpl::OnDragTargetDragEnter(const DropData& drop_data, | 2446 void RenderViewImpl::OnDragTargetDragEnter( |
2408 const gfx::Point& client_point, | 2447 const std::vector<DropData::Metadata>& drop_meta_data, |
2409 const gfx::Point& screen_point, | 2448 const gfx::Point& client_point, |
2410 WebDragOperationsMask ops, | 2449 const gfx::Point& screen_point, |
2411 int key_modifiers) { | 2450 WebDragOperationsMask ops, |
| 2451 int key_modifiers) { |
2412 WebDragOperation operation = webview()->dragTargetDragEnter( | 2452 WebDragOperation operation = webview()->dragTargetDragEnter( |
2413 DropDataToWebDragData(drop_data), | 2453 DropMetaDataToWebDragData(drop_meta_data), client_point, screen_point, |
2414 ConvertWindowPointToViewport(client_point), | 2454 ops, key_modifiers); |
2415 screen_point, | |
2416 ops, | |
2417 key_modifiers); | |
2418 | 2455 |
2419 Send(new DragHostMsg_UpdateDragCursor(GetRoutingID(), operation)); | 2456 Send(new DragHostMsg_UpdateDragCursor(GetRoutingID(), operation)); |
2420 } | 2457 } |
2421 | 2458 |
2422 void RenderViewImpl::OnDragTargetDragOver(const gfx::Point& client_point, | 2459 void RenderViewImpl::OnDragTargetDragOver(const gfx::Point& client_point, |
2423 const gfx::Point& screen_point, | 2460 const gfx::Point& screen_point, |
2424 WebDragOperationsMask ops, | 2461 WebDragOperationsMask ops, |
2425 int key_modifiers) { | 2462 int key_modifiers) { |
2426 WebDragOperation operation = webview()->dragTargetDragOver( | 2463 WebDragOperation operation = webview()->dragTargetDragOver( |
2427 ConvertWindowPointToViewport(client_point), | 2464 ConvertWindowPointToViewport(client_point), |
2428 screen_point, | 2465 screen_point, |
2429 ops, | 2466 ops, |
2430 key_modifiers); | 2467 key_modifiers); |
2431 | 2468 |
2432 Send(new DragHostMsg_UpdateDragCursor(GetRoutingID(), operation)); | 2469 Send(new DragHostMsg_UpdateDragCursor(GetRoutingID(), operation)); |
2433 } | 2470 } |
2434 | 2471 |
2435 void RenderViewImpl::OnDragTargetDragLeave() { | 2472 void RenderViewImpl::OnDragTargetDragLeave() { |
2436 webview()->dragTargetDragLeave(); | 2473 webview()->dragTargetDragLeave(); |
2437 } | 2474 } |
2438 | 2475 |
2439 void RenderViewImpl::OnDragTargetDrop(const gfx::Point& client_point, | 2476 void RenderViewImpl::OnDragTargetDrop(const DropData& drop_data, |
| 2477 const gfx::Point& client_point, |
2440 const gfx::Point& screen_point, | 2478 const gfx::Point& screen_point, |
2441 int key_modifiers) { | 2479 int key_modifiers) { |
2442 webview()->dragTargetDrop( | 2480 webview()->dragTargetDrop(DropDataToWebDragData(drop_data), client_point, |
2443 ConvertWindowPointToViewport(client_point), screen_point, key_modifiers); | 2481 screen_point, key_modifiers); |
2444 } | 2482 } |
2445 | 2483 |
2446 void RenderViewImpl::OnDragSourceEnded(const gfx::Point& client_point, | 2484 void RenderViewImpl::OnDragSourceEnded(const gfx::Point& client_point, |
2447 const gfx::Point& screen_point, | 2485 const gfx::Point& screen_point, |
2448 WebDragOperation op) { | 2486 WebDragOperation op) { |
2449 webview()->dragSourceEndedAt( | 2487 webview()->dragSourceEndedAt( |
2450 ConvertWindowPointToViewport(client_point), screen_point, op); | 2488 ConvertWindowPointToViewport(client_point), screen_point, op); |
2451 } | 2489 } |
2452 | 2490 |
2453 void RenderViewImpl::OnDragSourceSystemDragEnded() { | 2491 void RenderViewImpl::OnDragSourceSystemDragEnded() { |
(...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3369 return render_frame->focused_pepper_plugin(); | 3407 return render_frame->focused_pepper_plugin(); |
3370 } | 3408 } |
3371 frame = frame->traverseNext(false); | 3409 frame = frame->traverseNext(false); |
3372 } | 3410 } |
3373 | 3411 |
3374 return nullptr; | 3412 return nullptr; |
3375 } | 3413 } |
3376 #endif | 3414 #endif |
3377 | 3415 |
3378 } // namespace content | 3416 } // namespace content |
OLD | NEW |