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; |
439 item.storageType = WebDragData::Item::StorageTypeString; | 478 item.storageType = WebDragData::Item::StorageTypeString; |
440 item.stringType = WebString::fromUTF8(ui::Clipboard::kMimeTypeText); | 479 item.stringType = WebString::fromUTF8(ui::Clipboard::kMimeTypeText); |
441 item.stringData = drop_data.text.string(); | 480 item.stringData = drop_data.text.string(); |
442 item_list.push_back(item); | 481 item_list.push_back(item); |
443 } | 482 } |
444 | 483 |
445 // TODO(dcheng): Do we need to distinguish between null and empty URLs? Is it | 484 if (drop_data.has_url) { |
446 // meaningful to write an empty URL to the clipboard? | |
447 if (!drop_data.url.is_empty()) { | |
448 WebDragData::Item item; | 485 WebDragData::Item item; |
449 item.storageType = WebDragData::Item::StorageTypeString; | 486 item.storageType = WebDragData::Item::StorageTypeString; |
450 item.stringType = WebString::fromUTF8(ui::Clipboard::kMimeTypeURIList); | 487 item.stringType = WebString::fromUTF8(ui::Clipboard::kMimeTypeURIList); |
451 item.stringData = WebString::fromUTF8(drop_data.url.spec()); | 488 item.stringData = WebString::fromUTF8(drop_data.url.spec()); |
452 item.title = drop_data.url_title; | 489 item.title = drop_data.url_title; |
453 item_list.push_back(item); | 490 item_list.push_back(item); |
454 } | 491 } |
455 | 492 |
456 if (!drop_data.html.is_null()) { | 493 if (!drop_data.html.is_null()) { |
457 WebDragData::Item item; | 494 WebDragData::Item item; |
(...skipping 1956 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2414 | 2451 |
2415 enabled_bindings_ |= enabled_bindings_flags; | 2452 enabled_bindings_ |= enabled_bindings_flags; |
2416 | 2453 |
2417 // Keep track of the total bindings accumulated in this process. | 2454 // Keep track of the total bindings accumulated in this process. |
2418 RenderProcess::current()->AddBindings(enabled_bindings_flags); | 2455 RenderProcess::current()->AddBindings(enabled_bindings_flags); |
2419 | 2456 |
2420 if (main_render_frame_) | 2457 if (main_render_frame_) |
2421 main_render_frame_->MaybeEnableMojoBindings(); | 2458 main_render_frame_->MaybeEnableMojoBindings(); |
2422 } | 2459 } |
2423 | 2460 |
2424 void RenderViewImpl::OnDragTargetDragEnter(const DropData& drop_data, | 2461 void RenderViewImpl::OnDragTargetDragEnter( |
2425 const gfx::Point& client_point, | 2462 const std::vector<DropData::Metadata>& drop_meta_data, |
2426 const gfx::Point& screen_point, | 2463 const gfx::Point& client_point, |
2427 WebDragOperationsMask ops, | 2464 const gfx::Point& screen_point, |
2428 int key_modifiers) { | 2465 WebDragOperationsMask ops, |
| 2466 int key_modifiers) { |
2429 WebDragOperation operation = webview()->dragTargetDragEnter( | 2467 WebDragOperation operation = webview()->dragTargetDragEnter( |
2430 DropDataToWebDragData(drop_data), | 2468 DropMetaDataToWebDragData(drop_meta_data), client_point, screen_point, |
2431 ConvertWindowPointToViewport(client_point), | 2469 ops, key_modifiers); |
2432 screen_point, | |
2433 ops, | |
2434 key_modifiers); | |
2435 | 2470 |
2436 Send(new DragHostMsg_UpdateDragCursor(GetRoutingID(), operation)); | 2471 Send(new DragHostMsg_UpdateDragCursor(GetRoutingID(), operation)); |
2437 } | 2472 } |
2438 | 2473 |
2439 void RenderViewImpl::OnDragTargetDragOver(const gfx::Point& client_point, | 2474 void RenderViewImpl::OnDragTargetDragOver(const gfx::Point& client_point, |
2440 const gfx::Point& screen_point, | 2475 const gfx::Point& screen_point, |
2441 WebDragOperationsMask ops, | 2476 WebDragOperationsMask ops, |
2442 int key_modifiers) { | 2477 int key_modifiers) { |
2443 WebDragOperation operation = webview()->dragTargetDragOver( | 2478 WebDragOperation operation = webview()->dragTargetDragOver( |
2444 ConvertWindowPointToViewport(client_point), | 2479 ConvertWindowPointToViewport(client_point), |
2445 screen_point, | 2480 screen_point, |
2446 ops, | 2481 ops, |
2447 key_modifiers); | 2482 key_modifiers); |
2448 | 2483 |
2449 Send(new DragHostMsg_UpdateDragCursor(GetRoutingID(), operation)); | 2484 Send(new DragHostMsg_UpdateDragCursor(GetRoutingID(), operation)); |
2450 } | 2485 } |
2451 | 2486 |
2452 void RenderViewImpl::OnDragTargetDragLeave() { | 2487 void RenderViewImpl::OnDragTargetDragLeave() { |
2453 webview()->dragTargetDragLeave(); | 2488 webview()->dragTargetDragLeave(); |
2454 } | 2489 } |
2455 | 2490 |
2456 void RenderViewImpl::OnDragTargetDrop(const gfx::Point& client_point, | 2491 void RenderViewImpl::OnDragTargetDrop(const DropData& drop_data, |
| 2492 const gfx::Point& client_point, |
2457 const gfx::Point& screen_point, | 2493 const gfx::Point& screen_point, |
2458 int key_modifiers) { | 2494 int key_modifiers) { |
2459 webview()->dragTargetDrop( | 2495 webview()->dragTargetDrop(DropDataToWebDragData(drop_data), client_point, |
2460 ConvertWindowPointToViewport(client_point), screen_point, key_modifiers); | 2496 screen_point, key_modifiers); |
2461 } | 2497 } |
2462 | 2498 |
2463 void RenderViewImpl::OnDragSourceEnded(const gfx::Point& client_point, | 2499 void RenderViewImpl::OnDragSourceEnded(const gfx::Point& client_point, |
2464 const gfx::Point& screen_point, | 2500 const gfx::Point& screen_point, |
2465 WebDragOperation op) { | 2501 WebDragOperation op) { |
2466 webview()->dragSourceEndedAt( | 2502 webview()->dragSourceEndedAt( |
2467 ConvertWindowPointToViewport(client_point), screen_point, op); | 2503 ConvertWindowPointToViewport(client_point), screen_point, op); |
2468 } | 2504 } |
2469 | 2505 |
2470 void RenderViewImpl::OnDragSourceSystemDragEnded() { | 2506 void RenderViewImpl::OnDragSourceSystemDragEnded() { |
(...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3386 return render_frame->focused_pepper_plugin(); | 3422 return render_frame->focused_pepper_plugin(); |
3387 } | 3423 } |
3388 frame = frame->traverseNext(false); | 3424 frame = frame->traverseNext(false); |
3389 } | 3425 } |
3390 | 3426 |
3391 return nullptr; | 3427 return nullptr; |
3392 } | 3428 } |
3393 #endif | 3429 #endif |
3394 | 3430 |
3395 } // namespace content | 3431 } // namespace content |
OLD | NEW |