| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include <vector> |
| 6 |
| 7 #include "chrome/browser/chromeos/device/fake_input_service_proxy.h" |
| 8 |
| 9 typedef device::InputServiceLinux::InputDeviceInfo InputDeviceInfo; |
| 10 |
| 11 namespace chromeos { |
| 12 |
| 13 FakeInputServiceProxy::FakeInputServiceProxy() { |
| 14 } |
| 15 |
| 16 FakeInputServiceProxy::~FakeInputServiceProxy() { |
| 17 } |
| 18 |
| 19 // static |
| 20 void FakeInputServiceProxy::WarmUp() { |
| 21 } |
| 22 |
| 23 void FakeInputServiceProxy::GetDevices(const GetDevicesCallback& callback) { |
| 24 std::vector<InputDeviceInfo> devices; |
| 25 for (auto& device_entry : devices_) { |
| 26 devices.push_back(device_entry.second); |
| 27 } |
| 28 callback.Run(devices); |
| 29 } |
| 30 |
| 31 void FakeInputServiceProxy::GetDeviceInfo(const std::string& id, |
| 32 const GetDeviceInfoCallback& callback) { |
| 33 InputDeviceInfo info; |
| 34 DeviceMap::const_iterator it = devices_.find(id); |
| 35 if (it == devices_.end()) { |
| 36 callback.Run(false, info); |
| 37 return; |
| 38 } |
| 39 info = it->second; |
| 40 callback.Run(true, info); |
| 41 } |
| 42 |
| 43 void FakeInputServiceProxy::AddDevice(InputDeviceInfo& info) { |
| 44 devices_[info.id] = info; |
| 45 FOR_EACH_OBSERVER(Observer, observers_, OnInputDeviceAdded(info)); |
| 46 } |
| 47 |
| 48 void FakeInputServiceProxy::RemoveDevice(const std::string& id) { |
| 49 devices_.erase(id); |
| 50 FOR_EACH_OBSERVER(Observer, observers_, OnInputDeviceRemoved(id)); |
| 51 } |
| 52 |
| 53 } // namespace chromeos |
| OLD | NEW |