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

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: Send "meta data" of dropData in DragEnter Created 4 years, 9 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 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 418
419 bool HandleMouseLockedInputEvent(const blink::WebMouseEvent& event) override { 419 bool HandleMouseLockedInputEvent(const blink::WebMouseEvent& event) override {
420 // The WebWidget handles mouse lock in WebKit's handleInputEvent(). 420 // The WebWidget handles mouse lock in WebKit's handleInputEvent().
421 return false; 421 return false;
422 } 422 }
423 423
424 private: 424 private:
425 blink::WebWidget* webwidget_; 425 blink::WebWidget* webwidget_;
426 }; 426 };
427 427
428 WebDragData DropDataToWebDragData(const DropData& drop_data) { 428 WebDragData DropDataToWebDragData(const DropData& drop_data,
429 bool is_meta_data) {
429 std::vector<WebDragData::Item> item_list; 430 std::vector<WebDragData::Item> item_list;
430 431
431 // These fields are currently unused when dragging into WebKit. 432 // These fields are currently unused when dragging into WebKit.
432 DCHECK(drop_data.download_metadata.empty()); 433 DCHECK(drop_data.download_metadata.empty());
433 DCHECK(drop_data.file_contents.empty()); 434 DCHECK(drop_data.file_contents.empty());
434 DCHECK(drop_data.file_description_filename.empty()); 435 DCHECK(drop_data.file_description_filename.empty());
435 436
436 if (!drop_data.text.is_null()) { 437 if (!drop_data.text.is_null()) {
437 WebDragData::Item item; 438 WebDragData::Item item;
438 item.storageType = WebDragData::Item::StorageTypeString; 439 item.storageType = WebDragData::Item::StorageTypeString;
439 item.stringType = WebString::fromUTF8(ui::Clipboard::kMimeTypeText); 440 item.stringType = WebString::fromUTF8(ui::Clipboard::kMimeTypeText);
440 item.stringData = drop_data.text.string(); 441 item.stringData = is_meta_data ? WebString::fromUTF8("")
442 : WebString(drop_data.text.string());
441 item_list.push_back(item); 443 item_list.push_back(item);
442 } 444 }
443 445
444 // TODO(dcheng): Do we need to distinguish between null and empty URLs? Is it 446 // TODO(dcheng): Do we need to distinguish between null and empty URLs? Is it
445 // meaningful to write an empty URL to the clipboard? 447 // meaningful to write an empty URL to the clipboard?
446 if (!drop_data.url.is_empty()) { 448 if (drop_data.has_url) {
447 WebDragData::Item item; 449 WebDragData::Item item;
448 item.storageType = WebDragData::Item::StorageTypeString; 450 item.storageType = WebDragData::Item::StorageTypeString;
449 item.stringType = WebString::fromUTF8(ui::Clipboard::kMimeTypeURIList); 451 item.stringType = WebString::fromUTF8(ui::Clipboard::kMimeTypeURIList);
450 item.stringData = WebString::fromUTF8(drop_data.url.spec()); 452 item.stringData = is_meta_data ? WebString::fromUTF8("")
451 item.title = drop_data.url_title; 453 : WebString::fromUTF8(drop_data.url.spec());
454 item.title =
455 is_meta_data ? WebString::fromUTF8("") : WebString(drop_data.url_title);
452 item_list.push_back(item); 456 item_list.push_back(item);
453 } 457 }
454 458
455 if (!drop_data.html.is_null()) { 459 if (!drop_data.html.is_null()) {
456 WebDragData::Item item; 460 WebDragData::Item item;
457 item.storageType = WebDragData::Item::StorageTypeString; 461 item.storageType = WebDragData::Item::StorageTypeString;
458 item.stringType = WebString::fromUTF8(ui::Clipboard::kMimeTypeHTML); 462 item.stringType = WebString::fromUTF8(ui::Clipboard::kMimeTypeHTML);
459 item.stringData = drop_data.html.string(); 463 item.stringData = is_meta_data ? WebString::fromUTF8("")
460 item.baseURL = drop_data.html_base_url; 464 : WebString(drop_data.html.string());
465 item.baseURL = is_meta_data ? GURL() : drop_data.html_base_url;
461 item_list.push_back(item); 466 item_list.push_back(item);
462 } 467 }
463 468
464 for (std::vector<ui::FileInfo>::const_iterator it = 469 for (std::vector<ui::FileInfo>::const_iterator it =
465 drop_data.filenames.begin(); 470 drop_data.filenames.begin();
466 it != drop_data.filenames.end(); 471 it != drop_data.filenames.end();
467 ++it) { 472 ++it) {
468 WebDragData::Item item; 473 WebDragData::Item item;
469 item.storageType = WebDragData::Item::StorageTypeFilename; 474 item.storageType = WebDragData::Item::StorageTypeFilename;
470 item.filenameData = it->path.AsUTF16Unsafe(); 475 item.filenameData = is_meta_data ? WebString::fromUTF8("")
471 item.displayNameData = it->display_name.AsUTF16Unsafe(); 476 : WebString(it->path.AsUTF16Unsafe());
477 item.displayNameData = is_meta_data
478 ? WebString::fromUTF8("")
479 : WebString(it->display_name.AsUTF16Unsafe());
472 item_list.push_back(item); 480 item_list.push_back(item);
473 } 481 }
474 482
475 for (std::vector<DropData::FileSystemFileInfo>::const_iterator it = 483 for (std::vector<DropData::FileSystemFileInfo>::const_iterator it =
476 drop_data.file_system_files.begin(); 484 drop_data.file_system_files.begin();
477 it != drop_data.file_system_files.end(); 485 it != drop_data.file_system_files.end();
478 ++it) { 486 ++it) {
479 WebDragData::Item item; 487 WebDragData::Item item;
480 item.storageType = WebDragData::Item::StorageTypeFileSystemFile; 488 item.storageType = WebDragData::Item::StorageTypeFileSystemFile;
481 item.fileSystemURL = it->url; 489 item.fileSystemURL = is_meta_data ? GURL() : it->url;
482 item.fileSystemFileSize = it->size; 490 item.fileSystemFileSize = is_meta_data ? 0 : it->size;
483 item_list.push_back(item); 491 item_list.push_back(item);
484 } 492 }
485 493
486 for (std::map<base::string16, base::string16>::const_iterator it = 494 for (std::map<base::string16, base::string16>::const_iterator it =
487 drop_data.custom_data.begin(); 495 drop_data.custom_data.begin();
488 it != drop_data.custom_data.end(); 496 it != drop_data.custom_data.end();
489 ++it) { 497 ++it) {
490 WebDragData::Item item; 498 WebDragData::Item item;
491 item.storageType = WebDragData::Item::StorageTypeString; 499 item.storageType = WebDragData::Item::StorageTypeString;
492 item.stringType = it->first; 500 item.stringType = it->first;
493 item.stringData = it->second; 501 item.stringData =
502 is_meta_data ? WebString::fromUTF8("") : WebString(it->second);
494 item_list.push_back(item); 503 item_list.push_back(item);
495 } 504 }
496 505
497 WebDragData result; 506 WebDragData result;
498 result.initialize(); 507 result.initialize();
499 result.setItems(item_list); 508 result.setItems(item_list);
500 result.setFilesystemId(drop_data.filesystem_id); 509 result.setFilesystemId(drop_data.filesystem_id);
510 result.setCanReadContent(!is_meta_data);
501 return result; 511 return result;
502 } 512 }
503 513
504 typedef void (*SetFontFamilyWrapper)(blink::WebSettings*, 514 typedef void (*SetFontFamilyWrapper)(blink::WebSettings*,
505 const base::string16&, 515 const base::string16&,
506 UScriptCode); 516 UScriptCode);
507 517
508 void SetStandardFontFamilyWrapper(WebSettings* settings, 518 void SetStandardFontFamilyWrapper(WebSettings* settings,
509 const base::string16& font, 519 const base::string16& font,
510 UScriptCode script) { 520 UScriptCode script) {
(...skipping 1894 matching lines...) Expand 10 before | Expand all | Expand 10 after
2405 // Keep track of the total bindings accumulated in this process. 2415 // Keep track of the total bindings accumulated in this process.
2406 RenderProcess::current()->AddBindings(enabled_bindings_flags); 2416 RenderProcess::current()->AddBindings(enabled_bindings_flags);
2407 } 2417 }
2408 2418
2409 void RenderViewImpl::OnDragTargetDragEnter(const DropData& drop_data, 2419 void RenderViewImpl::OnDragTargetDragEnter(const DropData& drop_data,
2410 const gfx::Point& client_point, 2420 const gfx::Point& client_point,
2411 const gfx::Point& screen_point, 2421 const gfx::Point& screen_point,
2412 WebDragOperationsMask ops, 2422 WebDragOperationsMask ops,
2413 int key_modifiers) { 2423 int key_modifiers) {
2414 WebDragOperation operation = webview()->dragTargetDragEnter( 2424 WebDragOperation operation = webview()->dragTargetDragEnter(
2415 DropDataToWebDragData(drop_data), 2425 DropDataToWebDragData(drop_data, true), client_point, screen_point, ops,
2416 client_point,
2417 screen_point,
2418 ops,
2419 key_modifiers); 2426 key_modifiers);
2420 2427
2421 Send(new DragHostMsg_UpdateDragCursor(routing_id(), operation)); 2428 Send(new DragHostMsg_UpdateDragCursor(routing_id(), operation));
2422 } 2429 }
2423 2430
2424 void RenderViewImpl::OnDragTargetDragOver(const gfx::Point& client_point, 2431 void RenderViewImpl::OnDragTargetDragOver(const gfx::Point& client_point,
2425 const gfx::Point& screen_point, 2432 const gfx::Point& screen_point,
2426 WebDragOperationsMask ops, 2433 WebDragOperationsMask ops,
2427 int key_modifiers) { 2434 int key_modifiers) {
2428 WebDragOperation operation = webview()->dragTargetDragOver( 2435 WebDragOperation operation = webview()->dragTargetDragOver(
2429 client_point, 2436 client_point,
2430 screen_point, 2437 screen_point,
2431 ops, 2438 ops,
2432 key_modifiers); 2439 key_modifiers);
2433 2440
2434 Send(new DragHostMsg_UpdateDragCursor(routing_id(), operation)); 2441 Send(new DragHostMsg_UpdateDragCursor(routing_id(), operation));
2435 } 2442 }
2436 2443
2437 void RenderViewImpl::OnDragTargetDragLeave() { 2444 void RenderViewImpl::OnDragTargetDragLeave() {
2438 webview()->dragTargetDragLeave(); 2445 webview()->dragTargetDragLeave();
2439 } 2446 }
2440 2447
2441 void RenderViewImpl::OnDragTargetDrop(const gfx::Point& client_point, 2448 void RenderViewImpl::OnDragTargetDrop(const DropData& drop_data,
2449 const gfx::Point& client_point,
2442 const gfx::Point& screen_point, 2450 const gfx::Point& screen_point,
2443 int key_modifiers) { 2451 int key_modifiers) {
2444 webview()->dragTargetDrop(client_point, screen_point, key_modifiers); 2452 webview()->dragTargetDrop(DropDataToWebDragData(drop_data, false),
2453 client_point, screen_point, key_modifiers);
2445 } 2454 }
2446 2455
2447 void RenderViewImpl::OnDragSourceEnded(const gfx::Point& client_point, 2456 void RenderViewImpl::OnDragSourceEnded(const gfx::Point& client_point,
2448 const gfx::Point& screen_point, 2457 const gfx::Point& screen_point,
2449 WebDragOperation op) { 2458 WebDragOperation op) {
2450 webview()->dragSourceEndedAt(client_point, screen_point, op); 2459 webview()->dragSourceEndedAt(client_point, screen_point, op);
2451 } 2460 }
2452 2461
2453 void RenderViewImpl::OnDragSourceSystemDragEnded() { 2462 void RenderViewImpl::OnDragSourceSystemDragEnded() {
2454 webview()->dragSourceSystemDragEnded(); 2463 webview()->dragSourceSystemDragEnded();
(...skipping 1082 matching lines...) Expand 10 before | Expand all | Expand 10 after
3537 if (IsUseZoomForDSFEnabled()) { 3546 if (IsUseZoomForDSFEnabled()) {
3538 webview()->setZoomFactorForDeviceScaleFactor(device_scale_factor_); 3547 webview()->setZoomFactorForDeviceScaleFactor(device_scale_factor_);
3539 } else { 3548 } else {
3540 webview()->setDeviceScaleFactor(device_scale_factor_); 3549 webview()->setDeviceScaleFactor(device_scale_factor_);
3541 } 3550 }
3542 webview()->settings()->setPreferCompositingToLCDTextEnabled( 3551 webview()->settings()->setPreferCompositingToLCDTextEnabled(
3543 PreferCompositingToLCDText(compositor_deps_, device_scale_factor_)); 3552 PreferCompositingToLCDText(compositor_deps_, device_scale_factor_));
3544 } 3553 }
3545 3554
3546 } // namespace content 3555 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698