Chromium Android WebView and permissions (Geolocation, Speech, UseMedia, ...)

907 views
Skip to first unread message

Iker Jamardo

unread,
Apr 20, 2017, 1:55:57 PM4/20/17
to Chromium-dev
Hello,

I am building Chromium tag 57.0.2987.5 for Android in the webview form. In the AwShellActivity I am adding the command line flag for activating the speech recognition API:

        CommandLine.init(new String[] { "chrome", "--ignore-gpu-blacklist", "--enable-blink-features=ScriptedSpeech" });

This works and I am able to get the webkitSpeechRecognition type in my HTML page as expected. But I cannot get it to work. I am not able to get any of the callbacks (onresult, onerror, ...) to be called.

My initial guess is that permission needs to be provided. I have enabled the required permissions in the Manifest and requested permissions in the Java code. I also guessed that maybe a onPermissionRequest callback should be implemented granting the permission. but nothing seems to work. I have also tested the Geolocation API and I am not able to make it work either.

Are there any limitation in the WebView "flavor" of Chromium regarding these APIs (Geo, Speech, Media, ...)?

Thank you very much in advance.


PhistucK

unread,
Apr 20, 2017, 2:05:13 PM4/20/17
to ijam...@google.com, Chromium-dev
Geolocation and speech stuff require API keys (and as far as I remember, are generally unavailable in WebView as a result). Have you supplied those?


PhistucK

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev+unsubscribe@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/822243d9-84f7-4fd7-814e-00b5c688dd07%40chromium.org.

Iker Jamardo

unread,
Apr 20, 2017, 5:16:04 PM4/20/17
to PhistucK, Chromium-dev
Thank you, did not know about this.

What is the easiest way to resolve this? Can I provide the same keys that other "flavors" of Chromium (chrome_public_apk or content_shell_apk) provide somehow to the android_webview_apk compilation?

Regards,
Iker.

Torne (Richard Coles)

unread,
Apr 20, 2017, 5:18:27 PM4/20/17
to ijam...@google.com, PhistucK, Chromium-dev

Webview doesn't need any API keys. Geolocation just calls the platform geolocation APIs and this has worked since the beginning of android, so if that doesn't work for you then I think you're doing something wrong. I'm not sure what the status of the speech API is.




PhistucK

To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.

Iker Jamardo

unread,
Apr 20, 2017, 5:28:23 PM4/20/17
to Torne (Richard Coles), PhistucK, Chromium-dev
Thank you for your feedback Torne, but when I mention the WebView, I mean compiling Chromium with the android_webview_apk target/type (just to confirm). I might be doing something wrong but I cannot seem to be able to make it work and I do not get the callbacks to be called.

Regards,
Iker.



PhistucK

To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev+unsubscribe@chromium.org.

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.

Torne (Richard Coles)

unread,
Apr 20, 2017, 7:09:48 PM4/20/17
to Iker Jamardo, PhistucK, Chromium-dev
All web features should work exactly the same in android_webview_apk as in the actual system webview; the differences are all in how it's hooked up to the embedding application in Java. Geolocation definitely should work.



PhistucK

To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.

Bo Liu

unread,
Apr 20, 2017, 7:27:58 PM4/20/17
to Torne (Richard Coles), Iker Jamardo, PhistucK, Chromium-dev
Did you implement onGeolocationPermissionsShowPrompt? android_webview_apk uses NullContentsClient by default I believe, which is a no-op.



PhistucK

To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev+unsubscribe@chromium.org.

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.

Iker Jamardo

unread,
Apr 20, 2017, 8:26:09 PM4/20/17
to bo...@chromium.org, Torne (Richard Coles), PhistucK, Chromium-dev
You are right, I was not handling the request to enable the location correctly in the onGeolocationPermissionsShowPrompt and now I get the location callback. Thank you.

Still, for the Speech API, I cannot seem to get it to work. Should I get the onPermissionRequest call for that one? The API in JS has been enabled (window.webkitSpeechRecognition exists) but callbacks are not being fired.

Thank you very much for all your responses and help. 

Regards,
Iker.

Iker Jamardo

unread,
Apr 21, 2017, 3:09:21 AM4/21/17
to bo...@chromium.org, Torne (Richard Coles), PhistucK, Chromium-dev
Ok, also added a test for getUserMedia. I finally get a call to onPermissionRequest for this one and correctly requesting the permissions allows me to use it (I can see the video feed and the audio recording).

Still no luck with the speech recognition API. I do not get a call for onPermissionRequest for this one (do not know if that is what is expected).

Regards,
Iker.

PhistucK

unread,
Apr 21, 2017, 9:39:33 AM4/21/17
to Iker Jamardo, bo...@chromium.org, Torne (Richard Coles), Chromium-dev
See crbug.com/487255, looks like it is not supported.


PhistucK

Torne (Richard Coles)

unread,
Apr 21, 2017, 11:10:17 AM4/21/17
to PhistucK, Iker Jamardo, bo...@chromium.org, Chromium-dev
Enabling the speech api in blink won't do anything useful: it's calling into higher level interfaces which are just not implemented in WebView. Blink only implements the API, not the actual speech recognition.



PhistucK

To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.

Iker Jamardo

unread,
Apr 21, 2017, 11:10:36 AM4/21/17
to PhistucK, Torne (Richard Coles), Chromium-dev, bo...@chromium.org
Thank you. Found that crbug page but the last comments in it plus being able to enable the js API at least got me confused.

Regards,
Iker
Reply all
Reply to author
Forward
0 new messages