summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/modules/credentialmanager/navigator_credentials.cc
blob: 8051c1c017f1fc666e597acdb4f4b35c2dfc93ed (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
// Copyright 2014 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/credentialmanager/navigator_credentials.h"

#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/navigator.h"
#include "third_party/blink/renderer/modules/credentialmanager/credentials_container.h"

namespace blink {

NavigatorCredentials::NavigatorCredentials(Navigator& navigator)
    : Supplement<Navigator>(navigator) {}

NavigatorCredentials& NavigatorCredentials::From(Navigator& navigator) {
  NavigatorCredentials* supplement =
      Supplement<Navigator>::From<NavigatorCredentials>(navigator);
  if (!supplement) {
    supplement = new NavigatorCredentials(navigator);
    ProvideTo(navigator, supplement);
  }
  return *supplement;
}

const char NavigatorCredentials::kSupplementName[] = "NavigatorCredentials";

CredentialsContainer* NavigatorCredentials::credentials(Navigator& navigator) {
  return NavigatorCredentials::From(navigator).credentials();
}

CredentialsContainer* NavigatorCredentials::credentials() {
  if (!credentials_container_)
    credentials_container_ = CredentialsContainer::Create();
  return credentials_container_.Get();
}

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

}  // namespace blink