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

Unified Diff: extensions/browser/api/hid/hid_device_manager.h

Issue 1115213004: Add chrome.hid.getUserSelectedDevices API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 5 years, 6 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/hid/hid_apitest.cc ('k') | extensions/browser/api/hid/hid_device_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/browser/api/hid/hid_device_manager.h
diff --git a/extensions/browser/api/hid/hid_device_manager.h b/extensions/browser/api/hid/hid_device_manager.h
index d39eccdac455a05285db52758d6c90e0d8dfac07..a3adb364be9d428ffbc24bf3f51f0e884df702e7 100644
--- a/extensions/browser/api/hid/hid_device_manager.h
+++ b/extensions/browser/api/hid/hid_device_manager.h
@@ -13,7 +13,6 @@
#include "base/memory/scoped_vector.h"
#include "base/scoped_observer.h"
#include "base/threading/thread_checker.h"
-#include "device/hid/hid_device_info.h"
#include "device/hid/hid_service.h"
#include "extensions/browser/browser_context_keyed_api_factory.h"
#include "extensions/browser/event_router.h"
@@ -21,6 +20,7 @@
namespace device {
class HidDeviceFilter;
+class HidDeviceInfo;
}
namespace extensions {
@@ -55,10 +55,18 @@ class HidDeviceManager : public BrowserContextKeyedAPI,
const std::vector<device::HidDeviceFilter>& filters,
const GetApiDevicesCallback& callback);
+ // Converts a list of HidDeviceInfo objects into a value that can be returned
+ // through the API.
+ scoped_ptr<base::ListValue> GetApiDevicesFromList(
+ const std::vector<scoped_refptr<device::HidDeviceInfo>>& devices);
+
scoped_refptr<device::HidDeviceInfo> GetDeviceInfo(int resource_id);
- static bool HasPermission(const Extension* extension,
- scoped_refptr<device::HidDeviceInfo> device_info);
+ // Checks if |extension| has permission to open |device_info|. Set
+ // |update_last_used| to update the timestamp in the DevicePermissionsManager.
+ bool HasPermission(const Extension* extension,
+ scoped_refptr<device::HidDeviceInfo> device_info,
+ bool update_last_used);
private:
friend class BrowserContextKeyedAPIFactory<HidDeviceManager>;
@@ -103,13 +111,14 @@ class HidDeviceManager : public BrowserContextKeyedAPI,
scoped_refptr<device::HidDeviceInfo> device_info);
base::ThreadChecker thread_checker_;
- EventRouter* event_router_;
- bool initialized_;
+ content::BrowserContext* browser_context_ = nullptr;
+ EventRouter* event_router_ = nullptr;
+ bool initialized_ = false;
ScopedObserver<device::HidService, device::HidService::Observer>
hid_service_observer_;
- bool enumeration_ready_;
+ bool enumeration_ready_ = false;
ScopedVector<GetApiDevicesParams> pending_enumerations_;
- int next_resource_id_;
+ int next_resource_id_ = 0;
ResourceIdToDeviceIdMap device_ids_;
DeviceIdToResourceIdMap resource_ids_;
base::WeakPtrFactory<HidDeviceManager> weak_factory_;
« no previous file with comments | « extensions/browser/api/hid/hid_apitest.cc ('k') | extensions/browser/api/hid/hid_device_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698