| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "device/bluetooth/bluetooth_device.h" | 5 #include "device/bluetooth/bluetooth_device.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "device/bluetooth/bluetooth_gatt_service.h" | 10 #include "device/bluetooth/bluetooth_gatt_service.h" |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 | 159 |
| 160 // Get the vendor part of the address: "00:11:22" for "00:11:22:33:44:55" | 160 // Get the vendor part of the address: "00:11:22" for "00:11:22:33:44:55" |
| 161 std::string vendor = GetAddress().substr(0, 8); | 161 std::string vendor = GetAddress().substr(0, 8); |
| 162 | 162 |
| 163 // Verbatim "Bluetooth Mouse", model 96674 | 163 // Verbatim "Bluetooth Mouse", model 96674 |
| 164 if (type == DEVICE_MOUSE && vendor == "00:12:A1") | 164 if (type == DEVICE_MOUSE && vendor == "00:12:A1") |
| 165 return false; | 165 return false; |
| 166 // Microsoft "Microsoft Bluetooth Notebook Mouse 5000", model X807028-001 | 166 // Microsoft "Microsoft Bluetooth Notebook Mouse 5000", model X807028-001 |
| 167 if (type == DEVICE_MOUSE && vendor == "7C:ED:8D") | 167 if (type == DEVICE_MOUSE && vendor == "7C:ED:8D") |
| 168 return false; | 168 return false; |
| 169 // Sony PlayStation Dualshock3 |
| 170 if (IsTrustable()) |
| 171 return false; |
| 172 |
| 169 // TODO: Move this database into a config file. | 173 // TODO: Move this database into a config file. |
| 170 | 174 |
| 171 return true; | 175 return true; |
| 172 } | 176 } |
| 173 | 177 |
| 178 bool BluetoothDevice::IsTrustable() const { |
| 179 // Sony PlayStation Dualshock3 |
| 180 if ((GetVendorID() == 0x054c && GetProductID() == 0x0268 && |
| 181 GetDeviceName() == "PLAYSTATION(R)3 Controller")) |
| 182 return true; |
| 183 |
| 184 return false; |
| 185 } |
| 186 |
| 174 std::vector<BluetoothGattService*> | 187 std::vector<BluetoothGattService*> |
| 175 BluetoothDevice::GetGattServices() const { | 188 BluetoothDevice::GetGattServices() const { |
| 176 std::vector<BluetoothGattService*> services; | 189 std::vector<BluetoothGattService*> services; |
| 177 for (GattServiceMap::const_iterator iter = gatt_services_.begin(); | 190 for (GattServiceMap::const_iterator iter = gatt_services_.begin(); |
| 178 iter != gatt_services_.end(); ++iter) | 191 iter != gatt_services_.end(); ++iter) |
| 179 services.push_back(iter->second); | 192 services.push_back(iter->second); |
| 180 return services; | 193 return services; |
| 181 } | 194 } |
| 182 | 195 |
| 183 BluetoothGattService* BluetoothDevice::GetGattService( | 196 BluetoothGattService* BluetoothDevice::GetGattService( |
| 184 const std::string& identifier) const { | 197 const std::string& identifier) const { |
| 185 GattServiceMap::const_iterator iter = gatt_services_.find(identifier); | 198 GattServiceMap::const_iterator iter = gatt_services_.find(identifier); |
| 186 if (iter != gatt_services_.end()) | 199 if (iter != gatt_services_.end()) |
| 187 return iter->second; | 200 return iter->second; |
| 188 return NULL; | 201 return NULL; |
| 189 } | 202 } |
| 190 | 203 |
| 191 } // namespace device | 204 } // namespace device |
| OLD | NEW |