| 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 | 64 |
| 65 usb_service->GetDevices(base::Bind(&UsbChooserController::GotUsbDeviceList, | 65 usb_service->GetDevices(base::Bind(&UsbChooserController::GotUsbDeviceList, |
| 66 weak_factory_.GetWeakPtr())); | 66 weak_factory_.GetWeakPtr())); |
| 67 } | 67 } |
| 68 | 68 |
| 69 UsbChooserController::~UsbChooserController() { | 69 UsbChooserController::~UsbChooserController() { |
| 70 if (!callback_.is_null()) | 70 if (!callback_.is_null()) |
| 71 callback_.Run(nullptr); | 71 callback_.Run(nullptr); |
| 72 } | 72 } |
| 73 | 73 |
| 74 base::string16 UsbChooserController::GetOkButtonLabel() const { |
| 75 return l10n_util::GetStringUTF16(IDS_USB_DEVICE_CHOOSER_CONNECT_BUTTON_TEXT); |
| 76 } |
| 77 |
| 74 size_t UsbChooserController::NumOptions() const { | 78 size_t UsbChooserController::NumOptions() const { |
| 75 return devices_.size(); | 79 return devices_.size(); |
| 76 } | 80 } |
| 77 | 81 |
| 78 base::string16 UsbChooserController::GetOption(size_t index) const { | 82 base::string16 UsbChooserController::GetOption(size_t index) const { |
| 79 DCHECK_LT(index, devices_.size()); | 83 DCHECK_LT(index, devices_.size()); |
| 80 const base::string16& device_name = devices_[index].second; | 84 const base::string16& device_name = devices_[index].second; |
| 81 const auto& it = device_name_map_.find(device_name); | 85 const auto& it = device_name_map_.find(device_name); |
| 82 DCHECK(it != device_name_map_.end()); | 86 DCHECK(it != device_name_map_.end()); |
| 83 return it->second == 1 | 87 return it->second == 1 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 | 175 |
| 172 bool UsbChooserController::DisplayDevice( | 176 bool UsbChooserController::DisplayDevice( |
| 173 scoped_refptr<device::UsbDevice> device) const { | 177 scoped_refptr<device::UsbDevice> device) const { |
| 174 return device::UsbDeviceFilter::MatchesAny(device, filters_) && | 178 return device::UsbDeviceFilter::MatchesAny(device, filters_) && |
| 175 (base::CommandLine::ForCurrentProcess()->HasSwitch( | 179 (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 176 switches::kDisableWebUsbSecurity) || | 180 switches::kDisableWebUsbSecurity) || |
| 177 device::FindInWebUsbAllowedOrigins( | 181 device::FindInWebUsbAllowedOrigins( |
| 178 device->webusb_allowed_origins(), | 182 device->webusb_allowed_origins(), |
| 179 render_frame_host_->GetLastCommittedURL().GetOrigin())); | 183 render_frame_host_->GetLastCommittedURL().GetOrigin())); |
| 180 } | 184 } |
| OLD | NEW |