Commit 4429dfc0 authored by Raphael Kubo da Costa's avatar Raphael Kubo da Costa Committed by Commit Bot

WebView: Grant sensor permission requests

Commit b6c4e590 ("Grant generic sensor permission for Android WebView")
started always granting sensors permission requests in
GetPermissionStatus().

However, commit 94c082d4 ("[sensors] Add sensors usage indicator") caused
SensorProviderProxyImpl to query PermissionManager via RequestPermission()
before making a given sensor available.

The Android WebView case was overlooked, and its RequestPermission()
implementation was still denying all requests for sensors. Update the policy
to always-grant, and while at it make CancelPermissionRequest() not show a
"not implemented" error for sensor requests, as the requests are always
granted anyway.

Doing so re-allows the WebView to provide device motion/orientation data to
users, while SensorProviderImpl::GetSensor() still prevents other types of
sensors from being accessed, just like before.

Bug: 852543
Change-Id: I3bd45f955f8ff9dca67b7b9bda940590dce258f1
Reviewed-on: https://chromium-review.googlesource.com/1104417Reviewed-by: default avatarTao Bai <michaelbai@chromium.org>
Reviewed-by: default avatarJun Cai <juncai@chromium.org>
Commit-Queue: Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com>
Cr-Commit-Position: refs/heads/master@{#568068}
parent e0bc8908
...@@ -322,7 +322,6 @@ int AwPermissionManager::RequestPermissions( ...@@ -322,7 +322,6 @@ int AwPermissionManager::RequestPermissions(
case PermissionType::NOTIFICATIONS: case PermissionType::NOTIFICATIONS:
case PermissionType::DURABLE_STORAGE: case PermissionType::DURABLE_STORAGE:
case PermissionType::BACKGROUND_SYNC: case PermissionType::BACKGROUND_SYNC:
case PermissionType::SENSORS:
case PermissionType::FLASH: case PermissionType::FLASH:
case PermissionType::ACCESSIBILITY_EVENTS: case PermissionType::ACCESSIBILITY_EVENTS:
case PermissionType::CLIPBOARD_READ: case PermissionType::CLIPBOARD_READ:
...@@ -334,6 +333,11 @@ int AwPermissionManager::RequestPermissions( ...@@ -334,6 +333,11 @@ int AwPermissionManager::RequestPermissions(
PermissionStatus::DENIED); PermissionStatus::DENIED);
break; break;
case PermissionType::MIDI: case PermissionType::MIDI:
case PermissionType::SENSORS:
// PermissionType::SENSORS requests are always granted so that access
// to device motion and device orientation data (and underlying
// sensors) works in the WebView. SensorProviderImpl::GetSensor()
// filters requests for other types of sensors.
pending_request_raw->SetPermissionStatus(permissions[i], pending_request_raw->SetPermissionStatus(permissions[i],
PermissionStatus::GRANTED); PermissionStatus::GRANTED);
break; break;
...@@ -509,7 +513,6 @@ void AwPermissionManager::CancelPermissionRequest(int request_id) { ...@@ -509,7 +513,6 @@ void AwPermissionManager::CancelPermissionRequest(int request_id) {
case PermissionType::AUDIO_CAPTURE: case PermissionType::AUDIO_CAPTURE:
case PermissionType::VIDEO_CAPTURE: case PermissionType::VIDEO_CAPTURE:
case PermissionType::BACKGROUND_SYNC: case PermissionType::BACKGROUND_SYNC:
case PermissionType::SENSORS:
case PermissionType::FLASH: case PermissionType::FLASH:
case PermissionType::ACCESSIBILITY_EVENTS: case PermissionType::ACCESSIBILITY_EVENTS:
case PermissionType::CLIPBOARD_READ: case PermissionType::CLIPBOARD_READ:
...@@ -519,6 +522,7 @@ void AwPermissionManager::CancelPermissionRequest(int request_id) { ...@@ -519,6 +522,7 @@ void AwPermissionManager::CancelPermissionRequest(int request_id) {
<< static_cast<int>(permission); << static_cast<int>(permission);
break; break;
case PermissionType::MIDI: case PermissionType::MIDI:
case PermissionType::SENSORS:
// There is nothing to cancel so this is simply ignored. // There is nothing to cancel so this is simply ignored.
break; break;
case PermissionType::NUM: case PermissionType::NUM:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment