| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 cr.define('options', function() { | |
| 6 const OptionsPage = options.OptionsPage; | |
| 7 | |
| 8 /** | |
| 9 * PackExtensionOverlay class | |
| 10 * Encapsulated handling of the 'Pack Extension' overlay page. | |
| 11 * @constructor | |
| 12 */ | |
| 13 function PackExtensionOverlay() { | |
| 14 OptionsPage.call(this, 'packExtensionOverlay', | |
| 15 templateData.packExtensionOverlayTabTitle, | |
| 16 'packExtensionOverlay'); | |
| 17 } | |
| 18 | |
| 19 cr.addSingletonGetter(PackExtensionOverlay); | |
| 20 | |
| 21 PackExtensionOverlay.prototype = { | |
| 22 // Inherit PackExtensionOverlay from OptionsPage. | |
| 23 __proto__: OptionsPage.prototype, | |
| 24 | |
| 25 /** | |
| 26 * Initialize the page. | |
| 27 */ | |
| 28 initializePage: function() { | |
| 29 // Call base class implementation to starts preference initialization. | |
| 30 OptionsPage.prototype.initializePage.call(this); | |
| 31 | |
| 32 $('packExtensionDismiss').onclick = function(event) { | |
| 33 OptionsPage.closeOverlay(); | |
| 34 }; | |
| 35 $('packExtensionCommit').onclick = function(event) { | |
| 36 var extensionPath = $('extensionRootDir').value; | |
| 37 var privateKeyPath = $('extensionPrivateKey').value; | |
| 38 chrome.send('pack', [extensionPath, privateKeyPath]); | |
| 39 }; | |
| 40 $('browseExtensionDir').addEventListener('click', | |
| 41 this.handleBrowseExtensionDir_.bind(this)); | |
| 42 $('browsePrivateKey').addEventListener('click', | |
| 43 this.handleBrowsePrivateKey_.bind(this)); | |
| 44 }, | |
| 45 | |
| 46 /** | |
| 47 * Utility function which asks the C++ to show a platform-specific file | |
| 48 * select dialog, and fire |callback| with the |filePath| that resulted. | |
| 49 * |selectType| can be either 'file' or 'folder'. |operation| can be 'load', | |
| 50 * 'packRoot', or 'pem' which are signals to the C++ to do some | |
| 51 * operation-specific configuration. | |
| 52 * @private | |
| 53 */ | |
| 54 showFileDialog_: function(selectType, operation, callback) { | |
| 55 handleFilePathSelected = function(filePath) { | |
| 56 callback(filePath); | |
| 57 handleFilePathSelected = function() {}; | |
| 58 }; | |
| 59 | |
| 60 chrome.send('extensionSettingsSelectFilePath', [selectType, operation]); | |
| 61 }, | |
| 62 | |
| 63 /** | |
| 64 * Handles the showing of the extension directory browser. | |
| 65 * @param {Event} e Change event. | |
| 66 * @private | |
| 67 */ | |
| 68 handleBrowseExtensionDir_: function(e) { | |
| 69 this.showFileDialog_('folder', 'load', function(filePath) { | |
| 70 $('extensionRootDir').value = filePath; | |
| 71 }); | |
| 72 }, | |
| 73 | |
| 74 /** | |
| 75 * Handles the showing of the extension private key file. | |
| 76 * @param {Event} e Change event. | |
| 77 * @private | |
| 78 */ | |
| 79 handleBrowsePrivateKey_: function(e) { | |
| 80 this.showFileDialog_('file', 'load', function(filePath) { | |
| 81 $('extensionPrivateKey').value = filePath; | |
| 82 }); | |
| 83 }, | |
| 84 }; | |
| 85 | |
| 86 // Export | |
| 87 return { | |
| 88 PackExtensionOverlay: PackExtensionOverlay | |
| 89 }; | |
| 90 }); | |
| OLD | NEW |