Fix a type mismatch on Windows caused by r201738.
[chromium-blink-merge.git] / chromeos / dbus / fake_bluetooth_input_client.cc
blob841eae39a933194f56062c589029b85a2af6b474
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.
5 #include "chromeos/dbus/fake_bluetooth_input_client.h"
7 #include <map>
9 #include "base/logging.h"
10 #include "base/stl_util.h"
11 #include "chromeos/dbus/fake_bluetooth_device_client.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"
19 namespace chromeos {
21 FakeBluetoothInputClient::Properties::Properties(
22 const PropertyChangedCallback& callback)
23 : ExperimentalBluetoothInputClient::Properties(
24 NULL,
25 bluetooth_input::kExperimentalBluetoothInputInterface,
26 callback) {
29 FakeBluetoothInputClient::Properties::~Properties() {
32 void FakeBluetoothInputClient::Properties::Get(
33 dbus::PropertyBase* property,
34 dbus::PropertySet::GetCallback callback) {
35 VLOG(1) << "Get " << property->name();
36 callback.Run(false);
39 void FakeBluetoothInputClient::Properties::GetAll() {
40 VLOG(1) << "GetAll";
43 void FakeBluetoothInputClient::Properties::Set(
44 dbus::PropertyBase *property,
45 dbus::PropertySet::SetCallback callback) {
46 VLOG(1) << "Set " << property->name();
47 callback.Run(false);
51 FakeBluetoothInputClient::FakeBluetoothInputClient() {
54 FakeBluetoothInputClient::~FakeBluetoothInputClient() {
55 // Clean up Properties structures
56 STLDeleteValues(&properties_map_);
59 void FakeBluetoothInputClient::AddObserver(Observer* observer) {
60 observers_.AddObserver(observer);
63 void FakeBluetoothInputClient::RemoveObserver(Observer* observer) {
64 observers_.RemoveObserver(observer);
67 FakeBluetoothInputClient::Properties*
68 FakeBluetoothInputClient::GetProperties(const dbus::ObjectPath& object_path) {
69 PropertiesMap::iterator iter = properties_map_.find(object_path);
70 if (iter != properties_map_.end())
71 return iter->second;
72 return NULL;
75 void FakeBluetoothInputClient::AddInputDevice(
76 const dbus::ObjectPath& object_path) {
77 if (properties_map_.find(object_path) != properties_map_.end())
78 return;
80 Properties* properties = new Properties(base::Bind(
81 &FakeBluetoothInputClient::OnPropertyChanged,
82 base::Unretained(this),
83 object_path));
85 // Mark Apple mouse and keyboard as ReconnectMode "any" and the Motorola and
86 // Microsoft devices as ReconnectMode "device".
87 if (object_path.value() == FakeBluetoothDeviceClient::kMotorolaKeyboardPath ||
88 object_path.value() == FakeBluetoothDeviceClient::kMicrosoftMousePath) {
89 properties->reconnect_mode.ReplaceValue(
90 bluetooth_input::kDeviceReconnectModeProperty);
91 } else {
92 properties->reconnect_mode.ReplaceValue(
93 bluetooth_input::kAnyReconnectModeProperty);
96 properties_map_[object_path] = properties;
98 FOR_EACH_OBSERVER(ExperimentalBluetoothInputClient::Observer, observers_,
99 InputAdded(object_path));
102 void FakeBluetoothInputClient::RemoveInputDevice(
103 const dbus::ObjectPath& object_path) {
104 PropertiesMap::iterator it = properties_map_.find(object_path);
106 if (it == properties_map_.end())
107 return;
109 FOR_EACH_OBSERVER(ExperimentalBluetoothInputClient::Observer, observers_,
110 InputRemoved(object_path));
112 delete it->second;
113 properties_map_.erase(it);
116 void FakeBluetoothInputClient::OnPropertyChanged(
117 const dbus::ObjectPath& object_path,
118 const std::string& property_name) {
119 FOR_EACH_OBSERVER(ExperimentalBluetoothInputClient::Observer, observers_,
120 InputPropertyChanged(object_path, property_name));
123 } // namespace chromeos