| 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 RecordWebUsbChooserClosure(devices_.size() == 0 | 132 RecordWebUsbChooserClosure(devices_.size() == 0 |
| 133 ? WEBUSB_CHOOSER_CLOSED_CANCELLED_NO_DEVICES | 133 ? WEBUSB_CHOOSER_CLOSED_CANCELLED_NO_DEVICES |
| 134 : WEBUSB_CHOOSER_CLOSED_CANCELLED); | 134 : WEBUSB_CHOOSER_CLOSED_CANCELLED); |
| 135 } | 135 } |
| 136 | 136 |
| 137 void UsbChooserController::Close() {} | 137 void UsbChooserController::Close() {} |
| 138 | 138 |
| 139 void UsbChooserController::OpenHelpCenterUrl() const { | 139 void UsbChooserController::OpenHelpCenterUrl() const { |
| 140 GetBrowser()->OpenURL(content::OpenURLParams( | 140 GetBrowser()->OpenURL(content::OpenURLParams( |
| 141 GURL(chrome::kChooserUsbOverviewURL), content::Referrer(), | 141 GURL(chrome::kChooserUsbOverviewURL), content::Referrer(), |
| 142 NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_AUTO_TOPLEVEL, | 142 WindowOpenDisposition::NEW_FOREGROUND_TAB, |
| 143 false /* is_renderer_initialized */)); | 143 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, false /* is_renderer_initialized */)); |
| 144 } | 144 } |
| 145 | 145 |
| 146 void UsbChooserController::OnDeviceAdded( | 146 void UsbChooserController::OnDeviceAdded( |
| 147 scoped_refptr<device::UsbDevice> device) { | 147 scoped_refptr<device::UsbDevice> device) { |
| 148 if (DisplayDevice(device)) { | 148 if (DisplayDevice(device)) { |
| 149 const base::string16& device_name = device->product_string(); | 149 const base::string16& device_name = device->product_string(); |
| 150 devices_.push_back(std::make_pair(device, device_name)); | 150 devices_.push_back(std::make_pair(device, device_name)); |
| 151 ++device_name_map_[device_name]; | 151 ++device_name_map_[device_name]; |
| 152 if (view()) | 152 if (view()) |
| 153 view()->OnOptionAdded(devices_.size() - 1); | 153 view()->OnOptionAdded(devices_.size() - 1); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 | 187 |
| 188 bool UsbChooserController::DisplayDevice( | 188 bool UsbChooserController::DisplayDevice( |
| 189 scoped_refptr<device::UsbDevice> device) const { | 189 scoped_refptr<device::UsbDevice> device) const { |
| 190 return device::UsbDeviceFilter::MatchesAny(device, filters_) && | 190 return device::UsbDeviceFilter::MatchesAny(device, filters_) && |
| 191 (base::CommandLine::ForCurrentProcess()->HasSwitch( | 191 (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 192 switches::kDisableWebUsbSecurity) || | 192 switches::kDisableWebUsbSecurity) || |
| 193 device::FindInWebUsbAllowedOrigins( | 193 device::FindInWebUsbAllowedOrigins( |
| 194 device->webusb_allowed_origins(), | 194 device->webusb_allowed_origins(), |
| 195 render_frame_host_->GetLastCommittedURL().GetOrigin())); | 195 render_frame_host_->GetLastCommittedURL().GetOrigin())); |
| 196 } | 196 } |
| OLD | NEW |