WebView2Feedback icon indicating copy to clipboard operation
WebView2Feedback copied to clipboard

Feature request: Device or permission "in use" event

Open RendijsSmukulis opened this issue 3 years ago • 8 comments

We currently have no good way to indicate to a user when some sensitive API is in use by a page, e.g. the page has access to the camera or the microphone that's currently recording.

It would be great to see an event that signals when these APIs are being actively used by site:

  • Geolocation
  • Camera
  • Microphone

With events fired when these are enabled and then later disabled.

AB#39484085

RendijsSmukulis avatar May 06 '22 12:05 RendijsSmukulis

Thanks for the feedback RendijsSmukulis! We've added this as a scenario on our backlog!

victorthoang avatar May 09 '22 18:05 victorthoang

Hi @RendijsSmukulis,

Can you expand more on the scenario you are trying to achieve here? For these events is it sufficient to be able to query the value set for these permissions?

Thank you

nishitha-burman avatar Sep 05 '22 00:09 nishitha-burman

Hi @nishitha-burman

In this case we want to display an indicator to the user that a permission is in use AND we also want to give them the ability to pause / resume usage. This means apart from being able to query the value we need to be able to disable / re-enable the outgoing audio / video stream temporarily. For example at JS level this means setting MediaStreamTrack.enabled to false (and then back to true for resuming).

q71114 avatar Sep 05 '22 10:09 q71114

@RendijsSmukulis and @q71114, can you check if the new experimental Permission Management APIs meet your needs? https://github.com/MicrosoftEdge/WebView2Feedback/issues/2427#issuecomment-1399097515 Thanks!

vickiez avatar Jan 21 '23 00:01 vickiez

@RendijsSmukulis and @q71114, can you check if the new experimental permission management APIs meet your needs? #2427 (comment) Thanks!

Hi @vickiez,

Thanks for the info, we'll check it out. Looking at the new APIs I don't see anything that provides "in use" status (eg. camera is recording). Are those APIs in a separate document?

q71114 avatar Jan 23 '23 09:01 q71114

@q71114 we haven't added an "in use" event but you may be able to accomplish what you need in a couple ways:

  • If you set the new SavesInProfile property on PermissionRequestedEventArgs to false, then the state set in PermissionRequested will only apply to the current request. You can then implement the caching of state on the app side. Here's an example: https://github.com/MicrosoftEdge/WebView2Feedback/blob/api-permissionmanagement/specs/PermissionManagement.md#extended-permissionrequestedeventargs-savesinprofile.
  • By default, state set in PermissionRequested is saved to the profile. You can use the new GetNonDefaultPermissionSettings API to get the list of saved permissions and check if a site has already been granted permission to know if a permission will be in use for a site. You can also use SetPermissionState to reset the state at any time.

Will either of these options work for your case?

vickiez avatar Jan 23 '23 18:01 vickiez

@vickiez thanks for the suggestion, but it doesn't offer enough support for all the cases that we want to cover I'm afraid.

We only display these "in use" indicators when they are actually being in use, so GetNonDefaultPermissionSettings won't work.

Using PermissionRequested with SavesInProfile property won't cover everything either because for example audio / video streams can be paused (muted) and they don't trigger PermissionRequested event, which is fine because they are not new request, but we still need to be able to display proper "in use" statuses for those scenarios. You can check it out here: https://jsfiddle.net/jib1/3ykab1e2/39/

q71114 avatar Jan 25 '23 15:01 q71114

I see, thanks for sharing the example! This request is relatively low priority on our backlog, but we are starting to work on #2440, which may be your preferred approach anyway. :)

vickiez avatar Jan 25 '23 21:01 vickiez