blob: a9caf53e8ab08a721fd94c236ed1ffa51b341a0b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "third_party/blink/renderer/modules/payments/payment_app_service_worker_registration.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/modules/payments/payment_manager.h"
#include "third_party/blink/renderer/modules/serviceworkers/service_worker_registration.h"
#include "third_party/blink/renderer/platform/bindings/script_state.h"
namespace blink {
PaymentAppServiceWorkerRegistration::~PaymentAppServiceWorkerRegistration() =
default;
// static
PaymentAppServiceWorkerRegistration& PaymentAppServiceWorkerRegistration::From(
ServiceWorkerRegistration& registration) {
PaymentAppServiceWorkerRegistration* supplement =
Supplement<ServiceWorkerRegistration>::From<
PaymentAppServiceWorkerRegistration>(registration);
if (!supplement) {
supplement = new PaymentAppServiceWorkerRegistration(®istration);
ProvideTo(registration, supplement);
}
return *supplement;
}
// static
PaymentManager* PaymentAppServiceWorkerRegistration::paymentManager(
ScriptState* script_state,
ServiceWorkerRegistration& registration) {
return PaymentAppServiceWorkerRegistration::From(registration)
.paymentManager(script_state);
}
PaymentManager* PaymentAppServiceWorkerRegistration::paymentManager(
ScriptState* script_state) {
if (!payment_manager_) {
payment_manager_ = PaymentManager::Create(registration_);
}
return payment_manager_.Get();
}
void PaymentAppServiceWorkerRegistration::Trace(blink::Visitor* visitor) {
visitor->Trace(registration_);
visitor->Trace(payment_manager_);
Supplement<ServiceWorkerRegistration>::Trace(visitor);
}
PaymentAppServiceWorkerRegistration::PaymentAppServiceWorkerRegistration(
ServiceWorkerRegistration* registration)
: registration_(registration) {}
// static
const char PaymentAppServiceWorkerRegistration::kSupplementName[] =
"PaymentAppServiceWorkerRegistration";
} // namespace blink
|