| 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(Script
State* scriptState) { |
| 38 if (!m_paymentAppManager) | 40 if (!m_paymentAppManager) |
| 39 m_paymentAppManager = PaymentAppManager::create(m_registration); | 41 m_paymentAppManager = PaymentAppManager::create(scriptState, m_registration)
; |
| 40 return m_paymentAppManager.get(); | 42 return m_paymentAppManager.get(); |
| 41 } | 43 } |
| 42 | 44 |
| 43 DEFINE_TRACE(PaymentAppServiceWorkerRegistration) { | 45 DEFINE_TRACE(PaymentAppServiceWorkerRegistration) { |
| 44 visitor->trace(m_registration); | 46 visitor->trace(m_registration); |
| 45 visitor->trace(m_paymentAppManager); | 47 visitor->trace(m_paymentAppManager); |
| 46 Supplement<ServiceWorkerRegistration>::trace(visitor); | 48 Supplement<ServiceWorkerRegistration>::trace(visitor); |
| 47 } | 49 } |
| 48 | 50 |
| 49 PaymentAppServiceWorkerRegistration::PaymentAppServiceWorkerRegistration( | 51 PaymentAppServiceWorkerRegistration::PaymentAppServiceWorkerRegistration( |
| 50 ServiceWorkerRegistration* registration) | 52 ServiceWorkerRegistration* registration) |
| 51 : m_registration(registration) {} | 53 : m_registration(registration) {} |
| 52 | 54 |
| 53 // static | 55 // static |
| 54 const char* PaymentAppServiceWorkerRegistration::supplementName() { | 56 const char* PaymentAppServiceWorkerRegistration::supplementName() { |
| 55 return "PaymentAppServiceWorkerRegistration"; | 57 return "PaymentAppServiceWorkerRegistration"; |
| 56 } | 58 } |
| 57 | 59 |
| 58 } // namespace blink | 60 } // namespace blink |
| OLD | NEW |