diff options
author | Florian Dold <florian.dold@gmail.com> | 2015-12-05 16:04:25 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2015-12-05 16:04:25 +0100 |
commit | a176c9148930eae42fc9bf6d5b973c68d6816295 (patch) | |
tree | 6d1cc4874e4725654ae42f352131abf17e86ba45 /extension | |
parent | 1089b40b1c03fa69c0e73dd43e4281aa96388171 (diff) | |
download | wallet-core-a176c9148930eae42fc9bf6d5b973c68d6816295.tar.xz |
Make wallet handshake conform more to spec.
Diffstat (limited to 'extension')
-rw-r--r-- | extension/content_scripts/notify.js | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/extension/content_scripts/notify.js b/extension/content_scripts/notify.js index 4a5c47c01..4f399b7f9 100644 --- a/extension/content_scripts/notify.js +++ b/extension/content_scripts/notify.js @@ -3,18 +3,28 @@ 'use strict'; -// Listen to messages from the backend. -chrome.runtime.onMessage.addListener( - function(request, sender, sendResponse) { - // do nothing, yet -}); - -if (document && document.body) -{ +// Install our handshake handlers only once the +// document is loaded +// TODO: change the spec to do it on the body +document.addEventListener("DOMContentLoaded", function(e) { + console.log("DOM fully loaded and parsed"); document.body.addEventListener('taler-checkout-probe', function(e) { let evt = new Event('taler-wallet-present'); document.body.dispatchEvent(evt); + console.log("merchant handshake done"); }); -} + document.body.addEventListener('taler-wire-probe', function(e) { + let evt = new Event('taler-wallet-present'); + document.body.dispatchEvent(evt); + console.log("bank handshake done"); + }); + document.body.addEventListener('taler-create-reserve', function(e) { + console.log("reserve creation " + JSON.stringify(e.detail)); + chrome.runtime.sendMessage({action:'new-reserve-request', detail:e.detail}, function(resp) { + console.log("got response"); + document.location.href = resp.url; + }); + }); +}); console.log("Taler wallet: content page loaded"); |