Bug 859764 - Part 6: Changes in Payment. r=ferjm, r=smaug
authorBevis Tseng <btseng@mozilla.com>
Mon, 19 Oct 2015 20:08:57 +0800
changeset 272624 5f4725e5f83b0e3f13030650b1164753e9e59874
parent 272623 f2fd072127111ba09ca1486f7e4984b66c96e66e
child 272625 83f811be5016f0c18e9bc75e86fe6d2b356b599b
push id29681
push userkwierso@gmail.com
push dateMon, 16 Nov 2015 23:39:08 +0000
treeherdermozilla-central@ffe020f91452 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersferjm, smaug
bugs859764
milestone45.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 859764 - Part 6: Changes in Payment. r=ferjm, r=smaug
dom/payment/PaymentProvider.js
dom/webidl/MozPaymentProvider.webidl
--- a/dom/payment/PaymentProvider.js
+++ b/dom/payment/PaymentProvider.js
@@ -226,41 +226,54 @@ PaymentProvider.prototype.removeSilentSm
     }
   } else if (_debug) {
     DEBUG("No callback found for " + aNumber);
   }
   return;
 };
 
 PaymentProvider.prototype._onSilentSms = function(aSubject, aTopic, aData) {
-  _debug && DEBUG("Got silent message! " + aSubject.sender + " - " + aSubject.body);
+  if (!aSubject || !(aSubject instanceof Ci.nsISmsMessage)) {
+    _debug && DEBUG("Invalid subject when receiving silent message!");
+    return;
+  }
 
-  let number = aSubject.sender;
+  let message = aSubject.QueryInterface(Ci.nsISmsMessage);
+
+  _debug && DEBUG("Got silent message! " + message.sender + " - " + message.body);
+
+  let number = message.sender;
   if (!number || this._silentNumbers.indexOf(number) == -1) {
     _debug && DEBUG("No observers for " + number);
     return;
   }
 
   // If the service ID is null it means that the payment provider asked the
   // user for her MSISDN, so we are in a MT only SMS auth flow. In this case
   // we manually set the service ID to the one corresponding with the SIM
   // that received the SMS.
   if (this._strategy.paymentServiceId === null) {
     let i = 0;
     while(i < gRil.numRadioInterfaces) {
-      if (this.iccInfo[i].iccId === aSubject.iccId) {
+      if (this.iccInfo[i].iccId === message.iccId) {
         this._strategy.paymentServiceId = i;
         break;
       }
       i++;
     }
   }
 
   this._silentSmsObservers[number].forEach(function(callback) {
-    callback(aSubject);
+    callback({
+      iccId: message.iccId,
+      sender: message.sender,
+      body: message.body,
+      timestamp: message.timestamp,
+      sentTimestamp: message.sentTimestamp
+    });
   });
 };
 
 PaymentProvider.prototype._cleanup = function() {
   if (!this._silentNumbers) {
     return;
   }
 
--- a/dom/webidl/MozPaymentProvider.webidl
+++ b/dom/webidl/MozPaymentProvider.webidl
@@ -1,23 +1,31 @@
 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* 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/.
  */
 
-callback SilentSmsCallback = void (optional MozSmsMessage message);
-
 dictionary PaymentIccInfo {
   DOMString mcc;
   DOMString mnc;
   DOMString iccId;
   boolean dataPrimary;
 };
 
+dictionary PaymentSmsMessage {
+  DOMString iccId;
+  DOMString sender;
+  DOMString body;
+  DOMTimeStamp timestamp;
+  DOMTimeStamp sentTimestamp;
+};
+
+callback SilentSmsCallback = void (optional PaymentSmsMessage message);
+
 [NavigatorProperty="mozPaymentProvider",
  NoInterfaceObject,
  HeaderFile="mozilla/dom/PaymentProviderUtils.h",
  Func="mozilla::dom::PaymentProviderUtils::EnabledForScope",
  JSImplementation="@mozilla.org/payment/provider;1"]
 interface PaymentProvider {
   readonly attribute DOMString? paymentServiceId;
   // We expose to the payment provider the information of all the SIMs