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

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: Addressed comments Created 7 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/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..cccd5877a71345ac02e376d515c0737f0a2ac9aa
--- /dev/null
+++ b/chrome/browser/resources/apps_debugger/js/pack_item_overlay.js
@@ -0,0 +1,160 @@
+// 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('appsDevtool', function() {
Dan Beam 2013/02/11 23:44:24 nit: apps_dev_tool or apps_devtool
Gaurav 2013/02/12 19:33:17 Done.
+ /**
+ * PackItemOverlay class
+ * Encapsulated handling of the 'Pack Item' overlay page.
+ * @constructor
+ */
+ function PackItemOverlay() {}
+
+ cr.addSingletonGetter(PackItemOverlay);
+
+ PackItemOverlay.prototype = {
+ /**
+ * Initialize the page.
Dan Beam 2013/02/11 23:44:24 can you add to this comment or simply remove it?
Gaurav 2013/02/12 19:33:17 Done.
+ */
+ 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.
+ * @private
+ */
+ handleDismiss_: function(e) {
+ AppsDevTool.showOverlay(null);
+ },
+
+ /**
+ * Handles a click on the pack button.
+ * @param {Event} e The click event.
+ * @private
+ */
+ handleCommit_: function(e) {
+ var itemPath = $('itemRootDir').value;
+ var privateKeyPath = $('itemPrivateKey').value;
+ chrome.developerPrivate.packDirectory(
+ itemPath, privateKeyPath, 0, this.onCommit_);
+ },
+
+ /**
+ * Handles a commit on the pack request.
+ * @param {string} response Message returned by packing api.
+ * @private
+ */
+ 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;
Dan Beam 2013/02/11 23:44:24 this should be item-root-dir (instead of itemRootD
Gaurav 2013/02/12 19:33:17 Done.
+ });
+ },
+
+ /**
+ * 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;
Dan Beam 2013/02/11 23:44:24 and item-private-key
Gaurav 2013/02/12 19:33:17 Done.
+ });
+ },
+ };
+
+ var hideOverlay = function() {
+ AppsDevTool.showOverlay(null);
Dan Beam 2013/02/11 23:44:24 same as handleDismiss_, combine
Gaurav 2013/02/12 19:33:17 Done.
+ };
+
+ /**
+ * Wrap up the pack process by showing the success |message| and closing
+ * the overlay.
+ * @param {string} message The message to show to the user.
+ */
+ PackItemOverlay.showSuccessMessage = function(response) {
+ alertOverlay.setValues(
+ str('packExtensionOverlay'),
+ response.message,
+ str('ok'),
+ '',
+ hideOverlay,
+ null);
+ AppsDevTool.showOverlay($('alertOverlay'));
Dan Beam 2013/02/11 23:44:24 alert-overlay
Gaurav 2013/02/12 19:33:17 The id "alertOverlay" is declared in a shared file
+ };
+
+ /**
+ * An alert overlay showing |message|, and upon acknowledgement, close
+ * the alert overlay and return to showing the PackItemOverlay.
+ * @param {string} message The message to show to the user.
+ */
+ PackItemOverlay.showError = function(response) {
+ alertOverlay.setValues(
+ str('packExtensionErrorTitle'),
+ response.message /* message returned by the packiing api */,
+ str('ok'),
+ '',
+ function() {
+ AppsDevTool.showOverlay($('packItemOverlay'));
+ },
+ null);
+ AppsDevTool.showOverlay($('alertOverlay'));
+ };
+
+ /**
+ * An alert overlay showing |message| as warning and proceeding after the
+ * user confirms the action.
+ */
+ PackItemOverlay.showWarningMessage = function(response) {
+ var closeAlert = function() {
Dan Beam 2013/02/11 23:44:24 why do you need this? this is the same as just us
Gaurav 2013/02/12 19:33:17 removed On 2013/02/11 23:44:24, Dan Beam wrote:
+ hideOverlay();
+ };
+
+ alertOverlay.setValues(
+ str('packExtensionWarningTitle'),
+ response.message /* message returned by the packing api */,
+ str('packExtensionProceedAnyway'),
+ str('cancel'),
+ function() {
+ chrome.developerPrivate.packDirectory(
+ response.item_path,
+ response.pem_path,
+ response.override_flags,
+ PackItemOverlay.showSuccessMessage);
+ closeAlert();
+ },
+ closeAlert());
Dan Beam 2013/02/11 23:44:24 this should not have calling parens(), have you tr
Gaurav 2013/02/12 19:33:17 Done.
+ AppsDevTool.showOverlay($('alertOverlay'));
+ };
+
+ // Export
+ return {
+ PackItemOverlay: PackItemOverlay,
+ };
+});

Powered by Google App Engine
This is Rietveld 408576698