Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(189)

Unified Diff: Source/modules/nfc/NavigatorNfc.cpp

Issue 1291663004: [webnfc]: Step 1: Add NavigatorNfc, Nfc and Layout tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/modules/nfc/NavigatorNfc.h ('k') | Source/modules/nfc/NavigatorNfc.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « Source/modules/nfc/NavigatorNfc.h ('k') | Source/modules/nfc/NavigatorNfc.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698