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

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: address comments 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 if (meta_data_item.kind == DropData::Kind::FILENAME) {
442 WebDragData::Item item;
443 item.storageType = WebDragData::Item::StorageTypeFilename;
444 item.filenameData = meta_data_item.filename.AsUTF16Unsafe();
dcheng 2016/05/10 07:29:09 Do we need to update this to handle the mime-type
hush (inactive) 2016/05/10 21:18:32 We definitely have to. I haven't figured out all t
445 item_list.push_back(item);
446 continue;
447 }
448
449 if (meta_data_item.kind == DropData::Kind::FILESYSTEMFILE) {
450 WebDragData::Item item;
451 item.storageType = WebDragData::Item::StorageTypeFileSystemFile;
452 item.fileSystemURL = meta_data_item.file_system_url;
453 item_list.push_back(item);
454 continue;
455 }
456 }
457
458 WebDragData result;
459 result.initialize();
460 result.setItems(item_list);
461 return result;
462 }
463
429 WebDragData DropDataToWebDragData(const DropData& drop_data) { 464 WebDragData DropDataToWebDragData(const DropData& drop_data) {
430 std::vector<WebDragData::Item> item_list; 465 std::vector<WebDragData::Item> item_list;
431 466
432 // These fields are currently unused when dragging into WebKit. 467 // These fields are currently unused when dragging into WebKit.
433 DCHECK(drop_data.download_metadata.empty()); 468 DCHECK(drop_data.download_metadata.empty());
434 DCHECK(drop_data.file_contents.empty()); 469 DCHECK(drop_data.file_contents.empty());
435 DCHECK(drop_data.file_description_filename.empty()); 470 DCHECK(drop_data.file_description_filename.empty());
436 471
437 if (!drop_data.text.is_null()) { 472 if (!drop_data.text.is_null()) {
438 WebDragData::Item item; 473 WebDragData::Item item;
(...skipping 2003 matching lines...) Expand 10 before | Expand all | Expand 10 after
2442 2477
2443 enabled_bindings_ |= enabled_bindings_flags; 2478 enabled_bindings_ |= enabled_bindings_flags;
2444 2479
2445 // Keep track of the total bindings accumulated in this process. 2480 // Keep track of the total bindings accumulated in this process.
2446 RenderProcess::current()->AddBindings(enabled_bindings_flags); 2481 RenderProcess::current()->AddBindings(enabled_bindings_flags);
2447 2482
2448 if (main_render_frame_) 2483 if (main_render_frame_)
2449 main_render_frame_->MaybeEnableMojoBindings(); 2484 main_render_frame_->MaybeEnableMojoBindings();
2450 } 2485 }
2451 2486
2452 void RenderViewImpl::OnDragTargetDragEnter(const DropData& drop_data, 2487 void RenderViewImpl::OnDragTargetDragEnter(
2453 const gfx::Point& client_point, 2488 const std::vector<DropData::MetaData>& drop_meta_data,
2454 const gfx::Point& screen_point, 2489 const gfx::Point& client_point,
2455 WebDragOperationsMask ops, 2490 const gfx::Point& screen_point,
2456 int key_modifiers) { 2491 WebDragOperationsMask ops,
2492 int key_modifiers) {
2457 WebDragOperation operation = webview()->dragTargetDragEnter( 2493 WebDragOperation operation = webview()->dragTargetDragEnter(
2458 DropDataToWebDragData(drop_data), 2494 DropMetaDataToWebDragData(drop_meta_data), client_point, screen_point,
2459 ConvertWindowPointToViewport(client_point), 2495 ops, key_modifiers);
2460 screen_point,
2461 ops,
2462 key_modifiers);
2463 2496
2464 Send(new DragHostMsg_UpdateDragCursor(GetRoutingID(), operation)); 2497 Send(new DragHostMsg_UpdateDragCursor(GetRoutingID(), operation));
2465 } 2498 }
2466 2499
2467 void RenderViewImpl::OnDragTargetDragOver(const gfx::Point& client_point, 2500 void RenderViewImpl::OnDragTargetDragOver(const gfx::Point& client_point,
2468 const gfx::Point& screen_point, 2501 const gfx::Point& screen_point,
2469 WebDragOperationsMask ops, 2502 WebDragOperationsMask ops,
2470 int key_modifiers) { 2503 int key_modifiers) {
2471 WebDragOperation operation = webview()->dragTargetDragOver( 2504 WebDragOperation operation = webview()->dragTargetDragOver(
2472 ConvertWindowPointToViewport(client_point), 2505 ConvertWindowPointToViewport(client_point),
2473 screen_point, 2506 screen_point,
2474 ops, 2507 ops,
2475 key_modifiers); 2508 key_modifiers);
2476 2509
2477 Send(new DragHostMsg_UpdateDragCursor(GetRoutingID(), operation)); 2510 Send(new DragHostMsg_UpdateDragCursor(GetRoutingID(), operation));
2478 } 2511 }
2479 2512
2480 void RenderViewImpl::OnDragTargetDragLeave() { 2513 void RenderViewImpl::OnDragTargetDragLeave() {
2481 webview()->dragTargetDragLeave(); 2514 webview()->dragTargetDragLeave();
2482 } 2515 }
2483 2516
2484 void RenderViewImpl::OnDragTargetDrop(const gfx::Point& client_point, 2517 void RenderViewImpl::OnDragTargetDrop(const DropData& drop_data,
2518 const gfx::Point& client_point,
2485 const gfx::Point& screen_point, 2519 const gfx::Point& screen_point,
2486 int key_modifiers) { 2520 int key_modifiers) {
2487 webview()->dragTargetDrop( 2521 webview()->dragTargetDrop(DropDataToWebDragData(drop_data), client_point,
2488 ConvertWindowPointToViewport(client_point), screen_point, key_modifiers); 2522 screen_point, key_modifiers);
2489 } 2523 }
2490 2524
2491 void RenderViewImpl::OnDragSourceEnded(const gfx::Point& client_point, 2525 void RenderViewImpl::OnDragSourceEnded(const gfx::Point& client_point,
2492 const gfx::Point& screen_point, 2526 const gfx::Point& screen_point,
2493 WebDragOperation op) { 2527 WebDragOperation op) {
2494 webview()->dragSourceEndedAt( 2528 webview()->dragSourceEndedAt(
2495 ConvertWindowPointToViewport(client_point), screen_point, op); 2529 ConvertWindowPointToViewport(client_point), screen_point, op);
2496 } 2530 }
2497 2531
2498 void RenderViewImpl::OnDragSourceSystemDragEnded() { 2532 void RenderViewImpl::OnDragSourceSystemDragEnded() {
(...skipping 925 matching lines...) Expand 10 before | Expand all | Expand 10 after
3424 if (IsUseZoomForDSFEnabled()) { 3458 if (IsUseZoomForDSFEnabled()) {
3425 webview()->setZoomFactorForDeviceScaleFactor(device_scale_factor_); 3459 webview()->setZoomFactorForDeviceScaleFactor(device_scale_factor_);
3426 } else { 3460 } else {
3427 webview()->setDeviceScaleFactor(device_scale_factor_); 3461 webview()->setDeviceScaleFactor(device_scale_factor_);
3428 } 3462 }
3429 webview()->settings()->setPreferCompositingToLCDTextEnabled( 3463 webview()->settings()->setPreferCompositingToLCDTextEnabled(
3430 PreferCompositingToLCDText(compositor_deps_, device_scale_factor_)); 3464 PreferCompositingToLCDText(compositor_deps_, device_scale_factor_));
3431 } 3465 }
3432 3466
3433 } // namespace content 3467 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698