| 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 #include "content/browser/bluetooth/web_bluetooth_service_impl.h" | 5 #include "content/browser/bluetooth/web_bluetooth_service_impl.h" |
| 6 | 6 |
| 7 #include "base/thread_task_runner_handle.h" | 7 #include "base/thread_task_runner_handle.h" |
| 8 #include "content/browser/bluetooth/bluetooth_blacklist.h" | 8 #include "content/browser/bluetooth/bluetooth_blacklist.h" |
| 9 #include "content/browser/bluetooth/bluetooth_dispatcher_host.h" | 9 #include "content/browser/bluetooth/bluetooth_dispatcher_host.h" |
| 10 #include "content/browser/renderer_host/render_process_host_impl.h" | 10 #include "content/browser/renderer_host/render_process_host_impl.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 base::Closure closure) { | 84 base::Closure closure) { |
| 85 binding_.set_connection_error_handler(closure); | 85 binding_.set_connection_error_handler(closure); |
| 86 } | 86 } |
| 87 | 87 |
| 88 void WebBluetoothServiceImpl::DidFinishNavigation( | 88 void WebBluetoothServiceImpl::DidFinishNavigation( |
| 89 NavigationHandle* navigation_handle) { | 89 NavigationHandle* navigation_handle) { |
| 90 if (navigation_handle->HasCommitted() && | 90 if (navigation_handle->HasCommitted() && |
| 91 navigation_handle->GetRenderFrameHost() == render_frame_host_ && | 91 navigation_handle->GetRenderFrameHost() == render_frame_host_ && |
| 92 !navigation_handle->IsSamePage()) { | 92 !navigation_handle->IsSamePage()) { |
| 93 // After navigation we need to clear the frame's state. | 93 // After navigation we need to clear the frame's state. |
| 94 characteristic_id_to_notify_session_.clear(); | 94 ClearState(); |
| 95 } | 95 } |
| 96 } | 96 } |
| 97 | 97 |
| 98 void WebBluetoothServiceImpl::AdapterPresentChanged( |
| 99 device::BluetoothAdapter* adapter, |
| 100 bool present) { |
| 101 if (!present) { |
| 102 ClearState(); |
| 103 } |
| 104 } |
| 105 |
| 98 void WebBluetoothServiceImpl::GattCharacteristicValueChanged( | 106 void WebBluetoothServiceImpl::GattCharacteristicValueChanged( |
| 99 device::BluetoothAdapter* adapter, | 107 device::BluetoothAdapter* adapter, |
| 100 device::BluetoothGattCharacteristic* characteristic, | 108 device::BluetoothGattCharacteristic* characteristic, |
| 101 const std::vector<uint8_t>& value) { | 109 const std::vector<uint8_t>& value) { |
| 102 // TODO(ortuno): Only send characteristic value changed events for | 110 // TODO(ortuno): Only send characteristic value changed events for |
| 103 // characteristics that we've returned in the past. We can't yet do | 111 // characteristics that we've returned in the past. We can't yet do |
| 104 // this because WebBluetoothServiceImpl doesn't have direct access | 112 // this because WebBluetoothServiceImpl doesn't have direct access |
| 105 // to the list of returned characteristics. | 113 // to the list of returned characteristics. |
| 106 // https://crbug.com/508771 | 114 // https://crbug.com/508771 |
| 107 if (BluetoothBlacklist::Get().IsExcluded(characteristic->GetUUID())) { | 115 if (BluetoothBlacklist::Get().IsExcluded(characteristic->GetUUID())) { |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 void WebBluetoothServiceImpl::CrashRendererAndClosePipe( | 377 void WebBluetoothServiceImpl::CrashRendererAndClosePipe( |
| 370 bad_message::BadMessageReason reason) { | 378 bad_message::BadMessageReason reason) { |
| 371 bad_message::ReceivedBadMessage(GetRenderProcessHost(), reason); | 379 bad_message::ReceivedBadMessage(GetRenderProcessHost(), reason); |
| 372 binding_.Close(); | 380 binding_.Close(); |
| 373 } | 381 } |
| 374 | 382 |
| 375 url::Origin WebBluetoothServiceImpl::GetOrigin() { | 383 url::Origin WebBluetoothServiceImpl::GetOrigin() { |
| 376 return render_frame_host_->GetLastCommittedOrigin(); | 384 return render_frame_host_->GetLastCommittedOrigin(); |
| 377 } | 385 } |
| 378 | 386 |
| 387 void WebBluetoothServiceImpl::ClearState() { |
| 388 characteristic_id_to_notify_session_.clear(); |
| 389 } |
| 390 |
| 379 } // namespace content | 391 } // namespace content |
| OLD | NEW |