| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "modules/payments/PaymentRequest.h" | 5 #include "modules/payments/PaymentRequest.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ExceptionState.h" | 7 #include "bindings/core/v8/ExceptionState.h" |
| 8 #include "bindings/core/v8/JSONValuesForV8.h" | 8 #include "bindings/core/v8/JSONValuesForV8.h" |
| 9 #include "bindings/core/v8/ScriptPromiseResolver.h" | 9 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 10 #include "bindings/core/v8/ScriptState.h" | 10 #include "bindings/core/v8/ScriptState.h" |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 for (const auto& method : pmd.supportedMethods()) { | 321 for (const auto& method : pmd.supportedMethods()) { |
| 322 if (uniqueMethods.contains(method)) { | 322 if (uniqueMethods.contains(method)) { |
| 323 exceptionState.throwTypeError("Duplicate payment method identifi
ers are not allowed"); | 323 exceptionState.throwTypeError("Duplicate payment method identifi
ers are not allowed"); |
| 324 return; | 324 return; |
| 325 } | 325 } |
| 326 uniqueMethods.add(method); | 326 uniqueMethods.add(method); |
| 327 } | 327 } |
| 328 | 328 |
| 329 String stringifiedData = ""; | 329 String stringifiedData = ""; |
| 330 if (pmd.hasData() && !pmd.data().isEmpty()) { | 330 if (pmd.hasData() && !pmd.data().isEmpty()) { |
| 331 RefPtr<JSONValue> value = toJSONValue(pmd.data().context(), pmd.data
().v8Value()); | 331 std::unique_ptr<JSONValue> value = toJSONValue(pmd.data().context(),
pmd.data().v8Value()); |
| 332 if (!value) { | 332 if (!value) { |
| 333 exceptionState.throwTypeError("Unable to parse payment method sp
ecific data"); | 333 exceptionState.throwTypeError("Unable to parse payment method sp
ecific data"); |
| 334 return; | 334 return; |
| 335 } | 335 } |
| 336 if (!value->isNull()) { | 336 if (!value->isNull()) { |
| 337 if (value->getType() != JSONValue::TypeObject) { | 337 if (value->getType() != JSONValue::TypeObject) { |
| 338 exceptionState.throwTypeError("Data should be a JSON-seriali
zable object"); | 338 exceptionState.throwTypeError("Data should be a JSON-seriali
zable object"); |
| 339 return; | 339 return; |
| 340 } | 340 } |
| 341 stringifiedData = JSONObject::cast(value)->toJSONString(); | 341 stringifiedData = JSONObject::cast(value.get())->toJSONString(); |
| 342 } | 342 } |
| 343 } | 343 } |
| 344 methodData->append(PaymentRequest::MethodData(pmd.supportedMethods(), st
ringifiedData)); | 344 methodData->append(PaymentRequest::MethodData(pmd.supportedMethods(), st
ringifiedData)); |
| 345 } | 345 } |
| 346 } | 346 } |
| 347 | 347 |
| 348 String getSelectedShippingOption(const PaymentDetails& details) | 348 String getSelectedShippingOption(const PaymentDetails& details) |
| 349 { | 349 { |
| 350 String result; | 350 String result; |
| 351 if (!details.hasShippingOptions()) | 351 if (!details.hasShippingOptions()) |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 695 { | 695 { |
| 696 m_completeResolver.clear(); | 696 m_completeResolver.clear(); |
| 697 m_showResolver.clear(); | 697 m_showResolver.clear(); |
| 698 m_abortResolver.clear(); | 698 m_abortResolver.clear(); |
| 699 if (m_clientBinding.is_bound()) | 699 if (m_clientBinding.is_bound()) |
| 700 m_clientBinding.Close(); | 700 m_clientBinding.Close(); |
| 701 m_paymentProvider.reset(); | 701 m_paymentProvider.reset(); |
| 702 } | 702 } |
| 703 | 703 |
| 704 } // namespace blink | 704 } // namespace blink |
| OLD | NEW |