Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(373)

Side by Side Diff: chrome/browser/usb/usb_chooser_controller.cc

Issue 2518933004: Add multiple selection support to chooser on desktops (Closed)
Patch Set: address comments Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/usb/usb_chooser_controller.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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_EQ(1u, indices.size());
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
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 }
OLDNEW
« no previous file with comments | « chrome/browser/usb/usb_chooser_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698