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

Side by Side Diff: chrome/browser/resources/net_internals/import_view.js

Issue 9596003: [WebUI] Make drag'n'drop future proof. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: doc Created 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/resources/ntp4/apps_page.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 /** 5 /**
6 * This view displays options for importing data from a log file. 6 * This view displays options for importing data from a log file.
7 */ 7 */
8 var ImportView = (function() { 8 var ImportView = (function() {
9 'use strict'; 9 'use strict';
10 10
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 }, 73 },
74 74
75 /** 75 /**
76 * Called when something is dragged over the drop target. 76 * Called when something is dragged over the drop target.
77 * 77 *
78 * Returns false to cancel default browser behavior when a single file is 78 * Returns false to cancel default browser behavior when a single file is
79 * being dragged. When this happens, we may not receive a list of files for 79 * being dragged. When this happens, we may not receive a list of files for
80 * security reasons, which is why we allow the |files| array to be empty. 80 * security reasons, which is why we allow the |files| array to be empty.
81 */ 81 */
82 onDrag: function(event) { 82 onDrag: function(event) {
83 return !event.dataTransfer.types.contains('Files') || 83 // NOTE: Use Array.prototype.indexOf here is necessary while WebKit
84 // decides which type of data structure dataTransfer.types will be
85 // (currently between DOMStringList and Array). These have different APIs
86 // so assuming one type or the other was breaking things. See
87 // http://crbug.com/115433. TODO(dbeam): Remove when standardized more.
88 var indexOf = Array.prototype.indexOf;
89 return indexOf.call(event.dataTransfer.types, 'Files') == -1 ||
84 event.dataTransfer.files.length > 1; 90 event.dataTransfer.files.length > 1;
85 }, 91 },
86 92
87 /** 93 /**
88 * Called when something is dropped onto the drop target. If it's a single 94 * Called when something is dropped onto the drop target. If it's a single
89 * file, tries to load it as a log file. 95 * file, tries to load it as a log file.
90 */ 96 */
91 onDrop: function(event) { 97 onDrop: function(event) {
92 if (!event.dataTransfer.types.contains('Files') || 98 var indexOf = Array.prototype.indexOf;
99 if (indexOf.call(event.dataTransfer.types, 'Files') == -1 ||
93 event.dataTransfer.files.length != 1) { 100 event.dataTransfer.files.length != 1) {
94 return; 101 return;
95 } 102 }
96 event.preventDefault(); 103 event.preventDefault();
97 104
98 // Loading a log file may hide the currently active tab. Switch to the 105 // Loading a log file may hide the currently active tab. Switch to the
99 // import tab to prevent this. 106 // import tab to prevent this.
100 document.location.hash = 'import'; 107 document.location.hash = 'import';
101 108
102 this.loadLogFile(event.dataTransfer.files[0]); 109 this.loadLogFile(event.dataTransfer.files[0]);
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 this.loadedInfoOsType_.innerText = ClientInfo.os_type; 219 this.loadedInfoOsType_.innerText = ClientInfo.os_type;
213 this.loadedInfoCommandLine_.innerText = ClientInfo.command_line; 220 this.loadedInfoCommandLine_.innerText = ClientInfo.command_line;
214 221
215 // User comments will not be available when dumped from command line. 222 // User comments will not be available when dumped from command line.
216 this.loadedInfoUserComments_.innerText = userComments || ''; 223 this.loadedInfoUserComments_.innerText = userComments || '';
217 } 224 }
218 }; 225 };
219 226
220 return ImportView; 227 return ImportView;
221 })(); 228 })();
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/ntp4/apps_page.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698