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