OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 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 "chromeos/dbus/fake_bluetooth_input_client.h" |
| 6 |
| 7 #include <map> |
| 8 |
| 9 #include "base/logging.h" |
| 10 #include "base/stl_util.h" |
| 11 #include "chromeos/dbus/bluetooth_property.h" |
| 12 #include "dbus/bus.h" |
| 13 #include "dbus/message.h" |
| 14 #include "dbus/object_manager.h" |
| 15 #include "dbus/object_path.h" |
| 16 #include "dbus/object_proxy.h" |
| 17 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 18 |
| 19 namespace chromeos { |
| 20 |
| 21 FakeBluetoothInputClient::Properties::~Properties() { |
| 22 } |
| 23 |
| 24 void FakeBluetoothInputClient::Properties::Get( |
| 25 dbus::PropertyBase* property, |
| 26 dbus::PropertySet::GetCallback callback) { |
| 27 VLOG(1) << "Get " << property->name(); |
| 28 callback.Run(false); |
| 29 } |
| 30 |
| 31 void FakeBluetoothInputClient::Properties::GetAll() { |
| 32 VLOG(1) << "GetAll"; |
| 33 } |
| 34 |
| 35 void FakeBluetoothInputClient::Properties::Set( |
| 36 dbus::PropertyBase *property, |
| 37 dbus::PropertySet::SetCallback callback) { |
| 38 VLOG(1) << "Set " << property->name(); |
| 39 callback.Run(false); |
| 40 } |
| 41 |
| 42 |
| 43 FakeBluetoothInputClient::FakeBluetoothInputClient() { |
| 44 } |
| 45 |
| 46 FakeBluetoothInputClient::~FakeBluetoothInputClient() { |
| 47 // Clean up Properties structures |
| 48 STLDeleteValues(&properties_map_); |
| 49 } |
| 50 |
| 51 void FakeBluetoothInputClient::AddObserver(Observer* observer) { |
| 52 observers_.AddObserver(observer); |
| 53 } |
| 54 |
| 55 void FakeBluetoothInputClient::RemoveObserver(Observer* observer) { |
| 56 observers_.RemoveObserver(observer); |
| 57 } |
| 58 |
| 59 FakeBluetoothInputClient::Properties* |
| 60 FakeBluetoothInputClient::GetProperties(const dbus::ObjectPath& object_path) { |
| 61 PropertiesMap::iterator iter = properties_map_.find(object_path); |
| 62 if (iter != properties_map_.end()) |
| 63 return iter->second; |
| 64 return NULL; |
| 65 } |
| 66 |
| 67 void FakeBluetoothInputClient::AnnounceInputDevice( |
| 68 const dbus::ObjectPath& object_path) { |
| 69 Properties* properties = new Properties(base::Bind( |
| 70 &FakeBluetoothInputClient::OnPropertyChanged, |
| 71 base::Unretained(this), |
| 72 object_path)); |
| 73 // TODO(deymo): Return a different ReconnectMode value for different devices. |
| 74 properties->reconnect_mode.ReplaceValue( |
| 75 bluetooth_input::kAnyReconnectModeProperty); |
| 76 |
| 77 properties_map_[object_path] = properties; |
| 78 } |
| 79 |
| 80 void FakeBluetoothInputClient::OnPropertyChanged( |
| 81 const dbus::ObjectPath& object_path, |
| 82 const std::string& property_name) { |
| 83 FOR_EACH_OBSERVER(ExperimentalBluetoothInputClient::Observer, observers_, |
| 84 InputPropertyChanged(object_path, property_name)); |
| 85 } |
| 86 |
| 87 } // namespace chromeos |
OLD | NEW |