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/PaymentAppManager.h" | 5 #include "modules/payments/PaymentAppManager.h" |
6 | 6 |
7 #include "bindings/core/v8/ScriptPromise.h" | 7 #include "bindings/core/v8/ScriptPromise.h" |
8 #include "bindings/core/v8/ScriptState.h" | 8 #include "bindings/core/v8/ScriptState.h" |
9 #include "core/dom/DOMException.h" | 9 #include "core/dom/DOMException.h" |
10 #include "modules/payments/PaymentAppManifest.h" | 10 #include "modules/payments/PaymentAppManifest.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 PaymentAppManager* PaymentAppManager::create( | 89 PaymentAppManager* PaymentAppManager::create( |
90 ServiceWorkerRegistration* registration) { | 90 ServiceWorkerRegistration* registration) { |
91 return new PaymentAppManager(registration); | 91 return new PaymentAppManager(registration); |
92 } | 92 } |
93 | 93 |
94 ScriptPromise PaymentAppManager::setManifest( | 94 ScriptPromise PaymentAppManager::setManifest( |
95 ScriptState* scriptState, | 95 ScriptState* scriptState, |
96 const PaymentAppManifest& manifest) { | 96 const PaymentAppManifest& manifest) { |
97 if (!m_manager) { | 97 if (!m_manager) { |
98 return ScriptPromise::rejectWithDOMException( | 98 return ScriptPromise::rejectWithDOMException( |
99 scriptState, DOMException::create(InvalidStateError, | 99 scriptState, |
100 "Payment app manager unavailable.")); | 100 DOMException::create(InvalidStateError, |
| 101 "Payment app manager unavailable.")); |
101 } | 102 } |
102 | 103 |
103 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); | 104 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); |
104 ScriptPromise promise = resolver->promise(); | 105 ScriptPromise promise = resolver->promise(); |
105 | 106 |
106 m_manager->SetManifest( | 107 m_manager->SetManifest( |
107 payments::mojom::blink::PaymentAppManifest::From(manifest), | 108 payments::mojom::blink::PaymentAppManifest::From(manifest), |
108 convertToBaseCallback(WTF::bind(&PaymentAppManager::onSetManifest, | 109 convertToBaseCallback(WTF::bind(&PaymentAppManager::onSetManifest, |
109 wrapPersistent(this), | 110 wrapPersistent(this), |
110 wrapPersistent(resolver)))); | 111 wrapPersistent(resolver)))); |
111 | 112 |
112 return promise; | 113 return promise; |
113 } | 114 } |
114 | 115 |
115 ScriptPromise PaymentAppManager::getManifest(ScriptState* scriptState) { | 116 ScriptPromise PaymentAppManager::getManifest(ScriptState* scriptState) { |
116 if (!m_manager) { | 117 if (!m_manager) { |
117 return ScriptPromise::rejectWithDOMException( | 118 return ScriptPromise::rejectWithDOMException( |
118 scriptState, DOMException::create(InvalidStateError, | 119 scriptState, |
119 "Payment app manager unavailable.")); | 120 DOMException::create(InvalidStateError, |
| 121 "Payment app manager unavailable.")); |
120 } | 122 } |
121 | 123 |
122 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); | 124 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); |
123 ScriptPromise promise = resolver->promise(); | 125 ScriptPromise promise = resolver->promise(); |
124 | 126 |
125 m_manager->GetManifest(convertToBaseCallback( | 127 m_manager->GetManifest(convertToBaseCallback( |
126 WTF::bind(&PaymentAppManager::onGetManifest, wrapPersistent(this), | 128 WTF::bind(&PaymentAppManager::onGetManifest, wrapPersistent(this), |
127 wrapPersistent(resolver)))); | 129 wrapPersistent(resolver)))); |
128 | 130 |
129 return promise; | 131 return promise; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 "No payment app manifest associated with the service worker.")); | 193 "No payment app manifest associated with the service worker.")); |
192 break; | 194 break; |
193 } | 195 } |
194 } | 196 } |
195 | 197 |
196 void PaymentAppManager::onServiceConnectionError() { | 198 void PaymentAppManager::onServiceConnectionError() { |
197 m_manager.reset(); | 199 m_manager.reset(); |
198 } | 200 } |
199 | 201 |
200 } // namespace blink | 202 } // namespace blink |
OLD | NEW |