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_controller.h" | 5 #include "chrome/browser/usb/usb_chooser_controller.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
69 } | 69 } |
70 | 70 |
71 return device_name; | 71 return device_name; |
72 } | 72 } |
73 | 73 |
74 } // namespace | 74 } // namespace |
75 | 75 |
76 UsbChooserController::UsbChooserController( | 76 UsbChooserController::UsbChooserController( |
77 RenderFrameHost* render_frame_host, | 77 RenderFrameHost* render_frame_host, |
78 const std::vector<UsbDeviceFilter>& device_filters, | 78 const std::vector<UsbDeviceFilter>& device_filters, |
79 const device::usb::ChooserService::GetPermissionCallback& callback) | 79 const device::mojom::UsbChooserService::GetPermissionCallback& callback) |
80 : ChooserController(render_frame_host, | 80 : ChooserController(render_frame_host, |
81 IDS_USB_DEVICE_CHOOSER_PROMPT_ORIGIN, | 81 IDS_USB_DEVICE_CHOOSER_PROMPT_ORIGIN, |
82 IDS_USB_DEVICE_CHOOSER_PROMPT_EXTENSION_NAME), | 82 IDS_USB_DEVICE_CHOOSER_PROMPT_EXTENSION_NAME), |
83 filters_(device_filters), | 83 filters_(device_filters), |
84 callback_(callback), | 84 callback_(callback), |
85 usb_service_observer_(this), | 85 usb_service_observer_(this), |
86 weak_factory_(this) { | 86 weak_factory_(this) { |
87 device::UsbService* usb_service = | 87 device::UsbService* usb_service = |
88 device::DeviceClient::Get()->GetUsbService(); | 88 device::DeviceClient::Get()->GetUsbService(); |
89 if (usb_service) { | 89 if (usb_service) { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
153 void UsbChooserController::Select(const std::vector<size_t>& indices) { | 153 void UsbChooserController::Select(const std::vector<size_t>& indices) { |
154 DCHECK_EQ(1u, indices.size()); | 154 DCHECK_EQ(1u, indices.size()); |
155 size_t index = indices[0]; | 155 size_t index = indices[0]; |
156 DCHECK_LT(index, devices_.size()); | 156 DCHECK_LT(index, devices_.size()); |
157 | 157 |
158 if (chooser_context_) { | 158 if (chooser_context_) { |
159 chooser_context_->GrantDevicePermission( | 159 chooser_context_->GrantDevicePermission( |
160 requesting_origin_, embedding_origin_, devices_[index].first->guid()); | 160 requesting_origin_, embedding_origin_, devices_[index].first->guid()); |
161 } | 161 } |
162 | 162 |
163 device::usb::DeviceInfoPtr device_info_ptr = | 163 auto device_info_ptr = |
164 device::usb::DeviceInfo::From(*devices_[index].first); | 164 device::mojom::UsbDeviceInfo::From(*devices_[index].first); |
165 callback_.Run(std::move(device_info_ptr)); | 165 callback_.Run(std::move(device_info_ptr)); |
mcasas
2017/04/14 22:00:46
nit:
callback_.Run(device::mojom::UsbDeviceInfo:
Reilly Grant (use Gerrit)
2017/04/14 22:15:30
Done.
| |
166 callback_.Reset(); // Reset |callback_| so that it is only run once. | 166 callback_.Reset(); // Reset |callback_| so that it is only run once. |
167 | 167 |
168 RecordWebUsbChooserClosure( | 168 RecordWebUsbChooserClosure( |
169 devices_[index].first->serial_number().empty() | 169 devices_[index].first->serial_number().empty() |
170 ? WEBUSB_CHOOSER_CLOSED_EPHEMERAL_PERMISSION_GRANTED | 170 ? WEBUSB_CHOOSER_CLOSED_EPHEMERAL_PERMISSION_GRANTED |
171 : WEBUSB_CHOOSER_CLOSED_PERMISSION_GRANTED); | 171 : WEBUSB_CHOOSER_CLOSED_PERMISSION_GRANTED); |
172 } | 172 } |
173 | 173 |
174 void UsbChooserController::Cancel() { | 174 void UsbChooserController::Cancel() { |
175 RecordWebUsbChooserClosure(devices_.size() == 0 | 175 RecordWebUsbChooserClosure(devices_.size() == 0 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
236 | 236 |
237 // Embedded frames must have their origin in the list provided by the device. | 237 // Embedded frames must have their origin in the list provided by the device. |
238 if (is_embedded_frame_) { | 238 if (is_embedded_frame_) { |
239 return device::FindInWebUsbAllowedOrigins(device->webusb_allowed_origins(), | 239 return device::FindInWebUsbAllowedOrigins(device->webusb_allowed_origins(), |
240 requesting_origin_, base::nullopt, | 240 requesting_origin_, base::nullopt, |
241 base::nullopt); | 241 base::nullopt); |
242 } | 242 } |
243 | 243 |
244 return true; | 244 return true; |
245 } | 245 } |
OLD | NEW |