| 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::GetTitle() const { |
| 75 std::pair<base::string16, bool> title_prefix = GetTitlePrefix(); |
| 76 return l10n_util::GetStringFUTF16( |
| 77 title_prefix.second ? IDS_USB_DEVICE_CHOOSER_PROMPT_ORIGIN |
| 78 : IDS_USB_DEVICE_CHOOSER_PROMPT_EXTENSION_NAME, |
| 79 title_prefix.first); |
| 80 } |
| 81 |
| 74 base::string16 UsbChooserController::GetOkButtonLabel() const { | 82 base::string16 UsbChooserController::GetOkButtonLabel() const { |
| 75 return l10n_util::GetStringUTF16(IDS_USB_DEVICE_CHOOSER_CONNECT_BUTTON_TEXT); | 83 return l10n_util::GetStringUTF16(IDS_USB_DEVICE_CHOOSER_CONNECT_BUTTON_TEXT); |
| 76 } | 84 } |
| 77 | 85 |
| 78 size_t UsbChooserController::NumOptions() const { | 86 size_t UsbChooserController::NumOptions() const { |
| 79 return devices_.size(); | 87 return devices_.size(); |
| 80 } | 88 } |
| 81 | 89 |
| 82 base::string16 UsbChooserController::GetOption(size_t index) const { | 90 base::string16 UsbChooserController::GetOption(size_t index) const { |
| 83 DCHECK_LT(index, devices_.size()); | 91 DCHECK_LT(index, devices_.size()); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 | 183 |
| 176 bool UsbChooserController::DisplayDevice( | 184 bool UsbChooserController::DisplayDevice( |
| 177 scoped_refptr<device::UsbDevice> device) const { | 185 scoped_refptr<device::UsbDevice> device) const { |
| 178 return device::UsbDeviceFilter::MatchesAny(device, filters_) && | 186 return device::UsbDeviceFilter::MatchesAny(device, filters_) && |
| 179 (base::CommandLine::ForCurrentProcess()->HasSwitch( | 187 (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 180 switches::kDisableWebUsbSecurity) || | 188 switches::kDisableWebUsbSecurity) || |
| 181 device::FindInWebUsbAllowedOrigins( | 189 device::FindInWebUsbAllowedOrigins( |
| 182 device->webusb_allowed_origins(), | 190 device->webusb_allowed_origins(), |
| 183 render_frame_host_->GetLastCommittedURL().GetOrigin())); | 191 render_frame_host_->GetLastCommittedURL().GetOrigin())); |
| 184 } | 192 } |
| OLD | NEW |