| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/browser/bluetooth/bluetooth_dispatcher_host.h" | 5 #include "content/browser/bluetooth/bluetooth_dispatcher_host.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "content/common/bluetooth/bluetooth_messages.h" | 8 #include "content/common/bluetooth/bluetooth_messages.h" |
| 9 #include "device/bluetooth/bluetooth_adapter.h" | 9 #include "device/bluetooth/bluetooth_adapter.h" |
| 10 #include "device/bluetooth/bluetooth_adapter_factory.h" | 10 #include "device/bluetooth/bluetooth_adapter_factory.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 scoped_refptr<device::BluetoothAdapter> adapter) { | 59 scoped_refptr<device::BluetoothAdapter> adapter) { |
| 60 if (adapter_.get()) | 60 if (adapter_.get()) |
| 61 adapter_->RemoveObserver(this); | 61 adapter_->RemoveObserver(this); |
| 62 adapter_ = adapter; | 62 adapter_ = adapter; |
| 63 if (adapter_.get()) | 63 if (adapter_.get()) |
| 64 adapter_->AddObserver(this); | 64 adapter_->AddObserver(this); |
| 65 } | 65 } |
| 66 | 66 |
| 67 void BluetoothDispatcherHost::OnRequestDevice(int thread_id, int request_id) { | 67 void BluetoothDispatcherHost::OnRequestDevice(int thread_id, int request_id) { |
| 68 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 68 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 69 BrowserThread::PostTask(BrowserThread::UI, | |
| 70 FROM_HERE, | |
| 71 base::Bind( | |
| 72 &BluetoothDispatcherHost::OnRequestDeviceOnUI, | |
| 73 this, thread_id, request_id)); | |
| 74 } | |
| 75 | |
| 76 void BluetoothDispatcherHost::OnRequestDeviceOnUI(int thread_id, | |
| 77 int request_id) { | |
| 78 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | |
| 79 // TODO(scheib) Extend this very simple mock implementation by using | 69 // TODO(scheib) Extend this very simple mock implementation by using |
| 80 // device/bluetooth/test mock adapter and related classes. | 70 // device/bluetooth/test mock adapter and related classes. |
| 81 switch (bluetooth_mock_data_set_) { | 71 switch (bluetooth_mock_data_set_) { |
| 82 case MockData::NOT_MOCKING: { | 72 case MockData::NOT_MOCKING: { |
| 83 // TODO(scheib): Filter devices by services: crbug.com/440594 | 73 // TODO(scheib): Filter devices by services: crbug.com/440594 |
| 84 // TODO(scheib): Device selection UI: crbug.com/436280 | 74 // TODO(scheib): Device selection UI: crbug.com/436280 |
| 85 // TODO(scheib): Utilize BluetoothAdapter::Observer::DeviceAdded/Removed. | 75 // TODO(scheib): Utilize BluetoothAdapter::Observer::DeviceAdded/Removed. |
| 86 BluetoothAdapter::DeviceList devices; | 76 BluetoothAdapter::DeviceList devices; |
| 87 if (adapter_.get()) | 77 if (adapter_.get()) |
| 88 devices = adapter_->GetDevices(); | 78 devices = adapter_->GetDevices(); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 bluetooth_request_device_reject_type_ = BluetoothError::SECURITY; | 140 bluetooth_request_device_reject_type_ = BluetoothError::SECURITY; |
| 151 } else if (name == "ResolveRequestDevice_Empty" || // TODO(scheib): Remove. | 141 } else if (name == "ResolveRequestDevice_Empty" || // TODO(scheib): Remove. |
| 152 name == "Single Empty Device") { | 142 name == "Single Empty Device") { |
| 153 bluetooth_mock_data_set_ = MockData::RESOLVE; | 143 bluetooth_mock_data_set_ = MockData::RESOLVE; |
| 154 } else { | 144 } else { |
| 155 bluetooth_mock_data_set_ = MockData::NOT_MOCKING; | 145 bluetooth_mock_data_set_ = MockData::NOT_MOCKING; |
| 156 } | 146 } |
| 157 } | 147 } |
| 158 | 148 |
| 159 } // namespace content | 149 } // namespace content |
| OLD | NEW |