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

Side by Side Diff: extensions/browser/api/usb/usb_api.h

Issue 1098823003: Separate USB device permissions prompt logic into subclasses. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address jyasskin@'s comments. Created 5 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #ifndef EXTENSIONS_BROWSER_API_USB_USB_API_H_ 5 #ifndef EXTENSIONS_BROWSER_API_USB_USB_API_H_
6 #define EXTENSIONS_BROWSER_API_USB_USB_API_H_ 6 #define EXTENSIONS_BROWSER_API_USB_USB_API_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "device/usb/usb_device.h" 13 #include "device/usb/usb_device.h"
14 #include "device/usb/usb_device_filter.h" 14 #include "device/usb/usb_device_filter.h"
15 #include "device/usb/usb_device_handle.h" 15 #include "device/usb/usb_device_handle.h"
16 #include "extensions/browser/api/api_resource_manager.h" 16 #include "extensions/browser/api/api_resource_manager.h"
17 #include "extensions/browser/api/device_permissions_prompt.h"
18 #include "extensions/browser/extension_function.h" 17 #include "extensions/browser/extension_function.h"
19 #include "extensions/common/api/usb.h" 18 #include "extensions/common/api/usb.h"
20 #include "net/base/io_buffer.h" 19 #include "net/base/io_buffer.h"
21 20
22 namespace extensions { 21 namespace extensions {
23 22
24 class DevicePermissionEntry; 23 class DevicePermissionEntry;
25 class DevicePermissions; 24 class DevicePermissions;
25 class DevicePermissionsPrompt;
26 class DevicePermissionsManager; 26 class DevicePermissionsManager;
27 class UsbDeviceResource; 27 class UsbDeviceResource;
28 28
29 class UsbPermissionCheckingFunction : public UIThreadExtensionFunction { 29 class UsbPermissionCheckingFunction : public UIThreadExtensionFunction {
30 protected: 30 protected:
31 UsbPermissionCheckingFunction(); 31 UsbPermissionCheckingFunction();
32 ~UsbPermissionCheckingFunction() override; 32 ~UsbPermissionCheckingFunction() override;
33 33
34 bool HasDevicePermission(scoped_refptr<device::UsbDevice> device); 34 bool HasDevicePermission(scoped_refptr<device::UsbDevice> device);
35 void RecordDeviceLastUsed(); 35 void RecordDeviceLastUsed();
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 ResponseAction Run() override; 101 ResponseAction Run() override;
102 102
103 void OnGetDevicesComplete( 103 void OnGetDevicesComplete(
104 const std::vector<scoped_refptr<device::UsbDevice>>& devices); 104 const std::vector<scoped_refptr<device::UsbDevice>>& devices);
105 105
106 std::vector<device::UsbDeviceFilter> filters_; 106 std::vector<device::UsbDeviceFilter> filters_;
107 107
108 DISALLOW_COPY_AND_ASSIGN(UsbGetDevicesFunction); 108 DISALLOW_COPY_AND_ASSIGN(UsbGetDevicesFunction);
109 }; 109 };
110 110
111 class UsbGetUserSelectedDevicesFunction 111 class UsbGetUserSelectedDevicesFunction : public UIThreadExtensionFunction {
112 : public UIThreadExtensionFunction,
113 public DevicePermissionsPrompt::Delegate {
114 public: 112 public:
115 DECLARE_EXTENSION_FUNCTION("usb.getUserSelectedDevices", 113 DECLARE_EXTENSION_FUNCTION("usb.getUserSelectedDevices",
116 USB_GETUSERSELECTEDDEVICES) 114 USB_GETUSERSELECTEDDEVICES)
117 115
118 UsbGetUserSelectedDevicesFunction(); 116 UsbGetUserSelectedDevicesFunction();
119 117
120 private: 118 private:
121 ~UsbGetUserSelectedDevicesFunction() override; 119 ~UsbGetUserSelectedDevicesFunction() override;
122 120
123 // ExtensionFunction: 121 // ExtensionFunction:
124 ResponseAction Run() override; 122 ResponseAction Run() override;
125 123
126 void OnUsbDevicesChosen( 124 void OnDevicesChosen(
127 const std::vector<scoped_refptr<device::UsbDevice>>& devices) override; 125 const std::vector<scoped_refptr<device::UsbDevice>>& devices);
128 126
129 scoped_ptr<DevicePermissionsPrompt> prompt_; 127 scoped_ptr<DevicePermissionsPrompt> prompt_;
130 128
131 DISALLOW_COPY_AND_ASSIGN(UsbGetUserSelectedDevicesFunction); 129 DISALLOW_COPY_AND_ASSIGN(UsbGetUserSelectedDevicesFunction);
132 }; 130 };
133 131
134 class UsbRequestAccessFunction : public UIThreadExtensionFunction { 132 class UsbRequestAccessFunction : public UIThreadExtensionFunction {
135 public: 133 public:
136 DECLARE_EXTENSION_FUNCTION("usb.requestAccess", USB_REQUESTACCESS) 134 DECLARE_EXTENSION_FUNCTION("usb.requestAccess", USB_REQUESTACCESS)
137 135
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 349
352 void OnComplete(bool success); 350 void OnComplete(bool success);
353 351
354 scoped_ptr<extensions::core_api::usb::ResetDevice::Params> parameters_; 352 scoped_ptr<extensions::core_api::usb::ResetDevice::Params> parameters_;
355 353
356 DISALLOW_COPY_AND_ASSIGN(UsbResetDeviceFunction); 354 DISALLOW_COPY_AND_ASSIGN(UsbResetDeviceFunction);
357 }; 355 };
358 } // namespace extensions 356 } // namespace extensions
359 357
360 #endif // EXTENSIONS_BROWSER_API_USB_USB_API_H_ 358 #endif // EXTENSIONS_BROWSER_API_USB_USB_API_H_
OLDNEW
« no previous file with comments | « extensions/browser/api/device_permissions_prompt.cc ('k') | extensions/browser/api/usb/usb_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698