Commit dee10e09 authored by Eric Lawrence's avatar Eric Lawrence Committed by Commit Bot

Simplify net-internals events viewer

The Events tab of net-internals used overly complicated logic to detect
file drop events. Simplify the logic, maintaining identical behavior.

Change-Id: I9959eeb3815b13eb790763eb1c5a518baf655914
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2473580Reviewed-by: default avatarMatt Menke <mmenke@chromium.org>
Reviewed-by: default avatarEric Roman <eroman@chromium.org>
Commit-Queue: Eric Lawrence [MSFT] <ericlaw@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#817589}
parent 2d71d5dc
......@@ -36,7 +36,7 @@ const EventsView = (function() {
EventsView.TAB_NAME = 'Events';
EventsView.TAB_HASH = '#events';
// IDs for special HTML elements in dns_view.html
// ID for special HTML element in events_view.html
EventsView.MAIN_BOX_ID = 'events-view-tab-content';
cr.addSingletonGetter(EventsView);
......@@ -46,31 +46,21 @@ const EventsView = (function() {
__proto__: superClass.prototype,
/**
* Called when something is dragged over the drop target.
*
* Returns false to cancel default browser behavior when a single file is
* being dragged. When this happens, we may not receive a list of files for
* security reasons, which is why we allow the |files| array to be empty.
* Prevent default browser behavior when a file is dragged over the page to
* allow our onDrop() handler to handle the drop.
*/
onDrag(event) {
// 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.
const indexOf = Array.prototype.indexOf;
return indexOf.call(event.dataTransfer.types, 'Files') == -1 ||
event.dataTransfer.files.length > 1;
if (event.dataTransfer.types.includes('Files')) {
event.preventDefault();
}
},
/**
* Called when something is dropped onto the drop target. If it's a single
* file, redirect to the events tab to show the depreciation message.
* If a single file is dropped, redirect to the events tab to show the
* deprecation message.
*/
onDrop(event) {
const indexOf = Array.prototype.indexOf;
if (indexOf.call(event.dataTransfer.types, 'Files') == -1 ||
event.dataTransfer.files.length != 1) {
if (event.dataTransfer.files.length !== 1) {
return;
}
event.preventDefault();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment