[WebUI] Make drag'n'drop future proof.
TEST=Drag and drop from external sources works on NTP and net-internals. BUG=115433 Review URL: http://codereview.chromium.org/9596003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@125109 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
chrome/browser/resources
@ -80,7 +80,13 @@ var ImportView = (function() {
|
||||
* security reasons, which is why we allow the |files| array to be empty.
|
||||
*/
|
||||
onDrag: function(event) {
|
||||
return !event.dataTransfer.types.contains('Files') ||
|
||||
// NOTE: Use Array.prototype.indexOf here is necessary while WebKit
|
||||
// decides which type of data structure dataTransfer.types will be
|
||||
// (currently between DOMStringList and Array). These have different APIs
|
||||
// so assuming one type or the other was breaking things. See
|
||||
// http://crbug.com/115433. TODO(dbeam): Remove when standardized more.
|
||||
var indexOf = Array.prototype.indexOf;
|
||||
return indexOf.call(event.dataTransfer.types, 'Files') == -1 ||
|
||||
event.dataTransfer.files.length > 1;
|
||||
},
|
||||
|
||||
@ -89,7 +95,8 @@ var ImportView = (function() {
|
||||
* file, tries to load it as a log file.
|
||||
*/
|
||||
onDrop: function(event) {
|
||||
if (!event.dataTransfer.types.contains('Files') ||
|
||||
var indexOf = Array.prototype.indexOf;
|
||||
if (indexOf.call(event.dataTransfer.types, 'Files') == -1 ||
|
||||
event.dataTransfer.files.length != 1) {
|
||||
return;
|
||||
}
|
||||
|
@ -790,8 +790,12 @@ cr.define('ntp', function() {
|
||||
|
||||
/** @inheritDoc */
|
||||
shouldAcceptDrag: function(e) {
|
||||
return !!ntp.getCurrentlyDraggingTile() ||
|
||||
(e.dataTransfer && e.dataTransfer.types.contains('text/uri-list'));
|
||||
if (ntp.getCurrentlyDraggingTile())
|
||||
return true;
|
||||
if (!e.dataTransfer || !e.dataTransfer.types)
|
||||
return false;
|
||||
return Array.prototype.indexOf.call(e.dataTransfer.types,
|
||||
'text/uri-list') != -1;
|
||||
},
|
||||
|
||||
/** @inheritDoc */
|
||||
|
Reference in New Issue
Block a user