Chromium Code Reviews| 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 shouldAcceptDrag: function(e) { | |
|
Evan Stade
2012/05/04 19:57:17
the js style checker will probably complain if you
| |
| 20 // We can't access filenames during the 'dragenter' event, so we have to | |
| 21 // wait until 'drop' to decide whether to do something with the file or | |
| 22 // not. | |
| 23 // See: http://www.w3.org/TR/2011/WD-html5-20110113/dnd.html#concept-dnd-p | |
| 24 return e.dataTransfer.types.indexOf('Files') > -1; | |
| 25 }, | |
| 26 doDragEnter: function() { | |
| 27 chrome.send('startDrag'); | |
| 28 ExtensionSettings.showOverlay(null); | |
| 29 ExtensionSettings.showOverlay($('dropTargetOverlay')); | |
| 30 }, | |
| 31 doDragLeave: function() { | |
| 32 ExtensionSettings.showOverlay(null); | |
| 33 chrome.send('stopDrag'); | |
| 34 }, | |
| 35 doDragOver: function(e) { | |
| 36 }, | |
| 37 doDrop: function(e) { | |
| 38 // Only process files that look like extensions. Other files should | |
| 39 // navigate the browser normally. | |
| 40 if (!e.dataTransfer.files.length || | |
| 41 !/\.crx$/.test(e.dataTransfer.files[0].name)) { | |
| 42 return; | |
| 43 } | |
| 44 | |
| 45 chrome.send('installDroppedFile'); | |
| 46 ExtensionSettings.showOverlay(null); | |
| 47 e.preventDefault(); | |
| 48 } | |
| 49 }; | |
| 50 | |
| 16 /** | 51 /** |
| 17 * ExtensionSettings class | 52 * ExtensionSettings class |
| 18 * @class | 53 * @class |
| 19 */ | 54 */ |
| 20 function ExtensionSettings() {} | 55 function ExtensionSettings() {} |
| 21 | 56 |
| 22 cr.addSingletonGetter(ExtensionSettings); | 57 cr.addSingletonGetter(ExtensionSettings); |
| 23 | 58 |
| 24 ExtensionSettings.prototype = { | 59 ExtensionSettings.prototype = { |
| 25 __proto__: HTMLDivElement.prototype, | 60 __proto__: HTMLDivElement.prototype, |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 46 this.handleDevControlsTransitionEnd_.bind(this)); | 81 this.handleDevControlsTransitionEnd_.bind(this)); |
| 47 | 82 |
| 48 // Set up the three dev mode buttons (load unpacked, pack and update). | 83 // Set up the three dev mode buttons (load unpacked, pack and update). |
| 49 $('load-unpacked').addEventListener('click', | 84 $('load-unpacked').addEventListener('click', |
| 50 this.handleLoadUnpackedExtension_.bind(this)); | 85 this.handleLoadUnpackedExtension_.bind(this)); |
| 51 $('pack-extension').addEventListener('click', | 86 $('pack-extension').addEventListener('click', |
| 52 this.handlePackExtension_.bind(this)); | 87 this.handlePackExtension_.bind(this)); |
| 53 $('update-extensions-now').addEventListener('click', | 88 $('update-extensions-now').addEventListener('click', |
| 54 this.handleUpdateExtensionNow_.bind(this)); | 89 this.handleUpdateExtensionNow_.bind(this)); |
| 55 | 90 |
| 91 if (!loadTimeData.getBoolean('offStoreInstallEnabled')) { | |
| 92 this.dragWrapper_ = | |
| 93 new cr.ui.DragWrapper(document.body, dragWrapperHandler); | |
| 94 } | |
| 95 | |
| 56 var packExtensionOverlay = extensions.PackExtensionOverlay.getInstance(); | 96 var packExtensionOverlay = extensions.PackExtensionOverlay.getInstance(); |
| 57 packExtensionOverlay.initializePage(); | 97 packExtensionOverlay.initializePage(); |
| 98 | |
| 99 cr.ui.overlay.setupOverlay($('dropTargetOverlay')); | |
| 58 }, | 100 }, |
| 59 | 101 |
| 60 /** | 102 /** |
| 61 * Handles the Load Unpacked Extension button. | 103 * Handles the Load Unpacked Extension button. |
| 62 * @param {Event} e Change event. | 104 * @param {Event} e Change event. |
| 63 * @private | 105 * @private |
| 64 */ | 106 */ |
| 65 handleLoadUnpackedExtension_: function(e) { | 107 handleLoadUnpackedExtension_: function(e) { |
| 66 chrome.send('extensionSettingsLoadUnpackedExtension'); | 108 chrome.send('extensionSettingsLoadUnpackedExtension'); |
| 67 | 109 |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 242 return { | 284 return { |
| 243 ExtensionSettings: ExtensionSettings | 285 ExtensionSettings: ExtensionSettings |
| 244 }; | 286 }; |
| 245 }); | 287 }); |
| 246 | 288 |
| 247 var ExtensionSettings = extensions.ExtensionSettings; | 289 var ExtensionSettings = extensions.ExtensionSettings; |
| 248 | 290 |
| 249 window.addEventListener('load', function(e) { | 291 window.addEventListener('load', function(e) { |
| 250 ExtensionSettings.getInstance().initialize(); | 292 ExtensionSettings.getInstance().initialize(); |
| 251 }); | 293 }); |
| OLD | NEW |