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

Side by Side Diff: chrome/browser/resources/extensions/pack_extension_overlay.js

Issue 974903004: [Extensions] Update closure compiler developerPrivate extern with enums (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 cr.define('extensions', function() { 5 cr.define('extensions', function() {
6 /** 6 /**
7 * PackExtensionOverlay class 7 * PackExtensionOverlay class
8 * Encapsulated handling of the 'Pack Extension' overlay page. 8 * Encapsulated handling of the 'Pack Extension' overlay page.
9 * @constructor 9 * @constructor
10 */ 10 */
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 handleCommit_: function(e) { 48 handleCommit_: function(e) {
49 var extensionPath = $('extension-root-dir').value; 49 var extensionPath = $('extension-root-dir').value;
50 var privateKeyPath = $('extension-private-key').value; 50 var privateKeyPath = $('extension-private-key').value;
51 chrome.developerPrivate.packDirectory( 51 chrome.developerPrivate.packDirectory(
52 extensionPath, privateKeyPath, 0, this.onPackResponse_.bind(this)); 52 extensionPath, privateKeyPath, 0, this.onPackResponse_.bind(this));
53 }, 53 },
54 54
55 /** 55 /**
56 * Utility function which asks the C++ to show a platform-specific file 56 * Utility function which asks the C++ to show a platform-specific file
57 * select dialog, and set the value property of |node| to the selected path. 57 * select dialog, and set the value property of |node| to the selected path.
58 * @param {SelectType} selectType The type of selection to use. 58 * @param {chrome.developerPrivate.SelectType} selectType
59 * @param {FileType} fileType The type of file to select. 59 * The type of selection to use.
60 * @param {chrome.developerPrivate.FileType} fileType
61 * The type of file to select.
60 * @param {HTMLInputElement} node The node to set the value of. 62 * @param {HTMLInputElement} node The node to set the value of.
61 * @private 63 * @private
62 */ 64 */
63 showFileDialog_: function(selectType, fileType, node) { 65 showFileDialog_: function(selectType, fileType, node) {
64 chrome.developerPrivate.choosePath(selectType, fileType, function(path) { 66 chrome.developerPrivate.choosePath(selectType, fileType, function(path) {
65 // Last error is set if the user canceled the dialog. 67 // Last error is set if the user canceled the dialog.
66 if (!chrome.runtime.lastError && path) 68 if (!chrome.runtime.lastError && path)
67 node.value = path; 69 node.value = path;
68 }); 70 });
69 }, 71 },
70 72
71 /** 73 /**
72 * Handles the showing of the extension directory browser. 74 * Handles the showing of the extension directory browser.
73 * @param {Event} e Change event. 75 * @param {Event} e Change event.
74 * @private 76 * @private
75 */ 77 */
76 handleBrowseExtensionDir_: function(e) { 78 handleBrowseExtensionDir_: function(e) {
77 this.showFileDialog_( 79 this.showFileDialog_(
78 'FOLDER', 80 chrome.developerPrivate.SelectType.FOLDER,
79 'LOAD', 81 chrome.developerPrivate.FileType.LOAD,
80 /** @type {HTMLInputElement} */ ($('extension-root-dir'))); 82 /** @type {HTMLInputElement} */ ($('extension-root-dir')));
81 }, 83 },
82 84
83 /** 85 /**
84 * Handles the showing of the extension private key file. 86 * Handles the showing of the extension private key file.
85 * @param {Event} e Change event. 87 * @param {Event} e Change event.
86 * @private 88 * @private
87 */ 89 */
88 handleBrowsePrivateKey_: function(e) { 90 handleBrowsePrivateKey_: function(e) {
89 this.showFileDialog_( 91 this.showFileDialog_(
90 'FILE', 92 chrome.developerPrivate.SelectType.FILE,
91 'PEM', 93 chrome.developerPrivate.FileType.PEM,
92 /** @type {HTMLInputElement} */ ($('extension-private-key'))); 94 /** @type {HTMLInputElement} */ ($('extension-private-key')));
93 }, 95 },
94 96
95 /** 97 /**
96 * Handles a response from a packDirectory call. 98 * Handles a response from a packDirectory call.
97 * @param {PackDirectoryResponse} response The response of the pack call. 99 * @param {PackDirectoryResponse} response The response of the pack call.
98 * @private 100 * @private
99 */ 101 */
100 onPackResponse_: function(response) { 102 onPackResponse_: function(response) {
101 /** @type {string} */ 103 /** @type {string} */
102 var alertTitle; 104 var alertTitle;
103 /** @type {string} */ 105 /** @type {string} */
104 var alertOk; 106 var alertOk;
105 /** @type {string} */ 107 /** @type {string} */
106 var alertCancel; 108 var alertCancel;
107 /** @type {function()} */ 109 /** @type {function()} */
108 var alertOkCallback; 110 var alertOkCallback;
109 /** @type {function()} */ 111 /** @type {function()} */
110 var alertCancelCallback; 112 var alertCancelCallback;
111 113
112 var closeAlert = function() { 114 var closeAlert = function() {
113 extensions.ExtensionSettings.showOverlay(null); 115 extensions.ExtensionSettings.showOverlay(null);
114 }; 116 };
115 117
116 // TODO(devlin): Once we expose enums on extension APIs, we should use
117 // those objects, instead of a string.
118 switch (response.status) { 118 switch (response.status) {
119 case 'SUCCESS': 119 case chrome.developerPrivate.PackStatus.SUCCESS:
120 alertTitle = loadTimeData.getString('packExtensionOverlay'); 120 alertTitle = loadTimeData.getString('packExtensionOverlay');
121 alertOk = loadTimeData.getString('ok'); 121 alertOk = loadTimeData.getString('ok');
122 alertOkCallback = closeAlert; 122 alertOkCallback = closeAlert;
123 // No 'Cancel' option. 123 // No 'Cancel' option.
124 break; 124 break;
125 case 'WARNING': 125 case chrome.developerPrivate.PackStatus.WARNING:
126 alertTitle = loadTimeData.getString('packExtensionWarningTitle'); 126 alertTitle = loadTimeData.getString('packExtensionWarningTitle');
127 alertOk = loadTimeData.getString('packExtensionProceedAnyway'); 127 alertOk = loadTimeData.getString('packExtensionProceedAnyway');
128 alertCancel = loadTimeData.getString('cancel'); 128 alertCancel = loadTimeData.getString('cancel');
129 alertOkCallback = function() { 129 alertOkCallback = function() {
130 chrome.developerPrivate.packDirectory( 130 chrome.developerPrivate.packDirectory(
131 response.item_path, 131 response.item_path,
132 response.pem_path, 132 response.pem_path,
133 response.override_flags, 133 response.override_flags,
134 this.onPackResponse_.bind(this)); 134 this.onPackResponse_.bind(this));
135 closeAlert(); 135 closeAlert();
136 }.bind(this); 136 }.bind(this);
137 alertCancelCallback = closeAlert; 137 alertCancelCallback = closeAlert;
138 break; 138 break;
139 case 'ERROR': 139 case chrome.developerPrivate.PackStatus.ERROR:
140 alertTitle = loadTimeData.getString('packExtensionErrorTitle'); 140 alertTitle = loadTimeData.getString('packExtensionErrorTitle');
141 alertOk = loadTimeData.getString('ok'); 141 alertOk = loadTimeData.getString('ok');
142 alertOkCallback = function() { 142 alertOkCallback = function() {
143 extensions.ExtensionSettings.showOverlay( 143 extensions.ExtensionSettings.showOverlay(
144 $('pack-extension-overlay')); 144 $('pack-extension-overlay'));
145 }; 145 };
146 // No 'Cancel' option. 146 // No 'Cancel' option.
147 break; 147 break;
148 default: 148 default:
149 assertNotReached(); 149 assertNotReached();
150 return; 150 return;
151 } 151 }
152 152
153 alertOverlay.setValues(alertTitle, 153 alertOverlay.setValues(alertTitle,
154 response.message, 154 response.message,
155 alertOk, 155 alertOk,
156 alertCancel, 156 alertCancel,
157 alertOkCallback, 157 alertOkCallback,
158 alertCancelCallback); 158 alertCancelCallback);
159 extensions.ExtensionSettings.showOverlay($('alertOverlay')); 159 extensions.ExtensionSettings.showOverlay($('alertOverlay'));
160 }, 160 },
161 }; 161 };
162 162
163 // Export 163 // Export
164 return { 164 return {
165 PackExtensionOverlay: PackExtensionOverlay 165 PackExtensionOverlay: PackExtensionOverlay
166 }; 166 };
167 }); 167 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698