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/webusb/NavigatorUSB.h" |
| 7 |
| 8 #include "core/frame/Navigator.h" |
| 9 #include "modules/webusb/USB.h" |
| 10 |
| 11 namespace blink { |
| 12 |
| 13 // static |
| 14 NavigatorUSB& NavigatorUSB::from(Navigator& navigator) |
| 15 { |
| 16 NavigatorUSB* supplement = static_cast<NavigatorUSB*>(HeapSupplement<Navigat
or>::from(navigator, supplementName())); |
| 17 if (!supplement) { |
| 18 supplement = new NavigatorUSB(navigator); |
| 19 provideTo(navigator, supplementName(), supplement); |
| 20 } |
| 21 return *supplement; |
| 22 } |
| 23 |
| 24 // static |
| 25 USB* NavigatorUSB::usb(Navigator& navigator) |
| 26 { |
| 27 return NavigatorUSB::from(navigator).usb(); |
| 28 } |
| 29 |
| 30 USB* NavigatorUSB::usb() |
| 31 { |
| 32 return m_usb.get(); |
| 33 } |
| 34 |
| 35 DEFINE_TRACE(NavigatorUSB) |
| 36 { |
| 37 visitor->trace(m_usb); |
| 38 HeapSupplement<Navigator>::trace(visitor); |
| 39 } |
| 40 |
| 41 NavigatorUSB::NavigatorUSB(Navigator& navigator) |
| 42 : m_usb(USB::create(*navigator.frame())) |
| 43 { |
| 44 } |
| 45 |
| 46 const char* NavigatorUSB::supplementName() |
| 47 { |
| 48 return "NavigatorUSB"; |
| 49 } |
| 50 |
| 51 } // namespace blink |
OLD | NEW |