| OLD | NEW |
| 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" |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 initialized_ = true; | 229 initialized_ = true; |
| 230 } | 230 } |
| 231 | 231 |
| 232 scoped_ptr<base::ListValue> HidDeviceManager::CreateApiDeviceList( | 232 scoped_ptr<base::ListValue> HidDeviceManager::CreateApiDeviceList( |
| 233 const Extension* extension, | 233 const Extension* extension, |
| 234 const std::vector<HidDeviceFilter>& filters) { | 234 const std::vector<HidDeviceFilter>& filters) { |
| 235 HidService* hid_service = device::DeviceClient::Get()->GetHidService(); | 235 HidService* hid_service = device::DeviceClient::Get()->GetHidService(); |
| 236 DCHECK(hid_service); | 236 DCHECK(hid_service); |
| 237 | 237 |
| 238 scoped_ptr<base::ListValue> api_devices(new base::ListValue()); | 238 scoped_ptr<base::ListValue> api_devices(new base::ListValue()); |
| 239 for (const std::pair<int, HidDeviceId>& map_entry : device_ids_) { | 239 for (const ResourceIdToDeviceIdMap::value_type& map_entry : device_ids_) { |
| 240 int resource_id = map_entry.first; | 240 int resource_id = map_entry.first; |
| 241 const HidDeviceId& device_id = map_entry.second; | 241 const HidDeviceId& device_id = map_entry.second; |
| 242 | 242 |
| 243 scoped_refptr<HidDeviceInfo> device_info = | 243 scoped_refptr<HidDeviceInfo> device_info = |
| 244 hid_service->GetDeviceInfo(device_id); | 244 hid_service->GetDeviceInfo(device_id); |
| 245 if (!device_info) { | 245 if (!device_info) { |
| 246 continue; | 246 continue; |
| 247 } | 247 } |
| 248 | 248 |
| 249 if (!filters.empty() && | 249 if (!filters.empty() && |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 void HidDeviceManager::DispatchEvent(const std::string& event_name, | 288 void HidDeviceManager::DispatchEvent(const std::string& event_name, |
| 289 scoped_ptr<base::ListValue> event_args, | 289 scoped_ptr<base::ListValue> event_args, |
| 290 scoped_refptr<HidDeviceInfo> device_info) { | 290 scoped_refptr<HidDeviceInfo> device_info) { |
| 291 scoped_ptr<Event> event(new Event(event_name, event_args.Pass())); | 291 scoped_ptr<Event> event(new Event(event_name, event_args.Pass())); |
| 292 event->will_dispatch_callback = | 292 event->will_dispatch_callback = |
| 293 base::Bind(&WillDispatchDeviceEvent, device_info); | 293 base::Bind(&WillDispatchDeviceEvent, device_info); |
| 294 event_router_->BroadcastEvent(event.Pass()); | 294 event_router_->BroadcastEvent(event.Pass()); |
| 295 } | 295 } |
| 296 | 296 |
| 297 } // namespace extensions | 297 } // namespace extensions |
| OLD | NEW |