Skip to content

Conversation

@aakash232
Copy link

@aakash232 aakash232 commented Dec 20, 2023

This recipe shows how to use User Media in an Extension Service Worker using the Offscreen document.

The extension aims to capture audio from the user in the context of extension (globally) via a media recorder in the offscreen document.

Aims to add a new sample fixing the issue : MV3 user's mic and cam permissions using iframe
Fixes #821

@aakash232
Copy link
Author

aakash232 commented Dec 20, 2023

@patrickkettner
As discussed on the mail, raised the PR for the sample.
Please review the same.

@aakash232
Copy link
Author

@oliverdunk
As discussed on the mail, raised the PR for the sample.
Please review and guide me for the same.

"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["contentScript.js"]
Copy link

@sorokinvj sorokinvj May 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can do just this

Suggested change
"js": ["contentScript.js"]
"js": ["contentScript.js", "requestPermissions.js"]

and run it without all the fuss with iframes, messaging to offscreen and back

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

however I still get permission in prompt state, so I am probably missing something from your code

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sorokinvj

#821 : The reason for requesting mic and cam permissions inside the iframe is because we want to ask for the permissions on behalf of the extension app (eg -> "[myExtension] wants to Use" instead of "www.google.com wants to use your camera and microphone") and hold onto the permissions across all tabs, only asking once for the permissions.


Your suggestion of injecting CS directly via manifest will not help in accomplishing above goal. But will definitely ease around the fuss if you don't need it in the context of your extension.

Attaching a snapshot for reference how your suggested code will ask for permissions.

image

Let me know if I am missing out something in your proposed flow.
Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MV3 user's mic and cam permissions using iframe

3 participants