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 "chrome/browser/usb/usb_chooser_context.h" | 5 #include "chrome/browser/usb/usb_chooser_context.h" |
6 | 6 |
7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "device/core/device_client.h" | 10 #include "device/core/device_client.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 return device_dict; | 42 return device_dict; |
43 } | 43 } |
44 } | 44 } |
45 return nullptr; | 45 return nullptr; |
46 } | 46 } |
47 | 47 |
48 } // namespace | 48 } // namespace |
49 | 49 |
50 UsbChooserContext::UsbChooserContext(Profile* profile) | 50 UsbChooserContext::UsbChooserContext(Profile* profile) |
51 : ChooserContextBase(profile, | 51 : ChooserContextBase(profile, |
| 52 CONTENT_SETTINGS_TYPE_USB, |
52 CONTENT_SETTINGS_TYPE_USB_CHOOSER_DATA), | 53 CONTENT_SETTINGS_TYPE_USB_CHOOSER_DATA), |
53 observer_(this) { | 54 observer_(this) { |
54 usb_service_ = device::DeviceClient::Get()->GetUsbService(); | 55 usb_service_ = device::DeviceClient::Get()->GetUsbService(); |
55 if (usb_service_) | 56 if (usb_service_) |
56 observer_.Add(usb_service_); | 57 observer_.Add(usb_service_); |
57 } | 58 } |
58 | 59 |
59 UsbChooserContext::~UsbChooserContext() {} | 60 UsbChooserContext::~UsbChooserContext() {} |
60 | 61 |
61 void UsbChooserContext::GrantDevicePermission(const GURL& requesting_origin, | 62 void UsbChooserContext::GrantDevicePermission(const GURL& requesting_origin, |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 bool UsbChooserContext::IsValidObject(const base::DictionaryValue& object) { | 119 bool UsbChooserContext::IsValidObject(const base::DictionaryValue& object) { |
119 return object.size() == 4 && object.HasKey(kDeviceNameKey) && | 120 return object.size() == 4 && object.HasKey(kDeviceNameKey) && |
120 object.HasKey(kVendorIdKey) && object.HasKey(kProductIdKey) && | 121 object.HasKey(kVendorIdKey) && object.HasKey(kProductIdKey) && |
121 object.HasKey(kSerialNumberKey); | 122 object.HasKey(kSerialNumberKey); |
122 } | 123 } |
123 | 124 |
124 void UsbChooserContext::OnDeviceRemoved(scoped_refptr<UsbDevice> device) { | 125 void UsbChooserContext::OnDeviceRemoved(scoped_refptr<UsbDevice> device) { |
125 for (auto& map_entry : ephemeral_devices_) | 126 for (auto& map_entry : ephemeral_devices_) |
126 map_entry.second.erase(device->guid()); | 127 map_entry.second.erase(device->guid()); |
127 } | 128 } |
OLD | NEW |