Diff

Differences From Artifact [f4c949a3a4]:

To Artifact [3c60365638]:


   403    403   }
   404    404   
   405    405   /*
   406    406    * Handler for messages from Chrome related to listing certificates
   407    407    */
   408    408   function cackeyListCertificates(chromeCallback) {
   409    409   	var callbackId;
          410  +	var promiseHandle = null, promiseResolve, promiseReject;
   410    411   
   411    412   	if (goog.DEBUG) {
   412    413   		console.log("[cackey] Asked to provide a list of certificates -- throwing that request over to the NaCl side... ");
   413    414   	}
          415  +
          416  +	if (!chromeCallback) {
          417  +		/*
          418  +		 * If no callback supplied, arrange for a promise to be returned instead
          419  +		 */
          420  +		promiseHandle = new Promise(function(resolve, reject) {
          421  +			promiseResolve = resolve;
          422  +			promiseReject = reject;
          423  +		});
          424  +
          425  +		chromeCallback = function(certs) {
          426  +			promiseResolve(certs);
          427  +		};
          428  +	}
   414    429   
   415    430   	callbackId = ++cackeyOutstandingCallbackCounter;
   416    431   
   417    432   	cackeyInitPCSC(function() {
   418    433   		cackeyHandle.postMessage(
   419    434   			{
   420    435   				'target': "cackey",
................................................................................
   426    441   		cackeyOutstandingCallbacks[callbackId] = chromeCallback;
   427    442   
   428    443   		if (goog.DEBUG) {
   429    444   			console.log("[cackey] Thrown.");
   430    445   		}
   431    446   	}, chromeCallback);
   432    447   
   433         -	return;
          448  +	return(promiseHandle);
   434    449   }
   435    450   
   436    451   /*
   437    452    * Handler for messages from Chrome related to listing readers
   438    453    */
   439    454   function cackeyListReaders(chromeCallback) {
   440    455   	var callbackId;