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

Side by Side Diff: chrome/browser/resources/settings/certificate_manager_page/certificates_browser_proxy.js

Issue 2954863003: MD Settings: Convert all browser proxies to use ES6 class syntax. (Closed)
Patch Set: Remove @constructor annotations. Created 3 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview A helper object used from the "Manage certificates" section 6 * @fileoverview A helper object used from the "Manage certificates" section
7 * to interact with the browser. 7 * to interact with the browser.
8 */ 8 */
9 9
10 /** 10 /**
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 * @typedef {{ 76 * @typedef {{
77 * title: string, 77 * title: string,
78 * description: string, 78 * description: string,
79 * certificateErrors: !Array<{name: string, error: string}> 79 * certificateErrors: !Array<{name: string, error: string}>
80 * }} 80 * }}
81 * @see chrome/browser/ui/webui/settings/certificates_handler.cc 81 * @see chrome/browser/ui/webui/settings/certificates_handler.cc
82 */ 82 */
83 var CertificatesImportError; 83 var CertificatesImportError;
84 84
85 cr.define('settings', function() { 85 cr.define('settings', function() {
86
87 /** @interface */ 86 /** @interface */
88 function CertificatesBrowserProxy() {} 87 class CertificatesBrowserProxy {
89
90 CertificatesBrowserProxy.prototype = {
91 /** 88 /**
92 * Triggers 5 events in the following order 89 * Triggers 5 events in the following order
93 * 1x 'certificates-model-ready' event. 90 * 1x 'certificates-model-ready' event.
94 * 4x 'certificates-changed' event, one for each certificate category. 91 * 4x 'certificates-changed' event, one for each certificate category.
95 */ 92 */
96 refreshCertificates: function() {}, 93 refreshCertificates() {}
97 94
98 /** @param {string} id */ 95 /** @param {string} id */
99 viewCertificate: function(id) {}, 96 viewCertificate(id) {}
100 97
101 /** @param {string} id */ 98 /** @param {string} id */
102 exportCertificate: function(id) {}, 99 exportCertificate(id) {}
103 100
104 /** 101 /**
105 * @param {string} id 102 * @param {string} id
106 * @return {!Promise} A promise resolved when the certificate has been 103 * @return {!Promise} A promise resolved when the certificate has been
107 * deleted successfully or rejected with a CertificatesError. 104 * deleted successfully or rejected with a CertificatesError.
108 */ 105 */
109 deleteCertificate: function(id) {}, 106 deleteCertificate(id) {}
110 107
111 /** 108 /**
112 * @param {string} id 109 * @param {string} id
113 * @return {!Promise<!CaTrustInfo>} 110 * @return {!Promise<!CaTrustInfo>}
114 */ 111 */
115 getCaCertificateTrust: function(id) {}, 112 getCaCertificateTrust(id) {}
116 113
117 /** 114 /**
118 * @param {string} id 115 * @param {string} id
119 * @param {boolean} ssl 116 * @param {boolean} ssl
120 * @param {boolean} email 117 * @param {boolean} email
121 * @param {boolean} objSign 118 * @param {boolean} objSign
122 * @return {!Promise} 119 * @return {!Promise}
123 */ 120 */
124 editCaCertificateTrust: function(id, ssl, email, objSign) {}, 121 editCaCertificateTrust(id, ssl, email, objSign) {}
125 122
126 cancelImportExportCertificate: function() {}, 123 cancelImportExportCertificate() {}
127 124
128 /** 125 /**
129 * @param {string} id 126 * @param {string} id
130 * @return {!Promise} A promise firing once the user has selected 127 * @return {!Promise} A promise firing once the user has selected
131 * the export location. A prompt should be shown to asking for a 128 * the export location. A prompt should be shown to asking for a
132 * password to use for encrypting the file. The password should be 129 * password to use for encrypting the file. The password should be
133 * passed back via a call to 130 * passed back via a call to
134 * exportPersonalCertificatePasswordSelected(). 131 * exportPersonalCertificatePasswordSelected().
135 */ 132 */
136 exportPersonalCertificate: function(id) {}, 133 exportPersonalCertificate(id) {}
137 134
138 /** 135 /**
139 * @param {string} password 136 * @param {string} password
140 * @return {!Promise} 137 * @return {!Promise}
141 */ 138 */
142 exportPersonalCertificatePasswordSelected: function(password) {}, 139 exportPersonalCertificatePasswordSelected(password) {}
143 140
144 /** 141 /**
145 * @param {boolean} useHardwareBacked 142 * @param {boolean} useHardwareBacked
146 * @return {!Promise<boolean>} A promise firing once the user has selected 143 * @return {!Promise<boolean>} A promise firing once the user has selected
147 * the file to be imported. If true a password prompt should be shown to 144 * the file to be imported. If true a password prompt should be shown to
148 * the user, and the password should be passed back via a call to 145 * the user, and the password should be passed back via a call to
149 * importPersonalCertificatePasswordSelected(). 146 * importPersonalCertificatePasswordSelected().
150 */ 147 */
151 importPersonalCertificate: function(useHardwareBacked) {}, 148 importPersonalCertificate(useHardwareBacked) {}
152 149
153 /** 150 /**
154 * @param {string} password 151 * @param {string} password
155 * @return {!Promise} 152 * @return {!Promise}
156 */ 153 */
157 importPersonalCertificatePasswordSelected: function(password) {}, 154 importPersonalCertificatePasswordSelected(password) {}
158 155
159 /** 156 /**
160 * @return {!Promise} A promise firing once the user has selected 157 * @return {!Promise} A promise firing once the user has selected
161 * the file to be imported, or failing with CertificatesError. 158 * the file to be imported, or failing with CertificatesError.
162 * Upon success, a prompt should be shown to the user to specify the 159 * Upon success, a prompt should be shown to the user to specify the
163 * trust levels, and that information should be passed back via a call 160 * trust levels, and that information should be passed back via a call
164 * to importCaCertificateTrustSelected(). 161 * to importCaCertificateTrustSelected().
165 */ 162 */
166 importCaCertificate: function() {}, 163 importCaCertificate() {}
167 164
168 /** 165 /**
169 * @param {boolean} ssl 166 * @param {boolean} ssl
170 * @param {boolean} email 167 * @param {boolean} email
171 * @param {boolean} objSign 168 * @param {boolean} objSign
172 * @return {!Promise} A promise firing once the trust level for the imported 169 * @return {!Promise} A promise firing once the trust level for the imported
173 * certificate has been successfully set. The promise is rejected if an 170 * certificate has been successfully set. The promise is rejected if an
174 * error occurred with either a CertificatesError or 171 * error occurred with either a CertificatesError or
175 * CertificatesImportError. 172 * CertificatesImportError.
176 */ 173 */
177 importCaCertificateTrustSelected: function(ssl, email, objSign) {}, 174 importCaCertificateTrustSelected(ssl, email, objSign) {}
178 175
179 /** 176 /**
180 * @return {!Promise} A promise firing once the certificate has been 177 * @return {!Promise} A promise firing once the certificate has been
181 * imported. The promise is rejected if an error occurred, with either 178 * imported. The promise is rejected if an error occurred, with either
182 * a CertificatesError or CertificatesImportError. 179 * a CertificatesError or CertificatesImportError.
183 */ 180 */
184 importServerCertificate: function() {}, 181 importServerCertificate() {}
185 }; 182 }
186 183
187 /** 184 /**
188 * @constructor
189 * @implements {settings.CertificatesBrowserProxy} 185 * @implements {settings.CertificatesBrowserProxy}
190 */ 186 */
191 function CertificatesBrowserProxyImpl() {} 187 class CertificatesBrowserProxyImpl {
188 /** @override */
189 refreshCertificates() {
190 chrome.send('refreshCertificates');
191 }
192
193 /** @override */
194 viewCertificate(id) {
195 chrome.send('viewCertificate', [id]);
196 }
197
198 /** @override */
199 exportCertificate(id) {
200 chrome.send('exportCertificate', [id]);
201 }
202
203 /** @override */
204 deleteCertificate(id) {
205 return cr.sendWithPromise('deleteCertificate', id);
206 }
207
208 /** @override */
209 exportPersonalCertificate(id) {
210 return cr.sendWithPromise('exportPersonalCertificate', id);
211 }
212
213 /** @override */
214 exportPersonalCertificatePasswordSelected(password) {
215 return cr.sendWithPromise(
216 'exportPersonalCertificatePasswordSelected', password);
217 }
218
219 /** @override */
220 importPersonalCertificate(useHardwareBacked) {
221 return cr.sendWithPromise('importPersonalCertificate', useHardwareBacked);
222 }
223
224 /** @override */
225 importPersonalCertificatePasswordSelected(password) {
226 return cr.sendWithPromise(
227 'importPersonalCertificatePasswordSelected', password);
228 }
229
230 /** @override */
231 getCaCertificateTrust(id) {
232 return cr.sendWithPromise('getCaCertificateTrust', id);
233 }
234
235 /** @override */
236 editCaCertificateTrust(id, ssl, email, objSign) {
237 return cr.sendWithPromise(
238 'editCaCertificateTrust', id, ssl, email, objSign);
239 }
240
241 /** @override */
242 importCaCertificateTrustSelected(ssl, email, objSign) {
243 return cr.sendWithPromise(
244 'importCaCertificateTrustSelected', ssl, email, objSign);
245 }
246
247 /** @override */
248 cancelImportExportCertificate() {
249 chrome.send('cancelImportExportCertificate');
250 }
251
252 /** @override */
253 importCaCertificate() {
254 return cr.sendWithPromise('importCaCertificate');
255 }
256
257 /** @override */
258 importServerCertificate() {
259 return cr.sendWithPromise('importServerCertificate');
260 }
261 }
262
192 // The singleton instance_ is replaced with a test version of this wrapper 263 // The singleton instance_ is replaced with a test version of this wrapper
193 // during testing. 264 // during testing.
194 cr.addSingletonGetter(CertificatesBrowserProxyImpl); 265 cr.addSingletonGetter(CertificatesBrowserProxyImpl);
195 266
196 CertificatesBrowserProxyImpl.prototype = {
197 /** @override */
198 refreshCertificates: function() {
199 chrome.send('refreshCertificates');
200 },
201
202 /** @override */
203 viewCertificate: function(id) {
204 chrome.send('viewCertificate', [id]);
205 },
206
207 /** @override */
208 exportCertificate: function(id) {
209 chrome.send('exportCertificate', [id]);
210 },
211
212 /** @override */
213 deleteCertificate: function(id) {
214 return cr.sendWithPromise('deleteCertificate', id);
215 },
216
217 /** @override */
218 exportPersonalCertificate: function(id) {
219 return cr.sendWithPromise('exportPersonalCertificate', id);
220 },
221
222 /** @override */
223 exportPersonalCertificatePasswordSelected: function(password) {
224 return cr.sendWithPromise(
225 'exportPersonalCertificatePasswordSelected', password);
226 },
227
228 /** @override */
229 importPersonalCertificate: function(useHardwareBacked) {
230 return cr.sendWithPromise('importPersonalCertificate', useHardwareBacked);
231 },
232
233 /** @override */
234 importPersonalCertificatePasswordSelected: function(password) {
235 return cr.sendWithPromise(
236 'importPersonalCertificatePasswordSelected', password);
237 },
238
239 /** @override */
240 getCaCertificateTrust: function(id) {
241 return cr.sendWithPromise('getCaCertificateTrust', id);
242 },
243
244 /** @override */
245 editCaCertificateTrust: function(id, ssl, email, objSign) {
246 return cr.sendWithPromise(
247 'editCaCertificateTrust', id, ssl, email, objSign);
248 },
249
250 /** @override */
251 importCaCertificateTrustSelected: function(ssl, email, objSign) {
252 return cr.sendWithPromise(
253 'importCaCertificateTrustSelected', ssl, email, objSign);
254 },
255
256 /** @override */
257 cancelImportExportCertificate: function() {
258 chrome.send('cancelImportExportCertificate');
259 },
260
261 /** @override */
262 importCaCertificate: function() {
263 return cr.sendWithPromise('importCaCertificate');
264 },
265
266 /** @override */
267 importServerCertificate: function() {
268 return cr.sendWithPromise('importServerCertificate');
269 },
270 };
271
272 return { 267 return {
273 CertificatesBrowserProxy: CertificatesBrowserProxy, 268 CertificatesBrowserProxy: CertificatesBrowserProxy,
274 CertificatesBrowserProxyImpl: CertificatesBrowserProxyImpl, 269 CertificatesBrowserProxyImpl: CertificatesBrowserProxyImpl,
275 }; 270 };
276 }); 271 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698