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

Side by Side Diff: Source/modules/webusb/NavigatorUSB.cpp

Issue 1245363002: Add WebUSB bindings and client interface (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: iface ctors, OWNERS, rebase 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 unified diff | Download patch
« no previous file with comments | « Source/modules/webusb/NavigatorUSB.h ('k') | Source/modules/webusb/NavigatorUSB.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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
OLDNEW
« no previous file with comments | « Source/modules/webusb/NavigatorUSB.h ('k') | Source/modules/webusb/NavigatorUSB.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698