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

Side by Side Diff: content/renderer/render_view_impl.cc

Issue 1723763002: Add WebDragData to blink::WebView::dragtargetDrop (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix compile on aura Created 4 years, 7 months 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/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
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 2003 matching lines...) Expand 10 before | Expand all | Expand 10 after
2442 2481
2443 enabled_bindings_ |= enabled_bindings_flags; 2482 enabled_bindings_ |= enabled_bindings_flags;
2444 2483
2445 // Keep track of the total bindings accumulated in this process. 2484 // Keep track of the total bindings accumulated in this process.
2446 RenderProcess::current()->AddBindings(enabled_bindings_flags); 2485 RenderProcess::current()->AddBindings(enabled_bindings_flags);
2447 2486
2448 if (main_render_frame_) 2487 if (main_render_frame_)
2449 main_render_frame_->MaybeEnableMojoBindings(); 2488 main_render_frame_->MaybeEnableMojoBindings();
2450 } 2489 }
2451 2490
2452 void RenderViewImpl::OnDragTargetDragEnter(const DropData& drop_data, 2491 void RenderViewImpl::OnDragTargetDragEnter(
2453 const gfx::Point& client_point, 2492 const std::vector<DropData::MetaData>& drop_meta_data,
2454 const gfx::Point& screen_point, 2493 const gfx::Point& client_point,
2455 WebDragOperationsMask ops, 2494 const gfx::Point& screen_point,
2456 int key_modifiers) { 2495 WebDragOperationsMask ops,
2496 int key_modifiers) {
2457 WebDragOperation operation = webview()->dragTargetDragEnter( 2497 WebDragOperation operation = webview()->dragTargetDragEnter(
2458 DropDataToWebDragData(drop_data), 2498 DropMetaDataToWebDragData(drop_meta_data), client_point, screen_point,
2459 ConvertWindowPointToViewport(client_point), 2499 ops, key_modifiers);
2460 screen_point,
2461 ops,
2462 key_modifiers);
2463 2500
2464 Send(new DragHostMsg_UpdateDragCursor(GetRoutingID(), operation)); 2501 Send(new DragHostMsg_UpdateDragCursor(GetRoutingID(), operation));
2465 } 2502 }
2466 2503
2467 void RenderViewImpl::OnDragTargetDragOver(const gfx::Point& client_point, 2504 void RenderViewImpl::OnDragTargetDragOver(const gfx::Point& client_point,
2468 const gfx::Point& screen_point, 2505 const gfx::Point& screen_point,
2469 WebDragOperationsMask ops, 2506 WebDragOperationsMask ops,
2470 int key_modifiers) { 2507 int key_modifiers) {
2471 WebDragOperation operation = webview()->dragTargetDragOver( 2508 WebDragOperation operation = webview()->dragTargetDragOver(
2472 ConvertWindowPointToViewport(client_point), 2509 ConvertWindowPointToViewport(client_point),
2473 screen_point, 2510 screen_point,
2474 ops, 2511 ops,
2475 key_modifiers); 2512 key_modifiers);
2476 2513
2477 Send(new DragHostMsg_UpdateDragCursor(GetRoutingID(), operation)); 2514 Send(new DragHostMsg_UpdateDragCursor(GetRoutingID(), operation));
2478 } 2515 }
2479 2516
2480 void RenderViewImpl::OnDragTargetDragLeave() { 2517 void RenderViewImpl::OnDragTargetDragLeave() {
2481 webview()->dragTargetDragLeave(); 2518 webview()->dragTargetDragLeave();
2482 } 2519 }
2483 2520
2484 void RenderViewImpl::OnDragTargetDrop(const gfx::Point& client_point, 2521 void RenderViewImpl::OnDragTargetDrop(const DropData& drop_data,
2522 const gfx::Point& client_point,
2485 const gfx::Point& screen_point, 2523 const gfx::Point& screen_point,
2486 int key_modifiers) { 2524 int key_modifiers) {
2487 webview()->dragTargetDrop( 2525 webview()->dragTargetDrop(DropDataToWebDragData(drop_data), client_point,
2488 ConvertWindowPointToViewport(client_point), screen_point, key_modifiers); 2526 screen_point, key_modifiers);
2489 } 2527 }
2490 2528
2491 void RenderViewImpl::OnDragSourceEnded(const gfx::Point& client_point, 2529 void RenderViewImpl::OnDragSourceEnded(const gfx::Point& client_point,
2492 const gfx::Point& screen_point, 2530 const gfx::Point& screen_point,
2493 WebDragOperation op) { 2531 WebDragOperation op) {
2494 webview()->dragSourceEndedAt( 2532 webview()->dragSourceEndedAt(
2495 ConvertWindowPointToViewport(client_point), screen_point, op); 2533 ConvertWindowPointToViewport(client_point), screen_point, op);
2496 } 2534 }
2497 2535
2498 void RenderViewImpl::OnDragSourceSystemDragEnded() { 2536 void RenderViewImpl::OnDragSourceSystemDragEnded() {
(...skipping 925 matching lines...) Expand 10 before | Expand all | Expand 10 after
3424 if (IsUseZoomForDSFEnabled()) { 3462 if (IsUseZoomForDSFEnabled()) {
3425 webview()->setZoomFactorForDeviceScaleFactor(device_scale_factor_); 3463 webview()->setZoomFactorForDeviceScaleFactor(device_scale_factor_);
3426 } else { 3464 } else {
3427 webview()->setDeviceScaleFactor(device_scale_factor_); 3465 webview()->setDeviceScaleFactor(device_scale_factor_);
3428 } 3466 }
3429 webview()->settings()->setPreferCompositingToLCDTextEnabled( 3467 webview()->settings()->setPreferCompositingToLCDTextEnabled(
3430 PreferCompositingToLCDText(compositor_deps_, device_scale_factor_)); 3468 PreferCompositingToLCDText(compositor_deps_, device_scale_factor_));
3431 } 3469 }
3432 3470
3433 } // namespace content 3471 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698