| 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..f97ae28ec74f741fe3881563ebee13837a66fcea
|
| --- /dev/null
|
| +++ b/Source/modules/webusb/NavigatorUSB.cpp
|
| @@ -0,0 +1,51 @@
|
| +// 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 {
|
| +
|
| +// static
|
| +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;
|
| +}
|
| +
|
| +// static
|
| +USB* NavigatorUSB::usb(Navigator& navigator)
|
| +{
|
| + return NavigatorUSB::from(navigator).usb();
|
| +}
|
| +
|
| +USB* NavigatorUSB::usb()
|
| +{
|
| + return m_usb.get();
|
| +}
|
| +
|
| +DEFINE_TRACE(NavigatorUSB)
|
| +{
|
| + visitor->trace(m_usb);
|
| + HeapSupplement<Navigator>::trace(visitor);
|
| +}
|
| +
|
| +NavigatorUSB::NavigatorUSB(Navigator& navigator)
|
| + : m_usb(USB::create(*navigator.frame()))
|
| +{
|
| +}
|
| +
|
| +const char* NavigatorUSB::supplementName()
|
| +{
|
| + return "NavigatorUSB";
|
| +}
|
| +
|
| +} // namespace blink
|
|
|