| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 cr.define('extensions', function() { | 5 cr.define('extensions', function() { |
| 6 'use strict'; | 6 'use strict'; |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * @param {boolean} dragEnabled | 9 * @param {boolean} dragEnabled |
| 10 * @param {!EventTarget} target | 10 * @param {!EventTarget} target |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 // External Extension installation can be disabled globally, e.g. while a | 27 // External Extension installation can be disabled globally, e.g. while a |
| 28 // different overlay is already showing. | 28 // different overlay is already showing. |
| 29 if (!this.dragEnabled) | 29 if (!this.dragEnabled) |
| 30 return false; | 30 return false; |
| 31 | 31 |
| 32 // We can't access filenames during the 'dragenter' event, so we have to | 32 // We can't access filenames during the 'dragenter' event, so we have to |
| 33 // wait until 'drop' to decide whether to do something with the file or | 33 // wait until 'drop' to decide whether to do something with the file or |
| 34 // not. | 34 // not. |
| 35 // See: http://www.w3.org/TR/2011/WD-html5-20110113/dnd.html#concept-dnd-p | 35 // See: http://www.w3.org/TR/2011/WD-html5-20110113/dnd.html#concept-dnd-p |
| 36 return !!e.dataTransfer.types && | 36 return !!e.dataTransfer.types && |
| 37 e.dataTransfer.types.indexOf('Files') > -1; | 37 e.dataTransfer.types.indexOf('Files') > -1; |
| 38 }, | 38 }, |
| 39 | 39 |
| 40 /** @override */ | 40 /** @override */ |
| 41 doDragEnter: function() { | 41 doDragEnter: function() { |
| 42 chrome.send('startDrag'); | 42 chrome.send('startDrag'); |
| 43 this.eventTarget_.dispatchEvent( | 43 this.eventTarget_.dispatchEvent( |
| 44 new CustomEvent('extension-drag-started')); | 44 new CustomEvent('extension-drag-started')); |
| 45 }, | 45 }, |
| 46 | 46 |
| 47 /** @override */ | 47 /** @override */ |
| (...skipping 29 matching lines...) Expand all Loading... |
| 77 /\.(crx|user\.js|zip)$/i.test(e.dataTransfer.files[0].name)) { | 77 /\.(crx|user\.js|zip)$/i.test(e.dataTransfer.files[0].name)) { |
| 78 toSend = 'installDroppedFile'; | 78 toSend = 'installDroppedFile'; |
| 79 } | 79 } |
| 80 | 80 |
| 81 if (toSend) { | 81 if (toSend) { |
| 82 e.preventDefault(); | 82 e.preventDefault(); |
| 83 chrome.send(toSend); | 83 chrome.send(toSend); |
| 84 } | 84 } |
| 85 }, | 85 }, |
| 86 | 86 |
| 87 /** @private */ | 87 /** @private */ |
| 88 fireDragEnded_: function() { | 88 fireDragEnded_: function() { |
| 89 this.eventTarget_.dispatchEvent(new CustomEvent('extension-drag-ended')); | 89 this.eventTarget_.dispatchEvent(new CustomEvent('extension-drag-ended')); |
| 90 } | 90 } |
| 91 }; | 91 }; |
| 92 | 92 |
| 93 return { | 93 return { |
| 94 DragAndDropHandler: DragAndDropHandler, | 94 DragAndDropHandler: DragAndDropHandler, |
| 95 }; | 95 }; |
| 96 }); | 96 }); |
| OLD | NEW |