| 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" |
| 11 #include "modules/payments/PaymentAppOption.h" | 11 #include "modules/payments/PaymentAppOption.h" |
| 12 #include "modules/payments/PaymentInstruments.h" |
| 12 #include "modules/serviceworkers/ServiceWorkerRegistration.h" | 13 #include "modules/serviceworkers/ServiceWorkerRegistration.h" |
| 13 #include "platform/mojo/MojoHelper.h" | 14 #include "platform/mojo/MojoHelper.h" |
| 14 #include "public/platform/InterfaceProvider.h" | 15 #include "public/platform/InterfaceProvider.h" |
| 15 #include "public/platform/Platform.h" | 16 #include "public/platform/Platform.h" |
| 16 | 17 |
| 17 namespace mojo { | 18 namespace mojo { |
| 18 | 19 |
| 19 using payments::mojom::blink::PaymentAppManifest; | 20 using payments::mojom::blink::PaymentAppManifest; |
| 20 using payments::mojom::blink::PaymentAppManifestPtr; | 21 using payments::mojom::blink::PaymentAppManifestPtr; |
| 21 using payments::mojom::blink::PaymentAppOption; | 22 using payments::mojom::blink::PaymentAppOption; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); | 123 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); |
| 123 ScriptPromise promise = resolver->promise(); | 124 ScriptPromise promise = resolver->promise(); |
| 124 | 125 |
| 125 m_manager->GetManifest(convertToBaseCallback( | 126 m_manager->GetManifest(convertToBaseCallback( |
| 126 WTF::bind(&PaymentAppManager::onGetManifest, wrapPersistent(this), | 127 WTF::bind(&PaymentAppManager::onGetManifest, wrapPersistent(this), |
| 127 wrapPersistent(resolver)))); | 128 wrapPersistent(resolver)))); |
| 128 | 129 |
| 129 return promise; | 130 return promise; |
| 130 } | 131 } |
| 131 | 132 |
| 133 PaymentInstruments* PaymentAppManager::instruments() { |
| 134 if (!m_instruments) { |
| 135 m_instruments = new PaymentInstruments(); |
| 136 } |
| 137 return m_instruments; |
| 138 } |
| 139 |
| 132 DEFINE_TRACE(PaymentAppManager) { | 140 DEFINE_TRACE(PaymentAppManager) { |
| 133 visitor->trace(m_registration); | 141 visitor->trace(m_registration); |
| 142 visitor->trace(m_instruments); |
| 134 } | 143 } |
| 135 | 144 |
| 136 PaymentAppManager::PaymentAppManager(ServiceWorkerRegistration* registration) | 145 PaymentAppManager::PaymentAppManager(ServiceWorkerRegistration* registration) |
| 137 : m_registration(registration) { | 146 : m_registration(registration), m_instruments(nullptr) { |
| 138 DCHECK(registration); | 147 DCHECK(registration); |
| 139 Platform::current()->interfaceProvider()->getInterface( | 148 Platform::current()->interfaceProvider()->getInterface( |
| 140 mojo::MakeRequest(&m_manager)); | 149 mojo::MakeRequest(&m_manager)); |
| 141 | 150 |
| 142 m_manager.set_connection_error_handler(convertToBaseCallback(WTF::bind( | 151 m_manager.set_connection_error_handler(convertToBaseCallback(WTF::bind( |
| 143 &PaymentAppManager::onServiceConnectionError, wrapWeakPersistent(this)))); | 152 &PaymentAppManager::onServiceConnectionError, wrapWeakPersistent(this)))); |
| 144 | 153 |
| 145 m_manager->Init(m_registration->scope()); | 154 m_manager->Init(m_registration->scope()); |
| 146 } | 155 } |
| 147 | 156 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 "No payment app manifest associated with the service worker.")); | 200 "No payment app manifest associated with the service worker.")); |
| 192 break; | 201 break; |
| 193 } | 202 } |
| 194 } | 203 } |
| 195 | 204 |
| 196 void PaymentAppManager::onServiceConnectionError() { | 205 void PaymentAppManager::onServiceConnectionError() { |
| 197 m_manager.reset(); | 206 m_manager.reset(); |
| 198 } | 207 } |
| 199 | 208 |
| 200 } // namespace blink | 209 } // namespace blink |
| OLD | NEW |