Detect whether a website runs in Chrome browser or webView of an Chrome app

3,553 views
Skip to first unread message

Dave L

unread,
Dec 14, 2015, 6:58:16 PM12/14/15
to Chromium-discuss
Hi, 
Does anyone know how to detect whether a website runs in Chrome browser or webview of an Chrome packaged app ?
The navigator.userAgent won't tell the difference.

Thanks

PhistucK

unread,
Dec 15, 2015, 2:26:23 AM12/15/15
to Dave L, Chromium-discuss
I am not sure it should. I am not sure you should be able to detect that.

You can use crbug.com for feature requests (look for an existing one first).


PhistucK

--
--
Chromium Discussion mailing list: chromium...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-discuss

---
You received this message because you are subscribed to the Google Groups "Chromium-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-discu...@chromium.org.

Torne (Richard Coles)

unread,
Dec 15, 2015, 7:16:53 AM12/15/15
to phis...@gmail.com, Dave L, Chromium-discuss
The useragent does, in fact, have a difference; WebView includes "; wv" in the platform token, as explained here: https://developer.chrome.com/multidevice/user-agent


PhistucK

unread,
Dec 15, 2015, 7:33:36 AM12/15/15
to Torne (Richard Coles), Dave L, Chromium-discuss
​Dave is referring to the <webview> element, used by Chrome applications. I do not think it applies.​


PhistucK

Dave L

unread,
Jan 6, 2016, 1:56:41 PM1/6/16
to Chromium-discuss, to...@chromium.org, mele...@gmail.com
Thanks for your info.
I resolved my issue by appending kind of "webview-id" into useragent string on loading webview.
window.onload = function () {
     ...
     var userAgent = navigator.userAgent;
     userAgent = "mywebview " + userAgent;
     ...
Reply all
Reply to author
Forward
0 new messages