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 <utility> | 7 #include <utility> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 } | 152 } |
153 } | 153 } |
154 | 154 |
155 bool UsbChooserContext::HasDevicePermission( | 155 bool UsbChooserContext::HasDevicePermission( |
156 const GURL& requesting_origin, | 156 const GURL& requesting_origin, |
157 const GURL& embedding_origin, | 157 const GURL& embedding_origin, |
158 scoped_refptr<const device::UsbDevice> device) { | 158 scoped_refptr<const device::UsbDevice> device) { |
159 auto it = ephemeral_devices_.find( | 159 auto it = ephemeral_devices_.find( |
160 std::make_pair(requesting_origin, embedding_origin)); | 160 std::make_pair(requesting_origin, embedding_origin)); |
161 if (it != ephemeral_devices_.end() && | 161 if (it != ephemeral_devices_.end() && |
162 ContainsValue(it->second, device->guid())) { | 162 base::ContainsValue(it->second, device->guid())) { |
163 return true; | 163 return true; |
164 } | 164 } |
165 | 165 |
166 std::vector<std::unique_ptr<base::DictionaryValue>> device_list = | 166 std::vector<std::unique_ptr<base::DictionaryValue>> device_list = |
167 GetGrantedObjects(requesting_origin, embedding_origin); | 167 GetGrantedObjects(requesting_origin, embedding_origin); |
168 for (const std::unique_ptr<base::DictionaryValue>& device_dict : | 168 for (const std::unique_ptr<base::DictionaryValue>& device_dict : |
169 device_list) { | 169 device_list) { |
170 int vendor_id; | 170 int vendor_id; |
171 int product_id; | 171 int product_id; |
172 base::string16 serial_number; | 172 base::string16 serial_number; |
(...skipping 13 matching lines...) Expand all Loading... |
186 bool UsbChooserContext::IsValidObject(const base::DictionaryValue& object) { | 186 bool UsbChooserContext::IsValidObject(const base::DictionaryValue& object) { |
187 return object.size() == 4 && object.HasKey(kDeviceNameKey) && | 187 return object.size() == 4 && object.HasKey(kDeviceNameKey) && |
188 object.HasKey(kVendorIdKey) && object.HasKey(kProductIdKey) && | 188 object.HasKey(kVendorIdKey) && object.HasKey(kProductIdKey) && |
189 object.HasKey(kSerialNumberKey); | 189 object.HasKey(kSerialNumberKey); |
190 } | 190 } |
191 | 191 |
192 void UsbChooserContext::OnDeviceRemoved(scoped_refptr<UsbDevice> device) { | 192 void UsbChooserContext::OnDeviceRemoved(scoped_refptr<UsbDevice> device) { |
193 for (auto& map_entry : ephemeral_devices_) | 193 for (auto& map_entry : ephemeral_devices_) |
194 map_entry.second.erase(device->guid()); | 194 map_entry.second.erase(device->guid()); |
195 } | 195 } |
OLD | NEW |