Chromium Code Reviews| Index: chrome/browser/resources/extensions/extensions.js |
| diff --git a/chrome/browser/resources/extensions/extensions.js b/chrome/browser/resources/extensions/extensions.js |
| index 51f7c80e6ec25f0561af9cc5da90dd9d92df4527..873340ef230d2e6e87e5b2229d2ed9fde9dca35c 100644 |
| --- a/chrome/browser/resources/extensions/extensions.js |
| +++ b/chrome/browser/resources/extensions/extensions.js |
| @@ -2,6 +2,7 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| +<include src="../shared/js/cr/ui/drag_wrapper.js"></include> |
| <include src="../uber/uber_utils.js"></include> |
| <include src="extension_list.js"></include> |
| <include src="pack_extension_overlay.js"></include> |
| @@ -13,6 +14,40 @@ var webui_responded_ = false; |
| cr.define('extensions', function() { |
| var ExtensionsList = options.ExtensionsList; |
| + // Implements the DragWrapper handler interface. |
| + var dragWrapperHandler = { |
| + shouldAcceptDrag: function(e) { |
|
Evan Stade
2012/05/04 19:57:17
the js style checker will probably complain if you
|
| + // We can't access filenames during the 'dragenter' event, so we have to |
| + // wait until 'drop' to decide whether to do something with the file or |
| + // not. |
| + // See: http://www.w3.org/TR/2011/WD-html5-20110113/dnd.html#concept-dnd-p |
| + return e.dataTransfer.types.indexOf('Files') > -1; |
| + }, |
| + doDragEnter: function() { |
| + chrome.send('startDrag'); |
| + ExtensionSettings.showOverlay(null); |
| + ExtensionSettings.showOverlay($('dropTargetOverlay')); |
| + }, |
| + doDragLeave: function() { |
| + ExtensionSettings.showOverlay(null); |
| + chrome.send('stopDrag'); |
| + }, |
| + doDragOver: function(e) { |
| + }, |
| + doDrop: function(e) { |
| + // Only process files that look like extensions. Other files should |
| + // navigate the browser normally. |
| + if (!e.dataTransfer.files.length || |
| + !/\.crx$/.test(e.dataTransfer.files[0].name)) { |
| + return; |
| + } |
| + |
| + chrome.send('installDroppedFile'); |
| + ExtensionSettings.showOverlay(null); |
| + e.preventDefault(); |
| + } |
| + }; |
| + |
| /** |
| * ExtensionSettings class |
| * @class |
| @@ -53,8 +88,15 @@ cr.define('extensions', function() { |
| $('update-extensions-now').addEventListener('click', |
| this.handleUpdateExtensionNow_.bind(this)); |
| + if (!loadTimeData.getBoolean('offStoreInstallEnabled')) { |
| + this.dragWrapper_ = |
| + new cr.ui.DragWrapper(document.body, dragWrapperHandler); |
| + } |
| + |
| var packExtensionOverlay = extensions.PackExtensionOverlay.getInstance(); |
| packExtensionOverlay.initializePage(); |
| + |
| + cr.ui.overlay.setupOverlay($('dropTargetOverlay')); |
| }, |
| /** |