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

Unified Diff: chrome/browser/resources/apps_debugger/js/pack_item_overlay.js

Issue 11794034: Adds functionality to pack an extension / app from the app. (Closed) Base URL: http://git.chromium.org/chromium/src.git@bacha_lo
Patch Set: . Created 7 years, 11 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/apps_debugger/js/pack_item_overlay.js
diff --git a/chrome/browser/resources/apps_debugger/js/pack_item_overlay.js b/chrome/browser/resources/apps_debugger/js/pack_item_overlay.js
new file mode 100644
index 0000000000000000000000000000000000000000..1438e3f676fdd3b136284ac50391b4b617d62bdd
--- /dev/null
+++ b/chrome/browser/resources/apps_debugger/js/pack_item_overlay.js
@@ -0,0 +1,151 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+cr.define('extensions', function() {
+ /**
+ * PackItemOverlay class
+ * Encapsulated handling of the 'Pack Item' overlay page.
+ * @constructor
+ */
+ function PackItemOverlay() {
Dan Beam 2013/02/07 01:54:44 nit: don't think you need this \n
Gaurav 2013/02/08 04:39:19 Done.
+ }
+
+ cr.addSingletonGetter(PackItemOverlay);
+
+ PackItemOverlay.prototype = {
+ /**
+ * Initialize the page.
+ */
+ initializePage: function() {
+ var overlay = $('overlay');
+ cr.ui.overlay.setupOverlay(overlay);
+ overlay.addEventListener('cancelOverlay', this.handleDismiss_.bind(this));
+
+ $('packItemDismiss').addEventListener('click',
+ this.handleDismiss_.bind(this));
+ $('packItemCommit').addEventListener('click',
+ this.handleCommit_.bind(this));
+ $('browseItemDir').addEventListener('click',
+ this.handleBrowseItemDir_.bind(this));
+ $('browsePrivateKey').addEventListener('click',
+ this.handleBrowsePrivateKey_.bind(this));
+ },
+
+ /**
+ * Handles a click on the dismiss button.
+ * @param {Event} e The click event.
Dan Beam 2013/02/07 01:54:44 @private
Gaurav 2013/02/08 04:39:19 Done.
+ */
+ handleDismiss_: function(e) {
+ AppsDebugger.showOverlay(null);
+ },
+
+ /**
+ * Handles a click on the pack button.
+ * @param {Event} e The click event.
Dan Beam 2013/02/07 01:54:44 @private
Gaurav 2013/02/08 04:39:19 Done.
+ */
+ handleCommit_: function(e) {
+ var itemPath = $('itemRootDir').value;
+ var privateKeyPath = $('itemPrivateKey').value;
+ chrome.developerPrivate.packDirectory(
+ itemPath, privateKeyPath, 0, this.onCommit_);
+ },
+
Dan Beam 2013/02/07 01:54:44 nit: jsdoc
Gaurav 2013/02/08 04:39:19 Done.
Gaurav 2013/02/08 04:39:19 Done.
+ onCommit_: function(response) {
+ if (response.status == 'SUCCESS')
+ PackItemOverlay.showSuccessMessage(response);
+ else if (response.status == 'ERROR')
+ PackItemOverlay.showError(response);
+ else
+ PackItemOverlay.showWarningMessage(response);
+ },
+
+ /**
+ * Handles the showing of the item directory browser.
+ * @param {Event} e Change event.
+ * @private
+ */
+ handleBrowseItemDir_: function(e) {
+ chrome.developerPrivate.choosePath('FOLDER', 'LOAD', function(filePath) {
+ $('itemRootDir').value = filePath;
+ });
+ },
+
+ /**
+ * Handles the showing of the item private key file.
+ * @param {Event} e Change event.
+ * @private
+ */
+ handleBrowsePrivateKey_: function(e) {
+ chrome.developerPrivate.choosePath('FILE', 'PEM', function(filePath) {
+ $('itemPrivateKey').value = filePath;
+ });
+ },
+ };
+
+ /**
+ * Wrap up the pack process by showing the success |message| and closing
+ * the overlay.
+ * @param {String} message The message to show to the user.
Dan Beam 2013/02/07 01:54:44 nit: @param {string}
Gaurav 2013/02/08 04:39:19 Done.
+ */
+ PackItemOverlay.showSuccessMessage = function(response) {
+ alertOverlay.setValues(
Dan Beam 2013/02/07 01:54:44 nit: this is a little scary looking, can you do on
Gaurav 2013/02/08 04:39:19 Done.
+ str('packExtensionOverlay'),
+ response.message,
+ str('ok'),
+ '',
+ function() {
+ AppsDebugger.showOverlay(null);
+ },
+ null);
+ AppsDebugger.showOverlay($('alertOverlay'));
+ };
+
+ /**
+ * An alert overlay showing |message|, and upon acknowledgement, close
+ * the alert overlay and return to showing the PackItemOverlay.
Dan Beam 2013/02/07 01:54:44 nit: missing @param
Gaurav 2013/02/08 04:39:19 Done.
+ */
+ PackItemOverlay.showError = function(response) {
+ alertOverlay.setValues(
+ str('packExtensionErrorTitle'),
+ response.message,
+ str('ok'),
+ '',
+ function() {
+ AppsDebugger.showOverlay($('packItemOverlay'));
+ },
+ null);
+ AppsDebugger.showOverlay($('alertOverlay'));
+ };
+
+ /**
+ * An alert overlay showing |message| as warning and proceeding after the
+ * user confirms the action.
Dan Beam 2013/02/07 01:54:44 nit: missing @param
+ */
+ PackItemOverlay.showWarningMessage = function(response) {
+ var closeAlert = function() {
+ AppsDebugger.showOverlay(null);
Dan Beam 2013/02/07 01:54:44 nit: can you make a central function and re-use it
Gaurav 2013/02/08 04:39:19 Done.
+ };
+
+ alertOverlay.setValues(
+ str('packExtensionWarningTitle'),
+ response.message,
+ str('packExtensionProceedAnyway'),
+ str('cancel'),
+ function() {
+ chrome.developerPrivate.packDirectory(
+ response.item_path,
+ response.pem_path,
+ response.override_flags,
+ PackItemOverlay.showSuccessMessage);
+ closeAlert();
+ },
+ closeAlert());
+ AppsDebugger.showOverlay($('alertOverlay'));
+ };
+
+ // Export
+ return {
+ PackItemOverlay: PackItemOverlay
Dan Beam 2013/02/07 01:54:44 opt nit: I prefer , at the end
Gaurav 2013/02/08 04:39:19 Done.
+ };
+});

Powered by Google App Engine
This is Rietveld 408576698