| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/nfc/NavigatorNFC.h" | 5 #include "modules/nfc/NavigatorNFC.h" |
| 6 | 6 |
| 7 #include "core/frame/Navigator.h" | 7 #include "core/frame/Navigator.h" |
| 8 #include "modules/nfc/NFC.h" | 8 #include "modules/nfc/NFC.h" |
| 9 | 9 |
| 10 namespace blink { | 10 namespace blink { |
| 11 | 11 |
| 12 NavigatorNFC::NavigatorNFC() | 12 NavigatorNFC::NavigatorNFC() |
| 13 { | 13 { |
| 14 } | 14 } |
| 15 | 15 |
| 16 const char* NavigatorNFC::supplementName() | 16 const char* NavigatorNFC::supplementName() |
| 17 { | 17 { |
| 18 return "NavigatorNFC"; | 18 return "NavigatorNFC"; |
| 19 } | 19 } |
| 20 | 20 |
| 21 NavigatorNFC& NavigatorNFC::from(Navigator& navigator) | 21 NavigatorNFC& NavigatorNFC::from(Navigator& navigator) |
| 22 { | 22 { |
| 23 NavigatorNFC* supplement = static_cast<NavigatorNFC*>(HeapSupplement<Navigat
or>::from(navigator, supplementName())); | 23 NavigatorNFC* supplement = static_cast<NavigatorNFC*>(Supplement<Navigator>:
:from(navigator, supplementName())); |
| 24 if (!supplement) { | 24 if (!supplement) { |
| 25 supplement = new NavigatorNFC(); | 25 supplement = new NavigatorNFC(); |
| 26 provideTo(navigator, supplementName(), supplement); | 26 provideTo(navigator, supplementName(), supplement); |
| 27 } | 27 } |
| 28 return *supplement; | 28 return *supplement; |
| 29 } | 29 } |
| 30 | 30 |
| 31 NFC* NavigatorNFC::nfc(Navigator& navigator) | 31 NFC* NavigatorNFC::nfc(Navigator& navigator) |
| 32 { | 32 { |
| 33 NavigatorNFC& self = NavigatorNFC::from(navigator); | 33 NavigatorNFC& self = NavigatorNFC::from(navigator); |
| 34 if (!self.m_nfc) { | 34 if (!self.m_nfc) { |
| 35 if (!navigator.frame()) | 35 if (!navigator.frame()) |
| 36 return nullptr; | 36 return nullptr; |
| 37 self.m_nfc = NFC::create(navigator.frame()); | 37 self.m_nfc = NFC::create(navigator.frame()); |
| 38 } | 38 } |
| 39 return self.m_nfc.get(); | 39 return self.m_nfc.get(); |
| 40 } | 40 } |
| 41 | 41 |
| 42 DEFINE_TRACE(NavigatorNFC) | 42 DEFINE_TRACE(NavigatorNFC) |
| 43 { | 43 { |
| 44 visitor->trace(m_nfc); | 44 visitor->trace(m_nfc); |
| 45 HeapSupplement<Navigator>::trace(visitor); | 45 Supplement<Navigator>::trace(visitor); |
| 46 } | 46 } |
| 47 | 47 |
| 48 } // namespace blink | 48 } // namespace blink |
| OLD | NEW |