Chromium Code Reviews| Index: Source/modules/nfc/NavigatorNfc.cpp |
| diff --git a/Source/modules/nfc/NavigatorNfc.cpp b/Source/modules/nfc/NavigatorNfc.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..103517f401e96819b675406d0e6367becb1411a8 |
| --- /dev/null |
| +++ b/Source/modules/nfc/NavigatorNfc.cpp |
| @@ -0,0 +1,50 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "config.h" |
| +#include "modules/nfc/NavigatorNfc.h" |
| + |
| +#include "core/frame/Navigator.h" |
| +#include "modules/nfc/Nfc.h" |
| + |
| +namespace blink { |
| + |
| +NavigatorNfc::NavigatorNfc() |
| +{ |
| +} |
| + |
| +const char* NavigatorNfc::supplementName() |
| +{ |
| + return "NavigatorNfc"; |
| +} |
| + |
| +NavigatorNfc& NavigatorNfc::from(Navigator& navigator) |
| +{ |
| + NavigatorNfc* supplement = static_cast<NavigatorNfc*>(HeapSupplement<Navigator>::from(navigator, supplementName())); |
| + if (!supplement) { |
| + supplement = new NavigatorNfc(); |
| + provideTo(navigator, supplementName(), supplement); |
| + } |
| + return *supplement; |
| +} |
| + |
| +Nfc* NavigatorNfc::nfc(ExecutionContext* context, Navigator& navigator) |
| +{ |
| + NavigatorNfc& self = NavigatorNfc::from(navigator); |
| + if (!self.m_nfc) { |
| + if (!navigator.frame()) |
| + return nullptr; |
| + self.m_nfc = new Nfc(context, navigator.frame()); |
| + 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.
|
| + } |
| + return self.m_nfc.get(); |
| +} |
| + |
| +DEFINE_TRACE(NavigatorNfc) |
| +{ |
| + visitor->trace(m_nfc); |
| + HeapSupplement<Navigator>::trace(visitor); |
| +} |
| + |
| +} // namespace blink |