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