Index: build/chrome/build-deps ================================================================== --- build/chrome/build-deps +++ build/chrome/build-deps @@ -237,10 +237,12 @@ #ifdef __cplusplus #include #include void pcscNaClInit(pp::Instance *instance, pp::Core *core); +bool pcscNaClHandleMessage(const pp::Var &message); + #endif #endif _EOF_ # Copy out JavaScript files for later use @@ -300,25 +302,30 @@ ## Create initialization procedure, since it lacks one cat << \_EOF_ > third_party/pcsc-lite/client-side/pcsc_nacl_init.cc #include #include +#include #include #include "pcsc_nacl_global.h" #include "dom_requests_manager.h" #include "pcsc_nacl.h" + +static DomRequestsManager *pcscNaClDRM = NULL; void pcscNaClInit(pp::Instance *instance, pp::Core *core) { DomRequestsManager::PpDelegateImpl *drmDelegateImpl; PcscNacl *pcsc_nacl; fprintf(stderr, "Called pcscNaClInit()\n"); drmDelegateImpl = new DomRequestsManager::PpDelegateImpl(instance, core); - pcsc_nacl = new PcscNacl(new DomRequestsManager("pcsc-nacl", drmDelegateImpl), "khpfeaanjngmcnplbdlpegiifgpfgdco", "CACKey"); + pcscNaClDRM = new DomRequestsManager("pcsc-nacl", drmDelegateImpl); + + pcsc_nacl = new PcscNacl(pcscNaClDRM, "khpfeaanjngmcnplbdlpegiifgpfgdco", "CACKey"); fprintf(stderr, "New PcscNacl object = %p\n", pcsc_nacl); if (!pcsc_nacl->Initialize()) { fprintf(stderr, "PcscNacl->Initialize() failed !"); @@ -332,10 +339,14 @@ fprintf(stderr, "Returning.\n"); return; } + +bool pcscNaClHandleMessage(const pp::Var &message) { + return(pcscNaClDRM->HandleMessage(message)); +} _EOF_ ## Make it make -C third_party/pcsc-lite/client-side || exit 1 Index: build/chrome/cackey-chrome-init.cc ================================================================== --- build/chrome/cackey-chrome-init.cc +++ build/chrome/cackey-chrome-init.cc @@ -89,10 +89,12 @@ /* * Send the reply back to the requestor, hopefully they are waiting for this message */ PostMessage(*reply); + delete message; + return; } virtual void HandleMessage(const pp::Var& messagePlain) { pp::VarDictionary *message; @@ -100,10 +102,12 @@ /* * The incoming message must be a dictionary */ if (!messagePlain.is_dictionary()) { + pcscNaClHandleMessage(messagePlain); + return; } /* * Process the appropriate command from the incoming message @@ -112,22 +116,34 @@ /* * Verify that this message is destined for us */ if (!message->HasKey("target")) { + delete message; + + pcscNaClHandleMessage(messagePlain); + return; } target = message->Get("target"); if (target.AsString() != "cackey") { + delete message; + + pcscNaClHandleMessage(messagePlain); + return; } /* * Determine what we are being asked to do */ if (!message->HasKey("command")) { + delete message; + + pcscNaClHandleMessage(messagePlain); + return; } /* * Process the request in another thread Index: build/chrome/cackey.js ================================================================== --- build/chrome/cackey.js +++ build/chrome/cackey.js @@ -313,13 +313,17 @@ function cackeyInit() { var elementEmbed; /* Verify that we can register callbacks */ if (!chrome.certificateProvider) { - console.error("This extension only works on ChromeOS!"); + if (!GoogleSmartCard.IS_DEBUG_BUILD) { + console.error("This extension only works on ChromeOS!"); - return; + return; + } else { + console.log("This extension only works on ChromeOS, but you appear to be debugging it -- trying anyway."); + } } if (cackeyHandle != null) { return; } @@ -332,15 +336,15 @@ elementEmbed.id = "cackeyModule"; elementEmbed.addEventListener('error', function(messageEvent) { console.error("Error loading CACKey PNaCl Module: " + messageEvent.data); }, true); elementEmbed.addEventListener('load', cackeyInitLoaded, true); elementEmbed.addEventListener('message', function(messageEvent) { console.log("Start message"); console.log(messageEvent.data); console.log("End message"); }, true); - new GoogleSmartCard.PcscNacl(elementEmbed); - - document.body.appendChild(elementEmbed) - cackeyHandle = elementEmbed; + + document.body.appendChild(cackeyHandle) + + new GoogleSmartCard.PcscNacl(cackeyHandle); } function cackeyListCertificates(chromeCallback) { var certificates = [];