Diff

Differences From Artifact [dc80ae3ba4]:

To Artifact [b238d95675]:


     4      4   
     5      5   function onCertificatesRejected(rejectedCerts) {
     6      6   	// If certificates were rejected by the API, log an error, for example.
     7      7   	console.error(rejectedCerts.length + ' certificates were rejected.');
     8      8   	return;
     9      9   }
    10     10   
           11  +/*
           12  + * Optional features for CACKey
           13  + */
           14  +var cackeyFeatures = {
           15  +	customPINPrompt: true
           16  +};
           17  +
    11     18   /*
    12     19    * Handle for the CACKey NaCl Target
    13     20    */
    14     21   var cackeyHandle = null;
    15     22   var cackeyPCSCHandle = null;
    16     23   var cackeyPCSCHandleUsable = false;
    17     24   var cackeyPCSCHandleLastUsed = (new Date()).getTime();
................................................................................
   338    345   					if (!pinWindow) {
   339    346   						console.error("[cackey] No window was provided for PIN entry, this will not go well.");
   340    347   	
   341    348   						return;
   342    349   					}
   343    350   	
   344    351   					pinWindowPreviousHandle = pinWindow;
   345         -	
          352  +
   346    353   					pinWindow.drawAttention();
   347    354   					pinWindow.focus();
   348    355   	
   349    356   					/*
   350    357   					 * Register a handler to handle the window being closed without
   351    358   					 * having sent anything
   352    359   					 */
................................................................................
   369    376   					})
   370    377   	
   371    378   					/*
   372    379   					 * Pass this message off to the other window so that it may resubmit the request.
   373    380   					 */
   374    381   					pinWindow.contentWindow.parentWindow = window;
   375    382   					pinWindow.contentWindow.messageEvent = messageEvent;
          383  +
          384  +					if (cackeyFeatures.customPINPrompt) {
          385  +						pinWindow.contentWindow.pinprompt = messageEvent.data.pinprompt;
          386  +					}
   376    387   	
   377    388   					return;
   378    389   				});
   379    390   			} else {
   380    391   				chrome.certificateProvider.requestPin({
   381    392   					signRequestId: messageEvent.data.originalrequest.signRequestId,
   382    393   					requestType: "PIN"
   383    394   				}, function(userInfo) {
   384         -					chrome.certificateProvider.stopPinRequest({
   385         -						signRequestId: messageEvent.data.originalrequest.signRequestId
   386         -					}, function() {
   387         -						var pinValue = "";
          395  +					var destroyError;
          396  +					var pinValue = "";
   388    397   
   389         -						pinWindowPreviousHandle = null;
          398  +					try {
          399  +						chrome.certificateProvider.stopPinRequest({
          400  +							signRequestId: messageEvent.data.originalrequest.signRequestId
          401  +						}, function() {});
          402  +					} catch (destroyError) {
          403  +						/* Do nothing, we don't care if it fails really */
          404  +					}
   390    405   
   391         -						if (userInfo && userInfo.userInput) {
   392         -							pinValue = userInfo.userInput;
   393         -						}
          406  +					pinWindowPreviousHandle = null;
   394    407   
   395         -						return(cackeyPINPromptCompleted(pinValue));
   396         -					});
          408  +					if (userInfo && userInfo.userInput) {
          409  +						pinValue = userInfo.userInput;
          410  +					}
          411  +
          412  +					return(cackeyPINPromptCompleted(pinValue));
   397    413   				});
   398    414   			}
   399    415   
   400    416   			/*
   401    417   			 * We return here instead of break to avoid deleting the callback
   402    418   			 * entry.
   403    419   			 */