summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorreillyg <reillyg@chromium.org>2015-07-10 13:59:39 -0700
committerCommit bot <commit-bot@chromium.org>2015-07-10 21:00:15 +0000
commit0ebe983f1cfdd383a4954127f564b83a4fe4992f (patch)
treeab278d2dc4425d73732f289fc38fa64c2d1aed38
parentc02ff720599da01dd4c96e3e6bda0020a24e1a45 (diff)
downloadchromium_src-0ebe983f1cfdd383a4954127f564b83a4fe4992f.zip
chromium_src-0ebe983f1cfdd383a4954127f564b83a4fe4992f.tar.gz
chromium_src-0ebe983f1cfdd383a4954127f564b83a4fe4992f.tar.bz2
Remove fallback when requesting a single USB interface.
This reverts commit 2d475d0ed37bf8f19385537ad31e361f1b21624b. The permission broker now supports opening devices that are partially claimed through the OpenPath method and RequestPathAccess will always fail for these devices so the fallback path from RequestPathAccess to OpenPath is always taken. BUG=500057 Review URL: https://codereview.chromium.org/1227313003 Cr-Commit-Position: refs/heads/master@{#338354}
-rw-r--r--device/usb/usb_device.cc7
-rw-r--r--device/usb/usb_device.h5
-rw-r--r--device/usb/usb_device_impl.cc34
-rw-r--r--device/usb/usb_device_impl.h2
-rw-r--r--extensions/browser/api/usb/usb_api.cc12
-rw-r--r--extensions/browser/api/usb/usb_api.h1
6 files changed, 5 insertions, 56 deletions
diff --git a/device/usb/usb_device.cc b/device/usb/usb_device.cc
index 5fa7a34..ceab5ea 100644
--- a/device/usb/usb_device.cc
+++ b/device/usb/usb_device.cc
@@ -30,11 +30,4 @@ void UsbDevice::CheckUsbAccess(const ResultCallback& callback) {
callback.Run(true);
}
-void UsbDevice::OpenInterface(int interface_id, const OpenCallback& callback) {
- // On most platforms nothing special is necessary to open a device for access
- // to a particular interface. This is needed until crbug.com/496469 is
- // resolved.
- Open(callback);
-}
-
} // namespace device
diff --git a/device/usb/usb_device.h b/device/usb/usb_device.h
index 0d84328..53087c8 100644
--- a/device/usb/usb_device.h
+++ b/device/usb/usb_device.h
@@ -46,11 +46,6 @@ class UsbDevice : public base::RefCountedThreadSafe<UsbDevice> {
// Creates a UsbDeviceHandle for further manipulation.
virtual void Open(const OpenCallback& callback) = 0;
- // Creates a UsbDeviceHandle for further manipulation. This method is a
- // temporary workaround for crbug.com/500057 while the work to finish
- // crbug.com/496469 is completed.
- virtual void OpenInterface(int interface_id, const OpenCallback& callback);
-
// Explicitly closes a device handle. This method will be automatically called
// by the destructor of a UsbDeviceHandle as well.
virtual bool Close(scoped_refptr<UsbDeviceHandle> handle) = 0;
diff --git a/device/usb/usb_device_impl.cc b/device/usb/usb_device_impl.cc
index 7122522..114e6ac 100644
--- a/device/usb/usb_device_impl.cc
+++ b/device/usb/usb_device_impl.cc
@@ -145,20 +145,6 @@ void UsbDeviceImpl::Open(const OpenCallback& callback) {
#endif // defined(OS_CHROMEOS)
}
-#if defined(OS_CHROMEOS)
-
-void UsbDeviceImpl::OpenInterface(int interface_id,
- const OpenCallback& callback) {
- chromeos::PermissionBrokerClient* client =
- chromeos::DBusThreadManager::Get()->GetPermissionBrokerClient();
- DCHECK(client) << "Could not get permission broker client.";
- client->RequestPathAccess(
- device_path_, interface_id,
- base::Bind(&UsbDeviceImpl::OnPathAccessRequestComplete, this, callback));
-}
-
-#endif // defined(OS_CHROMEOS)
-
bool UsbDeviceImpl::Close(scoped_refptr<UsbDeviceHandle> handle) {
DCHECK(thread_checker_.CalledOnValidThread());
@@ -265,26 +251,6 @@ void UsbDeviceImpl::OnOpenRequestComplete(const OpenCallback& callback,
base::Passed(&fd), callback));
}
-void UsbDeviceImpl::OnPathAccessRequestComplete(const OpenCallback& callback,
- bool success) {
- if (success) {
- blocking_task_runner_->PostTask(
- FROM_HERE,
- base::Bind(&UsbDeviceImpl::OpenOnBlockingThread, this, callback));
- } else {
- // Once permission_broker changes for crbug.com/496469 land,
- // RequestPathAccess will fail for partially claimed devices regardless of
- // the interface number requested. Fall back to OpenPath to prevent a
- // regression. This code will then be removed.
- chromeos::PermissionBrokerClient* client =
- chromeos::DBusThreadManager::Get()->GetPermissionBrokerClient();
- DCHECK(client) << "Could not get permission broker client.";
- client->OpenPath(
- device_path_,
- base::Bind(&UsbDeviceImpl::OnOpenRequestComplete, this, callback));
- }
-}
-
void UsbDeviceImpl::OpenOnBlockingThreadWithFd(dbus::FileDescriptor fd,
const OpenCallback& callback) {
fd.CheckValidity();
diff --git a/device/usb/usb_device_impl.h b/device/usb/usb_device_impl.h
index 586b08d..3e9c8d0 100644
--- a/device/usb/usb_device_impl.h
+++ b/device/usb/usb_device_impl.h
@@ -39,7 +39,6 @@ class UsbDeviceImpl : public UsbDevice {
// UsbDevice implementation:
#if defined(OS_CHROMEOS)
void CheckUsbAccess(const ResultCallback& callback) override;
- void OpenInterface(int interface_id, const OpenCallback& callback) override;
#endif // OS_CHROMEOS
void Open(const OpenCallback& callback) override;
bool Close(scoped_refptr<UsbDeviceHandle> handle) override;
@@ -85,7 +84,6 @@ class UsbDeviceImpl : public UsbDevice {
#if defined(OS_CHROMEOS)
void OnOpenRequestComplete(const OpenCallback& callback,
dbus::FileDescriptor fd);
- void OnPathAccessRequestComplete(const OpenCallback& callback, bool success);
void OpenOnBlockingThreadWithFd(dbus::FileDescriptor fd,
const OpenCallback& callback);
#endif
diff --git a/extensions/browser/api/usb/usb_api.cc b/extensions/browser/api/usb/usb_api.cc
index c96227c..d02cadb 100644
--- a/extensions/browser/api/usb/usb_api.cc
+++ b/extensions/browser/api/usb/usb_api.cc
@@ -492,10 +492,10 @@ ExtensionFunction::ResponseAction UsbFindDevicesFunction::Run() {
vendor_id_ = parameters->options.vendor_id;
product_id_ = parameters->options.product_id;
- interface_id_ = parameters->options.interface_id.get()
- ? *parameters->options.interface_id.get()
- : UsbDevicePermissionData::ANY_INTERFACE;
- UsbDevicePermission::CheckParam param(vendor_id_, product_id_, interface_id_);
+ int interface_id = parameters->options.interface_id.get()
+ ? *parameters->options.interface_id.get()
+ : UsbDevicePermissionData::ANY_INTERFACE;
+ UsbDevicePermission::CheckParam param(vendor_id_, product_id_, interface_id);
if (!extension()->permissions_data()->CheckAPIPermissionWithParam(
APIPermission::kUsbDevice, &param)) {
return RespondNow(Error(kErrorPermissionDenied));
@@ -522,9 +522,7 @@ void UsbFindDevicesFunction::OnGetDevicesComplete(
device->product_id() != product_id_) {
barrier_.Run();
} else {
- device->OpenInterface(
- interface_id_,
- base::Bind(&UsbFindDevicesFunction::OnDeviceOpened, this));
+ device->Open(base::Bind(&UsbFindDevicesFunction::OnDeviceOpened, this));
}
}
}
diff --git a/extensions/browser/api/usb/usb_api.h b/extensions/browser/api/usb/usb_api.h
index a321756..f0f1e04 100644
--- a/extensions/browser/api/usb/usb_api.h
+++ b/extensions/browser/api/usb/usb_api.h
@@ -79,7 +79,6 @@ class UsbFindDevicesFunction : public UIThreadExtensionFunction {
uint16_t vendor_id_;
uint16_t product_id_;
- int interface_id_;
scoped_ptr<base::ListValue> result_;
base::Closure barrier_;