summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/modules/permissions/navigator_permissions.cc
blob: e477dc3b0e521c7cadb5fa5698dd3f56482afa4d (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
// Copyright 2015 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/permissions/navigator_permissions.h"

#include "third_party/blink/renderer/core/frame/navigator.h"
#include "third_party/blink/renderer/modules/permissions/permissions.h"

namespace blink {

NavigatorPermissions::NavigatorPermissions() = default;

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

// static
NavigatorPermissions& NavigatorPermissions::From(Navigator& navigator) {
  NavigatorPermissions* supplement =
      Supplement<Navigator>::From<NavigatorPermissions>(navigator);
  if (!supplement) {
    supplement = MakeGarbageCollected<NavigatorPermissions>();
    ProvideTo(navigator, supplement);
  }
  return *supplement;
}

// static
Permissions* NavigatorPermissions::permissions(Navigator& navigator) {
  NavigatorPermissions& self = NavigatorPermissions::From(navigator);
  if (!self.permissions_)
    self.permissions_ = MakeGarbageCollected<Permissions>();
  return self.permissions_.Get();
}

void NavigatorPermissions::Trace(blink::Visitor* visitor) {
  visitor->Trace(permissions_);
  Supplement<Navigator>::Trace(visitor);
}

}  // namespace blink