Index: Source/modules/webusb/NavigatorUSB.cpp |
diff --git a/Source/modules/webusb/NavigatorUSB.cpp b/Source/modules/webusb/NavigatorUSB.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..bd854f0bcb3e176561105e5b2986469d237f25c2 |
--- /dev/null |
+++ b/Source/modules/webusb/NavigatorUSB.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/webusb/NavigatorUSB.h" |
+ |
+#include "core/frame/Navigator.h" |
+#include "modules/webusb/USB.h" |
+ |
+namespace blink { |
+ |
+NavigatorUSB& NavigatorUSB::from(Navigator& navigator) |
+{ |
+ NavigatorUSB* supplement = static_cast<NavigatorUSB*>(HeapSupplement<Navigator>::from(navigator, supplementName())); |
+ if (!supplement) { |
+ supplement = new NavigatorUSB(navigator); |
+ provideTo(navigator, supplementName(), supplement); |
+ } |
+ return *supplement; |
+} |
+ |
+USB* NavigatorUSB::usb(Navigator& navigator) |
+{ |
+ return NavigatorUSB::from(navigator).usb(); |
+} |
+ |
+USB* NavigatorUSB::usb() |
+{ |
+ return m_usb; |
+} |
+ |
+DEFINE_TRACE(NavigatorUSB) |
+{ |
+ visitor->trace(m_usb); |
+ HeapSupplement<Navigator>::trace(visitor); |
+} |
+ |
+NavigatorUSB::NavigatorUSB(Navigator& navigator) |
+{ |
+ if (navigator.frame()) |
+ m_usb = USB::create(*navigator.frame()); |
+} |
+ |
+const char* NavigatorUSB::supplementName() |
+{ |
+ return "NavigatorUSB"; |
+} |
+ |
+} // namespace blink |