Bug 1441752 - Adding an new attribute regionCode in PaymentAddress. r=baku
authorEden Chuang <echuang@mozilla.com>
Fri, 28 Sep 2018 12:21:59 +0200
changeset 495646 c29045d2314381fe6fd9e95c4635e5e0e02595ee
parent 495645 34e369fb83b50018f760b6cc619f3c15808e5d1c
child 495647 db490391893fe385398cae8e82de0cae55e916b6
push id9984
push userffxbld-merge
push dateMon, 15 Oct 2018 21:07:35 +0000
treeherdermozilla-beta@183d27ea8570 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1441752
milestone64.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 1441752 - Adding an new attribute regionCode in PaymentAddress. r=baku
browser/components/payments/content/paymentDialogWrapper.js
dom/interfaces/payments/nsIPaymentAddress.idl
dom/payments/BasicCardPayment.cpp
dom/payments/PaymentAddress.cpp
dom/payments/PaymentAddress.h
dom/payments/PaymentRequest.cpp
dom/payments/PaymentRequest.h
dom/payments/PaymentRequestData.cpp
dom/payments/PaymentRequestData.h
dom/payments/PaymentRequestManager.cpp
dom/payments/ipc/PPaymentRequest.ipdl
dom/payments/ipc/PaymentRequestParent.cpp
dom/webidl/PaymentAddress.webidl
--- a/browser/components/payments/content/paymentDialogWrapper.js
+++ b/browser/components/payments/content/paymentDialogWrapper.js
@@ -262,16 +262,17 @@ var paymentDialogWrapper = {
                                    billingAddress);
     return basicCardResponseData;
   },
 
   createPaymentAddress({
     country = "",
     addressLines = [],
     region = "",
+    regionCode = "",
     city = "",
     dependentLocality = "",
     postalCode = "",
     sortingCode = "",
     organization = "",
     recipient = "",
     phone = "",
   }) {
@@ -281,16 +282,17 @@ var paymentDialogWrapper = {
     for (let line of addressLines) {
       const address = Cc["@mozilla.org/supports-string;1"].createInstance(Ci.nsISupportsString);
       address.data = line;
       addressLine.appendElement(address);
     }
     paymentAddress.init(country,
                         addressLine,
                         region,
+                        regionCode,
                         city,
                         dependentLocality,
                         postalCode,
                         sortingCode,
                         organization,
                         recipient,
                         phone);
     return paymentAddress;
--- a/dom/interfaces/payments/nsIPaymentAddress.idl
+++ b/dom/interfaces/payments/nsIPaymentAddress.idl
@@ -8,27 +8,29 @@
 interface nsIArray;
 
 [builtinclass, scriptable, uuid(49a02241-7e48-477a-9345-9f246925dcb3)]
 interface nsIPaymentAddress : nsISupports
 {
   readonly attribute AString country;
   readonly attribute nsIArray addressLine;
   readonly attribute AString region;
+  readonly attribute AString regionCode;
   readonly attribute AString city;
   readonly attribute AString dependentLocality;
   readonly attribute AString postalCode;
   readonly attribute AString sortingCode;
   readonly attribute AString organization;
   readonly attribute AString recipient;
   readonly attribute AString phone;
 
   void init(in AString aCountry,
             in nsIArray aAddressLine,
             in AString aRegion,
+            in AString aRegionCode,
             in AString aCity,
             in AString aDependentLocality,
             in AString aPostalCode,
             in AString aSortingCode,
             in AString aOrganization,
             in AString aRecipient,
             in AString aPhone);
 };
--- a/dom/payments/BasicCardPayment.cpp
+++ b/dom/payments/BasicCardPayment.cpp
@@ -31,16 +31,17 @@ namespace dom {
 #define CardNumber NS_LITERAL_STRING("cardNumber")
 #define ExpiryMonth NS_LITERAL_STRING("expiryMonth")
 #define ExpiryYear NS_LITERAL_STRING("expiryYear")
 #define CardSecurityCode NS_LITERAL_STRING("cardSecurityCode")
 
 #define Country NS_LITERAL_STRING("country")
 #define AddressLine NS_LITERAL_STRING("addressLine")
 #define Region NS_LITERAL_STRING("region")
+#define RegionCode NS_LITERAL_STRING("regionCode")
 #define City NS_LITERAL_STRING("city")
 #define DependentLocality NS_LITERAL_STRING("dependentLocality")
 #define PostalCode NS_LITERAL_STRING("postalCode")
 #define SortingCode NS_LITERAL_STRING("sortingCode")
 #define Organization NS_LITERAL_STRING("organization")
 #define Recipient NS_LITERAL_STRING("recipient")
 #define Phone NS_LITERAL_STRING("phone")
 
@@ -109,16 +110,17 @@ bool IsBasicCardKey(const nsAString& aKe
          CardSecurityCode.Equals(aKey);
 }
 
 bool IsAddressKey(const nsAString& aKey)
 {
   return Country.Equals(aKey) ||
          AddressLine.Equals(aKey) ||
          Region.Equals(aKey) ||
+         RegionCode.Equals(aKey) ||
          City.Equals(aKey) ||
          DependentLocality.Equals(aKey) ||
          PostalCode.Equals(aKey) ||
          SortingCode.Equals(aKey) ||
          Organization.Equals(aKey) ||
          Recipient.Equals(aKey) ||
          Phone.Equals(aKey);
 }
@@ -253,16 +255,17 @@ BasicCardService::EncodeBasicCardData(co
     nsCOMPtr<nsISupportsString> address = do_QueryElementAt(addressLine, index);
     MOZ_ASSERT(address);
     nsAutoString addressString;
     NS_ENSURE_SUCCESS(address->GetData(addressString), NS_ERROR_FAILURE);
     addressLineString += addressString + AddressLineSpliter;
   }
   EncodeBasicCardProperty(AddressLine ,addressLineString , aResult);
   EncodeAddressProperty(aBillingAddress, Region, aResult);
+  EncodeAddressProperty(aBillingAddress, RegionCode, aResult);
   EncodeAddressProperty(aBillingAddress, City, aResult);
   EncodeAddressProperty(aBillingAddress, DependentLocality, aResult);
   EncodeAddressProperty(aBillingAddress, PostalCode, aResult);
   EncodeAddressProperty(aBillingAddress, SortingCode, aResult);
   EncodeAddressProperty(aBillingAddress, Organization, aResult);
   EncodeAddressProperty(aBillingAddress, Recipient, aResult);
   EncodeAddressProperty(aBillingAddress, Phone, aResult);
   return NS_OK;
@@ -273,16 +276,17 @@ BasicCardService::DecodeBasicCardData(co
                                       nsPIDOMWindowInner* aWindow,
                                       BasicCardResponse& aResponse)
 {
   // aWindow can be nullptr
   bool isBillingAddressPassed = false;
   nsTArray<nsString> addressLine;
   nsAutoString country;
   nsAutoString region;
+  nsAutoString regionCode;
   nsAutoString city;
   nsAutoString dependentLocality;
   nsAutoString postalCode;
   nsAutoString sortingCode;
   nsAutoString organization;
   nsAutoString recipient;
   nsAutoString phone;
 
@@ -306,16 +310,17 @@ BasicCardService::DecodeBasicCardData(co
 
     DecodeBasicCardProperty(key, value, CardholderName, aResponse);
     DecodeBasicCardProperty(key, value, ExpiryMonth, aResponse);
     DecodeBasicCardProperty(key, value, ExpiryYear, aResponse);
     DecodeBasicCardProperty(key, value, CardSecurityCode, aResponse);
 
     DecodeAddressProperty(key, value, Country, country);
     DecodeAddressProperty(key, value, Region, region);
+    DecodeAddressProperty(key, value, RegionCode, regionCode);
     DecodeAddressProperty(key, value, City, city);
     DecodeAddressProperty(key, value, DependentLocality, dependentLocality);
     DecodeAddressProperty(key, value, PostalCode, postalCode);
     DecodeAddressProperty(key, value, SortingCode, sortingCode);
     DecodeAddressProperty(key, value, Organization, organization);
     DecodeAddressProperty(key, value, Recipient, recipient);
     DecodeAddressProperty(key, value, Phone, phone);
 
@@ -327,16 +332,17 @@ BasicCardService::DecodeBasicCardData(co
     }
   }
   if (isBillingAddressPassed) {
     aResponse.mBillingAddress.Construct();
     aResponse.mBillingAddress.Value() = new PaymentAddress(aWindow,
                                                            country,
                                                            addressLine,
                                                            region,
+                                                           regionCode,
                                                            city,
                                                            dependentLocality,
                                                            postalCode,
                                                            sortingCode,
                                                            organization,
                                                            recipient,
                                                            phone);
   }
@@ -374,16 +380,17 @@ BasicCardService::IsValidBasicCardErrors
 #undef CardholderName
 #undef CardNumber
 #undef ExpiryMonth
 #undef ExpiryYear
 #undef CardSecurityCode
 #undef Country
 #undef AddressLine
 #undef Region
+#undef RegionCode
 #undef City
 #undef DependentLocality
 #undef PostalCode
 #undef SortingCode
 #undef Organization
 #undef Recipient
 #undef Phone
 #undef PropertySpliter
--- a/dom/payments/PaymentAddress.cpp
+++ b/dom/payments/PaymentAddress.cpp
@@ -19,26 +19,28 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(
   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
   NS_INTERFACE_MAP_ENTRY(nsISupports)
 NS_INTERFACE_MAP_END
 
 PaymentAddress::PaymentAddress(nsPIDOMWindowInner* aWindow,
                                const nsAString& aCountry,
                                const nsTArray<nsString>& aAddressLine,
                                const nsAString& aRegion,
+                               const nsAString& aRegionCode,
                                const nsAString& aCity,
                                const nsAString& aDependentLocality,
                                const nsAString& aPostalCode,
                                const nsAString& aSortingCode,
                                const nsAString& aOrganization,
                                const nsAString& aRecipient,
                                const nsAString& aPhone)
   : mCountry(aCountry)
   , mAddressLine(aAddressLine)
   , mRegion(aRegion)
+  , mRegionCode(aRegionCode)
   , mCity(aCity)
   , mDependentLocality(aDependentLocality)
   , mPostalCode(aPostalCode)
   , mSortingCode(aSortingCode)
   , mOrganization(aOrganization)
   , mRecipient(aRecipient)
   , mPhone(aPhone)
   , mOwner(aWindow)
@@ -59,16 +61,22 @@ PaymentAddress::GetAddressLine(nsTArray<
 
 void
 PaymentAddress::GetRegion(nsAString& aRetVal) const
 {
   aRetVal = mRegion;
 }
 
 void
+PaymentAddress::GetRegionCode(nsAString& aRetVal) const
+{
+  aRetVal = mRegionCode;
+}
+
+void
 PaymentAddress::GetCity(nsAString& aRetVal) const
 {
   aRetVal = mCity;
 }
 
 void
 PaymentAddress::GetDependentLocality(nsAString& aRetVal) const
 {
--- a/dom/payments/PaymentAddress.h
+++ b/dom/payments/PaymentAddress.h
@@ -19,16 +19,17 @@ class PaymentAddress final : public nsIS
 public:
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(PaymentAddress)
 
   PaymentAddress(nsPIDOMWindowInner* aWindow,
                  const nsAString& aCountry,
                  const nsTArray<nsString>& aAddressLine,
                  const nsAString& aRegion,
+                 const nsAString& aRegionCode,
                  const nsAString& aCity,
                  const nsAString& aDependentLocality,
                  const nsAString& aPostalCode,
                  const nsAString& aSortingCode,
                  const nsAString& aOrganization,
                  const nsAString& aRecipient,
                  const nsAString& aPhone);
 
@@ -42,16 +43,18 @@ public:
 
   // Getter functions
   void GetCountry(nsAString& aRetVal) const;
 
   void GetAddressLine(nsTArray<nsString>& aRetVal) const;
 
   void GetRegion(nsAString& aRetVal) const;
 
+  void GetRegionCode(nsAString& aRetVal) const;
+
   void GetCity(nsAString& aRetVal) const;
 
   void GetDependentLocality(nsAString& aRetVal) const;
 
   void GetPostalCode(nsAString& aRetVal) const;
 
   void GetSortingCode(nsAString& aRetVal) const;
 
@@ -62,16 +65,17 @@ public:
   void GetPhone(nsAString& aRetVal) const;
 
 private:
   ~PaymentAddress();
 
   nsString mCountry;
   nsTArray<nsString> mAddressLine;
   nsString mRegion;
+  nsString mRegionCode;
   nsString mCity;
   nsString mDependentLocality;
   nsString mPostalCode;
   nsString mSortingCode;
   nsString mOrganization;
   nsString mRecipient;
   nsString mPhone;
 
--- a/dom/payments/PaymentRequest.cpp
+++ b/dom/payments/PaymentRequest.cpp
@@ -1035,31 +1035,34 @@ PaymentRequest::GetShippingAddress() con
   RefPtr<PaymentAddress> address = mShippingAddress;
   return address.forget();
 }
 
 nsresult
 PaymentRequest::UpdateShippingAddress(const nsAString& aCountry,
                                       const nsTArray<nsString>& aAddressLine,
                                       const nsAString& aRegion,
+                                      const nsAString& aRegionCode,
                                       const nsAString& aCity,
                                       const nsAString& aDependentLocality,
                                       const nsAString& aPostalCode,
                                       const nsAString& aSortingCode,
                                       const nsAString& aOrganization,
                                       const nsAString& aRecipient,
                                       const nsAString& aPhone)
 {
   nsTArray<nsString> emptyArray;
   mShippingAddress = new PaymentAddress(GetOwner(), aCountry, emptyArray,
-                                        aRegion, aCity, aDependentLocality,
-                                        aPostalCode, aSortingCode,
-                                        EmptyString(), EmptyString(), EmptyString());
+                                        aRegion, aRegionCode, aCity,
+                                        aDependentLocality, aPostalCode,
+                                        aSortingCode, EmptyString(),
+                                        EmptyString(), EmptyString());
   mFullShippingAddress = new PaymentAddress(GetOwner(), aCountry, aAddressLine,
-                                            aRegion, aCity, aDependentLocality,
+                                            aRegion, aRegionCode, aCity,
+                                            aDependentLocality,
                                             aPostalCode, aSortingCode,
                                             aOrganization, aRecipient, aPhone);
   // Fire shippingaddresschange event
   return DispatchUpdateEvent(NS_LITERAL_STRING("shippingaddresschange"));
 }
 
 void
 PaymentRequest::SetShippingOption(const nsAString& aShippingOption)
--- a/dom/payments/PaymentRequest.h
+++ b/dom/payments/PaymentRequest.h
@@ -121,16 +121,17 @@ public:
 
   already_AddRefed<PaymentResponse> GetResponse() const;
 
   already_AddRefed<PaymentAddress> GetShippingAddress() const;
   // Update mShippingAddress and fire shippingaddresschange event
   nsresult UpdateShippingAddress(const nsAString& aCountry,
                                  const nsTArray<nsString>& aAddressLine,
                                  const nsAString& aRegion,
+                                 const nsAString& aRegionCode,
                                  const nsAString& aCity,
                                  const nsAString& aDependentLocality,
                                  const nsAString& aPostalCode,
                                  const nsAString& aSortingCode,
                                  const nsAString& aOrganization,
                                  const nsAString& aRecipient,
                                  const nsAString& aPhone);
 
--- a/dom/payments/PaymentRequestData.cpp
+++ b/dom/payments/PaymentRequestData.cpp
@@ -810,27 +810,29 @@ PaymentRequest::GetCompleteStatus(nsAStr
 /* PaymentAddress */
 
 NS_IMPL_ISUPPORTS(PaymentAddress, nsIPaymentAddress)
 
 NS_IMETHODIMP
 PaymentAddress::Init(const nsAString& aCountry,
                      nsIArray* aAddressLine,
                      const nsAString& aRegion,
+                     const nsAString& aRegionCode,
                      const nsAString& aCity,
                      const nsAString& aDependentLocality,
                      const nsAString& aPostalCode,
                      const nsAString& aSortingCode,
                      const nsAString& aOrganization,
                      const nsAString& aRecipient,
                      const nsAString& aPhone)
 {
   mCountry = aCountry;
   mAddressLine = aAddressLine;
   mRegion = aRegion;
+  mRegionCode = aRegionCode;
   mCity = aCity;
   mDependentLocality = aDependentLocality;
   mPostalCode = aPostalCode;
   mSortingCode = aSortingCode;
   mOrganization = aOrganization;
   mRecipient = aRecipient;
   mPhone = aPhone;
   return NS_OK;
@@ -855,16 +857,23 @@ PaymentAddress::GetAddressLine(nsIArray*
 NS_IMETHODIMP
 PaymentAddress::GetRegion(nsAString& aRegion)
 {
   aRegion = mRegion;
   return NS_OK;
 }
 
 NS_IMETHODIMP
+PaymentAddress::GetRegionCode(nsAString& aRegionCode)
+{
+  aRegionCode = mRegionCode;
+  return NS_OK;
+}
+
+NS_IMETHODIMP
 PaymentAddress::GetCity(nsAString& aCity)
 {
   aCity = mCity;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 PaymentAddress::GetDependentLocality(nsAString& aDependentLocality)
--- a/dom/payments/PaymentRequestData.h
+++ b/dom/payments/PaymentRequestData.h
@@ -282,16 +282,17 @@ public:
   PaymentAddress() = default;
 
 private:
   ~PaymentAddress() = default;
 
   nsString mCountry;
   nsCOMPtr<nsIArray> mAddressLine;
   nsString mRegion;
+  nsString mRegionCode;
   nsString mCity;
   nsString mDependentLocality;
   nsString mPostalCode;
   nsString mSortingCode;
   nsString mOrganization;
   nsString mRecipient;
   nsString mPhone;
 };
--- a/dom/payments/PaymentRequestManager.cpp
+++ b/dom/payments/PaymentRequestManager.cpp
@@ -647,16 +647,17 @@ PaymentRequestManager::RespondPayment(Pa
 
 nsresult
 PaymentRequestManager::ChangeShippingAddress(PaymentRequest* aRequest,
                                              const IPCPaymentAddress& aAddress)
 {
   return aRequest->UpdateShippingAddress(aAddress.country(),
                                          aAddress.addressLine(),
                                          aAddress.region(),
+                                         aAddress.regionCode(),
                                          aAddress.city(),
                                          aAddress.dependentLocality(),
                                          aAddress.postalCode(),
                                          aAddress.sortingCode(),
                                          aAddress.organization(),
                                          aAddress.recipient(),
                                          aAddress.phone());
 }
--- a/dom/payments/ipc/PPaymentRequest.ipdl
+++ b/dom/payments/ipc/PPaymentRequest.ipdl
@@ -170,16 +170,17 @@ union IPCPaymentActionResponse
   IPCPaymentCompleteActionResponse;
 };
 
 struct IPCPaymentAddress
 {
   nsString country;
   nsString[] addressLine;
   nsString region;
+  nsString regionCode;
   nsString city;
   nsString dependentLocality;
   nsString postalCode;
   nsString sortingCode;
   nsString organization;
   nsString recipient;
   nsString phone;
 };
--- a/dom/payments/ipc/PaymentRequestParent.cpp
+++ b/dom/payments/ipc/PaymentRequestParent.cpp
@@ -216,16 +216,20 @@ PaymentRequestParent::ChangeShippingAddr
   nsCOMPtr<nsIArray> iaddressLine;
   rv = aAddress->GetAddressLine(getter_AddRefs(iaddressLine));
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsAutoString region;
   rv = aAddress->GetRegion(region);
   NS_ENSURE_SUCCESS(rv, rv);
 
+  nsAutoString regionCode;
+  rv = aAddress->GetRegionCode(regionCode);
+  NS_ENSURE_SUCCESS(rv, rv);
+
   nsAutoString city;
   rv = aAddress->GetCity(city);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsAutoString dependentLocality;
   rv = aAddress->GetDependentLocality(dependentLocality);
   NS_ENSURE_SUCCESS(rv, rv);
 
@@ -257,17 +261,17 @@ PaymentRequestParent::ChangeShippingAddr
     nsCOMPtr<nsISupportsString> iaddress = do_QueryElementAt(iaddressLine, index);
     MOZ_ASSERT(iaddress);
     nsAutoString address;
     rv = iaddress->GetData(address);
     NS_ENSURE_SUCCESS(rv, rv);
     addressLine.AppendElement(address);
   }
 
-  IPCPaymentAddress ipcAddress(country, addressLine, region, city,
+  IPCPaymentAddress ipcAddress(country, addressLine, region, regionCode, city,
                                dependentLocality, postalCode, sortingCode,
                                organization, recipient, phone);
 
   nsAutoString requestId(aRequestId);
   if (!SendChangeShippingAddress(requestId, ipcAddress)) {
     return NS_ERROR_FAILURE;
   }
   return NS_OK;
--- a/dom/webidl/PaymentAddress.webidl
+++ b/dom/webidl/PaymentAddress.webidl
@@ -16,16 +16,17 @@ interface PaymentAddress {
   [Default] object toJSON();
 
   readonly attribute DOMString              country;
   // TODO: Use FrozenArray once available. (Bug 1236777)
   // readonly attribute FrozenArray<DOMString> addressLine;
   [Frozen, Cached, Pure]
   readonly attribute sequence<DOMString>    addressLine;
   readonly attribute DOMString              region;
+  readonly attribute DOMString              regionCode;
   readonly attribute DOMString              city;
   readonly attribute DOMString              dependentLocality;
   readonly attribute DOMString              postalCode;
   readonly attribute DOMString              sortingCode;
   readonly attribute DOMString              organization;
   readonly attribute DOMString              recipient;
   readonly attribute DOMString              phone;
 };