Chromium Code Reviews| 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 : ContextClient(navigator.frame()) {} | 16 : Supplement<Navigator>(navigator) {} |
| 17 | 17 |
| 18 NavigatorCredentials& NavigatorCredentials::from(Navigator& navigator) { | 18 NavigatorCredentials& NavigatorCredentials::from(Navigator& navigator) { |
| 19 NavigatorCredentials* supplement = static_cast<NavigatorCredentials*>( | 19 NavigatorCredentials* supplement = static_cast<NavigatorCredentials*>( |
| 20 Supplement<Navigator>::from(navigator, supplementName())); | 20 Supplement<Navigator>::from(navigator, supplementName())); |
| 21 if (!supplement) { | 21 if (!supplement) { |
| 22 supplement = new NavigatorCredentials(navigator); | 22 supplement = new NavigatorCredentials(navigator); |
| 23 provideTo(navigator, supplementName(), supplement); | 23 provideTo(navigator, supplementName(), supplement); |
| 24 } | 24 } |
| 25 return *supplement; | 25 return *supplement; |
| 26 } | 26 } |
| 27 | 27 |
| 28 const char* NavigatorCredentials::supplementName() { | 28 const char* NavigatorCredentials::supplementName() { |
| 29 return "NavigatorCredentials"; | 29 return "NavigatorCredentials"; |
| 30 } | 30 } |
| 31 | 31 |
| 32 CredentialsContainer* NavigatorCredentials::credentials(Navigator& navigator) { | 32 CredentialsContainer* NavigatorCredentials::credentials(Navigator& navigator) { |
| 33 return NavigatorCredentials::from(navigator).credentials(); | 33 return NavigatorCredentials::from(navigator).credentials(); |
| 34 } | 34 } |
| 35 | 35 |
| 36 CredentialsContainer* NavigatorCredentials::credentials() { | 36 CredentialsContainer* NavigatorCredentials::credentials() { |
| 37 if (!m_credentialsContainer && frame()) | 37 if (!m_credentialsContainer) |
|
haraken
2017/01/06 01:04:50
I don't think the frame() check makes sense. So dr
sof
2017/01/06 06:25:57
yes, no implicit dependency on there being a frame
| |
| 38 m_credentialsContainer = CredentialsContainer::create(); | 38 m_credentialsContainer = CredentialsContainer::create(); |
| 39 return m_credentialsContainer.get(); | 39 return m_credentialsContainer.get(); |
| 40 } | 40 } |
| 41 | 41 |
| 42 DEFINE_TRACE(NavigatorCredentials) { | 42 DEFINE_TRACE(NavigatorCredentials) { |
| 43 visitor->trace(m_credentialsContainer); | 43 visitor->trace(m_credentialsContainer); |
| 44 Supplement<Navigator>::trace(visitor); | 44 Supplement<Navigator>::trace(visitor); |
| 45 ContextClient::trace(visitor); | |
| 46 } | 45 } |
| 47 | 46 |
| 48 } // namespace blink | 47 } // namespace blink |
| OLD | NEW |