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

Unified Diff: extensions/browser/api/usb/usb_api.h

Issue 599303004: Add getUserSelectedDevices to the USB extensions API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add device_permissions_prompt.* to BUILD.gn. Created 6 years, 2 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
« no previous file with comments | « extensions/browser/api/extensions_api_client.cc ('k') | extensions/browser/api/usb/usb_api.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/browser/api/usb/usb_api.h
diff --git a/extensions/browser/api/usb/usb_api.h b/extensions/browser/api/usb/usb_api.h
index c2753e74287018b2d54e71e7cbdc29447cb9858b..92e5e2dabf2dda985a2e259edecdeee685a54519 100644
--- a/extensions/browser/api/usb/usb_api.h
+++ b/extensions/browser/api/usb/usb_api.h
@@ -15,11 +15,13 @@
#include "device/usb/usb_device_handle.h"
#include "extensions/browser/api/api_resource_manager.h"
#include "extensions/browser/api/async_api_function.h"
+#include "extensions/browser/api/device_permissions_prompt.h"
#include "extensions/common/api/usb.h"
#include "net/base/io_buffer.h"
namespace extensions {
+class DevicePermissions;
class UsbDeviceResource;
class UsbAsyncApiFunction : public AsyncApiFunction {
@@ -32,15 +34,9 @@ class UsbAsyncApiFunction : public AsyncApiFunction {
virtual bool PrePrepare() override;
virtual bool Respond() override;
- static void CreateDeviceFilter(
- const extensions::core_api::usb::DeviceFilter& input,
- device::UsbDeviceFilter* output);
-
bool HasDevicePermission(scoped_refptr<device::UsbDevice> device);
-
scoped_refptr<device::UsbDevice> GetDeviceOrCompleteWithError(
const extensions::core_api::usb::Device& input_device);
-
scoped_refptr<device::UsbDeviceHandle> GetDeviceHandleOrCompleteWithError(
const extensions::core_api::usb::ConnectionHandle& input_device_handle);
@@ -49,6 +45,7 @@ class UsbAsyncApiFunction : public AsyncApiFunction {
void CompleteWithError(const std::string& error);
ApiResourceManager<UsbDeviceResource>* manager_;
+ scoped_ptr<DevicePermissions> device_permissions_;
};
class UsbAsyncApiTransferFunction : public UsbAsyncApiFunction {
@@ -103,12 +100,32 @@ class UsbGetDevicesFunction : public UsbAsyncApiFunction {
virtual ~UsbGetDevicesFunction();
private:
- void EnumerationCompletedFileThread(
- scoped_ptr<std::vector<scoped_refptr<device::UsbDevice> > > devices);
-
scoped_ptr<extensions::core_api::usb::GetDevices::Params> parameters_;
};
+class UsbGetUserSelectedDevicesFunction
+ : public UIThreadExtensionFunction,
+ public DevicePermissionsPrompt::Delegate {
+ public:
+ DECLARE_EXTENSION_FUNCTION("usb.getUserSelectedDevices",
+ USB_GETUSERSELECTEDDEVICES)
+
+ UsbGetUserSelectedDevicesFunction();
+
+ protected:
+ virtual ~UsbGetUserSelectedDevicesFunction();
+ virtual ResponseAction Run() override;
+
+ private:
+ virtual void OnUsbDevicesChosen(
+ const std::vector<scoped_refptr<device::UsbDevice>>& devices) override;
+
+ scoped_ptr<DevicePermissionsPrompt> prompt_;
+ std::vector<uint32> device_ids_;
+ std::vector<scoped_refptr<device::UsbDevice>> devices_;
+ std::vector<base::string16> serial_numbers_;
+};
+
class UsbRequestAccessFunction : public UsbAsyncApiFunction {
public:
DECLARE_EXTENSION_FUNCTION("usb.requestAccess", USB_REQUESTACCESS)
« no previous file with comments | « extensions/browser/api/extensions_api_client.cc ('k') | extensions/browser/api/usb/usb_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698