зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1435157 - Support AddressErrors in WebPayment. r=baku.
1. Add AddressErrors in PaymentRequest.webidl. 2. IPC for passing AddressErrors. 3. Getters for AddressErrors in nsIPaymentDetails. --HG-- extra : rebase_source : 64c57003d57e064b5284cc64447c0c0740f16121
This commit is contained in:
Родитель
5ac39f4f7b
Коммит
029423a6e2
|
@ -61,8 +61,11 @@ interface nsIPaymentDetails : nsISupports
|
|||
readonly attribute nsIArray shippingOptions;
|
||||
readonly attribute nsIArray modifiers;
|
||||
readonly attribute AString error;
|
||||
[implicit_jscontext]
|
||||
readonly attribute jsval shippingAddressErrors;
|
||||
|
||||
void update(in nsIPaymentDetails aDetails, in boolean aRequestShipping);
|
||||
AString shippingAddressErrorsJSON();
|
||||
};
|
||||
|
||||
[scriptable, builtinclass, uuid(d53f9f20-138e-47cc-9fd5-db16a3f6d301)]
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
* 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/. */
|
||||
|
||||
#include "mozilla/dom/PaymentRequestBinding.h"
|
||||
#include "nsArrayUtils.h"
|
||||
#include "nsIMutableArray.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
|
@ -339,13 +340,15 @@ PaymentDetails::PaymentDetails(const nsAString& aId,
|
|||
nsIArray* aDisplayItems,
|
||||
nsIArray* aShippingOptions,
|
||||
nsIArray* aModifiers,
|
||||
const nsAString& aError)
|
||||
const nsAString& aError,
|
||||
const nsAString& aShippingAddressErrors)
|
||||
: mId(aId)
|
||||
, mTotalItem(aTotalItem)
|
||||
, mDisplayItems(aDisplayItems)
|
||||
, mShippingOptions(aShippingOptions)
|
||||
, mModifiers(aModifiers)
|
||||
, mError(aError)
|
||||
, mShippingAddressErrors(aShippingAddressErrors)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -417,7 +420,8 @@ PaymentDetails::Create(const IPCPaymentDetails& aIPCDetails,
|
|||
|
||||
nsCOMPtr<nsIPaymentDetails> details =
|
||||
new PaymentDetails(aIPCDetails.id(), total, displayItems, shippingOptions,
|
||||
modifiers, aIPCDetails.error());
|
||||
modifiers, aIPCDetails.error(),
|
||||
aIPCDetails.shippingAddressErrors());
|
||||
|
||||
details.forget(aDetails);
|
||||
return NS_OK;
|
||||
|
@ -474,6 +478,17 @@ PaymentDetails::GetError(nsAString& aError)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
PaymentDetails::GetShippingAddressErrors(JSContext* aCx, JS::MutableHandleValue aErrors)
|
||||
{
|
||||
AddressErrors errors;
|
||||
errors.Init(mShippingAddressErrors);
|
||||
if (!ToJSValue(aCx, errors, aErrors)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
PaymentDetails::Update(nsIPaymentDetails* aDetails, const bool aRequestShipping)
|
||||
{
|
||||
|
@ -523,9 +538,18 @@ PaymentDetails::Update(nsIPaymentDetails* aDetails, const bool aRequestShipping)
|
|||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
aDetails->ShippingAddressErrorsJSON(mShippingAddressErrors);
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
NS_IMETHODIMP
|
||||
PaymentDetails::ShippingAddressErrorsJSON(nsAString& aErrors)
|
||||
{
|
||||
aErrors = mShippingAddressErrors;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* PaymentOptions */
|
||||
|
||||
NS_IMPL_ISUPPORTS(PaymentOptions,
|
||||
|
|
|
@ -137,7 +137,8 @@ private:
|
|||
nsIArray* aDisplayItems,
|
||||
nsIArray* aShippingOptions,
|
||||
nsIArray* aModifiers,
|
||||
const nsAString& aError);
|
||||
const nsAString& aError,
|
||||
const nsAString& aShippingAddressError);
|
||||
|
||||
~PaymentDetails() = default;
|
||||
|
||||
|
@ -147,6 +148,7 @@ private:
|
|||
nsCOMPtr<nsIArray> mShippingOptions;
|
||||
nsCOMPtr<nsIArray> mModifiers;
|
||||
nsString mError;
|
||||
nsString mShippingAddressErrors;
|
||||
};
|
||||
|
||||
class PaymentOptions final : public nsIPaymentOptions
|
||||
|
@ -185,7 +187,7 @@ public:
|
|||
nsIArray* aPaymentMethods,
|
||||
nsIPaymentDetails* aPaymentDetails,
|
||||
nsIPaymentOptions* aPaymentOptions,
|
||||
const nsAString& aShippingOption);
|
||||
const nsAString& aShippingOption);
|
||||
|
||||
private:
|
||||
~PaymentRequest() = default;
|
||||
|
|
|
@ -178,6 +178,7 @@ ConvertDetailsInit(JSContext* aCx,
|
|||
shippingOptions,
|
||||
modifiers,
|
||||
EmptyString(), // error message
|
||||
EmptyString(), // shippingAddressErrors
|
||||
aDetails.mDisplayItems.WasPassed(),
|
||||
aDetails.mShippingOptions.WasPassed(),
|
||||
aDetails.mModifiers.WasPassed());
|
||||
|
@ -211,12 +212,18 @@ ConvertDetailsUpdate(JSContext* aCx,
|
|||
error = aDetails.mError.Value();
|
||||
}
|
||||
|
||||
nsString shippingAddressErrors(EmptyString());
|
||||
if (!aDetails.mShippingAddressErrors.ToJSON(shippingAddressErrors)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
aIPCDetails = IPCPaymentDetails(EmptyString(), // id
|
||||
total,
|
||||
displayItems,
|
||||
shippingOptions,
|
||||
modifiers,
|
||||
error,
|
||||
shippingAddressErrors,
|
||||
aDetails.mDisplayItems.WasPassed(),
|
||||
aDetails.mShippingOptions.WasPassed(),
|
||||
aDetails.mModifiers.WasPassed());
|
||||
|
|
|
@ -55,6 +55,7 @@ struct IPCPaymentDetails
|
|||
IPCPaymentShippingOption[] shippingOptions;
|
||||
IPCPaymentDetailsModifier[] modifiers;
|
||||
nsString error;
|
||||
nsString shippingAddressErrors;
|
||||
bool displayItemsPassed;
|
||||
bool shippingOptionsPassed;
|
||||
bool modifiersPassed;
|
||||
|
|
|
@ -54,9 +54,25 @@ dictionary PaymentDetailsInit : PaymentDetailsBase {
|
|||
required PaymentItem total;
|
||||
};
|
||||
|
||||
dictionary AddressErrors {
|
||||
DOMString addressLine;
|
||||
DOMString city;
|
||||
DOMString country;
|
||||
DOMString dependentLocality;
|
||||
DOMString languageCode;
|
||||
DOMString organization;
|
||||
DOMString phone;
|
||||
DOMString postalCode;
|
||||
DOMString recipient;
|
||||
DOMString region;
|
||||
DOMString regionCode;
|
||||
DOMString sortingCode;
|
||||
};
|
||||
|
||||
dictionary PaymentDetailsUpdate : PaymentDetailsBase {
|
||||
DOMString error;
|
||||
PaymentItem total;
|
||||
DOMString error;
|
||||
AddressErrors shippingAddressErrors;
|
||||
PaymentItem total;
|
||||
};
|
||||
|
||||
enum PaymentShippingType {
|
||||
|
|
Загрузка…
Ссылка в новой задаче