Index: build/chrome/cackey.js ================================================================== --- build/chrome/cackey.js +++ build/chrome/cackey.js @@ -20,11 +20,12 @@ var cackeyOutstandingCallbackCounter = -1; /* * Communication with the PIN entry window */ -var pinWindowDidWork = 0; +var pinWindowPINValue = ""; +var pinWindowPreviousHandle = null; /* * Handle a response from the NaCl side regarding certificates available */ function cackeyMessageIncomingListCertificates(message, chromeCallback) { @@ -99,11 +100,20 @@ chromeCallback(); break; case "retry": - pinWindowDidWork = 0; + pinWindowPINValue = ""; + + if (pinWindowPreviousHandle) { + /* + * An existing PIN entry is in progress + * Wait for it to complete and tie this request to that one. + */ + + /* XXX:TODO */ + } chrome.app.window.create("pin.html", { "id": "cackeyPINEntry", "resizable": false, "alwaysOnTop": true, @@ -120,19 +130,23 @@ console.log("[cackey] No window was provided for PIN entry, this will not go well."); return; } + pinWindowPreviousHandle = pinWindow; + pinWindow.drawAttention(); pinWindow.focus(); /* * Register a handler to handle the window being closed without * having sent anything */ pinWindow.onClosed.addListener(function() { - if (pinWindowDidWork != 1) { + pinWindowPreviousHandle = null; + + if (pinWindowPINValue == "") { console.log("[cackey] The PIN dialog was closed without resubmitting the request, treating it as a failure"); messageEvent.data.status = "error"; messageEvent.data.error = "PIN window closed without a PIN being provided"; @@ -174,10 +188,12 @@ if (nextFunction != null) { nextFunction(messageEvent.data, chromeCallback); } delete cackeyOutstandingCallbacks[messageEvent.data.id]; + + pinWindowPINValue = ""; return; } /* Index: build/chrome/pin.js ================================================================== --- build/chrome/pin.js +++ build/chrome/pin.js @@ -1,8 +1,7 @@ function clickOk() { - - parentWindow.pinWindowDidWork = 1; + parentWindow.pinWindowPINValue = document.getElementById('pin').value; window.close(); return; }