Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1063)

Side by Side Diff: content/browser/bluetooth/bluetooth_dispatcher_host.cc

Issue 1737423002: bluetooth: Add Web Bluetooth blacklist checks to readValue & writeValue. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bt-blacklist-char-
Patch Set: addressed ortuno Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 848 matching lines...) Expand 10 before | Expand all | Expand 10 after
859 return; 859 return;
860 } 860 }
861 861
862 if (query_result.outcome != CacheQueryOutcome::SUCCESS) { 862 if (query_result.outcome != CacheQueryOutcome::SUCCESS) {
863 RecordCharacteristicReadValueOutcome(query_result.outcome); 863 RecordCharacteristicReadValueOutcome(query_result.outcome);
864 Send(new BluetoothMsg_ReadCharacteristicValueError( 864 Send(new BluetoothMsg_ReadCharacteristicValueError(
865 thread_id, request_id, query_result.GetWebError())); 865 thread_id, request_id, query_result.GetWebError()));
866 return; 866 return;
867 } 867 }
868 868
869 if (BluetoothBlacklist::Get().IsExcludedFromReads(
870 query_result.characteristic->GetUUID())) {
871 RecordCharacteristicReadValueOutcome(UMAGATTOperationOutcome::BLACKLISTED);
872 Send(new BluetoothMsg_ReadCharacteristicValueError(
873 thread_id, request_id, WebBluetoothError::BlacklistedRead));
874 return;
875 }
876
869 query_result.characteristic->ReadRemoteCharacteristic( 877 query_result.characteristic->ReadRemoteCharacteristic(
870 base::Bind(&BluetoothDispatcherHost::OnCharacteristicValueRead, 878 base::Bind(&BluetoothDispatcherHost::OnCharacteristicValueRead,
871 weak_ptr_on_ui_thread_, thread_id, request_id), 879 weak_ptr_on_ui_thread_, thread_id, request_id),
872 base::Bind(&BluetoothDispatcherHost::OnCharacteristicReadValueError, 880 base::Bind(&BluetoothDispatcherHost::OnCharacteristicReadValueError,
873 weak_ptr_on_ui_thread_, thread_id, request_id)); 881 weak_ptr_on_ui_thread_, thread_id, request_id));
874 } 882 }
875 883
876 void BluetoothDispatcherHost::OnWriteValue( 884 void BluetoothDispatcherHost::OnWriteValue(
877 int thread_id, 885 int thread_id,
878 int request_id, 886 int request_id,
(...skipping 22 matching lines...) Expand all
901 return; 909 return;
902 } 910 }
903 911
904 if (query_result.outcome != CacheQueryOutcome::SUCCESS) { 912 if (query_result.outcome != CacheQueryOutcome::SUCCESS) {
905 RecordCharacteristicWriteValueOutcome(query_result.outcome); 913 RecordCharacteristicWriteValueOutcome(query_result.outcome);
906 Send(new BluetoothMsg_WriteCharacteristicValueError( 914 Send(new BluetoothMsg_WriteCharacteristicValueError(
907 thread_id, request_id, query_result.GetWebError())); 915 thread_id, request_id, query_result.GetWebError()));
908 return; 916 return;
909 } 917 }
910 918
919 if (BluetoothBlacklist::Get().IsExcludedFromWrites(
920 query_result.characteristic->GetUUID())) {
921 RecordCharacteristicWriteValueOutcome(UMAGATTOperationOutcome::BLACKLISTED);
922 Send(new BluetoothMsg_WriteCharacteristicValueError(
923 thread_id, request_id, WebBluetoothError::BlacklistedWrite));
924 return;
925 }
926
911 query_result.characteristic->WriteRemoteCharacteristic( 927 query_result.characteristic->WriteRemoteCharacteristic(
912 value, base::Bind(&BluetoothDispatcherHost::OnWriteValueSuccess, 928 value, base::Bind(&BluetoothDispatcherHost::OnWriteValueSuccess,
913 weak_ptr_on_ui_thread_, thread_id, request_id), 929 weak_ptr_on_ui_thread_, thread_id, request_id),
914 base::Bind(&BluetoothDispatcherHost::OnWriteValueFailed, 930 base::Bind(&BluetoothDispatcherHost::OnWriteValueFailed,
915 weak_ptr_on_ui_thread_, thread_id, request_id)); 931 weak_ptr_on_ui_thread_, thread_id, request_id));
916 } 932 }
917 933
918 void BluetoothDispatcherHost::OnStartNotifications( 934 void BluetoothDispatcherHost::OnStartNotifications(
919 int thread_id, 935 int thread_id,
920 int request_id, 936 int request_id,
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after
1541 1557
1542 bool BluetoothDispatcherHost::CanFrameAccessCharacteristicInstance( 1558 bool BluetoothDispatcherHost::CanFrameAccessCharacteristicInstance(
1543 int frame_routing_id, 1559 int frame_routing_id,
1544 const std::string& characteristic_instance_id) { 1560 const std::string& characteristic_instance_id) {
1545 return QueryCacheForCharacteristic(GetOrigin(frame_routing_id), 1561 return QueryCacheForCharacteristic(GetOrigin(frame_routing_id),
1546 characteristic_instance_id) 1562 characteristic_instance_id)
1547 .outcome != CacheQueryOutcome::BAD_RENDERER; 1563 .outcome != CacheQueryOutcome::BAD_RENDERER;
1548 } 1564 }
1549 1565
1550 } // namespace content 1566 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/bluetooth/bluetooth_blacklist_unittest.cc ('k') | content/browser/bluetooth/bluetooth_metrics.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698