| 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 | 66 |
| 67 usb_service->GetDevices(base::Bind(&UsbChooserController::GotUsbDeviceList, | 67 usb_service->GetDevices(base::Bind(&UsbChooserController::GotUsbDeviceList, |
| 68 weak_factory_.GetWeakPtr())); | 68 weak_factory_.GetWeakPtr())); |
| 69 } | 69 } |
| 70 | 70 |
| 71 UsbChooserController::~UsbChooserController() { | 71 UsbChooserController::~UsbChooserController() { |
| 72 if (!callback_.is_null()) | 72 if (!callback_.is_null()) |
| 73 callback_.Run(nullptr); | 73 callback_.Run(nullptr); |
| 74 } | 74 } |
| 75 | 75 |
| 76 bool UsbChooserController::HasIconBeforeText() const { |
| 77 return false; |
| 78 } |
| 79 |
| 76 base::string16 UsbChooserController::GetNoOptionsText() const { | 80 base::string16 UsbChooserController::GetNoOptionsText() const { |
| 77 return l10n_util::GetStringUTF16(IDS_DEVICE_CHOOSER_NO_DEVICES_FOUND_PROMPT); | 81 return l10n_util::GetStringUTF16(IDS_DEVICE_CHOOSER_NO_DEVICES_FOUND_PROMPT); |
| 78 } | 82 } |
| 79 | 83 |
| 80 base::string16 UsbChooserController::GetOkButtonLabel() const { | 84 base::string16 UsbChooserController::GetOkButtonLabel() const { |
| 81 return l10n_util::GetStringUTF16(IDS_USB_DEVICE_CHOOSER_CONNECT_BUTTON_TEXT); | 85 return l10n_util::GetStringUTF16(IDS_USB_DEVICE_CHOOSER_CONNECT_BUTTON_TEXT); |
| 82 } | 86 } |
| 83 | 87 |
| 84 size_t UsbChooserController::NumOptions() const { | 88 size_t UsbChooserController::NumOptions() const { |
| 85 return devices_.size(); | 89 return devices_.size(); |
| 86 } | 90 } |
| 87 | 91 |
| 92 int UsbChooserController::GetSignalStrengthLevel(size_t index) const { |
| 93 return -1; |
| 94 } |
| 95 |
| 88 base::string16 UsbChooserController::GetOption(size_t index) const { | 96 base::string16 UsbChooserController::GetOption(size_t index) const { |
| 89 DCHECK_LT(index, devices_.size()); | 97 DCHECK_LT(index, devices_.size()); |
| 90 const base::string16& device_name = devices_[index].second; | 98 const base::string16& device_name = devices_[index].second; |
| 91 const auto& it = device_name_map_.find(device_name); | 99 const auto& it = device_name_map_.find(device_name); |
| 92 DCHECK(it != device_name_map_.end()); | 100 DCHECK(it != device_name_map_.end()); |
| 93 return it->second == 1 | 101 return it->second == 1 |
| 94 ? device_name | 102 ? device_name |
| 95 : l10n_util::GetStringFUTF16( | 103 : l10n_util::GetStringFUTF16( |
| 96 IDS_DEVICE_CHOOSER_DEVICE_NAME_WITH_ID, device_name, | 104 IDS_DEVICE_CHOOSER_DEVICE_NAME_WITH_ID, device_name, |
| 97 devices_[index].first->serial_number()); | 105 devices_[index].first->serial_number()); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 | 195 |
| 188 bool UsbChooserController::DisplayDevice( | 196 bool UsbChooserController::DisplayDevice( |
| 189 scoped_refptr<device::UsbDevice> device) const { | 197 scoped_refptr<device::UsbDevice> device) const { |
| 190 return device::UsbDeviceFilter::MatchesAny(device, filters_) && | 198 return device::UsbDeviceFilter::MatchesAny(device, filters_) && |
| 191 (base::CommandLine::ForCurrentProcess()->HasSwitch( | 199 (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 192 switches::kDisableWebUsbSecurity) || | 200 switches::kDisableWebUsbSecurity) || |
| 193 device::FindInWebUsbAllowedOrigins( | 201 device::FindInWebUsbAllowedOrigins( |
| 194 device->webusb_allowed_origins(), | 202 device->webusb_allowed_origins(), |
| 195 render_frame_host_->GetLastCommittedURL().GetOrigin())); | 203 render_frame_host_->GetLastCommittedURL().GetOrigin())); |
| 196 } | 204 } |
| OLD | NEW |