Remove ExtensionPrefs::SetDidExtensionEscalatePermissions.
[chromium-blink-merge.git] / chromeos / dbus / fake_bluetooth_input_client.cc
blobd32bbefe0d74805fdc46d7bbf40421d99818d22b
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_proxy.h"
16 #include "third_party/cros_system_api/dbus/service_constants.h"
18 namespace chromeos {
20 FakeBluetoothInputClient::Properties::Properties(
21 const PropertyChangedCallback& callback)
22 : BluetoothInputClient::Properties(
23 NULL,
24 bluetooth_input::kBluetoothInputInterface,
25 callback) {
28 FakeBluetoothInputClient::Properties::~Properties() {
31 void FakeBluetoothInputClient::Properties::Get(
32 dbus::PropertyBase* property,
33 dbus::PropertySet::GetCallback callback) {
34 VLOG(1) << "Get " << property->name();
35 callback.Run(false);
38 void FakeBluetoothInputClient::Properties::GetAll() {
39 VLOG(1) << "GetAll";
42 void FakeBluetoothInputClient::Properties::Set(
43 dbus::PropertyBase *property,
44 dbus::PropertySet::SetCallback callback) {
45 VLOG(1) << "Set " << property->name();
46 callback.Run(false);
50 FakeBluetoothInputClient::FakeBluetoothInputClient() {
53 FakeBluetoothInputClient::~FakeBluetoothInputClient() {
54 // Clean up Properties structures
55 STLDeleteValues(&properties_map_);
58 void FakeBluetoothInputClient::Init(dbus::Bus* bus) {
61 void FakeBluetoothInputClient::AddObserver(Observer* observer) {
62 observers_.AddObserver(observer);
65 void FakeBluetoothInputClient::RemoveObserver(Observer* observer) {
66 observers_.RemoveObserver(observer);
69 FakeBluetoothInputClient::Properties*
70 FakeBluetoothInputClient::GetProperties(const dbus::ObjectPath& object_path) {
71 PropertiesMap::iterator iter = properties_map_.find(object_path);
72 if (iter != properties_map_.end())
73 return iter->second;
74 return NULL;
77 void FakeBluetoothInputClient::AddInputDevice(
78 const dbus::ObjectPath& object_path) {
79 if (properties_map_.find(object_path) != properties_map_.end())
80 return;
82 Properties* properties = new Properties(base::Bind(
83 &FakeBluetoothInputClient::OnPropertyChanged,
84 base::Unretained(this),
85 object_path));
87 // The LegacyAutopair and DisplayPinCode devices represent a typical mouse
88 // and keyboard respectively, so mark them as ReconnectMode "any". The
89 // DisplayPasskey device represents a Bluetooth 2.1+ keyboard and the
90 // ConnectUnpairable device represents a pre-standardization mouse, so mark
91 // them as ReconnectMode "device".
92 if (object_path.value() == FakeBluetoothDeviceClient::kDisplayPasskeyPath ||
93 object_path.value() ==
94 FakeBluetoothDeviceClient::kConnectUnpairablePath) {
95 properties->reconnect_mode.ReplaceValue(
96 bluetooth_input::kDeviceReconnectModeProperty);
97 } else {
98 properties->reconnect_mode.ReplaceValue(
99 bluetooth_input::kAnyReconnectModeProperty);
102 properties_map_[object_path] = properties;
104 FOR_EACH_OBSERVER(BluetoothInputClient::Observer, observers_,
105 InputAdded(object_path));
108 void FakeBluetoothInputClient::RemoveInputDevice(
109 const dbus::ObjectPath& object_path) {
110 PropertiesMap::iterator it = properties_map_.find(object_path);
112 if (it == properties_map_.end())
113 return;
115 FOR_EACH_OBSERVER(BluetoothInputClient::Observer, observers_,
116 InputRemoved(object_path));
118 delete it->second;
119 properties_map_.erase(it);
122 void FakeBluetoothInputClient::OnPropertyChanged(
123 const dbus::ObjectPath& object_path,
124 const std::string& property_name) {
125 FOR_EACH_OBSERVER(BluetoothInputClient::Observer, observers_,
126 InputPropertyChanged(object_path, property_name));
129 } // namespace chromeos