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

Unified Diff: chrome/browser/usb/usb_device.h

Issue 22914023: Introducing chrome.usb.getDevices/openDevice API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@usb-interface
Patch Set: Adding chrome.usb.requestAccess Created 7 years, 4 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/usb/usb_device.h
diff --git a/chrome/browser/usb/usb_device.h b/chrome/browser/usb/usb_device.h
index 8891ad0c53735236333935cfd2b9aff9563f6207..d89f679792fb7d22dd54e619db3d745debe5f2af 100644
--- a/chrome/browser/usb/usb_device.h
+++ b/chrome/browser/usb/usb_device.h
@@ -9,6 +9,7 @@
#include <vector>
#include "base/basictypes.h"
+#include "base/callback.h"
#include "base/memory/ref_counted.h"
#include "base/threading/thread_checker.h"
#include "chrome/browser/usb/usb_interface.h"
@@ -28,6 +29,16 @@ class UsbDevice : public base::RefCountedThreadSafe<UsbDevice> {
PlatformUsbDevice platform_device() const { return platform_device_; }
uint16 vendor_id() const { return vendor_id_; }
uint16 product_id() const { return product_id_; }
+ uint32 unique_id() const { return unique_id_; }
+
+#if defined(OS_CHROMEOS)
+ // On ChromeOS, if an interface of a claimed device is not claimed, the
+ // permission broker can change the owner of the device so that the unclaimed
+ // interfaces can be used. If this argument is missing, permission broker will
+ // not be used and this method fails if the device is claimed.
+ virtual void RequestUsbAcess(
+ int interface_id, const base::Callback<void(bool success)>& callback);
+#endif // OS_CHROMEOS
// Creates a UsbDeviceHandle for further manipulation.
// Blocking method. Must be called on FILE thread.
@@ -52,7 +63,8 @@ class UsbDevice : public base::RefCountedThreadSafe<UsbDevice> {
UsbDevice(scoped_refptr<UsbContext> context,
PlatformUsbDevice platform_device,
uint16 vendor_id,
- uint16 product_id);
+ uint16 product_id,
+ uint32 unique_id);
// Constructor called in test only.
UsbDevice();
@@ -61,10 +73,20 @@ class UsbDevice : public base::RefCountedThreadSafe<UsbDevice> {
// Called only be UsbService.
virtual void OnDisconnect();
+#if defined(OS_CHROMEOS)
+ // This method is called when permission broker replied our request.
+ // We will simply relay it to FILE thread.
+ // |callback| comes first because it will be base::Bind'ed.
+ void OnRequestUsbAccessReplied(
+ const base::Callback<void(bool success)>& callback,
+ bool success);
+#endif // OS_CHROMEOS
+
private:
PlatformUsbDevice platform_device_;
uint16 vendor_id_;
uint16 product_id_;
+ uint32 unique_id_;
// Retain the context so that it will not be released before UsbDevice.
scoped_refptr<UsbContext> context_;

Powered by Google App Engine
This is Rietveld 408576698