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 82b261fd8cd1e92346d04facebc4549300248a05..f13138a08f5e34a58f2f64a43202b8c1796a1c9f 100644 | 
| --- a/chrome/browser/resources/settings/certificate_manager_page/certificate_list.js | 
| +++ b/chrome/browser/resources/settings/certificate_manager_page/certificate_list.js | 
| @@ -64,10 +64,11 @@ Polymer({ | 
| /** | 
| * Handles a rejected Promise returned from |browserProxy_|. | 
| + * @param {!HTMLElement} anchor | 
| * @param {*} error Expects {!CertificatesError|!CertificatesImportError}. | 
| * @private | 
| */ | 
| - onRejected_: function(error) { | 
| + onRejected_: function(anchor, error) { | 
| if (error === null) { | 
| // Nothing to do here. Null indicates that the user clicked "cancel" on | 
| // a native file chooser dialog. | 
| @@ -76,58 +77,69 @@ Polymer({ | 
| // Otherwise propagate the error to the parents, such that a dialog | 
| // displaying the error will be shown. | 
| - this.fire('certificates-error', error); | 
| + this.fire('certificates-error', {error: error, anchor: anchor}); | 
| }, | 
| /** | 
| * @param {?NewCertificateSubNode} subnode | 
| + * @param {!HTMLElement} anchor | 
| * @private | 
| */ | 
| - dispatchImportActionEvent_: function(subnode) { | 
| + dispatchImportActionEvent_: function(subnode, anchor) { | 
| this.fire( | 
| settings.CertificateActionEvent, | 
| /** @type {!CertificateActionEventDetail} */ ({ | 
| action: CertificateAction.IMPORT, | 
| subnode: subnode, | 
| certificateType: this.certificateType, | 
| + anchor: anchor, | 
| })); | 
| }, | 
| - /** @private */ | 
| - onImportTap_: function() { | 
| - this.handleImport_(false); | 
| + /** | 
| + * @param {!Event} e | 
| + * @private | 
| + */ | 
| + onImportTap_: function(e) { | 
| + this.handleImport_(false, /** @type {!HTMLElement} */ ( | 
| + Polymer.dom(e).localTarget)); | 
| }, | 
| // <if expr="chromeos"> | 
| - /** @private */ | 
| - onImportAndBindTap_: function() { | 
| - this.handleImport_(true); | 
| + /** | 
| + * @private | 
| + * @param {!Event} e | 
| + */ | 
| + onImportAndBindTap_: function(e) { | 
| + this.handleImport_(true, /** @type {!HTMLElement} */ ( | 
| + Polymer.dom(e).localTarget)); | 
| }, | 
| // </if> | 
| /** | 
| * @param {boolean} useHardwareBacked | 
| + * @param {!HTMLElement} anchor | 
| * @private | 
| */ | 
| - handleImport_: function(useHardwareBacked) { | 
| + handleImport_: function(useHardwareBacked, anchor) { | 
| var browserProxy = settings.CertificatesBrowserProxyImpl.getInstance(); | 
| if (this.certificateType == CertificateType.PERSONAL) { | 
| browserProxy.importPersonalCertificate(useHardwareBacked).then( | 
| function(showPasswordPrompt) { | 
| if (showPasswordPrompt) | 
| - this.dispatchImportActionEvent_(null); | 
| + this.dispatchImportActionEvent_(null, anchor); | 
| }.bind(this), | 
| - this.onRejected_.bind(this)); | 
| + this.onRejected_.bind(this, anchor)); | 
| } else if (this.certificateType == CertificateType.CA) { | 
| browserProxy.importCaCertificate().then( | 
| function(certificateName) { | 
| - this.dispatchImportActionEvent_({name: certificateName}); | 
| + this.dispatchImportActionEvent_({name: certificateName}, anchor); | 
| }.bind(this), | 
| - this.onRejected_.bind(this)); | 
| + this.onRejected_.bind(this, anchor)); | 
| } else if (this.certificateType == CertificateType.SERVER) { | 
| browserProxy.importServerCertificate().catch( | 
| - this.onRejected_.bind(this)); | 
| + this.onRejected_.bind(this, anchor)); | 
| 
 
tommycli
2017/04/04 22:42:29
Nice partially applied function.
 
dpapad
2017/04/04 23:15:42
Ack!
 
 | 
| } else { | 
| assertNotReached(); | 
| } |