OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/credentialmanager/NavigatorCredentials.h" | 5 #include "modules/credentialmanager/NavigatorCredentials.h" |
6 | 6 |
7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
8 #include "core/frame/LocalDOMWindow.h" | 8 #include "core/frame/LocalDOMWindow.h" |
9 #include "core/frame/LocalFrame.h" | 9 #include "core/frame/LocalFrame.h" |
10 #include "core/frame/Navigator.h" | 10 #include "core/frame/Navigator.h" |
11 #include "modules/credentialmanager/CredentialsContainer.h" | 11 #include "modules/credentialmanager/CredentialsContainer.h" |
12 | 12 |
13 namespace blink { | 13 namespace blink { |
14 | 14 |
15 NavigatorCredentials::NavigatorCredentials(Navigator& navigator) | 15 NavigatorCredentials::NavigatorCredentials(Navigator& navigator) |
16 : DOMWindowProperty(navigator.frame()) | 16 : DOMWindowProperty(navigator.frame()) |
17 { | 17 { |
18 } | 18 } |
19 | 19 |
20 NavigatorCredentials::~NavigatorCredentials() | 20 NavigatorCredentials::~NavigatorCredentials() |
21 { | 21 { |
22 } | 22 } |
23 | 23 |
24 NavigatorCredentials& NavigatorCredentials::from(Navigator& navigator) | 24 NavigatorCredentials& NavigatorCredentials::from(Navigator& navigator) |
25 { | 25 { |
26 NavigatorCredentials* supplement = static_cast<NavigatorCredentials*>(HeapSu
pplement<Navigator>::from(navigator, supplementName())); | 26 NavigatorCredentials* supplement = static_cast<NavigatorCredentials*>(Supple
ment<Navigator>::from(navigator, supplementName())); |
27 if (!supplement) { | 27 if (!supplement) { |
28 supplement = new NavigatorCredentials(navigator); | 28 supplement = new NavigatorCredentials(navigator); |
29 provideTo(navigator, supplementName(), supplement); | 29 provideTo(navigator, supplementName(), supplement); |
30 } | 30 } |
31 return *supplement; | 31 return *supplement; |
32 } | 32 } |
33 | 33 |
34 const char* NavigatorCredentials::supplementName() | 34 const char* NavigatorCredentials::supplementName() |
35 { | 35 { |
36 return "NavigatorCredentials"; | 36 return "NavigatorCredentials"; |
37 } | 37 } |
38 | 38 |
39 CredentialsContainer* NavigatorCredentials::credentials(Navigator& navigator) | 39 CredentialsContainer* NavigatorCredentials::credentials(Navigator& navigator) |
40 { | 40 { |
41 return NavigatorCredentials::from(navigator).credentials(); | 41 return NavigatorCredentials::from(navigator).credentials(); |
42 } | 42 } |
43 | 43 |
44 CredentialsContainer* NavigatorCredentials::credentials() | 44 CredentialsContainer* NavigatorCredentials::credentials() |
45 { | 45 { |
46 if (!m_credentialsContainer && frame()) | 46 if (!m_credentialsContainer && frame()) |
47 m_credentialsContainer = CredentialsContainer::create(); | 47 m_credentialsContainer = CredentialsContainer::create(); |
48 return m_credentialsContainer.get(); | 48 return m_credentialsContainer.get(); |
49 } | 49 } |
50 | 50 |
51 DEFINE_TRACE(NavigatorCredentials) | 51 DEFINE_TRACE(NavigatorCredentials) |
52 { | 52 { |
53 visitor->trace(m_credentialsContainer); | 53 visitor->trace(m_credentialsContainer); |
54 HeapSupplement<Navigator>::trace(visitor); | 54 Supplement<Navigator>::trace(visitor); |
55 DOMWindowProperty::trace(visitor); | 55 DOMWindowProperty::trace(visitor); |
56 } | 56 } |
57 | 57 |
58 } // namespace blink | 58 } // namespace blink |
OLD | NEW |