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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
102 return WebUSBPermissionProvider::HasDevicePermission(render_frame_host_, | 102 return WebUSBPermissionProvider::HasDevicePermission(render_frame_host_, |
103 devices_[index].first); | 103 devices_[index].first); |
104 } | 104 } |
105 | 105 |
106 void UsbChooserController::RefreshOptions() {} | 106 void UsbChooserController::RefreshOptions() {} |
107 | 107 |
108 base::string16 UsbChooserController::GetStatus() const { | 108 base::string16 UsbChooserController::GetStatus() const { |
109 return base::string16(); | 109 return base::string16(); |
110 } | 110 } |
111 | 111 |
112 void UsbChooserController::Select(size_t index) { | 112 void UsbChooserController::Select(const std::vector<size_t>& indices) { |
113 DCHECK(indices.size() == 1); | |
Reilly Grant (use Gerrit)
2016/11/22 20:55:27
DCHECK_EQ(indices.size(), 1)
juncai
2016/11/22 23:12:06
Done.
| |
114 size_t index = indices[0]; | |
113 DCHECK_LT(index, devices_.size()); | 115 DCHECK_LT(index, devices_.size()); |
114 content::WebContents* web_contents = | 116 content::WebContents* web_contents = |
115 content::WebContents::FromRenderFrameHost(render_frame_host_); | 117 content::WebContents::FromRenderFrameHost(render_frame_host_); |
116 GURL embedding_origin = | 118 GURL embedding_origin = |
117 web_contents->GetMainFrame()->GetLastCommittedURL().GetOrigin(); | 119 web_contents->GetMainFrame()->GetLastCommittedURL().GetOrigin(); |
118 Profile* profile = | 120 Profile* profile = |
119 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 121 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
120 UsbChooserContext* chooser_context = | 122 UsbChooserContext* chooser_context = |
121 UsbChooserContextFactory::GetForProfile(profile); | 123 UsbChooserContextFactory::GetForProfile(profile); |
122 chooser_context->GrantDevicePermission( | 124 chooser_context->GrantDevicePermission( |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
193 | 195 |
194 bool UsbChooserController::DisplayDevice( | 196 bool UsbChooserController::DisplayDevice( |
195 scoped_refptr<device::UsbDevice> device) const { | 197 scoped_refptr<device::UsbDevice> device) const { |
196 return device::UsbDeviceFilter::MatchesAny(device, filters_) && | 198 return device::UsbDeviceFilter::MatchesAny(device, filters_) && |
197 (base::CommandLine::ForCurrentProcess()->HasSwitch( | 199 (base::CommandLine::ForCurrentProcess()->HasSwitch( |
198 switches::kDisableWebUsbSecurity) || | 200 switches::kDisableWebUsbSecurity) || |
199 device::FindInWebUsbAllowedOrigins( | 201 device::FindInWebUsbAllowedOrigins( |
200 device->webusb_allowed_origins(), | 202 device->webusb_allowed_origins(), |
201 render_frame_host_->GetLastCommittedURL().GetOrigin())); | 203 render_frame_host_->GetLastCommittedURL().GetOrigin())); |
202 } | 204 } |
OLD | NEW |