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

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

Issue 1837253002: bluetooth: Change definition of WebBluetoothError to mojo enum (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@my-origin
Patch Set: Created 4 years, 8 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/bluetooth/BluetoothError.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 } 111 }
112 } 112 }
113 return false; 113 return false;
114 } 114 }
115 115
116 WebBluetoothError TranslateConnectError( 116 WebBluetoothError TranslateConnectError(
117 device::BluetoothDevice::ConnectErrorCode error_code) { 117 device::BluetoothDevice::ConnectErrorCode error_code) {
118 switch (error_code) { 118 switch (error_code) {
119 case device::BluetoothDevice::ERROR_UNKNOWN: 119 case device::BluetoothDevice::ERROR_UNKNOWN:
120 RecordConnectGATTOutcome(UMAConnectGATTOutcome::UNKNOWN); 120 RecordConnectGATTOutcome(UMAConnectGATTOutcome::UNKNOWN);
121 return WebBluetoothError::ConnectUnknownError; 121 return WebBluetoothError::CONNECT_UNKNOWN_ERROR;
122 case device::BluetoothDevice::ERROR_INPROGRESS: 122 case device::BluetoothDevice::ERROR_INPROGRESS:
123 RecordConnectGATTOutcome(UMAConnectGATTOutcome::IN_PROGRESS); 123 RecordConnectGATTOutcome(UMAConnectGATTOutcome::IN_PROGRESS);
124 return WebBluetoothError::ConnectAlreadyInProgress; 124 return WebBluetoothError::CONNECT_ALREADY_IN_PROGRESS;
125 case device::BluetoothDevice::ERROR_FAILED: 125 case device::BluetoothDevice::ERROR_FAILED:
126 RecordConnectGATTOutcome(UMAConnectGATTOutcome::FAILED); 126 RecordConnectGATTOutcome(UMAConnectGATTOutcome::FAILED);
127 return WebBluetoothError::ConnectUnknownFailure; 127 return WebBluetoothError::CONNECT_UNKNOWN_FAILURE;
128 case device::BluetoothDevice::ERROR_AUTH_FAILED: 128 case device::BluetoothDevice::ERROR_AUTH_FAILED:
129 RecordConnectGATTOutcome(UMAConnectGATTOutcome::AUTH_FAILED); 129 RecordConnectGATTOutcome(UMAConnectGATTOutcome::AUTH_FAILED);
130 return WebBluetoothError::ConnectAuthFailed; 130 return WebBluetoothError::CONNECT_AUTH_FAILED;
131 case device::BluetoothDevice::ERROR_AUTH_CANCELED: 131 case device::BluetoothDevice::ERROR_AUTH_CANCELED:
132 RecordConnectGATTOutcome(UMAConnectGATTOutcome::AUTH_CANCELED); 132 RecordConnectGATTOutcome(UMAConnectGATTOutcome::AUTH_CANCELED);
133 return WebBluetoothError::ConnectAuthCanceled; 133 return WebBluetoothError::CONNECT_AUTH_CANCELED;
134 case device::BluetoothDevice::ERROR_AUTH_REJECTED: 134 case device::BluetoothDevice::ERROR_AUTH_REJECTED:
135 RecordConnectGATTOutcome(UMAConnectGATTOutcome::AUTH_REJECTED); 135 RecordConnectGATTOutcome(UMAConnectGATTOutcome::AUTH_REJECTED);
136 return WebBluetoothError::ConnectAuthRejected; 136 return WebBluetoothError::CONNECT_AUTH_REJECTED;
137 case device::BluetoothDevice::ERROR_AUTH_TIMEOUT: 137 case device::BluetoothDevice::ERROR_AUTH_TIMEOUT:
138 RecordConnectGATTOutcome(UMAConnectGATTOutcome::AUTH_TIMEOUT); 138 RecordConnectGATTOutcome(UMAConnectGATTOutcome::AUTH_TIMEOUT);
139 return WebBluetoothError::ConnectAuthTimeout; 139 return WebBluetoothError::CONNECT_AUTH_TIMEOUT;
140 case device::BluetoothDevice::ERROR_UNSUPPORTED_DEVICE: 140 case device::BluetoothDevice::ERROR_UNSUPPORTED_DEVICE:
141 RecordConnectGATTOutcome(UMAConnectGATTOutcome::UNSUPPORTED_DEVICE); 141 RecordConnectGATTOutcome(UMAConnectGATTOutcome::UNSUPPORTED_DEVICE);
142 return WebBluetoothError::ConnectUnsupportedDevice; 142 return WebBluetoothError::CONNECT_UNSUPPORTED_DEVICE;
143 case device::BluetoothDevice::ERROR_ATTRIBUTE_LENGTH_INVALID: 143 case device::BluetoothDevice::ERROR_ATTRIBUTE_LENGTH_INVALID:
144 RecordConnectGATTOutcome(UMAConnectGATTOutcome::ATTRIBUTE_LENGTH_INVALID); 144 RecordConnectGATTOutcome(UMAConnectGATTOutcome::ATTRIBUTE_LENGTH_INVALID);
145 return WebBluetoothError::ConnectAttributeLengthInvalid; 145 return WebBluetoothError::CONNECT_ATTRIBUTE_LENGTH_INVALID;
146 case device::BluetoothDevice::ERROR_CONNECTION_CONGESTED: 146 case device::BluetoothDevice::ERROR_CONNECTION_CONGESTED:
147 RecordConnectGATTOutcome(UMAConnectGATTOutcome::CONNECTION_CONGESTED); 147 RecordConnectGATTOutcome(UMAConnectGATTOutcome::CONNECTION_CONGESTED);
148 return WebBluetoothError::ConnectConnectionCongested; 148 return WebBluetoothError::CONNECT_CONNECTION_CONGESTED;
149 case device::BluetoothDevice::ERROR_INSUFFICIENT_ENCRYPTION: 149 case device::BluetoothDevice::ERROR_INSUFFICIENT_ENCRYPTION:
150 RecordConnectGATTOutcome(UMAConnectGATTOutcome::INSUFFICIENT_ENCRYPTION); 150 RecordConnectGATTOutcome(UMAConnectGATTOutcome::INSUFFICIENT_ENCRYPTION);
151 return WebBluetoothError::ConnectInsufficientEncryption; 151 return WebBluetoothError::CONNECT_INSUFFICIENT_ENCRYPTION;
152 case device::BluetoothDevice::ERROR_OFFSET_INVALID: 152 case device::BluetoothDevice::ERROR_OFFSET_INVALID:
153 RecordConnectGATTOutcome(UMAConnectGATTOutcome::OFFSET_INVALID); 153 RecordConnectGATTOutcome(UMAConnectGATTOutcome::OFFSET_INVALID);
154 return WebBluetoothError::ConnectOffsetInvalid; 154 return WebBluetoothError::CONNECT_OFFSET_INVALID;
155 case device::BluetoothDevice::ERROR_READ_NOT_PERMITTED: 155 case device::BluetoothDevice::ERROR_READ_NOT_PERMITTED:
156 RecordConnectGATTOutcome(UMAConnectGATTOutcome::READ_NOT_PERMITTED); 156 RecordConnectGATTOutcome(UMAConnectGATTOutcome::READ_NOT_PERMITTED);
157 return WebBluetoothError::ConnectReadNotPermitted; 157 return WebBluetoothError::CONNECT_READ_NOT_PERMITTED;
158 case device::BluetoothDevice::ERROR_REQUEST_NOT_SUPPORTED: 158 case device::BluetoothDevice::ERROR_REQUEST_NOT_SUPPORTED:
159 RecordConnectGATTOutcome(UMAConnectGATTOutcome::REQUEST_NOT_SUPPORTED); 159 RecordConnectGATTOutcome(UMAConnectGATTOutcome::REQUEST_NOT_SUPPORTED);
160 return WebBluetoothError::ConnectRequestNotSupported; 160 return WebBluetoothError::CONNECT_REQUEST_NOT_SUPPORTED;
161 case device::BluetoothDevice::ERROR_WRITE_NOT_PERMITTED: 161 case device::BluetoothDevice::ERROR_WRITE_NOT_PERMITTED:
162 RecordConnectGATTOutcome(UMAConnectGATTOutcome::WRITE_NOT_PERMITTED); 162 RecordConnectGATTOutcome(UMAConnectGATTOutcome::WRITE_NOT_PERMITTED);
163 return WebBluetoothError::ConnectWriteNotPermitted; 163 return WebBluetoothError::CONNECT_WRITE_NOT_PERMITTED;
164 case device::BluetoothDevice::NUM_CONNECT_ERROR_CODES: 164 case device::BluetoothDevice::NUM_CONNECT_ERROR_CODES:
165 NOTREACHED(); 165 NOTREACHED();
166 return WebBluetoothError::UntranslatedConnectErrorCode; 166 return WebBluetoothError::UNTRANSLATED_CONNECT_ERROR_CODE;
167 } 167 }
168 NOTREACHED(); 168 NOTREACHED();
169 return WebBluetoothError::UntranslatedConnectErrorCode; 169 return WebBluetoothError::UNTRANSLATED_CONNECT_ERROR_CODE;
170 } 170 }
171 171
172 blink::WebBluetoothError TranslateGATTError( 172 blink::WebBluetoothError TranslateGATTError(
173 BluetoothGattService::GattErrorCode error_code, 173 BluetoothGattService::GattErrorCode error_code,
174 UMAGATTOperation operation) { 174 UMAGATTOperation operation) {
175 switch (error_code) { 175 switch (error_code) {
176 case BluetoothGattService::GATT_ERROR_UNKNOWN: 176 case BluetoothGattService::GATT_ERROR_UNKNOWN:
177 RecordGATTOperationOutcome(operation, UMAGATTOperationOutcome::UNKNOWN); 177 RecordGATTOperationOutcome(operation, UMAGATTOperationOutcome::UNKNOWN);
178 return blink::WebBluetoothError::GATTUnknownError; 178 return blink::WebBluetoothError::GATT_UNKNOWN_ERROR;
179 case BluetoothGattService::GATT_ERROR_FAILED: 179 case BluetoothGattService::GATT_ERROR_FAILED:
180 RecordGATTOperationOutcome(operation, UMAGATTOperationOutcome::FAILED); 180 RecordGATTOperationOutcome(operation, UMAGATTOperationOutcome::FAILED);
181 return blink::WebBluetoothError::GATTUnknownFailure; 181 return blink::WebBluetoothError::GATT_UNKNOWN_FAILURE;
182 case BluetoothGattService::GATT_ERROR_IN_PROGRESS: 182 case BluetoothGattService::GATT_ERROR_IN_PROGRESS:
183 RecordGATTOperationOutcome(operation, 183 RecordGATTOperationOutcome(operation,
184 UMAGATTOperationOutcome::IN_PROGRESS); 184 UMAGATTOperationOutcome::IN_PROGRESS);
185 return blink::WebBluetoothError::GATTOperationInProgress; 185 return blink::WebBluetoothError::GATT_OPERATION_IN_PROGRESS;
186 case BluetoothGattService::GATT_ERROR_INVALID_LENGTH: 186 case BluetoothGattService::GATT_ERROR_INVALID_LENGTH:
187 RecordGATTOperationOutcome(operation, 187 RecordGATTOperationOutcome(operation,
188 UMAGATTOperationOutcome::INVALID_LENGTH); 188 UMAGATTOperationOutcome::INVALID_LENGTH);
189 return blink::WebBluetoothError::GATTInvalidAttributeLength; 189 return blink::WebBluetoothError::GATT_INVALID_ATTRIBUTE_LENGTH;
190 case BluetoothGattService::GATT_ERROR_NOT_PERMITTED: 190 case BluetoothGattService::GATT_ERROR_NOT_PERMITTED:
191 RecordGATTOperationOutcome(operation, 191 RecordGATTOperationOutcome(operation,
192 UMAGATTOperationOutcome::NOT_PERMITTED); 192 UMAGATTOperationOutcome::NOT_PERMITTED);
193 return blink::WebBluetoothError::GATTNotPermitted; 193 return blink::WebBluetoothError::GATT_NOT_PERMITTED;
194 case BluetoothGattService::GATT_ERROR_NOT_AUTHORIZED: 194 case BluetoothGattService::GATT_ERROR_NOT_AUTHORIZED:
195 RecordGATTOperationOutcome(operation, 195 RecordGATTOperationOutcome(operation,
196 UMAGATTOperationOutcome::NOT_AUTHORIZED); 196 UMAGATTOperationOutcome::NOT_AUTHORIZED);
197 return blink::WebBluetoothError::GATTNotAuthorized; 197 return blink::WebBluetoothError::GATT_NOT_AUTHORIZED;
198 case BluetoothGattService::GATT_ERROR_NOT_PAIRED: 198 case BluetoothGattService::GATT_ERROR_NOT_PAIRED:
199 RecordGATTOperationOutcome(operation, 199 RecordGATTOperationOutcome(operation,
200 UMAGATTOperationOutcome::NOT_PAIRED); 200 UMAGATTOperationOutcome::NOT_PAIRED);
201 return blink::WebBluetoothError::GATTNotPaired; 201 return blink::WebBluetoothError::GATT_NOT_PAIRED;
202 case BluetoothGattService::GATT_ERROR_NOT_SUPPORTED: 202 case BluetoothGattService::GATT_ERROR_NOT_SUPPORTED:
203 RecordGATTOperationOutcome(operation, 203 RecordGATTOperationOutcome(operation,
204 UMAGATTOperationOutcome::NOT_SUPPORTED); 204 UMAGATTOperationOutcome::NOT_SUPPORTED);
205 return blink::WebBluetoothError::GATTNotSupported; 205 return blink::WebBluetoothError::GATT_NOT_SUPPORTED;
206 } 206 }
207 NOTREACHED(); 207 NOTREACHED();
208 return blink::WebBluetoothError::GATTUntranslatedErrorCode; 208 return blink::WebBluetoothError::GATT_UNTRANSLATED_ERROR_CODE;
209 } 209 }
210 210
211 void StopDiscoverySession( 211 void StopDiscoverySession(
212 scoped_ptr<device::BluetoothDiscoverySession> discovery_session) { 212 scoped_ptr<device::BluetoothDiscoverySession> discovery_session) {
213 // Nothing goes wrong if the discovery session fails to stop, and we don't 213 // Nothing goes wrong if the discovery session fails to stop, and we don't
214 // need to wait for it before letting the user's script proceed, so we ignore 214 // need to wait for it before letting the user's script proceed, so we ignore
215 // the results here. 215 // the results here.
216 discovery_session->Stop(base::Bind(&base::DoNothing), 216 discovery_session->Stop(base::Bind(&base::DoNothing),
217 base::Bind(&base::DoNothing)); 217 base::Bind(&base::DoNothing));
218 } 218 }
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 : device(nullptr), 419 : device(nullptr),
420 service(nullptr), 420 service(nullptr),
421 characteristic(nullptr), 421 characteristic(nullptr),
422 outcome(outcome) {} 422 outcome(outcome) {}
423 ~CacheQueryResult() {} 423 ~CacheQueryResult() {}
424 WebBluetoothError GetWebError() const { 424 WebBluetoothError GetWebError() const {
425 switch (outcome) { 425 switch (outcome) {
426 case CacheQueryOutcome::SUCCESS: 426 case CacheQueryOutcome::SUCCESS:
427 case CacheQueryOutcome::BAD_RENDERER: 427 case CacheQueryOutcome::BAD_RENDERER:
428 NOTREACHED(); 428 NOTREACHED();
429 return WebBluetoothError::DeviceNoLongerInRange; 429 return WebBluetoothError::DEVICE_NO_LONGER_IN_RANGE;
430 case CacheQueryOutcome::NO_DEVICE: 430 case CacheQueryOutcome::NO_DEVICE:
431 return WebBluetoothError::DeviceNoLongerInRange; 431 return WebBluetoothError::DEVICE_NO_LONGER_IN_RANGE;
432 case CacheQueryOutcome::NO_SERVICE: 432 case CacheQueryOutcome::NO_SERVICE:
433 return WebBluetoothError::ServiceNoLongerExists; 433 return WebBluetoothError::SERVICE_NO_LONGER_EXISTS;
434 case CacheQueryOutcome::NO_CHARACTERISTIC: 434 case CacheQueryOutcome::NO_CHARACTERISTIC:
435 return WebBluetoothError::CharacteristicNoLongerExists; 435 return WebBluetoothError::CHARACTERISTIC_NO_LONGER_EXISTS;
436 } 436 }
437 NOTREACHED(); 437 NOTREACHED();
438 return WebBluetoothError::DeviceNoLongerInRange; 438 return WebBluetoothError::DEVICE_NO_LONGER_IN_RANGE;
439 } 439 }
440 440
441 device::BluetoothDevice* device; 441 device::BluetoothDevice* device;
442 device::BluetoothGattService* service; 442 device::BluetoothGattService* service;
443 device::BluetoothGattCharacteristic* characteristic; 443 device::BluetoothGattCharacteristic* characteristic;
444 CacheQueryOutcome outcome; 444 CacheQueryOutcome outcome;
445 }; 445 };
446 446
447 struct BluetoothDispatcherHost::PrimaryServicesRequest { 447 struct BluetoothDispatcherHost::PrimaryServicesRequest {
448 enum CallingFunction { GET_PRIMARY_SERVICE, GET_PRIMARY_SERVICES }; 448 enum CallingFunction { GET_PRIMARY_SERVICE, GET_PRIMARY_SERVICES };
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 case PrimaryServicesRequest::GET_PRIMARY_SERVICE: 584 case PrimaryServicesRequest::GET_PRIMARY_SERVICE:
585 if (!services.empty()) { 585 if (!services.empty()) {
586 AddToServicesMapAndSendGetPrimaryServiceSuccess( 586 AddToServicesMapAndSendGetPrimaryServiceSuccess(
587 *services[0], request.thread_id, request.request_id); 587 *services[0], request.thread_id, request.request_id);
588 } else { 588 } else {
589 VLOG(1) << "No service found"; 589 VLOG(1) << "No service found";
590 RecordGetPrimaryServiceOutcome( 590 RecordGetPrimaryServiceOutcome(
591 UMAGetPrimaryServiceOutcome::NOT_FOUND); 591 UMAGetPrimaryServiceOutcome::NOT_FOUND);
592 Send(new BluetoothMsg_GetPrimaryServiceError( 592 Send(new BluetoothMsg_GetPrimaryServiceError(
593 request.thread_id, request.request_id, 593 request.thread_id, request.request_id,
594 WebBluetoothError::ServiceNotFound)); 594 WebBluetoothError::SERVICE_NOT_FOUND));
595 } 595 }
596 break; 596 break;
597 case PrimaryServicesRequest::GET_PRIMARY_SERVICES: 597 case PrimaryServicesRequest::GET_PRIMARY_SERVICES:
598 NOTIMPLEMENTED(); 598 NOTIMPLEMENTED();
599 break; 599 break;
600 } 600 }
601 } 601 }
602 DCHECK(!ContainsKey(pending_primary_services_requests_, device_address)) 602 DCHECK(!ContainsKey(pending_primary_services_requests_, device_address))
603 << "Sending get-service responses unexpectedly queued another request."; 603 << "Sending get-service responses unexpectedly queued another request.";
604 } 604 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 if (BluetoothAdapterFactory::IsBluetoothAdapterAvailable()) { 651 if (BluetoothAdapterFactory::IsBluetoothAdapterAvailable()) {
652 BluetoothAdapterFactory::GetAdapter(base::Bind( 652 BluetoothAdapterFactory::GetAdapter(base::Bind(
653 &BluetoothDispatcherHost::OnGetAdapter, weak_ptr_on_ui_thread_, 653 &BluetoothDispatcherHost::OnGetAdapter, weak_ptr_on_ui_thread_,
654 base::Bind(&BluetoothDispatcherHost::OnRequestDeviceImpl, 654 base::Bind(&BluetoothDispatcherHost::OnRequestDeviceImpl,
655 weak_ptr_on_ui_thread_, thread_id, request_id, 655 weak_ptr_on_ui_thread_, thread_id, request_id,
656 frame_routing_id, filters, optional_services))); 656 frame_routing_id, filters, optional_services)));
657 return; 657 return;
658 } 658 }
659 RecordRequestDeviceOutcome(UMARequestDeviceOutcome::NO_BLUETOOTH_ADAPTER); 659 RecordRequestDeviceOutcome(UMARequestDeviceOutcome::NO_BLUETOOTH_ADAPTER);
660 Send(new BluetoothMsg_RequestDeviceError( 660 Send(new BluetoothMsg_RequestDeviceError(
661 thread_id, request_id, WebBluetoothError::NoBluetoothAdapter)); 661 thread_id, request_id, WebBluetoothError::NO_BLUETOOTH_ADAPTER));
662 return; 662 return;
663 } 663 }
664 OnRequestDeviceImpl(thread_id, request_id, frame_routing_id, filters, 664 OnRequestDeviceImpl(thread_id, request_id, frame_routing_id, filters,
665 optional_services); 665 optional_services);
666 } 666 }
667 667
668 void BluetoothDispatcherHost::OnGATTServerConnect( 668 void BluetoothDispatcherHost::OnGATTServerConnect(
669 int thread_id, 669 int thread_id,
670 int request_id, 670 int request_id,
671 int frame_routing_id, 671 int frame_routing_id,
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 int frame_routing_id, 735 int frame_routing_id,
736 const std::string& device_id, 736 const std::string& device_id,
737 const std::string& service_uuid) { 737 const std::string& service_uuid) {
738 DCHECK_CURRENTLY_ON(BrowserThread::UI); 738 DCHECK_CURRENTLY_ON(BrowserThread::UI);
739 RecordWebBluetoothFunctionCall(UMAWebBluetoothFunction::GET_PRIMARY_SERVICE); 739 RecordWebBluetoothFunctionCall(UMAWebBluetoothFunction::GET_PRIMARY_SERVICE);
740 RecordGetPrimaryServiceService(BluetoothUUID(service_uuid)); 740 RecordGetPrimaryServiceService(BluetoothUUID(service_uuid));
741 741
742 if (!allowed_devices_map_.IsOriginAllowedToAccessService( 742 if (!allowed_devices_map_.IsOriginAllowedToAccessService(
743 GetOrigin(frame_routing_id), device_id, service_uuid)) { 743 GetOrigin(frame_routing_id), device_id, service_uuid)) {
744 Send(new BluetoothMsg_GetPrimaryServiceError( 744 Send(new BluetoothMsg_GetPrimaryServiceError(
745 thread_id, request_id, WebBluetoothError::NotAllowedToAccessService)); 745 thread_id, request_id,
746 WebBluetoothError::NOT_ALLOWED_TO_ACCESS_SERVICE));
746 return; 747 return;
747 } 748 }
748 749
749 const CacheQueryResult query_result = 750 const CacheQueryResult query_result =
750 QueryCacheForDevice(GetOrigin(frame_routing_id), device_id); 751 QueryCacheForDevice(GetOrigin(frame_routing_id), device_id);
751 752
752 if (query_result.outcome != CacheQueryOutcome::SUCCESS) { 753 if (query_result.outcome != CacheQueryOutcome::SUCCESS) {
753 RecordGetPrimaryServiceOutcome(query_result.outcome); 754 RecordGetPrimaryServiceOutcome(query_result.outcome);
754 Send(new BluetoothMsg_GetPrimaryServiceError(thread_id, request_id, 755 Send(new BluetoothMsg_GetPrimaryServiceError(thread_id, request_id,
755 query_result.GetWebError())); 756 query_result.GetWebError()));
(...skipping 21 matching lines...) Expand all
777 AddToServicesMapAndSendGetPrimaryServiceSuccess(service, thread_id, 778 AddToServicesMapAndSendGetPrimaryServiceSuccess(service, thread_id,
778 request_id); 779 request_id);
779 return; 780 return;
780 } 781 }
781 782
782 // 3. 783 // 3.
783 if (query_result.device->IsGattServicesDiscoveryComplete()) { 784 if (query_result.device->IsGattServicesDiscoveryComplete()) {
784 VLOG(1) << "Service not found in device."; 785 VLOG(1) << "Service not found in device.";
785 RecordGetPrimaryServiceOutcome(UMAGetPrimaryServiceOutcome::NOT_FOUND); 786 RecordGetPrimaryServiceOutcome(UMAGetPrimaryServiceOutcome::NOT_FOUND);
786 Send(new BluetoothMsg_GetPrimaryServiceError( 787 Send(new BluetoothMsg_GetPrimaryServiceError(
787 thread_id, request_id, WebBluetoothError::ServiceNotFound)); 788 thread_id, request_id, WebBluetoothError::SERVICE_NOT_FOUND));
788 return; 789 return;
789 } 790 }
790 791
791 VLOG(1) << "Adding service request to pending requests."; 792 VLOG(1) << "Adding service request to pending requests.";
792 // 4. 793 // 4.
793 AddToPendingPrimaryServicesRequest( 794 AddToPendingPrimaryServicesRequest(
794 query_result.device->GetAddress(), 795 query_result.device->GetAddress(),
795 PrimaryServicesRequest(thread_id, request_id, service_uuid, 796 PrimaryServicesRequest(thread_id, request_id, service_uuid,
796 PrimaryServicesRequest::GET_PRIMARY_SERVICE)); 797 PrimaryServicesRequest::GET_PRIMARY_SERVICE));
797 } 798 }
798 799
799 void BluetoothDispatcherHost::OnGetCharacteristic( 800 void BluetoothDispatcherHost::OnGetCharacteristic(
800 int thread_id, 801 int thread_id,
801 int request_id, 802 int request_id,
802 int frame_routing_id, 803 int frame_routing_id,
803 const std::string& service_instance_id, 804 const std::string& service_instance_id,
804 const std::string& characteristic_uuid) { 805 const std::string& characteristic_uuid) {
805 DCHECK_CURRENTLY_ON(BrowserThread::UI); 806 DCHECK_CURRENTLY_ON(BrowserThread::UI);
806 RecordWebBluetoothFunctionCall(UMAWebBluetoothFunction::GET_CHARACTERISTIC); 807 RecordWebBluetoothFunctionCall(UMAWebBluetoothFunction::GET_CHARACTERISTIC);
807 RecordGetCharacteristicCharacteristic(characteristic_uuid); 808 RecordGetCharacteristicCharacteristic(characteristic_uuid);
808 809
809 // Check Blacklist for characteristic_uuid. 810 // Check Blacklist for characteristic_uuid.
810 if (BluetoothBlacklist::Get().IsExcluded( 811 if (BluetoothBlacklist::Get().IsExcluded(
811 BluetoothUUID(characteristic_uuid))) { 812 BluetoothUUID(characteristic_uuid))) {
812 RecordGetCharacteristicOutcome(UMAGetCharacteristicOutcome::BLACKLISTED); 813 RecordGetCharacteristicOutcome(UMAGetCharacteristicOutcome::BLACKLISTED);
813 Send(new BluetoothMsg_GetCharacteristicError( 814 Send(new BluetoothMsg_GetCharacteristicError(
814 thread_id, request_id, 815 thread_id, request_id,
815 WebBluetoothError::BlacklistedCharacteristicUUID)); 816 WebBluetoothError::BLACKLISTED_CHARACTERISTIC_UUID));
816 return; 817 return;
817 } 818 }
818 819
819 const CacheQueryResult query_result = 820 const CacheQueryResult query_result =
820 QueryCacheForService(GetOrigin(frame_routing_id), service_instance_id); 821 QueryCacheForService(GetOrigin(frame_routing_id), service_instance_id);
821 822
822 if (query_result.outcome == CacheQueryOutcome::BAD_RENDERER) { 823 if (query_result.outcome == CacheQueryOutcome::BAD_RENDERER) {
823 return; 824 return;
824 } 825 }
825 826
(...skipping 21 matching lines...) Expand all
847 // TODO(ortuno): Use generated instance ID instead. 848 // TODO(ortuno): Use generated instance ID instead.
848 // https://crbug.com/495379 849 // https://crbug.com/495379
849 Send(new BluetoothMsg_GetCharacteristicSuccess( 850 Send(new BluetoothMsg_GetCharacteristicSuccess(
850 thread_id, request_id, characteristic_instance_id, 851 thread_id, request_id, characteristic_instance_id,
851 static_cast<uint32_t>(characteristic->GetProperties()))); 852 static_cast<uint32_t>(characteristic->GetProperties())));
852 return; 853 return;
853 } 854 }
854 } 855 }
855 RecordGetCharacteristicOutcome(UMAGetCharacteristicOutcome::NOT_FOUND); 856 RecordGetCharacteristicOutcome(UMAGetCharacteristicOutcome::NOT_FOUND);
856 Send(new BluetoothMsg_GetCharacteristicError( 857 Send(new BluetoothMsg_GetCharacteristicError(
857 thread_id, request_id, WebBluetoothError::CharacteristicNotFound)); 858 thread_id, request_id, WebBluetoothError::CHARACTERISTIC_NOT_FOUND));
858 } 859 }
859 860
860 void BluetoothDispatcherHost::OnGetCharacteristics( 861 void BluetoothDispatcherHost::OnGetCharacteristics(
861 int thread_id, 862 int thread_id,
862 int request_id, 863 int request_id,
863 int frame_routing_id, 864 int frame_routing_id,
864 const std::string& service_instance_id, 865 const std::string& service_instance_id,
865 const std::string& characteristics_uuid) { 866 const std::string& characteristics_uuid) {
866 DCHECK_CURRENTLY_ON(BrowserThread::UI); 867 DCHECK_CURRENTLY_ON(BrowserThread::UI);
867 RecordWebBluetoothFunctionCall( 868 RecordWebBluetoothFunctionCall(
868 UMAWebBluetoothFunction::SERVICE_GET_CHARACTERISTICS); 869 UMAWebBluetoothFunction::SERVICE_GET_CHARACTERISTICS);
869 RecordGetCharacteristicsCharacteristic(characteristics_uuid); 870 RecordGetCharacteristicsCharacteristic(characteristics_uuid);
870 871
871 // Check Blacklist for characteristics_uuid. 872 // Check Blacklist for characteristics_uuid.
872 if (!characteristics_uuid.empty() && 873 if (!characteristics_uuid.empty() &&
873 BluetoothBlacklist::Get().IsExcluded( 874 BluetoothBlacklist::Get().IsExcluded(
874 BluetoothUUID(characteristics_uuid))) { 875 BluetoothUUID(characteristics_uuid))) {
875 RecordGetCharacteristicsOutcome(UMAGetCharacteristicOutcome::BLACKLISTED); 876 RecordGetCharacteristicsOutcome(UMAGetCharacteristicOutcome::BLACKLISTED);
876 Send(new BluetoothMsg_GetCharacteristicsError( 877 Send(new BluetoothMsg_GetCharacteristicsError(
877 thread_id, request_id, 878 thread_id, request_id,
878 WebBluetoothError::BlacklistedCharacteristicUUID)); 879 WebBluetoothError::BLACKLISTED_CHARACTERISTIC_UUID));
879 return; 880 return;
880 } 881 }
881 882
882 const CacheQueryResult query_result = 883 const CacheQueryResult query_result =
883 QueryCacheForService(GetOrigin(frame_routing_id), service_instance_id); 884 QueryCacheForService(GetOrigin(frame_routing_id), service_instance_id);
884 885
885 if (query_result.outcome == CacheQueryOutcome::BAD_RENDERER) { 886 if (query_result.outcome == CacheQueryOutcome::BAD_RENDERER) {
886 return; 887 return;
887 } 888 }
888 889
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 Send(new BluetoothMsg_GetCharacteristicsSuccess( 926 Send(new BluetoothMsg_GetCharacteristicsSuccess(
926 thread_id, request_id, characteristics_instance_ids, 927 thread_id, request_id, characteristics_instance_ids,
927 characteristics_uuids, characteristics_properties)); 928 characteristics_uuids, characteristics_properties));
928 return; 929 return;
929 } 930 }
930 RecordGetCharacteristicsOutcome( 931 RecordGetCharacteristicsOutcome(
931 characteristics_uuid.empty() 932 characteristics_uuid.empty()
932 ? UMAGetCharacteristicOutcome::NO_CHARACTERISTICS 933 ? UMAGetCharacteristicOutcome::NO_CHARACTERISTICS
933 : UMAGetCharacteristicOutcome::NOT_FOUND); 934 : UMAGetCharacteristicOutcome::NOT_FOUND);
934 Send(new BluetoothMsg_GetCharacteristicsError( 935 Send(new BluetoothMsg_GetCharacteristicsError(
935 thread_id, request_id, characteristics_uuid.empty() 936 thread_id, request_id,
936 ? WebBluetoothError::NoCharacteristicsFound 937 characteristics_uuid.empty()
937 : WebBluetoothError::CharacteristicNotFound)); 938 ? WebBluetoothError::NO_CHARACTERISTICS_FOUND
939 : WebBluetoothError::CHARACTERISTIC_NOT_FOUND));
938 } 940 }
939 941
940 void BluetoothDispatcherHost::OnReadValue( 942 void BluetoothDispatcherHost::OnReadValue(
941 int thread_id, 943 int thread_id,
942 int request_id, 944 int request_id,
943 int frame_routing_id, 945 int frame_routing_id,
944 const std::string& characteristic_instance_id) { 946 const std::string& characteristic_instance_id) {
945 DCHECK_CURRENTLY_ON(BrowserThread::UI); 947 DCHECK_CURRENTLY_ON(BrowserThread::UI);
946 RecordWebBluetoothFunctionCall( 948 RecordWebBluetoothFunctionCall(
947 UMAWebBluetoothFunction::CHARACTERISTIC_READ_VALUE); 949 UMAWebBluetoothFunction::CHARACTERISTIC_READ_VALUE);
948 950
949 const CacheQueryResult query_result = QueryCacheForCharacteristic( 951 const CacheQueryResult query_result = QueryCacheForCharacteristic(
950 GetOrigin(frame_routing_id), characteristic_instance_id); 952 GetOrigin(frame_routing_id), characteristic_instance_id);
951 953
952 if (query_result.outcome == CacheQueryOutcome::BAD_RENDERER) { 954 if (query_result.outcome == CacheQueryOutcome::BAD_RENDERER) {
953 return; 955 return;
954 } 956 }
955 957
956 if (query_result.outcome != CacheQueryOutcome::SUCCESS) { 958 if (query_result.outcome != CacheQueryOutcome::SUCCESS) {
957 RecordCharacteristicReadValueOutcome(query_result.outcome); 959 RecordCharacteristicReadValueOutcome(query_result.outcome);
958 Send(new BluetoothMsg_ReadCharacteristicValueError( 960 Send(new BluetoothMsg_ReadCharacteristicValueError(
959 thread_id, request_id, query_result.GetWebError())); 961 thread_id, request_id, query_result.GetWebError()));
960 return; 962 return;
961 } 963 }
962 964
963 if (BluetoothBlacklist::Get().IsExcludedFromReads( 965 if (BluetoothBlacklist::Get().IsExcludedFromReads(
964 query_result.characteristic->GetUUID())) { 966 query_result.characteristic->GetUUID())) {
965 RecordCharacteristicReadValueOutcome(UMAGATTOperationOutcome::BLACKLISTED); 967 RecordCharacteristicReadValueOutcome(UMAGATTOperationOutcome::BLACKLISTED);
966 Send(new BluetoothMsg_ReadCharacteristicValueError( 968 Send(new BluetoothMsg_ReadCharacteristicValueError(
967 thread_id, request_id, WebBluetoothError::BlacklistedRead)); 969 thread_id, request_id, WebBluetoothError::BLACKLISTED_READ));
968 return; 970 return;
969 } 971 }
970 972
971 query_result.characteristic->ReadRemoteCharacteristic( 973 query_result.characteristic->ReadRemoteCharacteristic(
972 base::Bind(&BluetoothDispatcherHost::OnCharacteristicValueRead, 974 base::Bind(&BluetoothDispatcherHost::OnCharacteristicValueRead,
973 weak_ptr_on_ui_thread_, thread_id, request_id), 975 weak_ptr_on_ui_thread_, thread_id, request_id),
974 base::Bind(&BluetoothDispatcherHost::OnCharacteristicReadValueError, 976 base::Bind(&BluetoothDispatcherHost::OnCharacteristicReadValueError,
975 weak_ptr_on_ui_thread_, thread_id, request_id)); 977 weak_ptr_on_ui_thread_, thread_id, request_id));
976 } 978 }
977 979
(...skipping 29 matching lines...) Expand all
1007 RecordCharacteristicWriteValueOutcome(query_result.outcome); 1009 RecordCharacteristicWriteValueOutcome(query_result.outcome);
1008 Send(new BluetoothMsg_WriteCharacteristicValueError( 1010 Send(new BluetoothMsg_WriteCharacteristicValueError(
1009 thread_id, request_id, query_result.GetWebError())); 1011 thread_id, request_id, query_result.GetWebError()));
1010 return; 1012 return;
1011 } 1013 }
1012 1014
1013 if (BluetoothBlacklist::Get().IsExcludedFromWrites( 1015 if (BluetoothBlacklist::Get().IsExcludedFromWrites(
1014 query_result.characteristic->GetUUID())) { 1016 query_result.characteristic->GetUUID())) {
1015 RecordCharacteristicWriteValueOutcome(UMAGATTOperationOutcome::BLACKLISTED); 1017 RecordCharacteristicWriteValueOutcome(UMAGATTOperationOutcome::BLACKLISTED);
1016 Send(new BluetoothMsg_WriteCharacteristicValueError( 1018 Send(new BluetoothMsg_WriteCharacteristicValueError(
1017 thread_id, request_id, WebBluetoothError::BlacklistedWrite)); 1019 thread_id, request_id, WebBluetoothError::BLACKLISTED_WRITE));
1018 return; 1020 return;
1019 } 1021 }
1020 1022
1021 query_result.characteristic->WriteRemoteCharacteristic( 1023 query_result.characteristic->WriteRemoteCharacteristic(
1022 value, base::Bind(&BluetoothDispatcherHost::OnWriteValueSuccess, 1024 value, base::Bind(&BluetoothDispatcherHost::OnWriteValueSuccess,
1023 weak_ptr_on_ui_thread_, thread_id, request_id), 1025 weak_ptr_on_ui_thread_, thread_id, request_id),
1024 base::Bind(&BluetoothDispatcherHost::OnWriteValueFailed, 1026 base::Bind(&BluetoothDispatcherHost::OnWriteValueFailed,
1025 weak_ptr_on_ui_thread_, thread_id, request_id)); 1027 weak_ptr_on_ui_thread_, thread_id, request_id));
1026 } 1028 }
1027 1029
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
1158 VLOG(1) << "requestDevice called with the following optional services: "; 1160 VLOG(1) << "requestDevice called with the following optional services: ";
1159 for (const BluetoothUUID& service : optional_services) 1161 for (const BluetoothUUID& service : optional_services)
1160 VLOG(1) << "\t" << service.value(); 1162 VLOG(1) << "\t" << service.value();
1161 1163
1162 // Check blacklist to reject invalid filters and adjust optional_services. 1164 // Check blacklist to reject invalid filters and adjust optional_services.
1163 if (BluetoothBlacklist::Get().IsExcluded(filters)) { 1165 if (BluetoothBlacklist::Get().IsExcluded(filters)) {
1164 RecordRequestDeviceOutcome( 1166 RecordRequestDeviceOutcome(
1165 UMARequestDeviceOutcome::BLACKLISTED_SERVICE_IN_FILTER); 1167 UMARequestDeviceOutcome::BLACKLISTED_SERVICE_IN_FILTER);
1166 Send(new BluetoothMsg_RequestDeviceError( 1168 Send(new BluetoothMsg_RequestDeviceError(
1167 thread_id, request_id, 1169 thread_id, request_id,
1168 WebBluetoothError::RequestDeviceWithBlacklistedUUID)); 1170 WebBluetoothError::REQUEST_DEVICE_WITH_BLACKLISTED_UUID));
1169 return; 1171 return;
1170 } 1172 }
1171 std::vector<BluetoothUUID> optional_services_blacklist_filtered( 1173 std::vector<BluetoothUUID> optional_services_blacklist_filtered(
1172 optional_services); 1174 optional_services);
1173 BluetoothBlacklist::Get().RemoveExcludedUuids( 1175 BluetoothBlacklist::Get().RemoveExcludedUuids(
1174 &optional_services_blacklist_filtered); 1176 &optional_services_blacklist_filtered);
1175 1177
1176 RenderFrameHostImpl* render_frame_host = 1178 RenderFrameHostImpl* render_frame_host =
1177 RenderFrameHostImpl::FromID(render_process_id_, frame_routing_id); 1179 RenderFrameHostImpl::FromID(render_process_id_, frame_routing_id);
1178 WebContents* web_contents = 1180 WebContents* web_contents =
1179 WebContents::FromRenderFrameHost(render_frame_host); 1181 WebContents::FromRenderFrameHost(render_frame_host);
1180 1182
1181 if (!render_frame_host || !web_contents) { 1183 if (!render_frame_host || !web_contents) {
1182 DLOG(WARNING) << "Got a requestDevice IPC without a matching " 1184 DLOG(WARNING) << "Got a requestDevice IPC without a matching "
1183 << "RenderFrameHost or WebContents: " << render_process_id_ 1185 << "RenderFrameHost or WebContents: " << render_process_id_
1184 << ", " << frame_routing_id; 1186 << ", " << frame_routing_id;
1185 RecordRequestDeviceOutcome(UMARequestDeviceOutcome::NO_RENDER_FRAME); 1187 RecordRequestDeviceOutcome(UMARequestDeviceOutcome::NO_RENDER_FRAME);
1186 Send(new BluetoothMsg_RequestDeviceError( 1188 Send(new BluetoothMsg_RequestDeviceError(
1187 thread_id, request_id, WebBluetoothError::RequestDeviceWithoutFrame)); 1189 thread_id, request_id,
1190 WebBluetoothError::REQUEST_DEVICE_WITHOUT_FRAME));
1188 return; 1191 return;
1189 } 1192 }
1190 1193
1191 const url::Origin requesting_origin = 1194 const url::Origin requesting_origin =
1192 render_frame_host->GetLastCommittedOrigin(); 1195 render_frame_host->GetLastCommittedOrigin();
1193 const url::Origin embedding_origin = 1196 const url::Origin embedding_origin =
1194 web_contents->GetMainFrame()->GetLastCommittedOrigin(); 1197 web_contents->GetMainFrame()->GetLastCommittedOrigin();
1195 1198
1196 if (requesting_origin.unique()) { 1199 if (requesting_origin.unique()) {
1197 VLOG(1) << "Request device with unique origin."; 1200 VLOG(1) << "Request device with unique origin.";
1198 Send(new BluetoothMsg_RequestDeviceError( 1201 Send(new BluetoothMsg_RequestDeviceError(
1199 thread_id, request_id, 1202 thread_id, request_id,
1200 WebBluetoothError::RequestDeviceWithUniqueOrigin)); 1203 WebBluetoothError::REQUEST_DEVICE_WITH_UNIQUE_ORIGIN));
1201 return; 1204 return;
1202 } 1205 }
1203 1206
1204 DCHECK(adapter_.get()); 1207 DCHECK(adapter_.get());
1205 1208
1206 if (!adapter_->IsPresent()) { 1209 if (!adapter_->IsPresent()) {
1207 VLOG(1) << "Bluetooth Adapter not present. Can't serve requestDevice."; 1210 VLOG(1) << "Bluetooth Adapter not present. Can't serve requestDevice.";
1208 RecordRequestDeviceOutcome( 1211 RecordRequestDeviceOutcome(
1209 UMARequestDeviceOutcome::BLUETOOTH_ADAPTER_NOT_PRESENT); 1212 UMARequestDeviceOutcome::BLUETOOTH_ADAPTER_NOT_PRESENT);
1210 Send(new BluetoothMsg_RequestDeviceError( 1213 Send(new BluetoothMsg_RequestDeviceError(
1211 thread_id, request_id, WebBluetoothError::NoBluetoothAdapter)); 1214 thread_id, request_id, WebBluetoothError::NO_BLUETOOTH_ADAPTER));
1212 return; 1215 return;
1213 } 1216 }
1214 1217
1215 // The renderer should never send empty filters. 1218 // The renderer should never send empty filters.
1216 if (HasEmptyOrInvalidFilter(filters)) { 1219 if (HasEmptyOrInvalidFilter(filters)) {
1217 bad_message::ReceivedBadMessage(this, 1220 bad_message::ReceivedBadMessage(this,
1218 bad_message::BDH_EMPTY_OR_INVALID_FILTERS); 1221 bad_message::BDH_EMPTY_OR_INVALID_FILTERS);
1219 return; 1222 return;
1220 } 1223 }
1221 1224
1222 if (!GetContentClient()->browser()->AllowWebBluetooth( 1225 if (!GetContentClient()->browser()->AllowWebBluetooth(
1223 web_contents->GetBrowserContext(), requesting_origin, 1226 web_contents->GetBrowserContext(), requesting_origin,
1224 embedding_origin)) { 1227 embedding_origin)) {
1225 RecordRequestDeviceOutcome( 1228 RecordRequestDeviceOutcome(
1226 UMARequestDeviceOutcome::BLUETOOTH_CHOOSER_GLOBALLY_DISABLED); 1229 UMARequestDeviceOutcome::BLUETOOTH_CHOOSER_GLOBALLY_DISABLED);
1227 Send(new BluetoothMsg_RequestDeviceError( 1230 Send(new BluetoothMsg_RequestDeviceError(
1228 thread_id, request_id, WebBluetoothError::ChooserDisabled)); 1231 thread_id, request_id, WebBluetoothError::CHOOSER_DISABLED));
1229 return; 1232 return;
1230 } 1233 }
1231 1234
1232 // Create storage for the information that backs the chooser, and show the 1235 // Create storage for the information that backs the chooser, and show the
1233 // chooser. 1236 // chooser.
1234 RequestDeviceSession* const session = new RequestDeviceSession( 1237 RequestDeviceSession* const session = new RequestDeviceSession(
1235 thread_id, request_id, frame_routing_id, requesting_origin, filters, 1238 thread_id, request_id, frame_routing_id, requesting_origin, filters,
1236 optional_services_blacklist_filtered); 1239 optional_services_blacklist_filtered);
1237 int chooser_id = request_device_sessions_.Add(session); 1240 int chooser_id = request_device_sessions_.Add(session);
1238 1241
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1362 const std::string& device_id) { 1365 const std::string& device_id) {
1363 DCHECK_CURRENTLY_ON(BrowserThread::UI); 1366 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1364 RequestDeviceSession* session = request_device_sessions_.Lookup(chooser_id); 1367 RequestDeviceSession* session = request_device_sessions_.Lookup(chooser_id);
1365 DCHECK(session) << "Session removed unexpectedly."; 1368 DCHECK(session) << "Session removed unexpectedly.";
1366 1369
1367 if ((event != BluetoothChooser::Event::DENIED_PERMISSION) && 1370 if ((event != BluetoothChooser::Event::DENIED_PERMISSION) &&
1368 (event != BluetoothChooser::Event::SELECTED)) { 1371 (event != BluetoothChooser::Event::SELECTED)) {
1369 RecordRequestDeviceOutcome(OutcomeFromChooserEvent(event)); 1372 RecordRequestDeviceOutcome(OutcomeFromChooserEvent(event));
1370 Send(new BluetoothMsg_RequestDeviceError( 1373 Send(new BluetoothMsg_RequestDeviceError(
1371 session->thread_id, session->request_id, 1374 session->thread_id, session->request_id,
1372 WebBluetoothError::ChooserCancelled)); 1375 WebBluetoothError::CHOOSER_CANCELLED));
1373 request_device_sessions_.Remove(chooser_id); 1376 request_device_sessions_.Remove(chooser_id);
1374 return; 1377 return;
1375 } 1378 }
1376 if (event == BluetoothChooser::Event::DENIED_PERMISSION) { 1379 if (event == BluetoothChooser::Event::DENIED_PERMISSION) {
1377 RecordRequestDeviceOutcome( 1380 RecordRequestDeviceOutcome(
1378 UMARequestDeviceOutcome::BLUETOOTH_CHOOSER_DENIED_PERMISSION); 1381 UMARequestDeviceOutcome::BLUETOOTH_CHOOSER_DENIED_PERMISSION);
1379 VLOG(1) << "Bluetooth chooser denied permission"; 1382 VLOG(1) << "Bluetooth chooser denied permission";
1380 Send(new BluetoothMsg_RequestDeviceError( 1383 Send(new BluetoothMsg_RequestDeviceError(
1381 session->thread_id, session->request_id, 1384 session->thread_id, session->request_id,
1382 WebBluetoothError::ChooserDeniedPermission)); 1385 WebBluetoothError::CHOOSER_DENIED_PERMISSION));
1383 request_device_sessions_.Remove(chooser_id); 1386 request_device_sessions_.Remove(chooser_id);
1384 return; 1387 return;
1385 } 1388 }
1386 DCHECK_EQ(static_cast<int>(event), 1389 DCHECK_EQ(static_cast<int>(event),
1387 static_cast<int>(BluetoothChooser::Event::SELECTED)); 1390 static_cast<int>(BluetoothChooser::Event::SELECTED));
1388 1391
1389 // |device_id| is the Device Address that RequestDeviceSession passed to 1392 // |device_id| is the Device Address that RequestDeviceSession passed to
1390 // chooser->AddDevice(). 1393 // chooser->AddDevice().
1391 const device::BluetoothDevice* const device = adapter_->GetDevice(device_id); 1394 const device::BluetoothDevice* const device = adapter_->GetDevice(device_id);
1392 if (device == nullptr) { 1395 if (device == nullptr) {
1393 VLOG(1) << "Device " << device_id << " no longer in adapter"; 1396 VLOG(1) << "Device " << device_id << " no longer in adapter";
1394 RecordRequestDeviceOutcome(UMARequestDeviceOutcome::CHOSEN_DEVICE_VANISHED); 1397 RecordRequestDeviceOutcome(UMARequestDeviceOutcome::CHOSEN_DEVICE_VANISHED);
1395 Send(new BluetoothMsg_RequestDeviceError( 1398 Send(new BluetoothMsg_RequestDeviceError(
1396 session->thread_id, session->request_id, 1399 session->thread_id, session->request_id,
1397 WebBluetoothError::ChosenDeviceVanished)); 1400 WebBluetoothError::CHOSEN_DEVICE_VANISHED));
1398 request_device_sessions_.Remove(chooser_id); 1401 request_device_sessions_.Remove(chooser_id);
1399 return; 1402 return;
1400 } 1403 }
1401 1404
1402 const std::string& device_id_for_origin = allowed_devices_map_.AddDevice( 1405 const std::string& device_id_for_origin = allowed_devices_map_.AddDevice(
1403 session->origin, device->GetAddress(), session->filters, 1406 session->origin, device->GetAddress(), session->filters,
1404 session->optional_services); 1407 session->optional_services);
1405 1408
1406 VLOG(1) << "Device: " << device->GetName(); 1409 VLOG(1) << "Device: " << device->GetName();
1407 VLOG(1) << "UUIDs: "; 1410 VLOG(1) << "UUIDs: ";
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
1664 1667
1665 bool BluetoothDispatcherHost::CanFrameAccessCharacteristicInstance( 1668 bool BluetoothDispatcherHost::CanFrameAccessCharacteristicInstance(
1666 int frame_routing_id, 1669 int frame_routing_id,
1667 const std::string& characteristic_instance_id) { 1670 const std::string& characteristic_instance_id) {
1668 return QueryCacheForCharacteristic(GetOrigin(frame_routing_id), 1671 return QueryCacheForCharacteristic(GetOrigin(frame_routing_id),
1669 characteristic_instance_id) 1672 characteristic_instance_id)
1670 .outcome != CacheQueryOutcome::BAD_RENDERER; 1673 .outcome != CacheQueryOutcome::BAD_RENDERER;
1671 } 1674 }
1672 1675
1673 } // namespace content 1676 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/bluetooth/BluetoothError.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698