| 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 const base::string16& device_name = devices_[index].second; | 86 const base::string16& device_name = devices_[index].second; |
| 87 const auto& it = device_name_map_.find(device_name); | 87 const auto& it = device_name_map_.find(device_name); |
| 88 DCHECK(it != device_name_map_.end()); | 88 DCHECK(it != device_name_map_.end()); |
| 89 return it->second == 1 | 89 return it->second == 1 |
| 90 ? device_name | 90 ? device_name |
| 91 : l10n_util::GetStringFUTF16( | 91 : l10n_util::GetStringFUTF16( |
| 92 IDS_DEVICE_CHOOSER_DEVICE_NAME_WITH_ID, device_name, | 92 IDS_DEVICE_CHOOSER_DEVICE_NAME_WITH_ID, device_name, |
| 93 devices_[index].first->serial_number()); | 93 devices_[index].first->serial_number()); |
| 94 } | 94 } |
| 95 | 95 |
| 96 void UsbChooserController::RefreshOptions() {} |
| 97 |
| 98 bool UsbChooserController::NeedsThrobber() const { |
| 99 return false; |
| 100 } |
| 101 |
| 102 bool UsbChooserController::NeedsStatus() const { |
| 103 return false; |
| 104 } |
| 105 |
| 96 void UsbChooserController::Select(size_t index) { | 106 void UsbChooserController::Select(size_t index) { |
| 97 DCHECK_LT(index, devices_.size()); | 107 DCHECK_LT(index, devices_.size()); |
| 98 content::WebContents* web_contents = | 108 content::WebContents* web_contents = |
| 99 content::WebContents::FromRenderFrameHost(render_frame_host_); | 109 content::WebContents::FromRenderFrameHost(render_frame_host_); |
| 100 GURL embedding_origin = | 110 GURL embedding_origin = |
| 101 web_contents->GetMainFrame()->GetLastCommittedURL().GetOrigin(); | 111 web_contents->GetMainFrame()->GetLastCommittedURL().GetOrigin(); |
| 102 Profile* profile = | 112 Profile* profile = |
| 103 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 113 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
| 104 UsbChooserContext* chooser_context = | 114 UsbChooserContext* chooser_context = |
| 105 UsbChooserContextFactory::GetForProfile(profile); | 115 UsbChooserContextFactory::GetForProfile(profile); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 | 187 |
| 178 bool UsbChooserController::DisplayDevice( | 188 bool UsbChooserController::DisplayDevice( |
| 179 scoped_refptr<device::UsbDevice> device) const { | 189 scoped_refptr<device::UsbDevice> device) const { |
| 180 return device::UsbDeviceFilter::MatchesAny(device, filters_) && | 190 return device::UsbDeviceFilter::MatchesAny(device, filters_) && |
| 181 (base::CommandLine::ForCurrentProcess()->HasSwitch( | 191 (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 182 switches::kDisableWebUsbSecurity) || | 192 switches::kDisableWebUsbSecurity) || |
| 183 device::FindInWebUsbAllowedOrigins( | 193 device::FindInWebUsbAllowedOrigins( |
| 184 device->webusb_allowed_origins(), | 194 device->webusb_allowed_origins(), |
| 185 render_frame_host_->GetLastCommittedURL().GetOrigin())); | 195 render_frame_host_->GetLastCommittedURL().GetOrigin())); |
| 186 } | 196 } |
| OLD | NEW |