Chromium Code Reviews| Index: chrome/browser/resources/settings/certificate_manager_page/certificate_list.js |
| diff --git a/chrome/browser/resources/settings/certificate_manager_page/certificate_list.js b/chrome/browser/resources/settings/certificate_manager_page/certificate_list.js |
| index 913ba18dc75519f6f6e856b6dce03b1a413f4469..56c283216cbbcb68b987a5c56ab262475b7d9c92 100644 |
| --- a/chrome/browser/resources/settings/certificate_manager_page/certificate_list.js |
| +++ b/chrome/browser/resources/settings/certificate_manager_page/certificate_list.js |
| @@ -19,4 +19,90 @@ Polymer({ |
| /** @type {!settings.CertificateType} */ |
| certificateType: String, |
| }, |
| + |
| + /** |
| + * @return {string} |
| + * @private |
| + */ |
| + getDescription_: function() { |
| + var get = function(string) { |
| + return loadTimeData.getString( |
| + 'certificateManager' + string + 'Description'); |
| + }; |
| + |
| + switch (this.certificateType) { |
| + case settings.CertificateType.PERSONAL: |
| + return get('YourCertificates'); |
|
Dan Beam
2016/04/01 18:38:02
I would recommend not splitting up these identifie
dpapad
2016/04/01 21:13:17
Done. Also modified 18n() definition to call getSt
|
| + case settings.CertificateType.SERVER: |
| + return get('Servers'); |
| + case settings.CertificateType.CA: |
| + return get('Authorities'); |
| + case settings.CertificateType.OTHER: |
| + return get('Others'); |
| + } |
| + |
| + assertNotReached(); |
| + }, |
| + |
| + /** |
| + * @return {boolean} |
| + * @private |
| + */ |
| + canImport_: function() { |
| + return this.certificateType != settings.CertificateType.OTHER; |
| + }, |
| + |
| + /** |
| + * Handles a rejected Promise returned from |browserProxy_|. |
| + * @param {null|!CertificatesError|!CertificatesImportError} error |
| + * @private |
| + */ |
| + onRejected_: function(error) { |
| + if (error === null) { |
| + // Nothing to do here. Null indicates that the user clicked "cancel" on |
| + // a native file chooser dialog. |
| + return; |
| + } |
| + |
| + // Otherwise propagate the error to the parents, such that a dialog |
| + // displaying the error will be shown. |
| + this.fire('certificates-error', error); |
| + }, |
| + |
| + |
| + /** @private */ |
| + dispatchImportActionEvent_: function() { |
| + this.fire( |
| + settings.CertificateActionEvent, |
| + /** @type {!CertificateActionEventDetail} */ ({ |
| + action: settings.CertificateAction.IMPORT, |
| + subnode: null, |
| + certificateType: this.certificateType, |
| + })); |
| + }, |
| + |
| + /** @private */ |
| + onImportTap_: function() { |
| + var browserProxy = settings.CertificatesBrowserProxyImpl.getInstance(); |
| + if (this.certificateType == settings.CertificateType.PERSONAL) { |
| + browserProxy.importPersonalCertificate(false).then( |
| + function(showPasswordPrompt) { |
| + if (showPasswordPrompt) { |
| + this.dispatchImportActionEvent_(); |
| + } |
|
Dan Beam
2016/04/01 18:38:02
nit: no curlies
dpapad
2016/04/01 21:13:17
Done.
|
| + }.bind(this), |
| + this.onRejected_.bind(this)); |
| + } else if (this.certificateType == settings.CertificateType.CA) { |
| + browserProxy.importCaCertificate().then( |
| + function(certificateName) { |
| + this.dispatchImportActionEvent_(); |
| + }.bind(this), |
| + this.onRejected_.bind(this)); |
| + } else if (this.certificateType == settings.CertificateType.SERVER) { |
| + browserProxy.importServerCertificate().catch( |
| + this.onRejected_.bind(this)); |
| + } else { |
| + assertNotReached(); |
| + } |
| + }, |
| }); |