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

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

Issue 1382783002: Store USB device permissions in website settings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address mlamouri@'s comments. Created 5 years, 1 month 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_USB_USB_CHOOSER_CONTEXT_H_
6 #define CHROME_BROWSER_USB_USB_CHOOSER_CONTEXT_H_
7
8 #include <map>
9 #include <set>
10 #include <string>
11
12 #include "base/macros.h"
13 #include "base/scoped_observer.h"
14 #include "chrome/browser/permissions/chooser_context_base.h"
15 #include "device/usb/usb_service.h"
16
17 class UsbChooserContext : public ChooserContextBase,
18 public device::UsbService::Observer {
19 public:
20 explicit UsbChooserContext(Profile* profile);
21 ~UsbChooserContext() override;
22
23 // Grants |requesting_origin| access to the USB device known to
24 // device::UsbService as |guid|.
25 void GrantDevicePermission(const GURL& requesting_origin,
26 const GURL& embedding_origin,
27 const std::string& guid);
28
29 // Revokes |requesting_origin|'s access to the USB device known to
30 // device::UsbService as |guid|.
31 void RevokeDevicePermission(const GURL& requesting_origin,
32 const GURL& embedding_origin,
33 const std::string& guid);
34
35 // Checks if |requesting_origin| (when embedded within |embedding_origin| has
36 // access to the USB device known to device::UsbService as |guid|.
37 bool HasDevicePermission(const GURL& requesting_origin,
38 const GURL& embedding_origin,
39 const std::string& guid);
40
41 private:
42 // ChooserContextBase implementation.
43 bool IsValidObject(const base::DictionaryValue& object) override;
44
45 // device::UsbService::Observer implementation.
46 void OnDeviceRemoved(scoped_refptr<device::UsbDevice> device) override;
47
48 std::map<GURL, std::set<std::string>> ephemeral_devices_;
49 device::UsbService* usb_service_;
50 ScopedObserver<device::UsbService, device::UsbService::Observer> observer_;
51
52 DISALLOW_COPY_AND_ASSIGN(UsbChooserContext);
53 };
54
55 #endif // CHROME_BROWSER_USB_USB_CHOOSER_CONTEXT_H_
OLDNEW
« no previous file with comments | « chrome/browser/profiles/chrome_browser_main_extra_parts_profiles.cc ('k') | chrome/browser/usb/usb_chooser_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698