Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(940)

Unified Diff: third_party/WebKit/Source/modules/payments/PaymentRequest.cpp

Issue 2473533002: Make NFC.cpp use JSON::Stringify (Closed)
Patch Set: Fix logic error Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/modules/nfc/NFC.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/modules/payments/PaymentRequest.cpp
diff --git a/third_party/WebKit/Source/modules/payments/PaymentRequest.cpp b/third_party/WebKit/Source/modules/payments/PaymentRequest.cpp
index fe2a3cf7c05d6c265d83a998e7621028744332e9..611200bc3596c8b8f1a6409d95c3ffc54ec997e9 100644
--- a/third_party/WebKit/Source/modules/payments/PaymentRequest.cpp
+++ b/third_party/WebKit/Source/modules/payments/PaymentRequest.cpp
@@ -348,43 +348,45 @@ bool validatePaymentDetails(const PaymentDetails& details,
}
void validateAndConvertPaymentMethodData(
- const HeapVector<PaymentMethodData>& paymentMethodData,
+ const HeapVector<PaymentMethodData>& paymentMethodDataVector,
Vector<PaymentRequest::MethodData>* methodData,
ExceptionState& exceptionState) {
- if (paymentMethodData.isEmpty()) {
+ if (paymentMethodDataVector.isEmpty()) {
exceptionState.throwTypeError(
"Must specify at least one payment method identifier");
return;
}
- for (const auto& pmd : paymentMethodData) {
- if (pmd.supportedMethods().isEmpty()) {
+ for (const auto& paymentMethodData : paymentMethodDataVector) {
+ if (paymentMethodData.supportedMethods().isEmpty()) {
exceptionState.throwTypeError(
"Must specify at least one payment method identifier");
return;
}
String stringifiedData = "";
- if (pmd.hasData() && !pmd.data().isEmpty()) {
- if (!pmd.data().v8Value()->IsObject() ||
- pmd.data().v8Value()->IsArray()) {
+ if (paymentMethodData.hasData() && !paymentMethodData.data().isEmpty()) {
+ if (!paymentMethodData.data().v8Value()->IsObject() ||
+ paymentMethodData.data().v8Value()->IsArray()) {
exceptionState.throwTypeError(
"Data should be a JSON-serializable object");
return;
}
- v8::MaybeLocal<v8::String> value = v8::JSON::Stringify(
- pmd.data().context(), pmd.data().v8Value().As<v8::Object>());
- if (value.IsEmpty()) {
+ v8::Local<v8::String> value;
+ if (!v8::JSON::Stringify(
+ paymentMethodData.data().context(),
+ paymentMethodData.data().v8Value().As<v8::Object>())
+ .ToLocal(&value)) {
exceptionState.throwTypeError(
"Unable to parse payment method specific data");
return;
}
- stringifiedData = v8StringToWebCoreString<String>(value.ToLocalChecked(),
- DoNotExternalize);
+ stringifiedData =
+ v8StringToWebCoreString<String>(value, DoNotExternalize);
}
- methodData->append(
- PaymentRequest::MethodData(pmd.supportedMethods(), stringifiedData));
+ methodData->append(PaymentRequest::MethodData(
+ paymentMethodData.supportedMethods(), stringifiedData));
}
}
« no previous file with comments | « third_party/WebKit/Source/modules/nfc/NFC.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698