OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "modules/payments/PaymentRequest.h" |
| 6 |
| 7 #include "bindings/core/v8/ExceptionState.h" |
| 8 #include "bindings/core/v8/SerializedScriptValueFactory.h" |
| 9 #include "core/dom/DOMException.h" |
| 10 #include "core/dom/ExceptionCode.h" |
| 11 #include "modules/EventTargetModulesNames.h" |
| 12 #include "platform/JSONValuesForV8.h" |
| 13 |
| 14 namespace blink { |
| 15 |
| 16 // static |
| 17 PaymentRequest* PaymentRequest::create(ExecutionContext* context, const Vector<S
tring>& supportedMethods, const PaymentDetails& details, ExceptionState& excepti
onState) |
| 18 { |
| 19 return new PaymentRequest(context, supportedMethods, details, PaymentOptions
(), ScriptValue(), exceptionState); |
| 20 } |
| 21 |
| 22 // static |
| 23 PaymentRequest* PaymentRequest::create(ExecutionContext* context, const Vector<S
tring>& supportedMethods, const PaymentDetails& details, const PaymentOptions& o
ptions, ExceptionState& exceptionState) |
| 24 { |
| 25 return new PaymentRequest(context, supportedMethods, details, options, Scrip
tValue(), exceptionState); |
| 26 } |
| 27 |
| 28 // static |
| 29 PaymentRequest* PaymentRequest::create(ExecutionContext* context, const Vector<S
tring>& supportedMethods, const PaymentDetails& details, const PaymentOptions& o
ptions, const ScriptValue& data, ExceptionState& exceptionState) |
| 30 { |
| 31 return new PaymentRequest(context, supportedMethods, details, options, data,
exceptionState); |
| 32 } |
| 33 |
| 34 PaymentRequest::~PaymentRequest() |
| 35 { |
| 36 } |
| 37 |
| 38 ScriptPromise PaymentRequest::show(ScriptState* scriptState) |
| 39 { |
| 40 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::crea
te(NotSupportedError, "Not implemented.")); |
| 41 } |
| 42 |
| 43 void PaymentRequest::abort() |
| 44 { |
| 45 } |
| 46 |
| 47 const AtomicString& PaymentRequest::interfaceName() const |
| 48 { |
| 49 return EventTargetNames::PaymentRequest; |
| 50 } |
| 51 |
| 52 ExecutionContext* PaymentRequest::executionContext() const |
| 53 { |
| 54 return ActiveDOMObject::executionContext(); |
| 55 } |
| 56 |
| 57 DEFINE_TRACE(PaymentRequest) |
| 58 { |
| 59 visitor->trace(m_details); |
| 60 visitor->trace(m_options); |
| 61 visitor->trace(m_shippingAddress); |
| 62 RefCountedGarbageCollectedEventTargetWithInlineData<PaymentRequest>::trace(v
isitor); |
| 63 ActiveDOMObject::trace(visitor); |
| 64 } |
| 65 |
| 66 PaymentRequest::PaymentRequest(ExecutionContext* context, const Vector<String>&
supportedMethods, const PaymentDetails& details, const PaymentOptions& options,
const ScriptValue& data, ExceptionState& exceptionState) |
| 67 : ActiveDOMObject(context) |
| 68 , m_supportedMethods(supportedMethods) |
| 69 , m_details(details) |
| 70 , m_options(options) |
| 71 { |
| 72 if (!data.isEmpty()) { |
| 73 RefPtr<JSONValue> value = toJSONValue(data.context(), data.v8Value()); |
| 74 if (value && value->type() == JSONValue::TypeObject) |
| 75 m_stringifiedData = JSONObject::cast(value)->toJSONString(); |
| 76 } |
| 77 |
| 78 suspendIfNeeded(); |
| 79 } |
| 80 |
| 81 } // namespace blink |
OLD | NEW |