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 // 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_to_device_, characteristic_to_service_, | 7 // BluetoothDispatcherHost map [service_to_device_, characteristic_to_service_, |
8 // descriptor_to_characteristic_] implies a hostile renderer because a renderer | 8 // descriptor_to_characteristic_] implies a hostile renderer because a renderer |
9 // obtains the corresponding ID from this class and it will be added to the map | 9 // obtains the corresponding ID from this class and it will be added to the map |
10 // at that time. | 10 // at that time. |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 // Clear adapter, releasing observer references. | 313 // Clear adapter, releasing observer references. |
314 set_adapter(scoped_refptr<device::BluetoothAdapter>()); | 314 set_adapter(scoped_refptr<device::BluetoothAdapter>()); |
315 } | 315 } |
316 | 316 |
317 // Stores information associated with an in-progress requestDevice call. This | 317 // Stores information associated with an in-progress requestDevice call. This |
318 // will include the state of the active chooser dialog in a future patch. | 318 // will include the state of the active chooser dialog in a future patch. |
319 struct BluetoothDispatcherHost::RequestDeviceSession { | 319 struct BluetoothDispatcherHost::RequestDeviceSession { |
320 public: | 320 public: |
321 RequestDeviceSession(int thread_id, | 321 RequestDeviceSession(int thread_id, |
322 int request_id, | 322 int request_id, |
323 int frame_routing_id, | |
324 url::Origin origin, | 323 url::Origin origin, |
325 const std::vector<BluetoothScanFilter>& filters, | 324 const std::vector<BluetoothScanFilter>& filters, |
326 const std::vector<BluetoothUUID>& optional_services) | 325 const std::vector<BluetoothUUID>& optional_services) |
327 : thread_id(thread_id), | 326 : thread_id(thread_id), |
328 request_id(request_id), | 327 request_id(request_id), |
329 frame_routing_id(frame_routing_id), | |
330 origin(origin), | 328 origin(origin), |
331 filters(filters), | 329 filters(filters), |
332 optional_services(optional_services) {} | 330 optional_services(optional_services) {} |
333 | 331 |
334 void AddFilteredDevice(const device::BluetoothDevice& device) { | 332 void AddFilteredDevice(const device::BluetoothDevice& device) { |
335 if (chooser && MatchesFilters(device, filters)) { | 333 if (chooser && MatchesFilters(device, filters)) { |
336 chooser->AddDevice(device.GetAddress(), device.GetName()); | 334 chooser->AddDevice(device.GetAddress(), device.GetName()); |
337 } | 335 } |
338 } | 336 } |
339 | 337 |
340 std::unique_ptr<device::BluetoothDiscoveryFilter> ComputeScanFilter() const { | 338 std::unique_ptr<device::BluetoothDiscoveryFilter> ComputeScanFilter() const { |
341 std::set<BluetoothUUID> services; | 339 std::set<BluetoothUUID> services; |
342 for (const BluetoothScanFilter& filter : filters) { | 340 for (const BluetoothScanFilter& filter : filters) { |
343 services.insert(filter.services.begin(), filter.services.end()); | 341 services.insert(filter.services.begin(), filter.services.end()); |
344 } | 342 } |
345 std::unique_ptr<device::BluetoothDiscoveryFilter> discovery_filter( | 343 std::unique_ptr<device::BluetoothDiscoveryFilter> discovery_filter( |
346 new device::BluetoothDiscoveryFilter( | 344 new device::BluetoothDiscoveryFilter( |
347 device::BluetoothDiscoveryFilter::TRANSPORT_DUAL)); | 345 device::BluetoothDiscoveryFilter::TRANSPORT_DUAL)); |
348 for (const BluetoothUUID& service : services) { | 346 for (const BluetoothUUID& service : services) { |
349 discovery_filter->AddUUID(service); | 347 discovery_filter->AddUUID(service); |
350 } | 348 } |
351 return discovery_filter; | 349 return discovery_filter; |
352 } | 350 } |
353 | 351 |
354 const int thread_id; | 352 const int thread_id; |
355 const int request_id; | 353 const int request_id; |
356 const int frame_routing_id; | |
357 const url::Origin origin; | 354 const url::Origin origin; |
358 const std::vector<BluetoothScanFilter> filters; | 355 const std::vector<BluetoothScanFilter> filters; |
359 const std::vector<BluetoothUUID> optional_services; | 356 const std::vector<BluetoothUUID> optional_services; |
360 std::unique_ptr<BluetoothChooser> chooser; | 357 std::unique_ptr<BluetoothChooser> chooser; |
361 std::unique_ptr<device::BluetoothDiscoverySession> discovery_session; | 358 std::unique_ptr<device::BluetoothDiscoverySession> discovery_session; |
362 }; | 359 }; |
363 | 360 |
364 BluetoothDispatcherHost::CacheQueryResult::CacheQueryResult() {} | 361 BluetoothDispatcherHost::CacheQueryResult::CacheQueryResult() {} |
365 | 362 |
366 BluetoothDispatcherHost::CacheQueryResult::CacheQueryResult( | 363 BluetoothDispatcherHost::CacheQueryResult::CacheQueryResult( |
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1038 thread_id, request_id, | 1035 thread_id, request_id, |
1039 WebBluetoothError::CHOOSER_NOT_SHOWN_API_GLOBALLY_DISABLED)); | 1036 WebBluetoothError::CHOOSER_NOT_SHOWN_API_GLOBALLY_DISABLED)); |
1040 return; | 1037 return; |
1041 } | 1038 } |
1042 case ContentBrowserClient::AllowWebBluetoothResult::ALLOW: | 1039 case ContentBrowserClient::AllowWebBluetoothResult::ALLOW: |
1043 break; | 1040 break; |
1044 } | 1041 } |
1045 | 1042 |
1046 // Create storage for the information that backs the chooser, and show the | 1043 // Create storage for the information that backs the chooser, and show the |
1047 // chooser. | 1044 // chooser. |
1048 RequestDeviceSession* const session = new RequestDeviceSession( | 1045 RequestDeviceSession* const session = |
1049 thread_id, request_id, frame_routing_id, requesting_origin, filters, | 1046 new RequestDeviceSession(thread_id, request_id, requesting_origin, |
1050 optional_services_blacklist_filtered); | 1047 filters, optional_services_blacklist_filtered); |
1051 int chooser_id = request_device_sessions_.Add(session); | 1048 int chooser_id = request_device_sessions_.Add(session); |
1052 | 1049 |
1053 BluetoothChooser::EventHandler chooser_event_handler = | 1050 BluetoothChooser::EventHandler chooser_event_handler = |
1054 base::Bind(&BluetoothDispatcherHost::OnBluetoothChooserEvent, | 1051 base::Bind(&BluetoothDispatcherHost::OnBluetoothChooserEvent, |
1055 weak_ptr_on_ui_thread_, chooser_id); | 1052 weak_ptr_on_ui_thread_, chooser_id); |
1056 if (WebContentsDelegate* delegate = web_contents->GetDelegate()) { | 1053 if (WebContentsDelegate* delegate = web_contents->GetDelegate()) { |
1057 session->chooser = | 1054 session->chooser = |
1058 delegate->RunBluetoothChooser(render_frame_host, chooser_event_handler); | 1055 delegate->RunBluetoothChooser(render_frame_host, chooser_event_handler); |
1059 } | 1056 } |
1060 if (!session->chooser) { | 1057 if (!session->chooser) { |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1415 const PrimaryServicesRequest& request) { | 1412 const PrimaryServicesRequest& request) { |
1416 pending_primary_services_requests_[device_address].push_back(request); | 1413 pending_primary_services_requests_[device_address].push_back(request); |
1417 } | 1414 } |
1418 | 1415 |
1419 url::Origin BluetoothDispatcherHost::GetOrigin(int frame_routing_id) { | 1416 url::Origin BluetoothDispatcherHost::GetOrigin(int frame_routing_id) { |
1420 return RenderFrameHostImpl::FromID(render_process_id_, frame_routing_id) | 1417 return RenderFrameHostImpl::FromID(render_process_id_, frame_routing_id) |
1421 ->GetLastCommittedOrigin(); | 1418 ->GetLastCommittedOrigin(); |
1422 } | 1419 } |
1423 | 1420 |
1424 } // namespace content | 1421 } // namespace content |
OLD | NEW |