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

Side by Side Diff: third_party/WebKit/Source/modules/payments/PaymentRequest.cpp

Issue 1702223002: PaymentRequest API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Windows linking. Created 4 years, 9 months 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 unified diff | Download patch
OLDNEW
(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/JSONValuesForV8.h"
9 #include "bindings/core/v8/ScriptState.h"
10 #include "core/dom/DOMException.h"
11 #include "core/dom/ExceptionCode.h"
12 #include "modules/EventTargetModulesNames.h"
13 #include "modules/payments/ShippingAddress.h"
14
15 namespace blink {
16
17 // static
18 PaymentRequest* PaymentRequest::create(ScriptState* scriptState, const Vector<St ring>& supportedMethods, const PaymentDetails& details, ExceptionState& exceptio nState)
19 {
20 return new PaymentRequest(scriptState, supportedMethods, details, PaymentOpt ions(), ScriptValue(), exceptionState);
21 }
22
23 // static
24 PaymentRequest* PaymentRequest::create(ScriptState* scriptState, const Vector<St ring>& supportedMethods, const PaymentDetails& details, const PaymentOptions& op tions, ExceptionState& exceptionState)
25 {
26 return new PaymentRequest(scriptState, supportedMethods, details, options, S criptValue(), exceptionState);
27 }
28
29 // static
30 PaymentRequest* PaymentRequest::create(ScriptState* scriptState, const Vector<St ring>& supportedMethods, const PaymentDetails& details, const PaymentOptions& op tions, const ScriptValue& data, ExceptionState& exceptionState)
31 {
32 return new PaymentRequest(scriptState, supportedMethods, details, options, d ata, exceptionState);
33 }
34
35 PaymentRequest::~PaymentRequest()
36 {
37 }
38
39 ScriptPromise PaymentRequest::show(ScriptState* scriptState)
40 {
41 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::crea te(NotSupportedError, "Not implemented."));
42 }
43
44 void PaymentRequest::abort()
45 {
46 }
47
48 const AtomicString& PaymentRequest::interfaceName() const
49 {
50 return EventTargetNames::PaymentRequest;
51 }
52
53 ExecutionContext* PaymentRequest::executionContext() const
54 {
55 return m_scriptState->executionContext();
56 }
57
58 DEFINE_TRACE(PaymentRequest)
59 {
60 visitor->trace(m_details);
61 visitor->trace(m_options);
62 visitor->trace(m_shippingAddress);
63 RefCountedGarbageCollectedEventTargetWithInlineData<PaymentRequest>::trace(v isitor);
64 }
65
66 PaymentRequest::PaymentRequest(ScriptState* scriptState, const Vector<String>& s upportedMethods, const PaymentDetails& details, const PaymentOptions& options, c onst ScriptValue& data, ExceptionState& exceptionState)
67 : m_scriptState(scriptState)
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->getType() == JSONValue::TypeObject)
75 m_stringifiedData = JSONObject::cast(value)->toJSONString();
76 }
77 }
78
79 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698