gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [taler-wallet-webex] branch master updated (f4ef4d63 -> 6aa


From: gnunet
Subject: [GNUnet-SVN] [taler-wallet-webex] branch master updated (f4ef4d63 -> 6aa929f2)
Date: Tue, 20 Feb 2018 15:13:15 +0100

This is an automated email from the git hooks/post-receive script.

dold pushed a change to branch master
in repository wallet-webex.

    from f4ef4d63 version bump
     new aa475735 fix file include pattern
     new 6aa929f2 Fix redirect for Firefox on Android

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 gulpfile.js            |  2 +-
 manifest.json          |  4 ++--
 src/webex/compat.ts    | 22 +++++++++++-----------
 src/webex/wxBackend.ts | 36 ++++++++++++++++++++++++++++++++----
 4 files changed, 46 insertions(+), 18 deletions(-)

diff --git a/gulpfile.js b/gulpfile.js
index f9ba97b7..2e4abfc9 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -73,7 +73,7 @@ const paths = {
     "emscripten/taler-emscripten-lib.js",
     "img/icon.png",
     "img/logo.png",
-    "src/**/*.{js,css,html}",
+    "src/webex/**/*.{js,css,html}",
   ],
   // for the source distribution
   extra: [
diff --git a/manifest.json b/manifest.json
index 60b2874d..b27fcd23 100644
--- a/manifest.json
+++ b/manifest.json
@@ -4,8 +4,8 @@
   "name": "GNU Taler Wallet (git)",
   "description": "Privacy preserving and transparent payments",
   "author": "GNU Taler Developers",
-  "version": "0.6.54",
-  "version_name": "0.5.0-pre7",
+  "version": "0.6.56",
+  "version_name": "0.5.0-pre9",
 
   "minimum_chrome_version": "51",
   "minimum_opera_version": "36",
diff --git a/src/webex/compat.ts b/src/webex/compat.ts
index f532c43b..30ffd4a8 100644
--- a/src/webex/compat.ts
+++ b/src/webex/compat.ts
@@ -14,15 +14,15 @@
  TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
  */
 
- /**
-  * Compatibility helpers needed for browsers that don't implement
-  * WebExtension APIs consistently.
-  */
+/**
+* Compatibility helpers needed for browsers that don't implement
+* WebExtension APIs consistently.
+*/
 
-  export function isFirefox(): boolean {
-      const rt = chrome.runtime as any;
-      if (typeof rt.getBrowserInfo === "function") {
-          return true;
-      }
-      return false;
-  }
+export function isFirefox(): boolean {
+    const rt = chrome.runtime as any;
+    if (typeof rt.getBrowserInfo === "function") {
+        return true;
+    }
+    return false;
+}
diff --git a/src/webex/wxBackend.ts b/src/webex/wxBackend.ts
index f1116637..d7c43225 100644
--- a/src/webex/wxBackend.ts
+++ b/src/webex/wxBackend.ts
@@ -44,6 +44,8 @@ import {
   Wallet,
 } from "../wallet";
 
+import { isFirefox } from "./compat";
+
 import {
   PurchaseRecord,
   Stores,
@@ -449,7 +451,21 @@ async function talerPay(fields: any, url: string, tabId: 
number): Promise<string
 }
 
 
-function makeSyncWalletRedirect(url: string, params?: {[name: string]: string 
| undefined}): object {
+function getTab(tabId: number): Promise<chrome.tabs.Tab> {
+  return new Promise((resolve, reject) => {
+    chrome.tabs.get(tabId, (tab: chrome.tabs.Tab) => resolve(tab));
+  });
+}
+
+
+function waitMs(timeoutMs: number): Promise<void> {
+  return new Promise((resolve, reject) => {
+      chrome.extension.getBackgroundPage().setTimeout(() => resolve(), 
timeoutMs);
+  });
+}
+
+
+function makeSyncWalletRedirect(url: string, tabId: number, oldUrl: string, 
params?: {[name: string]: string | undefined}): object {
   const innerUrl = new URI(chrome.extension.getURL("/src/webex/pages/" + url));
   if (params) {
     for (const key in params) {
@@ -460,6 +476,18 @@ function makeSyncWalletRedirect(url: string, params?: 
{[name: string]: string |
   }
   const outerUrl = new 
URI(chrome.extension.getURL("/src/webex/pages/redirect.html"));
   outerUrl.addSearch("url", innerUrl);
+  if (isFirefox()) {
+    // Some platforms don't support the sync redirect (yet), so fall back to
+    // async redirect after a timeout.
+    const doit = async() => {
+      await waitMs(150);
+      const tab = await getTab(tabId);
+      if (tab.url === oldUrl) {
+        chrome.tabs.update(tabId, { url: outerUrl.href() });
+      }
+    };
+    doit();
+  }
   return { redirectUrl: outerUrl.href() };
 }
 
@@ -512,7 +540,7 @@ function handleHttpPayment(headerList: 
chrome.webRequest.HttpHeader[], url: stri
   }
   // Synchronous fast path for new contract
   if (fields.contract_url) {
-    return makeSyncWalletRedirect("confirm-contract.html", {
+    return makeSyncWalletRedirect("confirm-contract.html", tabId, url, {
       contractUrl: fields.contract_url,
       sessionId: fields.session_id,
       resourceUrl: fields.resource_url,
@@ -521,13 +549,13 @@ function handleHttpPayment(headerList: 
chrome.webRequest.HttpHeader[], url: stri
 
   // Synchronous fast path for tip
   if (fields.tip) {
-    return makeSyncWalletRedirect("tip.html", { tip_token: fields.tip });
+    return makeSyncWalletRedirect("tip.html", tabId, url, { tip_token: 
fields.tip });
   }
 
   // Synchronous fast path for refund
   if (fields.refund_url) {
     console.log("processing refund");
-    return makeSyncWalletRedirect("refund.html", { refundUrl: 
fields.refund_url });
+    return makeSyncWalletRedirect("refund.html", tabId, url, { refundUrl: 
fields.refund_url });
   }
 
   // We need to do some asynchronous operation, we can't directly redirect

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]