Commit b875af1c authored by rdevlin.cronin's avatar rdevlin.cronin Committed by Commit bot

[Extensions] Update closure compiler developerPrivate extern with enums

Update the closure compiler extern for the developerPrivate API to have enum
definitions, now that enums are exposed on the api object.
Update chrome://extensions to use these enums.

BUG=463184
BUG=461039

Review URL: https://codereview.chromium.org/974903004

Cr-Commit-Position: refs/heads/master@{#318968}
parent 9a920de9
......@@ -55,8 +55,10 @@ cr.define('extensions', function() {
/**
* Utility function which asks the C++ to show a platform-specific file
* 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 {chrome.developerPrivate.SelectType} selectType
* The type of selection to use.
* @param {chrome.developerPrivate.FileType} fileType
* The type of file to select.
* @param {HTMLInputElement} node The node to set the value of.
* @private
*/
......@@ -75,8 +77,8 @@ cr.define('extensions', function() {
*/
handleBrowseExtensionDir_: function(e) {
this.showFileDialog_(
'FOLDER',
'LOAD',
chrome.developerPrivate.SelectType.FOLDER,
chrome.developerPrivate.FileType.LOAD,
/** @type {HTMLInputElement} */ ($('extension-root-dir')));
},
......@@ -87,8 +89,8 @@ cr.define('extensions', function() {
*/
handleBrowsePrivateKey_: function(e) {
this.showFileDialog_(
'FILE',
'PEM',
chrome.developerPrivate.SelectType.FILE,
chrome.developerPrivate.FileType.PEM,
/** @type {HTMLInputElement} */ ($('extension-private-key')));
},
......@@ -113,16 +115,14 @@ cr.define('extensions', function() {
extensions.ExtensionSettings.showOverlay(null);
};
// TODO(devlin): Once we expose enums on extension APIs, we should use
// those objects, instead of a string.
switch (response.status) {
case 'SUCCESS':
case chrome.developerPrivate.PackStatus.SUCCESS:
alertTitle = loadTimeData.getString('packExtensionOverlay');
alertOk = loadTimeData.getString('ok');
alertOkCallback = closeAlert;
// No 'Cancel' option.
break;
case 'WARNING':
case chrome.developerPrivate.PackStatus.WARNING:
alertTitle = loadTimeData.getString('packExtensionWarningTitle');
alertOk = loadTimeData.getString('packExtensionProceedAnyway');
alertCancel = loadTimeData.getString('cancel');
......@@ -136,7 +136,7 @@ cr.define('extensions', function() {
}.bind(this);
alertCancelCallback = closeAlert;
break;
case 'ERROR':
case chrome.developerPrivate.PackStatus.ERROR:
alertTitle = loadTimeData.getString('packExtensionErrorTitle');
alertOk = loadTimeData.getString('ok');
alertOkCallback = function() {
......
......@@ -5,7 +5,7 @@
/** @fileoverview Externs generated from namespace: developerPrivate */
// Note: hand-modified to change Array to !Array in ItemInfo typedef, and add
// typedef {string} for idl enums.
// enum definitions.
/**
* @typedef {string}
......@@ -82,24 +82,44 @@ var InspectOptions;
var ReloadOptions;
/**
* @typedef {string}
* @enum {string}
*/
var PackStatus;
chrome.developerPrivate.PackStatus = {
SUCCESS: 'SUCCESS',
ERROR: 'ERROR',
WARNING: 'WARNING',
};
/**
* @typedef {string}
* @enum {string}
*/
var FileType;
chrome.developerPrivate.FileType = {
LOAD: 'LOAD',
PEM: 'PEM',
};
/**
* @typedef {string}
* @enum {string}
*/
var SelectType;
chrome.developerPrivate.SelectType = {
FILE: 'FILE',
FOLDER: 'FOLDER',
};
/**
* @typedef {string}
* @enum {string}
*/
var EventType;
chrome.developerPrivate.EventType = {
INSTALLED: 'INSTALLED',
UNINSTALLED: 'UNINSTALLED',
LOADED: 'LOADED',
UNLOADED: 'UNLOADED',
// New window / view opened.
VIEW_REGISTERED: 'VIEW_REGISTERED',
// window / view closed.
VIEW_UNREGISTERED: 'VIEW_UNREGISTERED',
ERROR_ADDED: 'ERROR_ADDED',
}
/**
* @typedef {{
......@@ -107,7 +127,7 @@ var EventType;
* item_path: string,
* pem_path: string,
* override_flags: number,
* status: PackStatus
* status: chrome.developerPrivate.PackStatus
* }}
*/
var PackDirectoryResponse;
......@@ -121,7 +141,7 @@ var ProjectInfo;
/**
* @typedef {{
* event_type: EventType,
* event_type: chrome.developerPrivate.EventType,
* item_id: string
* }}
*/
......@@ -244,8 +264,10 @@ chrome.developerPrivate.loadDirectory = function(directory, callback) {};
/**
* Open Dialog to browse to an entry.
* @param {SelectType} selectType Select a file or a folder.
* @param {FileType} fileType Required file type. For example, pem type is for
* @param {chrome.developerPrivate.SelectType} selectType
* Select a file or a folder.
* @param {chrome.developerPrivate.FileType} fileType
* Required file type. For example, pem type is for
* private key and load type is for an unpacked item.
* @param {Function} callback called with selected item's path.
*/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment