Index: third_party/WebKit/Source/modules/nfc/NFC.cpp |
diff --git a/third_party/WebKit/Source/modules/nfc/NFC.cpp b/third_party/WebKit/Source/modules/nfc/NFC.cpp |
index a8e470f1096f4ea3cd4a30c2d5821a160c7de889..408cd9e62f5a6f4e7514ee21cdddbee3cea3cc53 100644 |
--- a/third_party/WebKit/Source/modules/nfc/NFC.cpp |
+++ b/third_party/WebKit/Source/modules/nfc/NFC.cpp |
@@ -7,6 +7,7 @@ |
#include "bindings/core/v8/JSONValuesForV8.h" |
#include "bindings/core/v8/ScriptPromiseResolver.h" |
#include "bindings/core/v8/V8ArrayBuffer.h" |
+#include "bindings/core/v8/V8StringResource.h" |
#include "core/dom/DOMArrayBuffer.h" |
#include "core/dom/DOMException.h" |
#include "core/dom/Document.h" |
@@ -173,11 +174,14 @@ struct TypeConverter<mojo::WTFArray<uint8_t>, blink::ScriptValue> { |
return mojo::WTFArray<uint8_t>::From<WTF::String>(stringResource); |
} |
- if (value->IsObject() && !value->IsArrayBuffer()) { |
- std::unique_ptr<blink::JSONValue> jsonResult = |
- blink::toJSONValue(scriptValue.context(), value); |
- if (jsonResult && (jsonResult->getType() == blink::JSONValue::TypeObject)) |
- return mojo::WTFArray<uint8_t>::From(jsonResult->toJSONString()); |
+ if (value->IsObject() && !value->IsArray() && !value->IsArrayBuffer()) { |
+ v8::Local<v8::String> jsonString; |
+ if (v8::JSON::Stringify(scriptValue.context(), value.As<v8::Object>()) |
+ .ToLocal(&jsonString)) { |
+ WTF::String wtfString = blink::v8StringToWebCoreString<WTF::String>( |
+ jsonString, blink::DoNotExternalize); |
+ return mojo::WTFArray<uint8_t>::From(wtfString); |
+ } |
} |
if (value->IsArrayBuffer()) |