| 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: | 5 // ID Not In Map Note: |
| 6 // A service, characteristic, or descriptor ID not in the corresponding | 6 // A service, characteristic, or descriptor ID not in the corresponding |
| 7 // BluetoothDispatcherHost map [service_id_to_device_address_, | 7 // BluetoothDispatcherHost map [service_id_to_device_address_, |
| 8 // characteristic_id_to_service_id_, descriptor_to_characteristic_] implies a | 8 // characteristic_id_to_service_id_, descriptor_to_characteristic_] implies a |
| 9 // hostile renderer because a renderer obtains the corresponding ID from this | 9 // hostile renderer because a renderer obtains the corresponding ID from this |
| 10 // class and it will be added to the map at that time. | 10 // class and it will be added to the map at that time. |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 WebBluetoothServiceImpl::WebBluetoothServiceImpl( | 163 WebBluetoothServiceImpl::WebBluetoothServiceImpl( |
| 164 RenderFrameHost* render_frame_host, | 164 RenderFrameHost* render_frame_host, |
| 165 blink::mojom::WebBluetoothServiceRequest request) | 165 blink::mojom::WebBluetoothServiceRequest request) |
| 166 : WebContentsObserver(WebContents::FromRenderFrameHost(render_frame_host)), | 166 : WebContentsObserver(WebContents::FromRenderFrameHost(render_frame_host)), |
| 167 connected_devices_(new FrameConnectedBluetoothDevices(render_frame_host)), | 167 connected_devices_(new FrameConnectedBluetoothDevices(render_frame_host)), |
| 168 render_frame_host_(render_frame_host), | 168 render_frame_host_(render_frame_host), |
| 169 binding_(this, std::move(request)), | 169 binding_(this, std::move(request)), |
| 170 weak_ptr_factory_(this) { | 170 weak_ptr_factory_(this) { |
| 171 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 171 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 172 CHECK(web_contents()); | 172 CHECK(web_contents()); |
| 173 | 173 // TODO(nick): Commented out due to bad cast. |
| 174 GetBluetoothDispatcherHost()->AddAdapterObserver(this); | 174 // GetBluetoothDispatcherHost()->AddAdapterObserver(this); |
| 175 } | 175 } |
| 176 | 176 |
| 177 WebBluetoothServiceImpl::~WebBluetoothServiceImpl() { | 177 WebBluetoothServiceImpl::~WebBluetoothServiceImpl() { |
| 178 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 178 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 179 GetBluetoothDispatcherHost()->RemoveAdapterObserver(this); | 179 // TODO(nick): Commented out due to bad cast. |
| 180 // GetBluetoothDispatcherHost()->RemoveAdapterObserver(this); |
| 180 } | 181 } |
| 181 | 182 |
| 182 void WebBluetoothServiceImpl::SetClientConnectionErrorHandler( | 183 void WebBluetoothServiceImpl::SetClientConnectionErrorHandler( |
| 183 base::Closure closure) { | 184 base::Closure closure) { |
| 184 binding_.set_connection_error_handler(closure); | 185 binding_.set_connection_error_handler(closure); |
| 185 } | 186 } |
| 186 | 187 |
| 187 void WebBluetoothServiceImpl::DidFinishNavigation( | 188 void WebBluetoothServiceImpl::DidFinishNavigation( |
| 188 NavigationHandle* navigation_handle) { | 189 NavigationHandle* navigation_handle) { |
| 189 if (navigation_handle->HasCommitted() && | 190 if (navigation_handle->HasCommitted() && |
| (...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 804 } | 805 } |
| 805 | 806 |
| 806 return result; | 807 return result; |
| 807 } | 808 } |
| 808 | 809 |
| 809 RenderProcessHost* WebBluetoothServiceImpl::GetRenderProcessHost() { | 810 RenderProcessHost* WebBluetoothServiceImpl::GetRenderProcessHost() { |
| 810 return render_frame_host_->GetProcess(); | 811 return render_frame_host_->GetProcess(); |
| 811 } | 812 } |
| 812 | 813 |
| 813 BluetoothDispatcherHost* WebBluetoothServiceImpl::GetBluetoothDispatcherHost() { | 814 BluetoothDispatcherHost* WebBluetoothServiceImpl::GetBluetoothDispatcherHost() { |
| 815 // TODO(nick): This cast is illegal. Either call a RenderProcessHost method |
| 816 // here, or obtain this link some other way. |
| 814 RenderProcessHostImpl* render_process_host_impl = | 817 RenderProcessHostImpl* render_process_host_impl = |
| 815 static_cast<RenderProcessHostImpl*>(GetRenderProcessHost()); | 818 static_cast<RenderProcessHostImpl*>(GetRenderProcessHost()); |
| 816 return render_process_host_impl->GetBluetoothDispatcherHost(); | 819 return render_process_host_impl->GetBluetoothDispatcherHost(); |
| 817 } | 820 } |
| 818 | 821 |
| 819 void WebBluetoothServiceImpl::CrashRendererAndClosePipe( | 822 void WebBluetoothServiceImpl::CrashRendererAndClosePipe( |
| 820 bad_message::BadMessageReason reason) { | 823 bad_message::BadMessageReason reason) { |
| 821 bad_message::ReceivedBadMessage(GetRenderProcessHost(), reason); | 824 bad_message::ReceivedBadMessage(GetRenderProcessHost(), reason); |
| 822 binding_.Close(); | 825 binding_.Close(); |
| 823 } | 826 } |
| 824 | 827 |
| 825 url::Origin WebBluetoothServiceImpl::GetOrigin() { | 828 url::Origin WebBluetoothServiceImpl::GetOrigin() { |
| 826 return render_frame_host_->GetLastCommittedOrigin(); | 829 return render_frame_host_->GetLastCommittedOrigin(); |
| 827 } | 830 } |
| 828 | 831 |
| 829 void WebBluetoothServiceImpl::ClearState() { | 832 void WebBluetoothServiceImpl::ClearState() { |
| 830 characteristic_id_to_notify_session_.clear(); | 833 characteristic_id_to_notify_session_.clear(); |
| 831 pending_primary_services_requests_.clear(); | 834 pending_primary_services_requests_.clear(); |
| 832 characteristic_id_to_service_id_.clear(); | 835 characteristic_id_to_service_id_.clear(); |
| 833 service_id_to_device_address_.clear(); | 836 service_id_to_device_address_.clear(); |
| 834 connected_devices_.reset( | 837 connected_devices_.reset( |
| 835 new FrameConnectedBluetoothDevices(render_frame_host_)); | 838 new FrameConnectedBluetoothDevices(render_frame_host_)); |
| 836 } | 839 } |
| 837 | 840 |
| 838 } // namespace content | 841 } // namespace content |
| OLD | NEW |