Index: content/browser/bluetooth/bluetooth_dispatcher_host.cc |
diff --git a/content/browser/bluetooth/bluetooth_dispatcher_host.cc b/content/browser/bluetooth/bluetooth_dispatcher_host.cc |
index 634d69ce6c3c1d2906cb21e5d15024bc886333da..2bbb04fac5f202f60727bfb975af28a303ba9a99 100644 |
--- a/content/browser/bluetooth/bluetooth_dispatcher_host.cc |
+++ b/content/browser/bluetooth/bluetooth_dispatcher_host.cc |
@@ -25,8 +25,6 @@ BluetoothDispatcherHost::BluetoothDispatcherHost( |
BrowserContext* browser_context) |
: BrowserMessageFilter(BluetoothMsgStart), |
browser_context_(browser_context), |
- bluetooth_mock_data_set_(MockData::NOT_MOCKING), |
- bluetooth_request_device_reject_type_(BluetoothError::NOT_FOUND), |
weak_ptr_factory_(this) { |
DCHECK_CURRENTLY_ON(BrowserThread::UI); |
browser_context_->GetBluetoothAdapter(base::Bind( |
@@ -78,51 +76,23 @@ void BluetoothDispatcherHost::OnRequestDevice(int thread_id, int request_id) { |
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
// TODO(scheib) Extend this very simple mock implementation by using |
// device/bluetooth/test mock adapter and related classes. |
- switch (bluetooth_mock_data_set_) { |
- case MockData::NOT_MOCKING: { |
- // TODO(scheib): Filter devices by services: crbug.com/440594 |
- // TODO(scheib): Device selection UI: crbug.com/436280 |
- // TODO(scheib): Utilize BluetoothAdapter::Observer::DeviceAdded/Removed. |
- BluetoothAdapter::DeviceList devices; |
- |
- if (adapter_.get()) { |
- adapter_->StartDiscoverySession( |
- base::Bind(&BluetoothDispatcherHost::OnDiscoverySessionStarted, |
- weak_ptr_factory_.GetWeakPtr(), thread_id, request_id), |
- base::Bind(&BluetoothDispatcherHost::OnDiscoverySessionStartedError, |
- weak_ptr_factory_.GetWeakPtr(), thread_id, request_id)); |
- } else { |
- DLOG(WARNING) << "No BluetoothAdapter. Can't serve requestDevice."; |
- Send(new BluetoothMsg_RequestDeviceError(thread_id, request_id, |
- BluetoothError::NOT_FOUND)); |
- } |
- return; |
- } |
- case MockData::REJECT: { |
- Send(new BluetoothMsg_RequestDeviceError( |
- thread_id, request_id, bluetooth_request_device_reject_type_)); |
- return; |
- } |
- case MockData::RESOLVE: { |
- std::vector<std::string> uuids; |
- uuids.push_back("00001800-0000-1000-8000-00805f9b34fb"); |
- uuids.push_back("00001801-0000-1000-8000-00805f9b34fb"); |
- content::BluetoothDevice device_ipc( |
- "Empty Mock Device instanceID", // instance_id |
- base::UTF8ToUTF16("Empty Mock Device name"), // name |
- kUnspecifiedDeviceClass, // device_class |
- device::BluetoothDevice::VENDOR_ID_BLUETOOTH, // vendor_id_source |
- 0xFFFF, // vendor_id |
- 1, // product_id |
- 2, // product_version |
- true, // paired |
- uuids); // uuids |
- Send(new BluetoothMsg_RequestDeviceSuccess(thread_id, request_id, |
- device_ipc)); |
- return; |
- } |
+ // TODO(scheib): Filter devices by services: crbug.com/440594 |
+ // TODO(scheib): Device selection UI: crbug.com/436280 |
+ // TODO(scheib): Utilize BluetoothAdapter::Observer::DeviceAdded/Removed. |
+ BluetoothAdapter::DeviceList devices; |
+ |
+ if (adapter_.get()) { |
+ adapter_->StartDiscoverySession( |
+ base::Bind(&BluetoothDispatcherHost::OnDiscoverySessionStarted, |
+ weak_ptr_factory_.GetWeakPtr(), thread_id, request_id), |
+ base::Bind(&BluetoothDispatcherHost::OnDiscoverySessionStartedError, |
+ weak_ptr_factory_.GetWeakPtr(), thread_id, request_id)); |
+ } else { |
+ DLOG(WARNING) << "No BluetoothAdapter. Can't serve requestDevice."; |
+ Send(new BluetoothMsg_RequestDeviceError(thread_id, request_id, |
+ BluetoothError::NOT_FOUND)); |
} |
- NOTREACHED(); |
+ return; |
} |
void BluetoothDispatcherHost::OnConnectGATT( |
@@ -139,18 +109,10 @@ void BluetoothDispatcherHost::OnConnectGATT( |
void BluetoothDispatcherHost::OnSetBluetoothMockDataSetForTesting( |
const std::string& name) { |
DCHECK_CURRENTLY_ON(BrowserThread::UI); |
- if (name == "RejectRequestDevice_NotFoundError") { |
- bluetooth_mock_data_set_ = MockData::REJECT; |
- bluetooth_request_device_reject_type_ = BluetoothError::NOT_FOUND; |
- } else if (name == "RejectRequestDevice_SecurityError") { |
- bluetooth_mock_data_set_ = MockData::REJECT; |
- bluetooth_request_device_reject_type_ = BluetoothError::SECURITY; |
- } else if (name == "ResolveRequestDevice_Empty" || // TODO(scheib): Remove. |
- name == "Single Empty Device") { |
- bluetooth_mock_data_set_ = MockData::RESOLVE; |
- } else { |
- bluetooth_mock_data_set_ = MockData::NOT_MOCKING; |
- } |
+ browser_context_->GetBluetoothAdapterForTesting( |
scheib
2015/05/11 20:19:26
Whitespace typo, run git cl format.
ortuno
2015/05/12 19:33:19
Done.
|
+ base::Bind(&BluetoothDispatcherHost::set_adapter, |
+ weak_ptr_factory_.GetWeakPtr()), |
+ name); |
} |
void BluetoothDispatcherHost::OnDiscoverySessionStarted( |