OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "device/usb/usb_device.h" | 5 #include "device/usb/usb_device.h" |
6 | 6 |
7 #include "base/guid.h" | 7 #include "base/guid.h" |
8 #include "device/usb/webusb_descriptors.h" | 8 #include "device/usb/webusb_descriptors.h" |
9 | 9 |
10 namespace device { | 10 namespace device { |
11 | 11 |
| 12 UsbDevice::Observer::~Observer() {} |
| 13 |
| 14 void UsbDevice::Observer::OnDeviceRemoved(scoped_refptr<UsbDevice> device) {} |
| 15 |
12 UsbDevice::UsbDevice(uint16_t vendor_id, | 16 UsbDevice::UsbDevice(uint16_t vendor_id, |
13 uint16_t product_id, | 17 uint16_t product_id, |
14 const base::string16& manufacturer_string, | 18 const base::string16& manufacturer_string, |
15 const base::string16& product_string, | 19 const base::string16& product_string, |
16 const base::string16& serial_number) | 20 const base::string16& serial_number) |
17 : manufacturer_string_(manufacturer_string), | 21 : manufacturer_string_(manufacturer_string), |
18 product_string_(product_string), | 22 product_string_(product_string), |
19 serial_number_(serial_number), | 23 serial_number_(serial_number), |
20 guid_(base::GenerateGUID()), | 24 guid_(base::GenerateGUID()), |
21 vendor_id_(vendor_id), | 25 vendor_id_(vendor_id), |
22 product_id_(product_id) {} | 26 product_id_(product_id) {} |
23 | 27 |
24 UsbDevice::~UsbDevice() { | 28 UsbDevice::~UsbDevice() { |
25 } | 29 } |
26 | 30 |
27 void UsbDevice::CheckUsbAccess(const ResultCallback& callback) { | 31 void UsbDevice::CheckUsbAccess(const ResultCallback& callback) { |
28 // By default assume that access to the device is allowed. This is implemented | 32 // By default assume that access to the device is allowed. This is implemented |
29 // on Chrome OS by checking with permission_broker. | 33 // on Chrome OS by checking with permission_broker. |
30 callback.Run(true); | 34 callback.Run(true); |
31 } | 35 } |
32 | 36 |
| 37 void UsbDevice::AddObserver(Observer* observer) { |
| 38 observer_list_.AddObserver(observer); |
| 39 } |
| 40 |
| 41 void UsbDevice::RemoveObserver(Observer* observer) { |
| 42 observer_list_.RemoveObserver(observer); |
| 43 } |
| 44 |
| 45 void UsbDevice::NotifyDeviceRemoved() { |
| 46 FOR_EACH_OBSERVER(Observer, observer_list_, OnDeviceRemoved(this)); |
| 47 } |
| 48 |
33 } // namespace device | 49 } // namespace device |
OLD | NEW |