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

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

Issue 1262163003: Add WebUSB bindings and client interface [part 1] (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Handle null navigator.frame() without ASSERT 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 NavigatorUSB& NavigatorUSB::from(Navigator& navigator)
14 {
15 NavigatorUSB* supplement = static_cast<NavigatorUSB*>(HeapSupplement<Navigat or>::from(navigator, supplementName()));
16 if (!supplement) {
17 supplement = new NavigatorUSB(navigator);
18 provideTo(navigator, supplementName(), supplement);
19 }
20 return *supplement;
21 }
22
23 USB* NavigatorUSB::usb(Navigator& navigator)
24 {
25 return NavigatorUSB::from(navigator).usb();
26 }
27
28 USB* NavigatorUSB::usb()
29 {
30 return m_usb;
31 }
32
33 DEFINE_TRACE(NavigatorUSB)
34 {
35 visitor->trace(m_usb);
36 HeapSupplement<Navigator>::trace(visitor);
37 }
38
39 NavigatorUSB::NavigatorUSB(Navigator& navigator)
40 {
41 if (navigator.frame())
42 m_usb = USB::create(*navigator.frame());
43 }
44
45 const char* NavigatorUSB::supplementName()
46 {
47 return "NavigatorUSB";
48 }
49
50 } // 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