summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/modules/payments/html_iframe_element_payments.cc
blob: 154381ae6839582cd1bd8c66894e2399933b28cd (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
// 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/html_iframe_element_payments.h"

#include "third_party/blink/renderer/core/dom/qualified_name.h"
#include "third_party/blink/renderer/core/html/html_iframe_element.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"

namespace blink {

HTMLIFrameElementPayments::HTMLIFrameElementPayments() = default;

// static
const char HTMLIFrameElementPayments::kSupplementName[] =
    "HTMLIFrameElementPayments";

// static
bool HTMLIFrameElementPayments::FastHasAttribute(
    const HTMLIFrameElement& element,
    const QualifiedName& name) {
  DCHECK(name == html_names::kAllowpaymentrequestAttr);
  return element.FastHasAttribute(name);
}

// static
void HTMLIFrameElementPayments::SetBooleanAttribute(HTMLIFrameElement& element,
                                                    const QualifiedName& name,
                                                    bool value) {
  DCHECK(name == html_names::kAllowpaymentrequestAttr);
  element.SetBooleanAttribute(name, value);
}

// static
HTMLIFrameElementPayments& HTMLIFrameElementPayments::From(
    HTMLIFrameElement& iframe) {
  HTMLIFrameElementPayments* supplement =
      Supplement<HTMLIFrameElement>::From<HTMLIFrameElementPayments>(iframe);
  if (!supplement) {
    supplement = MakeGarbageCollected<HTMLIFrameElementPayments>();
    ProvideTo(iframe, supplement);
  }
  return *supplement;
}

// static
bool HTMLIFrameElementPayments::AllowPaymentRequest(
    HTMLIFrameElement& element) {
  return RuntimeEnabledFeatures::PaymentRequestEnabled() &&
         element.FastHasAttribute(html_names::kAllowpaymentrequestAttr);
}

void HTMLIFrameElementPayments::Trace(Visitor* visitor) const {
  Supplement<HTMLIFrameElement>::Trace(visitor);
}

}  // namespace blink