1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/**
* @fileoverview settings-certificate-subentry represents an SSL certificate
* sub-entry.
*/
Polymer({
is: 'settings-certificate-subentry',
properties: {
/** @type {!CertificateSubnode>} */
model: Object,
/** @type {!settings.CertificateType} */
certificateType: String,
},
/** @private {!settings.CertificatesManagerBrowserProxy} */
browserProxy_: null,
/** @override */
ready: function() {
this.browserProxy_ = settings.CertificatesBrowserProxyImpl.getInstance();
},
/**
* @param {!Event} event
* @private
*/
onViewTap_: function(event) {
this.closePopupMenu_();
this.browserProxy_.viewCertificate(this.model.id);
},
/**
* @param {!Event} event
* @private
*/
onEditTap_: function(event) {
this.closePopupMenu_();
// TODO(dpapad): Open edit dialog.
},
/**
* @param {!Event} event
* @private
*/
onDeleteTap_: function(event) {
this.closePopupMenu_();
// TODO(dpapad): Open delete confirmation dialog.
},
/**
* @param {!Event} event
* @private
*/
onExportTap_: function(event) {
this.closePopupMenu_();
if (this.certificateType == settings.CertificateType.PERSONAL) {
// TODO(dpapad): Open password encryption dialog.
} else {
this.browserProxy_.exportCertificate(this.model.id);
}
},
/** @private */
onImportTap_: function() {
this.closePopupMenu_();
if (this.certificateType == settings.CertificateType.PERSONAL) {
// TODO(dpapad): Figure out when to pass true (ChromeOS?).
this.browserProxy_.importPersonalCertificate(false).then(
function(showPasswordPrompt) {
if (showPasswordPrompt) {
// TODO(dpapad): Show password decryption dialog.
}
}.bind(this));
} else if (this.certificateType == settings.CertificateType.CA) {
this.browserProxy_.importCaCertificate().then(
function(certificateName) {
// TODO(dpapad): Show import dialog.
}.bind(this));
} else if (this.certificateType == settings.CertificateType.SERVER) {
this.browserProxy_.importServerCertificate();
}
},
/**
* @param {string} certificateType The type of this certificate.
* @return {boolean} Whether the certificate can be edited.
* @private
*/
canEdit_: function(certificateType) {
return this.certificateType == settings.CertificateType.CA;
},
/**
* @param {string} certificateType The type of this certificate.
* @return {boolean} Whether a certificate can be imported.
* @private
*/
canImport_: function(certificateType) {
return this.certificateType != settings.CertificateType.OTHER;
},
/** @private */
closePopupMenu_: function() {
this.$$('iron-dropdown').close();
},
});
|