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 = new Nfc(context, navigator.frame()); | |
39 self.m_nfc->suspendIfNeeded(); | |
haraken
2015/08/17 16:25:33
It would be better to create Nfc::create() and cal
riju_
2015/08/18 11:36:15
Done.
| |
40 } | |
41 return self.m_nfc.get(); | |
42 } | |
43 | |
44 DEFINE_TRACE(NavigatorNfc) | |
45 { | |
46 visitor->trace(m_nfc); | |
47 HeapSupplement<Navigator>::trace(visitor); | |
48 } | |
49 | |
50 } // namespace blink | |
OLD | NEW |