Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5772)

Unified Diff: chrome/browser/resources/extensions/pack_extension_overlay.js

Issue 958803004: [Extensions] Make chrome://extensions use developerPrivate for packing crxs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/extensions/pack_extension_overlay.js
diff --git a/chrome/browser/resources/extensions/pack_extension_overlay.js b/chrome/browser/resources/extensions/pack_extension_overlay.js
index 186f84102e632463ca50099b89a95438d9c8c4b9..5ab34dbd7f8172acdd5ebbd490c9d48a64642625 100644
--- a/chrome/browser/resources/extensions/pack_extension_overlay.js
+++ b/chrome/browser/resources/extensions/pack_extension_overlay.js
@@ -48,24 +48,24 @@ cr.define('extensions', function() {
handleCommit_: function(e) {
var extensionPath = $('extension-root-dir').value;
var privateKeyPath = $('extension-private-key').value;
- chrome.send('pack', [extensionPath, privateKeyPath, 0]);
+ chrome.developerPrivate.packDirectory(
+ extensionPath, privateKeyPath, 0, this.onPackResponse_.bind(this));
},
/**
* Utility function which asks the C++ to show a platform-specific file
- * select dialog, and fire |callback| with the |filePath| that resulted.
- * |selectType| can be either 'file' or 'folder'. |operation| can be 'load'
- * or 'pem' which are signals to the C++ to do some operation-specific
- * configuration.
+ * select dialog, and set the value property of |node| to the selected path.
+ * @param {SelectType} selectType The type of selection to use.
+ * @param {FileType} fileType The type of file to select.
+ * @param {HTMLInputElement} node The node to set the value of.
* @private
*/
- showFileDialog_: function(selectType, operation, callback) {
- window.handleFilePathSelected = function(filePath) {
- callback(filePath);
- window.handleFilePathSelected = function() {};
- };
-
- chrome.send('packExtensionSelectFilePath', [selectType, operation]);
+ showFileDialog_: function(selectType, fileType, node) {
+ chrome.developerPrivate.choosePath(selectType, fileType, function(path) {
+ // Last error is set if the user canceled the dialog.
+ if (!chrome.runtime.lastError && path)
+ node.value = path;
+ });
},
/**
@@ -74,9 +74,10 @@ cr.define('extensions', function() {
* @private
*/
handleBrowseExtensionDir_: function(e) {
- this.showFileDialog_('folder', 'load', function(filePath) {
- $('extension-root-dir').value = filePath;
- });
+ this.showFileDialog_(
+ 'FOLDER',
+ 'LOAD',
+ /** @type {HTMLInputElement} */ ($('extension-root-dir')));
},
/**
@@ -85,44 +86,75 @@ cr.define('extensions', function() {
* @private
*/
handleBrowsePrivateKey_: function(e) {
- this.showFileDialog_('file', 'pem', function(filePath) {
- $('extension-private-key').value = filePath;
- });
+ this.showFileDialog_(
+ 'FILE',
+ 'PEM',
+ /** @type {HTMLInputElement} */ ($('extension-private-key')));
},
- };
- /**
- * Wrap up the pack process by showing the success |message| and closing
- * the overlay.
- * @param {string} message The message to show to the user.
- */
- PackExtensionOverlay.showSuccessMessage = function(message) {
- alertOverlay.setValues(
- loadTimeData.getString('packExtensionOverlay'),
- message,
- loadTimeData.getString('ok'),
- '',
- function() {
- extensions.ExtensionSettings.showOverlay(null);
- });
- extensions.ExtensionSettings.showOverlay($('alertOverlay'));
- };
+ /**
+ * Handles a response from a packDirectory call.
+ * @param {PackDirectoryResponse} response The response of the pack call.
+ * @private
+ */
+ onPackResponse_: function(response) {
+ /** @type {string} */
+ var alertTitle;
+ /** @type {string} */
+ var alertOk;
+ /** @type {string} */
+ var alertCancel;
+ /** @type {function()} */
+ var alertOkCallback;
+ /** @type {function()} */
+ var alertCancelCallback;
- /**
- * Post an alert overlay showing |message|, and upon acknowledgement, close
- * the alert overlay and return to showing the PackExtensionOverlay.
- * @param {string} message The error message.
- */
- PackExtensionOverlay.showError = function(message) {
- alertOverlay.setValues(
- loadTimeData.getString('packExtensionErrorTitle'),
- message,
- loadTimeData.getString('ok'),
- '',
- function() {
- extensions.ExtensionSettings.showOverlay($('pack-extension-overlay'));
- });
- extensions.ExtensionSettings.showOverlay($('alertOverlay'));
+ var closeAlert = function() {
+ extensions.ExtensionSettings.showOverlay(null);
+ };
+
+ switch (response.status) {
+ case 'SUCCESS':
+ alertTitle = loadTimeData.getString('packExtensionOverlay');
+ alertOk = loadTimeData.getString('ok');
+ alertOkCallback = closeAlert;
+ // No 'Cancel' option.
+ break;
+ case 'WARNING':
+ alertTitle = loadTimeData.getString('packExtensionWarningTitle'),
+ alertOk = loadTimeData.getString('packExtensionProceedAnyway'),
+ alertCancel = loadTimeData.getString('cancel'),
Dan Beam 2015/02/27 22:57:17 , -> ;
Devlin 2015/02/27 23:38:37 Done.
+ alertOkCallback = function() {
+ chrome.developerPrivate.packDirectory(
+ response.item_path,
+ response.pem_path,
+ response.override_flags,
+ this.onPackResponse_.bind(this));
+ closeAlert();
+ }.bind(this);
+ alertCancelCallback = closeAlert;
+ break;
+ case 'ERROR':
+ alertTitle = loadTimeData.getString('packExtensionErrorTitle'),
+ alertOk = loadTimeData.getString('ok'),
Dan Beam 2015/02/27 22:57:17 , -> ;
Devlin 2015/02/27 23:38:38 Done.
+ alertOkCallback = function() {
+ extensions.ExtensionSettings.showOverlay(
+ $('pack-extension-overlay'));
+ };
+ // No 'Cancel' option.
+ break;
+ default:
+ assert(false);
Dan Beam 2015/02/27 22:57:17 assertNotReached(); also maybe return; ?
Devlin 2015/02/27 23:38:38 Done.
+ }
+
+ alertOverlay.setValues(alertTitle,
+ response.message,
+ alertOk,
+ alertCancel,
+ alertOkCallback,
+ alertCancelCallback);
+ extensions.ExtensionSettings.showOverlay($('alertOverlay'));
+ },
};
// Export
« no previous file with comments | « chrome/browser/resources/extensions/extensions.js ('k') | chrome/browser/ui/webui/extensions/extension_settings_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698