| 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..94721d3df5690b7194a086100789a7e2f52f6b0e 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,86 @@ Polymer({
|
| /** @type {!settings.CertificateType} */
|
| certificateType: String,
|
| },
|
| +
|
| + behaviors: [I18nBehavior],
|
| +
|
| + /**
|
| + * @return {string}
|
| + * @private
|
| + */
|
| + getDescription_: function() {
|
| + switch (this.certificateType) {
|
| + case settings.CertificateType.PERSONAL:
|
| + return this.i18n('certificateManagerYourCertificatesDescription');
|
| + case settings.CertificateType.SERVER:
|
| + return this.i18n('certificateManagerServersDescription');
|
| + case settings.CertificateType.CA:
|
| + return this.i18n('certificateManagerAuthoritiesDescription');
|
| + case settings.CertificateType.OTHER:
|
| + return this.i18n('certificateManagerOthersDescription');
|
| + }
|
| +
|
| + 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_();
|
| + }.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();
|
| + }
|
| + },
|
| });
|
|
|