| OLD | NEW |
| 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 <include src="../shared/js/cr/ui/drag_wrapper.js"></include> |
| 5 <include src="../uber/uber_utils.js"></include> | 6 <include src="../uber/uber_utils.js"></include> |
| 6 <include src="extension_list.js"></include> | 7 <include src="extension_list.js"></include> |
| 7 <include src="pack_extension_overlay.js"></include> | 8 <include src="pack_extension_overlay.js"></include> |
| 8 | 9 |
| 9 // Used for observing function of the backend datasource for this page by | 10 // Used for observing function of the backend datasource for this page by |
| 10 // tests. | 11 // tests. |
| 11 var webui_responded_ = false; | 12 var webui_responded_ = false; |
| 12 | 13 |
| 13 cr.define('extensions', function() { | 14 cr.define('extensions', function() { |
| 14 var ExtensionsList = options.ExtensionsList; | 15 var ExtensionsList = options.ExtensionsList; |
| 15 | 16 |
| 17 // Implements the DragWrapper handler interface. |
| 18 var dragWrapperHandler = { |
| 19 // @inheritdoc |
| 20 shouldAcceptDrag: function(e) { |
| 21 // We can't access filenames during the 'dragenter' event, so we have to |
| 22 // wait until 'drop' to decide whether to do something with the file or |
| 23 // not. |
| 24 // See: http://www.w3.org/TR/2011/WD-html5-20110113/dnd.html#concept-dnd-p |
| 25 return e.dataTransfer.types.indexOf('Files') > -1; |
| 26 }, |
| 27 // @inheritdoc |
| 28 doDragEnter: function() { |
| 29 chrome.send('startDrag'); |
| 30 ExtensionSettings.showOverlay(null); |
| 31 ExtensionSettings.showOverlay($('dropTargetOverlay')); |
| 32 }, |
| 33 // @inheritdoc |
| 34 doDragLeave: function() { |
| 35 ExtensionSettings.showOverlay(null); |
| 36 chrome.send('stopDrag'); |
| 37 }, |
| 38 // @inheritdoc |
| 39 doDragOver: function(e) { |
| 40 }, |
| 41 // @inheritdoc |
| 42 doDrop: function(e) { |
| 43 // Only process files that look like extensions. Other files should |
| 44 // navigate the browser normally. |
| 45 if (!e.dataTransfer.files.length || |
| 46 !/\.crx$/.test(e.dataTransfer.files[0].name)) { |
| 47 return; |
| 48 } |
| 49 |
| 50 chrome.send('installDroppedFile'); |
| 51 ExtensionSettings.showOverlay(null); |
| 52 e.preventDefault(); |
| 53 } |
| 54 }; |
| 55 |
| 16 /** | 56 /** |
| 17 * ExtensionSettings class | 57 * ExtensionSettings class |
| 18 * @class | 58 * @class |
| 19 */ | 59 */ |
| 20 function ExtensionSettings() {} | 60 function ExtensionSettings() {} |
| 21 | 61 |
| 22 cr.addSingletonGetter(ExtensionSettings); | 62 cr.addSingletonGetter(ExtensionSettings); |
| 23 | 63 |
| 24 ExtensionSettings.prototype = { | 64 ExtensionSettings.prototype = { |
| 25 __proto__: HTMLDivElement.prototype, | 65 __proto__: HTMLDivElement.prototype, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 46 this.handleDevControlsTransitionEnd_.bind(this)); | 86 this.handleDevControlsTransitionEnd_.bind(this)); |
| 47 | 87 |
| 48 // Set up the three dev mode buttons (load unpacked, pack and update). | 88 // Set up the three dev mode buttons (load unpacked, pack and update). |
| 49 $('load-unpacked').addEventListener('click', | 89 $('load-unpacked').addEventListener('click', |
| 50 this.handleLoadUnpackedExtension_.bind(this)); | 90 this.handleLoadUnpackedExtension_.bind(this)); |
| 51 $('pack-extension').addEventListener('click', | 91 $('pack-extension').addEventListener('click', |
| 52 this.handlePackExtension_.bind(this)); | 92 this.handlePackExtension_.bind(this)); |
| 53 $('update-extensions-now').addEventListener('click', | 93 $('update-extensions-now').addEventListener('click', |
| 54 this.handleUpdateExtensionNow_.bind(this)); | 94 this.handleUpdateExtensionNow_.bind(this)); |
| 55 | 95 |
| 96 if (!loadTimeData.getBoolean('offStoreInstallEnabled')) { |
| 97 this.dragWrapper_ = |
| 98 new cr.ui.DragWrapper(document.body, dragWrapperHandler); |
| 99 } |
| 100 |
| 56 var packExtensionOverlay = extensions.PackExtensionOverlay.getInstance(); | 101 var packExtensionOverlay = extensions.PackExtensionOverlay.getInstance(); |
| 57 packExtensionOverlay.initializePage(); | 102 packExtensionOverlay.initializePage(); |
| 103 |
| 104 cr.ui.overlay.setupOverlay($('dropTargetOverlay')); |
| 58 }, | 105 }, |
| 59 | 106 |
| 60 /** | 107 /** |
| 61 * Handles the Load Unpacked Extension button. | 108 * Handles the Load Unpacked Extension button. |
| 62 * @param {Event} e Change event. | 109 * @param {Event} e Change event. |
| 63 * @private | 110 * @private |
| 64 */ | 111 */ |
| 65 handleLoadUnpackedExtension_: function(e) { | 112 handleLoadUnpackedExtension_: function(e) { |
| 66 chrome.send('extensionSettingsLoadUnpackedExtension'); | 113 chrome.send('extensionSettingsLoadUnpackedExtension'); |
| 67 | 114 |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 return { | 289 return { |
| 243 ExtensionSettings: ExtensionSettings | 290 ExtensionSettings: ExtensionSettings |
| 244 }; | 291 }; |
| 245 }); | 292 }); |
| 246 | 293 |
| 247 var ExtensionSettings = extensions.ExtensionSettings; | 294 var ExtensionSettings = extensions.ExtensionSettings; |
| 248 | 295 |
| 249 window.addEventListener('load', function(e) { | 296 window.addEventListener('load', function(e) { |
| 250 ExtensionSettings.getInstance().initialize(); | 297 ExtensionSettings.getInstance().initialize(); |
| 251 }); | 298 }); |
| OLD | NEW |