| 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/PaymentAppServiceWorkerRegistration.h" | 5 #include "modules/payments/PaymentAppServiceWorkerRegistration.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ScriptState.h" | 7 #include "bindings/core/v8/ScriptState.h" |
| 8 #include "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
| 9 #include "modules/payments/PaymentAppManager.h" | 9 #include "modules/payments/PaymentManager.h" |
| 10 #include "modules/serviceworkers/ServiceWorkerRegistration.h" | 10 #include "modules/serviceworkers/ServiceWorkerRegistration.h" |
| 11 | 11 |
| 12 namespace blink { | 12 namespace blink { |
| 13 | 13 |
| 14 PaymentAppServiceWorkerRegistration::~PaymentAppServiceWorkerRegistration() {} | 14 PaymentAppServiceWorkerRegistration::~PaymentAppServiceWorkerRegistration() {} |
| 15 | 15 |
| 16 // static | 16 // static |
| 17 PaymentAppServiceWorkerRegistration& PaymentAppServiceWorkerRegistration::from( | 17 PaymentAppServiceWorkerRegistration& PaymentAppServiceWorkerRegistration::from( |
| 18 ServiceWorkerRegistration& registration) { | 18 ServiceWorkerRegistration& registration) { |
| 19 PaymentAppServiceWorkerRegistration* supplement = | 19 PaymentAppServiceWorkerRegistration* supplement = |
| 20 static_cast<PaymentAppServiceWorkerRegistration*>( | 20 static_cast<PaymentAppServiceWorkerRegistration*>( |
| 21 Supplement<ServiceWorkerRegistration>::from(registration, | 21 Supplement<ServiceWorkerRegistration>::from(registration, |
| 22 supplementName())); | 22 supplementName())); |
| 23 | 23 |
| 24 if (!supplement) { | 24 if (!supplement) { |
| 25 supplement = new PaymentAppServiceWorkerRegistration(®istration); | 25 supplement = new PaymentAppServiceWorkerRegistration(®istration); |
| 26 provideTo(registration, supplementName(), supplement); | 26 provideTo(registration, supplementName(), supplement); |
| 27 } | 27 } |
| 28 | 28 |
| 29 return *supplement; | 29 return *supplement; |
| 30 } | 30 } |
| 31 | 31 |
| 32 // static | 32 // static |
| 33 PaymentAppManager* PaymentAppServiceWorkerRegistration::paymentAppManager( | 33 PaymentManager* PaymentAppServiceWorkerRegistration::paymentManager( |
| 34 ScriptState* scriptState, | 34 ScriptState* scriptState, |
| 35 ServiceWorkerRegistration& registration) { | 35 ServiceWorkerRegistration& registration) { |
| 36 return PaymentAppServiceWorkerRegistration::from(registration) | 36 return PaymentAppServiceWorkerRegistration::from(registration) |
| 37 .paymentAppManager(scriptState); | 37 .paymentManager(scriptState); |
| 38 } | 38 } |
| 39 | 39 |
| 40 PaymentAppManager* PaymentAppServiceWorkerRegistration::paymentAppManager( | 40 PaymentManager* PaymentAppServiceWorkerRegistration::paymentManager( |
| 41 ScriptState* scriptState) { | 41 ScriptState* scriptState) { |
| 42 if (!m_paymentAppManager) { | 42 if (!m_paymentManager) { |
| 43 m_paymentAppManager = PaymentAppManager::create(m_registration); | 43 m_paymentManager = PaymentManager::create(m_registration); |
| 44 } | 44 } |
| 45 return m_paymentAppManager.get(); | 45 return m_paymentManager.get(); |
| 46 } | 46 } |
| 47 | 47 |
| 48 DEFINE_TRACE(PaymentAppServiceWorkerRegistration) { | 48 DEFINE_TRACE(PaymentAppServiceWorkerRegistration) { |
| 49 visitor->trace(m_registration); | 49 visitor->trace(m_registration); |
| 50 visitor->trace(m_paymentAppManager); | 50 visitor->trace(m_paymentManager); |
| 51 Supplement<ServiceWorkerRegistration>::trace(visitor); | 51 Supplement<ServiceWorkerRegistration>::trace(visitor); |
| 52 } | 52 } |
| 53 | 53 |
| 54 PaymentAppServiceWorkerRegistration::PaymentAppServiceWorkerRegistration( | 54 PaymentAppServiceWorkerRegistration::PaymentAppServiceWorkerRegistration( |
| 55 ServiceWorkerRegistration* registration) | 55 ServiceWorkerRegistration* registration) |
| 56 : m_registration(registration) {} | 56 : m_registration(registration) {} |
| 57 | 57 |
| 58 // static | 58 // static |
| 59 const char* PaymentAppServiceWorkerRegistration::supplementName() { | 59 const char* PaymentAppServiceWorkerRegistration::supplementName() { |
| 60 return "PaymentAppServiceWorkerRegistration"; | 60 return "PaymentAppServiceWorkerRegistration"; |
| 61 } | 61 } |
| 62 | 62 |
| 63 } // namespace blink | 63 } // namespace blink |
| OLD | NEW |