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

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

Issue 1382783002: Store USB device permissions in website settings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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/web_usb_permission_store.h
diff --git a/chrome/browser/usb/web_usb_permission_store.h b/chrome/browser/usb/web_usb_permission_store.h
new file mode 100644
index 0000000000000000000000000000000000000000..fd2dfefc3599cefed5048f95311704f8635ac4c3
--- /dev/null
+++ b/chrome/browser/usb/web_usb_permission_store.h
@@ -0,0 +1,46 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_USB_WEB_USB_PERMISSION_STORE_H_
+#define CHROME_BROWSER_USB_WEB_USB_PERMISSION_STORE_H_
+
+#include <map>
+#include <set>
+#include <string>
+
+#include "base/memory/ref_counted.h"
+#include "base/scoped_observer.h"
+#include "components/keyed_service/core/keyed_service.h"
+#include "device/usb/usb_service.h"
+#include "url/gurl.h"
Bernhard Bauer 2015/10/01 08:31:25 You could forward-declare GURL.
+
+namespace content {
+class BrowserContext;
+}
+
+class HostContentSettingsMap;
+
+class WebUSBPermissionStore : public KeyedService,
raymes 2015/10/01 01:28:19 I'd feel more comfortable if we had a ChooserPermi
+ public device::UsbService::Observer {
+ public:
+ static WebUSBPermissionStore* Get(content::BrowserContext* browser_context);
+
+ explicit WebUSBPermissionStore(content::BrowserContext* browser_context);
+ ~WebUSBPermissionStore() override;
+
+ void GrantDevicePermission(const GURL& origin, const std::string& guid);
+ void RevokeDevicePermission(const GURL& origin, const std::string& guid);
+ bool HasDevicePermission(const GURL& origin, const std::string& guid);
+
+ private:
+ // device::UsbService::Observer implementation.
+ void OnDeviceRemoved(scoped_refptr<device::UsbDevice> device) override;
+
+ std::map<GURL, std::set<std::string>> ephemeral_devices_;
+ HostContentSettingsMap* host_content_settings_map_;
+ device::UsbService* usb_service_;
+ ScopedObserver<device::UsbService, device::UsbService::Observer> observer_;
+};
Ken Rockot(use gerrit already) 2015/10/01 01:26:32 nit: DISALLOW_COPY_AND_ASSIGN
+
+#endif // CHROME_BROWSER_USB_WEB_USB_PERMISSION_STORE_H_

Powered by Google App Engine
This is Rietveld 408576698