Chromium Code Reviews| 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/web_usb_permission_provider.h" | 5 #include "chrome/browser/usb/web_usb_permission_provider.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/browser/usb/usb_chooser_context.h" | 12 #include "chrome/browser/usb/usb_chooser_context.h" |
| 13 #include "chrome/browser/usb/usb_chooser_context_factory.h" | 13 #include "chrome/browser/usb/usb_chooser_context_factory.h" |
| 14 #include "chrome/browser/usb/usb_tab_helper.h" | |
| 14 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
| 15 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
| 16 #include "content/public/browser/render_frame_host.h" | 17 #include "content/public/browser/render_frame_host.h" |
| 17 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
| 18 #include "device/usb/public/interfaces/device.mojom.h" | 19 #include "device/usb/public/interfaces/device.mojom.h" |
| 19 | 20 |
| 20 using content::WebContents; | 21 using content::WebContents; |
| 21 using device::usb::WebUsbDescriptorSet; | 22 using device::usb::WebUsbDescriptorSet; |
| 22 using device::usb::WebUsbConfigurationSubsetPtr; | 23 using device::usb::WebUsbConfigurationSubsetPtr; |
| 23 using device::usb::WebUsbFunctionSubsetPtr; | 24 using device::usb::WebUsbFunctionSubsetPtr; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 106 bool WebUSBPermissionProvider::HasFunctionPermission( | 107 bool WebUSBPermissionProvider::HasFunctionPermission( |
| 107 uint8_t requested_function, | 108 uint8_t requested_function, |
| 108 uint8_t configuration_value, | 109 uint8_t configuration_value, |
| 109 const device::usb::DeviceInfo& device_info) const { | 110 const device::usb::DeviceInfo& device_info) const { |
| 110 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 111 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 111 return FindOriginInDescriptorSet( | 112 return FindOriginInDescriptorSet( |
| 112 device_info.webusb_allowed_origins.get(), | 113 device_info.webusb_allowed_origins.get(), |
| 113 render_frame_host_->GetLastCommittedURL().GetOrigin(), | 114 render_frame_host_->GetLastCommittedURL().GetOrigin(), |
| 114 &configuration_value, &requested_function); | 115 &configuration_value, &requested_function); |
| 115 } | 116 } |
| 117 | |
| 118 void WebUSBPermissionProvider::IncrementConnectionCount() { | |
| 119 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | |
| 120 WebContents* web_contents = | |
| 121 WebContents::FromRenderFrameHost(render_frame_host_); | |
| 122 UsbTabHelper* tab_helper = UsbTabHelper::FromWebContents(web_contents); | |
|
miu
2016/04/08 18:23:03
Seems like this should be a call to GetOrCreateFro
Reilly Grant (use Gerrit)
2016/04/08 18:26:32
Yes, if we've gotten here then there must be a Usb
miu
2016/04/08 18:28:20
Sounds good. Just checking. :)
| |
| 123 tab_helper->IncrementConnectionCount(); | |
| 124 } | |
| 125 | |
| 126 void WebUSBPermissionProvider::DecrementConnectionCount() { | |
| 127 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | |
| 128 WebContents* web_contents = | |
| 129 WebContents::FromRenderFrameHost(render_frame_host_); | |
| 130 UsbTabHelper* tab_helper = UsbTabHelper::FromWebContents(web_contents); | |
| 131 tab_helper->DecrementConnectionCount(); | |
| 132 } | |
| OLD | NEW |