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

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

Issue 2463203002: Use JSON::Stringify instead of JSONValue (Closed)
Patch Set: Try to fix test failure 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 | « no previous file | 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 54bac4920032ba1be47d41d67e947a92412d5df8..fe2a3cf7c05d6c265d83a998e7621028744332e9 100644
--- a/third_party/WebKit/Source/modules/payments/PaymentRequest.cpp
+++ b/third_party/WebKit/Source/modules/payments/PaymentRequest.cpp
@@ -5,9 +5,9 @@
#include "modules/payments/PaymentRequest.h"
#include "bindings/core/v8/ExceptionState.h"
-#include "bindings/core/v8/JSONValuesForV8.h"
#include "bindings/core/v8/ScriptPromiseResolver.h"
#include "bindings/core/v8/ScriptState.h"
+#include "bindings/core/v8/V8StringResource.h"
#include "bindings/modules/v8/V8PaymentDetails.h"
#include "core/EventTypeNames.h"
#include "core/dom/DOMException.h"
@@ -366,21 +366,22 @@ void validateAndConvertPaymentMethodData(
String stringifiedData = "";
if (pmd.hasData() && !pmd.data().isEmpty()) {
- std::unique_ptr<JSONValue> value =
- toJSONValue(pmd.data().context(), pmd.data().v8Value());
- if (!value) {
+ if (!pmd.data().v8Value()->IsObject() ||
+ pmd.data().v8Value()->IsArray()) {
exceptionState.throwTypeError(
- "Unable to parse payment method specific data");
+ "Data should be a JSON-serializable object");
return;
}
- if (!value->isNull()) {
- if (value->getType() != JSONValue::TypeObject) {
- exceptionState.throwTypeError(
- "Data should be a JSON-serializable object");
- return;
- }
- stringifiedData = JSONObject::cast(value.get())->toJSONString();
+
+ v8::MaybeLocal<v8::String> value = v8::JSON::Stringify(
+ pmd.data().context(), pmd.data().v8Value().As<v8::Object>());
+ if (value.IsEmpty()) {
haraken 2016/11/02 01:19:01 v8::Local<v8::String> value; if (!v8::JSON::String
+ exceptionState.throwTypeError(
+ "Unable to parse payment method specific data");
+ return;
}
+ stringifiedData = v8StringToWebCoreString<String>(value.ToLocalChecked(),
+ DoNotExternalize);
}
methodData->append(
PaymentRequest::MethodData(pmd.supportedMethods(), stringifiedData));
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698