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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 cr.define('extensions', function() {
6 /**
7 * PackItemOverlay class
8 * Encapsulated handling of the 'Pack Item' overlay page.
9 * @constructor
10 */
11 function PackItemOverlay() {
12 }
13
14 cr.addSingletonGetter(PackItemOverlay);
15
16 PackItemOverlay.prototype = {
17 /**
18 * Initialize the page.
19 */
20 initializePage: function() {
21 var overlay = $('overlay');
22 cr.ui.overlay.setupOverlay(overlay);
23 overlay.addEventListener('cancelOverlay', this.handleDismiss_.bind(this));
24
25 $('packItemDismiss').addEventListener('click',
26 this.handleDismiss_.bind(this));
27 $('packItemCommit').addEventListener('click',
28 this.handleCommit_.bind(this));
29 $('browseItemDir').addEventListener('click',
30 this.handleBrowseItemDir_.bind(this));
31 $('browsePrivateKey').addEventListener('click',
32 this.handleBrowsePrivateKey_.bind(this));
33 },
34
35 /**
36 * Handles a click on the dismiss button.
37 * @param {Event} e The click event.
38 */
39 handleDismiss_: function(e) {
40 AppsDebugger.showOverlay(null);
41 },
42
43 /**
44 * Handles a click on the pack button.
45 * @param {Event} e The click event.
46 */
47 handleCommit_: function(e) {
48 var itemPath = $('itemRootDir').value;
49 var privateKeyPath = $('itemPrivateKey').value;
50 chrome.developerPrivate.packItem(
51 itemPath, privateKeyPath, 0, this.onCommit_);
52 },
53
54 onCommit_: function(response) {
55 if (response.status == 'SUCCESS') {
56 PackItemOverlay.showSuccessMessage(response);
57 } else if (response.status == 'ERROR') {
miket_OOO 2013/01/09 18:52:41 Braces optional here
Gaurav 2013/01/12 01:08:26 Done.
58 PackItemOverlay.showError(response);
59 } else {
60 PackItemOverlay.showWarningMessage(response);
61 }
62 },
63
64 /**
65 * Handles the showing of the item directory browser.
66 * @param {Event} e Change event.
67 * @private
68 */
69 handleBrowseItemDir_: function(e) {
70 chrome.developerPrivate.chooseItem('folder', 'load', function(filePath) {
71 $('itemRootDir').value = filePath;
72 });
73 },
74
75 /**
76 * Handles the showing of the item private key file.
77 * @param {Event} e Change event.
78 * @private
79 */
80 handleBrowsePrivateKey_: function(e) {
81 chrome.developerPrivate.chooseItem('file', 'pem', function(filePath) {
82 $('itemPrivateKey').value = filePath;
83 });
84 },
85 };
86
87 /**
88 * Wrap up the pack process by showing the success |message| and closing
89 * the overlay.
90 * @param {String} message The message to show to the user.
91 */
92 PackItemOverlay.showSuccessMessage = function(response) {
93 alertOverlay.setValues(
94 str('packExtensionOverlay'),
95 response.message,
96 str('ok'),
97 '',
98 function() {
99 AppsDebugger.showOverlay(null);
100 },
101 null);
102 AppsDebugger.showOverlay($('alertOverlay'));
103 };
104
105 /**
106 * An alert overlay showing |message|, and upon acknowledgement, close
107 * the alert overlay and return to showing the PackItemOverlay.
108 */
109 PackItemOverlay.showError = function(response) {
110 alertOverlay.setValues(
111 str('packExtensionErrorTitle'),
112 response.message,
113 str('ok'),
114 '',
115 function() {
116 AppsDebugger.showOverlay($('packItemOverlay'));
117 },
118 null);
119 AppsDebugger.showOverlay($('alertOverlay'));
120 };
121
122 /**
123 * An alert overlay showing |message| as warning and proceeding after the
124 * user confirms the action.
125 */
126 PackItemOverlay.showWarningMessage = function(response) {
127 var closeAlert = function() {
128 AppsDebugger.showOverlay(null);
129 };
130
131 alertOverlay.setValues(
132 str('packExtensionWarningTitle'),
133 response.message,
134 str('packExtensionProceedAnyway'),
135 str('cancel'),
136 function() {
137 chrome.developerPrivate.packItem(response.item_path,
138 response.pem_path,
139 response.override_flags,
140 PackItemOverlay.showSuccessMessage);
141 closeAlert();
142 },
143 closeAlert());
144 AppsDebugger.showOverlay($('alertOverlay'));
145 };
146
147 // Export
148 return {
149 PackItemOverlay: PackItemOverlay
150 };
151 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698