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

Side by Side Diff: extensions/browser/api/hid/hid_device_manager.cc

Issue 1226353004: Generate all extension schema namespaces as "api" and instead vary the generated bundle names. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 5 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
« no previous file with comments | « extensions/browser/api/hid/hid_api.cc ('k') | extensions/browser/api/idle/idle_api_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "extensions/browser/api/hid/hid_device_manager.h" 5 #include "extensions/browser/api/hid/hid_device_manager.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
11 #include "device/core/device_client.h" 11 #include "device/core/device_client.h"
12 #include "device/hid/hid_device_filter.h" 12 #include "device/hid/hid_device_filter.h"
13 #include "device/hid/hid_service.h" 13 #include "device/hid/hid_service.h"
14 #include "extensions/browser/api/device_permissions_manager.h" 14 #include "extensions/browser/api/device_permissions_manager.h"
15 #include "extensions/common/permissions/permissions_data.h" 15 #include "extensions/common/permissions/permissions_data.h"
16 #include "extensions/common/permissions/usb_device_permission.h" 16 #include "extensions/common/permissions/usb_device_permission.h"
17 17
18 namespace hid = extensions::core_api::hid; 18 namespace hid = extensions::api::hid;
19 19
20 using device::HidDeviceFilter; 20 using device::HidDeviceFilter;
21 using device::HidDeviceId; 21 using device::HidDeviceId;
22 using device::HidDeviceInfo; 22 using device::HidDeviceInfo;
23 using device::HidService; 23 using device::HidService;
24 24
25 namespace extensions { 25 namespace extensions {
26 26
27 namespace { 27 namespace {
28 28
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 void HidDeviceManager::OnDeviceAdded(scoped_refptr<HidDeviceInfo> device_info) { 206 void HidDeviceManager::OnDeviceAdded(scoped_refptr<HidDeviceInfo> device_info) {
207 DCHECK(thread_checker_.CalledOnValidThread()); 207 DCHECK(thread_checker_.CalledOnValidThread());
208 DCHECK_LT(next_resource_id_, std::numeric_limits<int>::max()); 208 DCHECK_LT(next_resource_id_, std::numeric_limits<int>::max());
209 int new_id = next_resource_id_++; 209 int new_id = next_resource_id_++;
210 DCHECK(!ContainsKey(resource_ids_, device_info->device_id())); 210 DCHECK(!ContainsKey(resource_ids_, device_info->device_id()));
211 resource_ids_[device_info->device_id()] = new_id; 211 resource_ids_[device_info->device_id()] = new_id;
212 device_ids_[new_id] = device_info->device_id(); 212 device_ids_[new_id] = device_info->device_id();
213 213
214 // Don't generate events during the initial enumeration. 214 // Don't generate events during the initial enumeration.
215 if (enumeration_ready_ && event_router_) { 215 if (enumeration_ready_ && event_router_) {
216 core_api::hid::HidDeviceInfo api_device_info; 216 api::hid::HidDeviceInfo api_device_info;
217 api_device_info.device_id = new_id; 217 api_device_info.device_id = new_id;
218 PopulateHidDeviceInfo(&api_device_info, device_info); 218 PopulateHidDeviceInfo(&api_device_info, device_info);
219 219
220 if (api_device_info.collections.size() > 0) { 220 if (api_device_info.collections.size() > 0) {
221 scoped_ptr<base::ListValue> args( 221 scoped_ptr<base::ListValue> args(
222 hid::OnDeviceAdded::Create(api_device_info)); 222 hid::OnDeviceAdded::Create(api_device_info));
223 DispatchEvent(events::HID_ON_DEVICE_ADDED, hid::OnDeviceAdded::kEventName, 223 DispatchEvent(events::HID_ON_DEVICE_ADDED, hid::OnDeviceAdded::kEventName,
224 args.Pass(), device_info); 224 args.Pass(), device_info);
225 } 225 }
226 } 226 }
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 scoped_ptr<base::ListValue> event_args, 322 scoped_ptr<base::ListValue> event_args,
323 scoped_refptr<HidDeviceInfo> device_info) { 323 scoped_refptr<HidDeviceInfo> device_info) {
324 scoped_ptr<Event> event( 324 scoped_ptr<Event> event(
325 new Event(histogram_value, event_name, event_args.Pass())); 325 new Event(histogram_value, event_name, event_args.Pass()));
326 event->will_dispatch_callback = base::Bind( 326 event->will_dispatch_callback = base::Bind(
327 &WillDispatchDeviceEvent, weak_factory_.GetWeakPtr(), device_info); 327 &WillDispatchDeviceEvent, weak_factory_.GetWeakPtr(), device_info);
328 event_router_->BroadcastEvent(event.Pass()); 328 event_router_->BroadcastEvent(event.Pass());
329 } 329 }
330 330
331 } // namespace extensions 331 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/api/hid/hid_api.cc ('k') | extensions/browser/api/idle/idle_api_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698