OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 // ID Not In Map Note: A service, characteristic, or descriptor ID not in the | 5 // ID Not In Map Note: A service, characteristic, or descriptor ID not in the |
6 // corresponding WebBluetoothServiceImpl map [service_id_to_device_address_, | 6 // corresponding WebBluetoothServiceImpl map [service_id_to_device_address_, |
7 // characteristic_id_to_service_id_, descriptor_id_to_characteristic_id_] | 7 // characteristic_id_to_service_id_, descriptor_id_to_characteristic_id_] |
8 // implies a hostile renderer because a renderer obtains the corresponding ID | 8 // implies a hostile renderer because a renderer obtains the corresponding ID |
9 // from this class and it will be added to the map at that time. | 9 // from this class and it will be added to the map at that time. |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "content/browser/renderer_host/render_process_host_impl.h" | 21 #include "content/browser/renderer_host/render_process_host_impl.h" |
22 #include "content/common/bluetooth/web_bluetooth_device_id.h" | 22 #include "content/common/bluetooth/web_bluetooth_device_id.h" |
23 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
24 #include "content/public/browser/navigation_handle.h" | 24 #include "content/public/browser/navigation_handle.h" |
25 #include "content/public/browser/render_frame_host.h" | 25 #include "content/public/browser/render_frame_host.h" |
26 #include "content/public/browser/web_contents.h" | 26 #include "content/public/browser/web_contents.h" |
27 #include "device/bluetooth/bluetooth_adapter_factory_wrapper.h" | 27 #include "device/bluetooth/bluetooth_adapter_factory_wrapper.h" |
28 #include "device/bluetooth/bluetooth_remote_gatt_characteristic.h" | 28 #include "device/bluetooth/bluetooth_remote_gatt_characteristic.h" |
29 #include "device/bluetooth/bluetooth_remote_gatt_descriptor.h" | 29 #include "device/bluetooth/bluetooth_remote_gatt_descriptor.h" |
30 | 30 |
| 31 #include "base/logging.h" |
| 32 |
31 using device::BluetoothAdapterFactoryWrapper; | 33 using device::BluetoothAdapterFactoryWrapper; |
32 using device::BluetoothUUID; | 34 using device::BluetoothUUID; |
33 | 35 |
34 namespace content { | 36 namespace content { |
35 | 37 |
36 namespace { | 38 namespace { |
37 | 39 |
38 blink::mojom::WebBluetoothResult TranslateConnectErrorAndRecord( | 40 blink::mojom::WebBluetoothResult TranslateConnectErrorAndRecord( |
39 device::BluetoothDevice::ConnectErrorCode error_code) { | 41 device::BluetoothDevice::ConnectErrorCode error_code) { |
40 switch (error_code) { | 42 switch (error_code) { |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 | 207 |
206 void WebBluetoothServiceImpl::AdapterPoweredChanged( | 208 void WebBluetoothServiceImpl::AdapterPoweredChanged( |
207 device::BluetoothAdapter* adapter, | 209 device::BluetoothAdapter* adapter, |
208 bool powered) { | 210 bool powered) { |
209 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 211 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
210 if (device_chooser_controller_.get()) { | 212 if (device_chooser_controller_.get()) { |
211 device_chooser_controller_->AdapterPoweredChanged(powered); | 213 device_chooser_controller_->AdapterPoweredChanged(powered); |
212 } | 214 } |
213 } | 215 } |
214 | 216 |
| 217 void WebBluetoothServiceImpl::AdapterDiscoveringChanged( |
| 218 device::BluetoothAdapter* adapter, |
| 219 bool discovering) { |
| 220 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 221 LOG(ERROR) << "[DJKim] WebBluetoothServiceImpl::AdapterDiscoveringChanged"; |
| 222 if (device_chooser_controller_.get()) { |
| 223 LOG(ERROR) << "[DJKim] WebBluetoothServiceImpl::AdapterDiscoveringChanged >>
AdapterDiscoveringChanged"; |
| 224 device_chooser_controller_->AdapterDiscoveringChanged(discovering); |
| 225 } else { |
| 226 LOG(ERROR) << "[DJKim] WebBluetoothServiceImpl::AdapterDiscoveringChanged >>
device_chooser_controller_ is NULL"; |
| 227 } |
| 228 } |
| 229 |
215 void WebBluetoothServiceImpl::DeviceAdded(device::BluetoothAdapter* adapter, | 230 void WebBluetoothServiceImpl::DeviceAdded(device::BluetoothAdapter* adapter, |
216 device::BluetoothDevice* device) { | 231 device::BluetoothDevice* device) { |
217 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 232 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
218 if (device_chooser_controller_.get()) { | 233 if (device_chooser_controller_.get()) { |
219 device_chooser_controller_->AddFilteredDevice(*device); | 234 device_chooser_controller_->AddFilteredDevice(*device); |
220 } | 235 } |
221 } | 236 } |
222 | 237 |
223 void WebBluetoothServiceImpl::DeviceChanged(device::BluetoothAdapter* adapter, | 238 void WebBluetoothServiceImpl::DeviceChanged(device::BluetoothAdapter* adapter, |
224 device::BluetoothDevice* device) { | 239 device::BluetoothDevice* device) { |
(...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1127 descriptor_id_to_characteristic_id_.clear(); | 1142 descriptor_id_to_characteristic_id_.clear(); |
1128 characteristic_id_to_service_id_.clear(); | 1143 characteristic_id_to_service_id_.clear(); |
1129 service_id_to_device_address_.clear(); | 1144 service_id_to_device_address_.clear(); |
1130 connected_devices_.reset( | 1145 connected_devices_.reset( |
1131 new FrameConnectedBluetoothDevices(render_frame_host_)); | 1146 new FrameConnectedBluetoothDevices(render_frame_host_)); |
1132 allowed_devices_map_ = BluetoothAllowedDevicesMap(); | 1147 allowed_devices_map_ = BluetoothAllowedDevicesMap(); |
1133 device_chooser_controller_.reset(); | 1148 device_chooser_controller_.reset(); |
1134 BluetoothAdapterFactoryWrapper::Get().ReleaseAdapter(this); | 1149 BluetoothAdapterFactoryWrapper::Get().ReleaseAdapter(this); |
1135 } | 1150 } |
1136 | 1151 |
| 1152 bool WebBluetoothServiceImpl::IsDiscoverySessionActive() { |
| 1153 if (device_chooser_controller_.get()) |
| 1154 return device_chooser_controller_->IsDiscoverySessionActive(); |
| 1155 |
| 1156 return false; |
| 1157 } |
| 1158 |
| 1159 void WebBluetoothServiceImpl::SimulateRequestDevice() { |
| 1160 //requestDevice(blink::mojom::WebBluetoothRequestDeviceOptionsPtr(), nullptr); |
| 1161 // In order to convert the arguments from service names and aliases to just |
| 1162 // UUIDs, do the following substeps: |
| 1163 // auto deviceOptions = mojom::blink::WebBluetoothRequestDeviceOptions::New(); |
| 1164 //convertRequestDeviceOptions(options, deviceOptions, exceptionState); |
| 1165 |
| 1166 //if (exceptionState.hadException()) |
| 1167 // return exceptionState.reject(scriptState); |
| 1168 |
| 1169 // Subsequent steps are handled in the browser process. |
| 1170 // ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(nullptr); |
| 1171 //ScriptPromise promise = resolver->promise(); |
| 1172 // TestCallback callback; |
| 1173 |
| 1174 |
| 1175 //RequestDevice( |
| 1176 // std::move(deviceOptions), |
| 1177 // callback); |
| 1178 //convertToBaseCallback(WTF::bind(&Bluetooth::RequestDeviceCallback, |
| 1179 // wrapPersistent(this), |
| 1180 // wrapPersistent(resolver)))); |
| 1181 } |
| 1182 |
1137 } // namespace content | 1183 } // namespace content |
OLD | NEW |