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