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 "modules/webusb/USBController.h" | |
6 | |
7 #include "platform/RuntimeEnabledFeatures.h" | |
8 #include "public/platform/modules/webusb/WebUSBClient.h" | |
9 | |
10 namespace blink { | |
11 | |
12 USBController::~USBController() | |
13 { | |
14 } | |
15 | |
16 void USBController::provideTo(LocalFrame& frame, WebUSBClient* client) | |
17 { | |
18 ASSERT(RuntimeEnabledFeatures::webUSBEnabled()); | |
19 USBController* controller = new USBController(frame, client); | |
20 Supplement<LocalFrame>::provideTo(frame, supplementName(), controller); | |
21 } | |
22 | |
23 USBController& USBController::from(LocalFrame& frame) | |
24 { | |
25 USBController* controller = static_cast<USBController*>(Supplement<LocalFram
e>::from(frame, supplementName())); | |
26 ASSERT(controller); | |
27 return *controller; | |
28 } | |
29 | |
30 const char* USBController::supplementName() | |
31 { | |
32 return "USBController"; | |
33 } | |
34 | |
35 USBController::USBController(LocalFrame& frame, WebUSBClient* client) | |
36 : LocalFrameLifecycleObserver(&frame) | |
37 , m_client(client) | |
38 { | |
39 } | |
40 | |
41 void USBController::willDetachFrameHost() | |
42 { | |
43 m_client = nullptr; | |
44 } | |
45 | |
46 DEFINE_TRACE(USBController) | |
47 { | |
48 Supplement<LocalFrame>::trace(visitor); | |
49 LocalFrameLifecycleObserver::trace(visitor); | |
50 } | |
51 | |
52 } // namespace blink | |
OLD | NEW |