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

Unified Diff: chrome/browser/resources/settings/certificate_manager_page/certificate_list.js

Issue 1842403004: MD Settings: Certificate manager, move "Import" button to the tab level. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing comment. Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
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();
+ }
+ },
});

Powered by Google App Engine
This is Rietveld 408576698