Bug 1251373 - Remove moz payment API support. r?margaret draft
authorJoel Maher <jmaher@mozilla.com>
Thu, 25 Feb 2016 13:08:50 -0800
changeset 334692 573715b904bbdac8f121067f32fb049ff1262cfa
parent 334691 525acdb20f3ae457cd7d05e2a4c4fafa63dab73d
child 514970 24ec457695a2aa347517693f3cf9ea3d17714920
push id11610
push userjmaher@mozilla.com
push dateThu, 25 Feb 2016 21:11:45 +0000
reviewersmargaret
bugs1251373
milestone47.0a1
Bug 1251373 - Remove moz payment API support. r?margaret MozReview-Commit-ID: IW63XQDyB16
mobile/android/app/mobile.js
mobile/android/chrome/content/browser.js
mobile/android/chrome/content/payment.xhtml
mobile/android/chrome/jar.mn
mobile/android/components/MobileComponents.manifest
mobile/android/components/PaymentProviderStrategy.js
mobile/android/components/PaymentsUI.js
mobile/android/components/moz.build
mobile/android/confvars.sh
mobile/android/installer/package-manifest.in
mobile/android/locales/en-US/chrome/payments.properties
mobile/android/locales/jar.mn
mobile/android/themes/core/jar.mn
mobile/android/themes/core/payment.css
--- a/mobile/android/app/mobile.js
+++ b/mobile/android/app/mobile.js
@@ -821,25 +821,16 @@ pref("browser.contentHandlers.types.1.ur
 pref("browser.contentHandlers.types.1.type", "application/vnd.mozilla.maybe.feed");
 pref("browser.contentHandlers.types.2.title", "chrome://browser/locale/region.properties");
 pref("browser.contentHandlers.types.2.uri", "chrome://browser/locale/region.properties");
 pref("browser.contentHandlers.types.2.type", "application/vnd.mozilla.maybe.feed");
 pref("browser.contentHandlers.types.3.title", "chrome://browser/locale/region.properties");
 pref("browser.contentHandlers.types.3.uri", "chrome://browser/locale/region.properties");
 pref("browser.contentHandlers.types.3.type", "application/vnd.mozilla.maybe.feed");
 
-// WebPayment
-pref("dom.mozPay.enabled", true);
-
-pref("dom.payment.provider.0.name", "Firefox Marketplace");
-pref("dom.payment.provider.0.description", "marketplace.firefox.com");
-pref("dom.payment.provider.0.uri", "https://marketplace.firefox.com/mozpay/?req=");
-pref("dom.payment.provider.0.type", "mozilla/payments/pay/v1");
-pref("dom.payment.provider.0.requestMethod", "GET");
-
 // Shortnumber matching needed for e.g. Brazil:
 // 01187654321 can be found with 87654321
 pref("dom.phonenumber.substringmatching.BR", 8);
 pref("dom.phonenumber.substringmatching.CO", 10);
 pref("dom.phonenumber.substringmatching.VE", 7);
 
 // Enable hardware-accelerated Skia canvas
 pref("gfx.canvas.azure.backends", "skia");
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -585,17 +585,16 @@ var BrowserApp = {
 
     // Notify Java that Gecko has loaded.
     Messaging.sendRequest({ type: "Gecko:Ready" });
 
     this.deck.addEventListener("DOMContentLoaded", function BrowserApp_delayedStartup() {
       BrowserApp.deck.removeEventListener("DOMContentLoaded", BrowserApp_delayedStartup, false);
 
       InitLater(() => Cu.import("resource://gre/modules/NotificationDB.jsm"));
-      InitLater(() => Cu.import("resource://gre/modules/Payment.jsm"));
       InitLater(() => Cu.import("resource://gre/modules/PresentationDeviceInfoManager.jsm"));
 
       InitLater(() => Services.obs.notifyObservers(window, "browser-delayed-startup-finished", ""));
       InitLater(() => Messaging.sendRequest({ type: "Gecko:DelayedStartup" }));
 
       if (AppConstants.NIGHTLY_BUILD) {
         InitLater(() => WebcompatReporter.init());
       }
deleted file mode 100644
--- a/mobile/android/chrome/content/payment.xhtml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!DOCTYPE html [
-  <!ENTITY % htmlDTD
-    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
-    "DTD/xhtml1-strict.dtd">
-  %htmlDTD;
-  <!ENTITY % globalDTD SYSTEM "chrome://global/locale/global.dtd">
-  %globalDTD;
-  <!ENTITY % browserDTD SYSTEM "chrome://browser/locale/browser.dtd" >
-  %browserDTD;
-]>
-
-<!-- This Source Code Form is subject to the terms of the Mozilla Public
-   - License, v. 2.0. If a copy of the MPL was not distributed with this
-   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
-
-<html xmlns="http://www.w3.org/1999/xhtml">
-  <head>
-    <title></title>
-    <meta name="viewport" content="width=device-width; user-scalable=0" />
-    <link rel="icon" type="image/png" sizes="64x64" href="chrome://branding/content/favicon64.png" />
-    <link rel="stylesheet" type="text/css" href="chrome://browser/skin/payment.css" media="all" />
-  </head>
-
-  <body dir="&locale.dir;">
-    <iframe id="payflow"></iframe>
-  </body>
-</html>
--- a/mobile/android/chrome/jar.mn
+++ b/mobile/android/chrome/jar.mn
@@ -62,17 +62,14 @@ chrome.jar:
 #endif
   content/aboutAccounts.xhtml          (content/aboutAccounts.xhtml)
   content/aboutAccounts.js             (content/aboutAccounts.js)
   content/aboutLogins.xhtml            (content/aboutLogins.xhtml)
   content/aboutLogins.js               (content/aboutLogins.js)
 #ifdef NIGHTLY_BUILD
   content/WebcompatReporter.js         (content/WebcompatReporter.js)
 #endif
-#ifdef MOZ_PAY
-  content/payment.xhtml                (content/payment.xhtml)
-#endif
 
 % content branding %content/branding/
 
 % override chrome://global/content/config.xul chrome://browser/content/config.xhtml
 % override chrome://global/content/netError.xhtml chrome://browser/content/netError.xhtml
 % override chrome://mozapps/content/extensions/extensions.xul chrome://browser/content/aboutAddons.xhtml
--- a/mobile/android/components/MobileComponents.manifest
+++ b/mobile/android/components/MobileComponents.manifest
@@ -94,22 +94,16 @@ contract @mozilla.org/addons/blocklist-p
 component {cbc08081-49b6-4561-9c18-a7707a50bda1} NSSDialogService.js
 contract @mozilla.org/nsCertificateDialogs;1 {cbc08081-49b6-4561-9c18-a7707a50bda1}
 contract @mozilla.org/nsClientAuthDialogs;1 {cbc08081-49b6-4561-9c18-a7707a50bda1}
 
 # SiteSpecificUserAgent.js
 component {d5234c9d-0ee2-4b3c-9da3-18be9e5cf7e6} SiteSpecificUserAgent.js
 contract @mozilla.org/dom/site-specific-user-agent;1 {d5234c9d-0ee2-4b3c-9da3-18be9e5cf7e6}
 
-# Payments
-component {3c6c9575-f57e-427b-a8aa-57bc3cbff48f} PaymentsUI.js
-contract @mozilla.org/payment/ui-glue;1 {3c6c9575-f57e-427b-a8aa-57bc3cbff48f}
-component {a497520d-37e7-4f18-8c27-5b8938e9490d} PaymentProviderStrategy.js
-contract @mozilla.org/payment/provider-strategy;1 {a497520d-37e7-4f18-8c27-5b8938e9490d}
-
 # FilePicker.js
 component {18a4e042-7c7c-424b-a583-354e68553a7f} FilePicker.js
 contract @mozilla.org/filepicker;1 {18a4e042-7c7c-424b-a583-354e68553a7f}
 
 #ifndef RELEASE_BUILD
 # TabSource.js
 component {5850c76e-b916-4218-b99a-31f004e0a7e7} TabSource.js
 contract @mozilla.org/tab-source-service;1 {5850c76e-b916-4218-b99a-31f004e0a7e7}
deleted file mode 100644
--- a/mobile/android/components/PaymentProviderStrategy.js
+++ /dev/null
@@ -1,64 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-"use strict";
-
-const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
-
-Cu.import("resource://gre/modules/XPCOMUtils.jsm");
-Cu.import("resource://gre/modules/Services.jsm");
-Cu.import("resource://gre/modules/JNI.jsm");
-
-function PaymentProviderStrategy() {
-}
-
-PaymentProviderStrategy.prototype = {
-  get paymentServiceId() {
-    // XXX Multi-SIM support for Android payments. Bug 1112052
-    return null;
-  },
-
-  set paymentServiceId(aServiceId) {
-    // XXX Multi-SIM support for Android payments. Bug 1112052
-  },
-
-  _getNetworkInfo: function(type) {
-    let jenv = JNI.GetForThread();
-    let jMethodName = "get" + type.toUpperCase();
-    let jGeckoNetworkManager = JNI.LoadClass(
-      jenv, "org/mozilla/gecko/GeckoNetworkManager", {
-      static_methods: [
-        { name: jMethodName, sig: "()I" },
-      ],
-    });
-    let val = jGeckoNetworkManager[jMethodName]();
-    JNI.UnloadClasses(jenv);
-
-    if (val < 0) {
-      return null;
-    }
-    return val;
-  },
-
-  get iccInfo() {
-    if (!this._iccInfo) {
-      // XXX Multi-SIM support for Android payments. Bug 1112052
-      this._iccInfo = [{
-        mcc: this._getNetworkInfo("mcc"),
-        mnc: this._getNetworkInfo("mnc")
-      }];
-    }
-    return this._iccInfo;
-  },
-
-  cleanup: function() {
-    // Nothing to do here.
-  },
-
-  classID: Components.ID("{a497520d-37e7-4f18-8c27-5b8938e9490d}"),
-
-  QueryInterface: XPCOMUtils.generateQI([Ci.nsIPaymentProviderStrategy])
-};
-
-this.NSGetFactory = XPCOMUtils.generateNSGetFactory([PaymentProviderStrategy]);
deleted file mode 100644
--- a/mobile/android/components/PaymentsUI.js
+++ /dev/null
@@ -1,153 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-"use strict";
-
-const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
-
-Cu.import("resource://gre/modules/XPCOMUtils.jsm");
-Cu.import("resource://gre/modules/Services.jsm");
-Cu.import("resource://gre/modules/JNI.jsm");
-Cu.import("resource://gre/modules/Promise.jsm");
-
-XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
-                                   "@mozilla.org/childprocessmessagemanager;1",
-                                   "nsIMessageSender");
-
-var paymentTabs = {};
-var cancelTabCallbacks = {};
-
-function PaymentUI() {
-}
-
-PaymentUI.prototype = {
-  get bundle() {
-    if (!this._bundle) {
-      this._bundle = Services.strings.createBundle("chrome://browser/locale/payments.properties");
-    }
-    return this._bundle;
-  },
-
-  _error: function(aCallback) {
-    return function _error(id, msg) {
-      if (aCallback) {
-        aCallback.onresult(id, msg);
-      }
-    };
-  },
-
-  // nsIPaymentUIGlue
-
-  confirmPaymentRequest: function confirmPaymentRequest(aRequestId,
-                                                        aRequests,
-                                                        aSuccessCb,
-                                                        aErrorCb) {
-    let _error = this._error(aErrorCb);
-
-    let listItems = [];
-
-    // If there's only one payment provider that will work, just move on without prompting the user.
-    if (aRequests.length == 1) {
-      aSuccessCb.onresult(aRequestId, aRequests[0].type);
-      return;
-    }
-
-    // Otherwise, let the user select a payment provider from a list.
-    for (let i = 0; i < aRequests.length; i++) {
-      let request = aRequests[i];
-      let requestText = request.providerName;
-      if (request.productPrice) {
-        requestText += " (" + request.productPrice[0].amount + " " +
-                              request.productPrice[0].currency + ")";
-      }
-      listItems.push({ label: requestText });
-    }
-
-    let p = new Prompt({
-      window: null,
-      title: this.bundle.GetStringFromName("payments.providerdialog.title"),
-    }).setSingleChoiceItems(listItems).show(function(data) {
-      if (data.button > -1 && aSuccessCb) {
-        aSuccessCb.onresult(aRequestId, aRequests[data.button].type);
-      } else {
-        _error(aRequestId, "USER_CANCELED");
-      }
-    });
-  },
-
-  showPaymentFlow: function showPaymentFlow(aRequestId,
-                                            aPaymentFlowInfo,
-                                            aErrorCb) {
-    function paymentCanceled(aErrorCb, aRequestId) {
-      return function() {
-        aErrorCb.onresult(aRequestId, "DIALOG_CLOSED_BY_USER");
-      }
-    }
-
-    let _error = this._error(aErrorCb);
-
-    // We ask the UI to browse to the selected payment flow.
-    let content = Services.wm.getMostRecentWindow("navigator:browser");
-    if (!content) {
-      _error(aRequestId, "NO_CONTENT_WINDOW");
-      return;
-    }
-
-    // TODO: For now, known payment providers (BlueVia and Mozilla Market)
-    // only accepts the JWT by GET, so we just add it to the URI.
-    // https://github.com/mozilla-b2g/gaia/blob/master/apps/system/js/payment.js
-    let tab = content.BrowserApp
-                     .addTab("chrome://browser/content/payment.xhtml");
-    tab.browser.addEventListener("DOMContentLoaded", function onloaded() {
-      tab.browser.removeEventListener("DOMContentLoaded", onloaded);
-      let document = tab.browser.contentDocument;
-      let frame = document.getElementById("payflow");
-      frame.setAttribute("mozbrowser", true);
-      let docshell = frame.contentWindow
-                          .QueryInterface(Ci.nsIInterfaceRequestor)
-                          .getInterface(Ci.nsIWebNavigation)
-                          .QueryInterface(Ci.nsIDocShell);
-      docshell.paymentRequestId = aRequestId;
-      frame.src = aPaymentFlowInfo.uri + aPaymentFlowInfo.jwt;
-      document.title = aPaymentFlowInfo.description || aPaymentFlowInfo.name ||
-                       frame.src;
-    });
-    paymentTabs[aRequestId] = tab;
-    cancelTabCallbacks[aRequestId] = paymentCanceled(aErrorCb, aRequestId);
-
-    // Fail the payment if the tab is closed on its own
-    tab.browser.addEventListener("TabClose", cancelTabCallbacks[aRequestId]);
-  },
-
-  closePaymentFlow: function closePaymentFlow(aRequestId) {
-    if (!paymentTabs[aRequestId]) {
-      return Promise.reject();
-    }
-
-    let deferred = Promise.defer();
-
-    paymentTabs[aRequestId].browser.removeEventListener(
-      "TabClose",
-      cancelTabCallbacks[aRequestId]
-    );
-    delete cancelTabCallbacks[aRequestId];
-
-    // We ask the UI to close the selected payment flow.
-    let content = Services.wm.getMostRecentWindow("navigator:browser");
-    if (content) {
-      content.BrowserApp.closeTab(paymentTabs[aRequestId]);
-    }
-    paymentTabs[aRequestId] = null;
-
-    deferred.resolve();
-
-    return deferred.promise;
-  },
-
-  classID: Components.ID("{3c6c9575-f57e-427b-a8aa-57bc3cbff48f}"),
-
-  QueryInterface: XPCOMUtils.generateQI([Ci.nsIPaymentUIGlue])
-}
-
-this.NSGetFactory = XPCOMUtils.generateNSGetFactory([PaymentUI]);
--- a/mobile/android/components/moz.build
+++ b/mobile/android/components/moz.build
@@ -33,24 +33,15 @@ if not CONFIG['MOZ_B2GDROID']:
         'FilePicker.js',
         'HelperAppDialog.js',
         'PromptService.js',
         'SessionStore.js',
         'SiteSpecificUserAgent.js',
         'WebappsUpdateTimer.js',
     ]
 
-if CONFIG['MOZ_PAY']:
-    if not CONFIG['MOZ_B2GDROID']:
-        EXTRA_COMPONENTS += [
-            'PaymentProviderStrategy.js',
-        ]
-    EXTRA_COMPONENTS += [
-        'PaymentsUI.js'
-    ]
-
 # Keep it this way if at all possible.  If you need preprocessing,
 # consider adding fields to AppConstants.jsm.
 EXTRA_PP_COMPONENTS += [
     'MobileComponents.manifest',
 ]
 
 DIRS += ['build']
--- a/mobile/android/confvars.sh
+++ b/mobile/android/confvars.sh
@@ -50,19 +50,16 @@ MOZ_APP_ID={aa3c5121-dab2-40e2-81ca-7ea2
 MOZ_APP_STATIC_INI=1
 
 # Enable on-demand decompression.  This requires a host compile toolchain to
 # build szip to use during packaging.
 if test "$COMPILE_ENVIRONMENT"; then
 MOZ_ENABLE_SZIP=1
 fi
 
-# Enable navigator.mozPay
-MOZ_PAY=1
-
 # Enable UI for healthreporter
 MOZ_SERVICES_HEALTHREPORT=1
 
 # Enable runtime locale switching.
 MOZ_LOCALE_SWITCHER=1
 
 # Enable second screen and casting support for external devices.
 MOZ_DEVICES=1
@@ -116,9 +113,9 @@ MOZ_ADDON_SIGNING=1
 # Note: The framework is always included in the app. This flag controls
 # usage of the framework.
 MOZ_SWITCHBOARD=1
 
 # Enable DLC background service and stop shipping fonts in Nightly
 if test "$NIGHTLY_BUILD"; then
   MOZ_ANDROID_DOWNLOAD_CONTENT_SERVICE=1
   MOZ_ANDROID_EXCLUDE_FONTS=1
-fi
\ No newline at end of file
+fi
--- a/mobile/android/installer/package-manifest.in
+++ b/mobile/android/installer/package-manifest.in
@@ -123,17 +123,16 @@
 @BINPATH@/components/dom_geolocation.xpt
 @BINPATH@/components/dom_media.xpt
 @BINPATH@/components/dom_messages.xpt
 @BINPATH@/components/dom_network.xpt
 @BINPATH@/components/dom_notification.xpt
 @BINPATH@/components/dom_html.xpt
 @BINPATH@/components/dom_offline.xpt
 @BINPATH@/components/dom_json.xpt
-@BINPATH@/components/dom_payment.xpt
 @BINPATH@/components/dom_power.xpt
 @BINPATH@/components/dom_quota.xpt
 @BINPATH@/components/dom_range.xpt
 @BINPATH@/components/dom_security.xpt
 @BINPATH@/components/dom_settings.xpt
 @BINPATH@/components/dom_permissionsettings.xpt
 @BINPATH@/components/dom_sidebar.xpt
 @BINPATH@/components/dom_mobilemessage.xpt
@@ -544,23 +543,16 @@
 @BINPATH@/components/MobileComponents.manifest
 @BINPATH@/components/MobileComponents.xpt
 @BINPATH@/components/NSSDialogService.js
 @BINPATH@/components/PromptService.js
 @BINPATH@/components/SessionStore.js
 @BINPATH@/components/SiteSpecificUserAgent.js
 @BINPATH@/components/Snippets.js
 
-@BINPATH@/components/Payment.js
-@BINPATH@/components/PaymentFlowInfo.js
-@BINPATH@/components/PaymentProvider.js
-@BINPATH@/components/Payment.manifest
-@BINPATH@/components/PaymentsUI.js
-@BINPATH@/components/PaymentProviderStrategy.js
-
 @BINPATH@/components/XPIDialogService.js
 
 #ifdef ENABLE_MARIONETTE
 @BINPATH@/chrome/marionette@JAREXT@
 @BINPATH@/chrome/marionette.manifest
 @BINPATH@/components/MarionetteComponents.manifest
 @BINPATH@/components/marionettecomponent.js
 #endif
deleted file mode 100644
--- a/mobile/android/locales/en-US/chrome/payments.properties
+++ /dev/null
@@ -1,1 +0,0 @@
-payments.providerdialog.title="Pay using"
--- a/mobile/android/locales/jar.mn
+++ b/mobile/android/locales/jar.mn
@@ -31,17 +31,16 @@
   locale/@AB_CD@/browser/checkbox.dtd             (%chrome/checkbox.dtd)
   locale/@AB_CD@/browser/notification.dtd         (%chrome/notification.dtd)
   locale/@AB_CD@/browser/pippki.properties        (%chrome/pippki.properties)
   locale/@AB_CD@/browser/sync.dtd                 (%chrome/sync.dtd)
   locale/@AB_CD@/browser/sync.properties          (%chrome/sync.properties)
   locale/@AB_CD@/browser/prompt.dtd               (%chrome/prompt.dtd)
   locale/@AB_CD@/browser/feedback.dtd             (%chrome/feedback.dtd)
   locale/@AB_CD@/browser/phishing.dtd             (%chrome/phishing.dtd)
-  locale/@AB_CD@/browser/payments.properties      (%chrome/payments.properties)
   locale/@AB_CD@/browser/handling.properties      (%chrome/handling.properties)
   locale/@AB_CD@/browser/webapp.properties        (%chrome/webapp.properties)
   locale/@AB_CD@/browser/aboutLogins.dtd          (%chrome/aboutLogins.dtd)
   locale/@AB_CD@/browser/aboutLogins.properties  (%chrome/aboutLogins.properties)
 #ifdef NIGHTLY_BUILD
   locale/@AB_CD@/browser/webcompatReporter.properties (%chrome/webcompatReporter.properties)
 #endif
 % resource search-plugins chrome://browser/locale/searchplugins/
--- a/mobile/android/themes/core/jar.mn
+++ b/mobile/android/themes/core/jar.mn
@@ -41,21 +41,16 @@ chrome.jar:
 % override chrome://global/skin/aboutMemory.css chrome://browser/skin/aboutMemory.css
 % override chrome://global/skin/aboutReader.css chrome://browser/skin/aboutReader.css
 % override chrome://global/skin/aboutReaderContent.css chrome://browser/skin/aboutReaderContent.css
 % override chrome://global/skin/aboutReaderControls.css chrome://browser/skin/aboutReaderControls.css
 % override chrome://global/skin/aboutSupport.css chrome://browser/skin/aboutSupport.css
 % override chrome://global/skin/media/videocontrols.css chrome://browser/skin/touchcontrols.css
 % override chrome://global/skin/netError.css chrome://browser/skin/netError.css
 
-#ifdef MOZ_PAY
-  skin/payment.css                         (payment.css)
-#endif
-#
-
   skin/aboutLogins.css                      (aboutLogins.css)
 
   skin/images/search.png                    (images/search.png)
   skin/images/lock.png                      (images/lock.png)
   skin/images/textfield.png                 (images/textfield.png)
 
   skin/images/5stars.png                    (images/5stars.png)
   skin/images/amo-logo.png                  (images/amo-logo.png)
deleted file mode 100644
--- a/mobile/android/themes/core/payment.css
+++ /dev/null
@@ -1,10 +0,0 @@
-#payflow {
-  position: fixed;
-  border: 0;
-  top: 0;
-  left: 0;
-  right: 0;
-  bottom: 0;
-  width: 100%;
-  height: 100%;
-}