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

Side by Side Diff: chrome/browser/usb/usb_chooser_context.h

Issue 1854483002: Remove WebUSB descriptor data from device.mojom. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@use_interface_associations
Patch Set: Created 4 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 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 #ifndef CHROME_BROWSER_USB_USB_CHOOSER_CONTEXT_H_ 5 #ifndef CHROME_BROWSER_USB_USB_CHOOSER_CONTEXT_H_
6 #define CHROME_BROWSER_USB_USB_CHOOSER_CONTEXT_H_ 6 #define CHROME_BROWSER_USB_USB_CHOOSER_CONTEXT_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 #include <utility> 11 #include <utility>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/scoped_observer.h" 15 #include "base/scoped_observer.h"
16 #include "chrome/browser/permissions/chooser_context_base.h" 16 #include "chrome/browser/permissions/chooser_context_base.h"
17 #include "device/usb/usb_service.h" 17 #include "device/usb/usb_service.h"
18 18
19 namespace device { 19 namespace device {
20 namespace usb { 20 class UsbDevice;
21 class DeviceInfo;
22 }
23 } 21 }
24 22
25 class UsbChooserContext : public ChooserContextBase, 23 class UsbChooserContext : public ChooserContextBase,
26 public device::UsbService::Observer { 24 public device::UsbService::Observer {
27 public: 25 public:
28 explicit UsbChooserContext(Profile* profile); 26 explicit UsbChooserContext(Profile* profile);
29 ~UsbChooserContext() override; 27 ~UsbChooserContext() override;
30 28
31 // These methods from ChooserContextBase are overridden in order to expose 29 // These methods from ChooserContextBase are overridden in order to expose
32 // ephemeral devices through the public interface. 30 // ephemeral devices through the public interface.
33 std::vector<scoped_ptr<base::DictionaryValue>> GetGrantedObjects( 31 std::vector<scoped_ptr<base::DictionaryValue>> GetGrantedObjects(
34 const GURL& requesting_origin, 32 const GURL& requesting_origin,
35 const GURL& embedding_origin) override; 33 const GURL& embedding_origin) override;
36 std::vector<scoped_ptr<ChooserContextBase::Object>> GetAllGrantedObjects() 34 std::vector<scoped_ptr<ChooserContextBase::Object>> GetAllGrantedObjects()
37 override; 35 override;
38 void RevokeObjectPermission(const GURL& requesting_origin, 36 void RevokeObjectPermission(const GURL& requesting_origin,
39 const GURL& embedding_origin, 37 const GURL& embedding_origin,
40 const base::DictionaryValue& object) override; 38 const base::DictionaryValue& object) override;
41 39
42 // Grants |requesting_origin| access to the USB device known to 40 // Grants |requesting_origin| access to the USB device known to
43 // device::UsbService as |guid|. 41 // device::UsbService as |guid|.
44 void GrantDevicePermission(const GURL& requesting_origin, 42 void GrantDevicePermission(const GURL& requesting_origin,
45 const GURL& embedding_origin, 43 const GURL& embedding_origin,
46 const std::string& guid); 44 const std::string& guid);
47 45
48 // Checks if |requesting_origin| (when embedded within |embedding_origin| has 46 // Checks if |requesting_origin| (when embedded within |embedding_origin| has
49 // access to a device with |device_info|. 47 // access to a device with |device_info|.
50 bool HasDevicePermission(const GURL& requesting_origin, 48 bool HasDevicePermission(const GURL& requesting_origin,
51 const GURL& embedding_origin, 49 const GURL& embedding_origin,
52 const device::usb::DeviceInfo& device_info); 50 scoped_refptr<const device::UsbDevice> device_info);
juncai 2016/04/01 17:05:24 change device_info parameter name to device since
Reilly Grant (use Gerrit) 2016/04/01 21:56:33 Fixed.
53 51
54 private: 52 private:
55 // ChooserContextBase implementation. 53 // ChooserContextBase implementation.
56 bool IsValidObject(const base::DictionaryValue& object) override; 54 bool IsValidObject(const base::DictionaryValue& object) override;
57 55
58 // device::UsbService::Observer implementation. 56 // device::UsbService::Observer implementation.
59 void OnDeviceRemoved(scoped_refptr<device::UsbDevice> device) override; 57 void OnDeviceRemoved(scoped_refptr<device::UsbDevice> device) override;
60 58
61 bool is_off_the_record_; 59 bool is_off_the_record_;
62 std::map<std::pair<GURL, GURL>, std::set<std::string>> ephemeral_devices_; 60 std::map<std::pair<GURL, GURL>, std::set<std::string>> ephemeral_devices_;
63 device::UsbService* usb_service_; 61 device::UsbService* usb_service_;
64 ScopedObserver<device::UsbService, device::UsbService::Observer> observer_; 62 ScopedObserver<device::UsbService, device::UsbService::Observer> observer_;
65 63
66 DISALLOW_COPY_AND_ASSIGN(UsbChooserContext); 64 DISALLOW_COPY_AND_ASSIGN(UsbChooserContext);
67 }; 65 };
68 66
69 #endif // CHROME_BROWSER_USB_USB_CHOOSER_CONTEXT_H_ 67 #endif // CHROME_BROWSER_USB_USB_CHOOSER_CONTEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698