Do google Chrome extensions support Chrome's Web Speech speech recognition API? I have included some javascript to create a speech recognition object, but when I launch my extension, I am not prompted for microphone access.
This is not an issue with my code. I have searched on google, but I can't find any information on whether Chrome extensions support the Web Speech API. I just want a yes/no answer.
Note: I believe the WebSpeech API won't work for local files.
The Web Speech API can already be used by Chrome extensions, even in the background page and extension button popups. The fact that it works is not necessarily an intended feature, and I have previously explained how it works and why it works in this answer to How to use webrtc insde google chrome extension?. The previous explanation is about WebRTC, but it applies equally to Web Speech, and can be used as follows:
Instantiate a webkitSpeechRecognition instance and start recording.
If a permission error is detected (onerror being triggered with event.error === 'not-allowed'), open an extension page (chrome-extension://[ID]/yourpage.html). This extension page can be opened in a new window, tab or iframe.
From this page, request access to the microphone. getUserMedia and SpeechRecognition both share the (persistent) audio permission, so to detect whether audio recording is allowed, you could use getUserMedia to request the permission without activating speech recognition. For instance:
navigator.webkitGetUserMedia({
audio: true,
}, function(stream) {
stream.stop();
// Now you know that you have audio permission. Do whatever you want...
}, function() {
// Aw. No permission (or no microphone available).
});
Update: Based on RobW's answer, this answer is now out of date, and the Web Speech API is now usable inside of extensions. (Unfortunately, I can't delete this answer unless the OP un-accepts it.)
The answer is not yet. Pages accessed through chrome-extension: URLs cannot access any media-input APIs, including speechRecognition and getUserMedia. Any attempt to the use APIs will immediately trigger an error callback.
I originally thought speechRecognition could work like the geolocation API: extension popups cannot prompt for geolocation permission, but chrome-extension: pages loaded as full browser pages can prompt for permission just like a normal page. However, media APIs do not behave this way; they fail regardless of whether the page is a popup or a full page.
There is a bug report to fix this and allow developers to specify media-access permissions in the manifest. When this bug is fixed, extensions can have a manifest-set permission that grants them automatic microphone/video access, so the inability to prompt for permission will become a non-issue (and therefore extensions with appropriate manifest permissions will be able to freely use the Speech API).
Related
I am developing a Google Cast sender application and on my web page in chrome browser, I need to detect if the Google Cast extension is installed or not before doing something.
I did some searching and found some suggestions for detecting chrome extensions if developer owns both website and extension. In my case, I am trying to detect an extension not developed by me. Is there an API or another way to detect installation of a third party chrome extension?
The standard way (used by the library itself) of detecting whether the extension is installed is to try and load a web-accessible file from it.
This, however, leads to an unwanted effect of producing error messages in the console (which are "network" errors and not JS errors, and therefore cannot be hidden) when Cast is not installed.
Also, you should not do this probing yourself, specifically because you don't control Google Cast - and it's not guaranteed to be stable in how it operates internally. There is a library you're expected to use as a Sender, and you should rely on the library initialization callback for detecting Cast.
I am creating a chrome app (packaged) and I have to create a socket and listen for the incoming broadcast messages as soon as chrome browser starts up.
I came across this API , but it seems to be only for extensions.
And also the API for listening when a window is created needs the permission
"permissions": ["tabs"], and this also is available only for extensions.
So is this possible for a chrome app?
Thanks in advance.
chrome.runtime.onStartup is also available to the Chrome Apps (it is listed as supported api on Chrome App Platform API page). So you can just use it in your chrome app.
Chrome Apps also have an onStartup event, as documented here.
Additionally, you will likely want to handle events like onInstalled to start your background socket tcpServer after the app is first installed (or updated).
The "tabs" permission is only available to extensions, since apps are not meant to interact with the browser/webpages at all, so you certainly won't be able to use that.
I would like to create an extension or app for the Chrome browser which would require access to a user's Google Calender (for creating new appointments).
I am unsure of which technology to better research and use, Chrome extensions or apps. My "app" wouldn't need much of a GUI, so I'm leaning towards extension — but I don't know if this would pose any difficulties for accessing a user's Google Calender to add an event.
Anyone one have any idea which technology is best for this situation, and why? Thanks!
Either, or... Go with an extension if you'd like.
I assume you've looked at the API reference?
https://developers.google.com/google-apps/calendar/
From there, I'd imagine you'd just need OAuth to authenticate the user. Here's the JS library:
https://code.google.com/p/google-api-javascript-client/
There are pros/cons of each types, apps or extensions.
Apps
If you would like to create a client application of Google Calendar which has many rich GUI components, this type will become a better solution.
In addition, Chrome apps can communicate with many hardware devices and other servers. Of course, your Chrome app can become as a server (that is, your app can open a server socket and accept a request from other client apps).
Chrome apps can be executed not depending on your Chrome Web browser. That is, Chrome apps cannot access to a context of your Chrome Web browser.
Probably, you don't want to get the pros above, I guess...
Extensions
If you would like to create a small UI for posting your schedule to Google Calendar, this type will become a better solution.
In addition, Chrome extensions can access to a context of your Chrome Web browser. That is, your extension can get page contents of each tab and inject your CSS and/or JS code. For example, your extension will get a URL of some opened tab and include it in a body of the posted schedule.
Chrome extensions completely depend on your Chrome Web browser. That is, your extension cannot execute independently.
Also, generally, high cost will be needed to develop Chrome apps than Chrome extensions. As the result, you should choose Chrome extensions, I believe.
I am trying to create a web page, which embeds several Google Docs in it. My problem is that when this page is viewed on an android device, then the user is presented with the terrible web based Google Docs editor. Therefore, I would like to have a link on my page, which opens the native Google Drive app on the users phone, so he/she can edit the document there. After searching for two hours, I am unable to figure out how to make a link, which automatically opens the document in the native app.
I succeeded with viewing the Google Drive app in google market using the following link:
market://details?id=com.google.android.apps.docs
I also experimented with
googledrive://no-idea-what-to-write-here
But that did not succeed either.
Is this possible at all, or does this only work on iOS?
There does not seem to be a good way to do what you want (at least according to my testing with Android 4.0.4; maybe the situation is different with other versions).
Using http: or https: links intercepted by an app
In theory, just using the https://docs.google.com/... link for the document should work for you. According to this answer on StackOverflow, intercepting http: or https: URLs is the proper way to start an app when opening a link from the Android browser. The Google Drive app does exactly this — it registers intent filters for https://drive.google.com, https://docs.google.com, https://spreadsheets.google.com and a bunch of similar URLs (including http: with the same host names). And this actually works — when using the stock Android browser, attempting to open a link pointing to https://drive.google.com results in the chooser popup with the Google Drive app included in the list (together with all installed browsers); selecting Google Drive results in opening the document in the Google Drive editor, as you want.
But the problem is that such intercepted HTTP[S] URLs work only in the stock Android browser — I have not been able to find any third-party browser which could show the app chooser when following such links. I tested Chrome, Dolphin, Firefox, Light Browser, Opera (including Classic and Mini), UC Browser, and all of them just opened the link internally instead of offering to pass it to the Google Drive app.
Using the intent: URI scheme
There is another way to make a link which starts an Android app — use the intent: URI scheme. I have not been able to find proper documentation for the intent: URI format; of course, the source code for the function which generates such URIs is available.
For your test document:
https://docs.google.com/document/d/1zSzDnV-90Ke3dzCCJ2CZ6iQ3JQ3F1hL1udGDqbNwwbY/edit?usp=sharing
the corresponding intent: link which opens it in the Google Drive app will be:
intent://docs.google.com/document/d/1zSzDnV-90Ke3dzCCJ2CZ6iQ3JQ3F1hL1udGDqbNwwbY/edit?usp=sharing#Intent;scheme=https;action=android.intent.action.VIEW;category=android.intent.category.DEFAULT;category=android.intent.category.BROWSABLE;package=com.google.android.apps.docs;end
A test link with this URI is on a separate page (it is not possible to make an actual link pointing to such URI here).
The process of conversion is as follows:
Replace starting https: with intent:.
Append intent parameters:
#Intent;scheme=https;action=android.intent.action.VIEW;category=android.intent.category.DEFAULT;category=android.intent.category.BROWSABLE;package=com.google.android.apps.docs;end
Here scheme=https correspond to https: in the original URL, so if you want to convert a plainhttp: URL, this field should be scheme=http. And package=com.google.android.apps.docs is the package name of the app which should handle the link.
Now, when such link is followed, the browser should open the Google Drive app directly (without showing the app chooser). However, if the app is not installed, Android will open the Market app instead, and perform a search for the specified package name, so that the user could install the required app.
It is also possible to make the intent: link without the package parameter:
intent://docs.google.com/document/d/1zSzDnV-90Ke3dzCCJ2CZ6iQ3JQ3F1hL1udGDqbNwwbY/edit?usp=sharing#Intent;scheme=https;action=android.intent.action.VIEW;category=android.intent.category.DEFAULT;category=android.intent.category.BROWSABLE;end
In this case the behavior should be the same as when the intercepted https: link is followed in the stock Android browser — the app chooser with the Google Drive app and all browser apps will be displayed, and if the Google Drive app is not installed, the user will not be redirected to install it from Market.
Unlike intercepted http: and https: links, intent: links work in a wider range of Android browser apps; unfortunately, some browsers do not support them. Results of my testing:
Works: stock Android 4.0.4 browser, Chrome, Light Browser, Opera, Opera Classic.
Does not work: Dolphin, Firefox (feature request is pending), UC Browser.
And, obviously, non-Android browsers would not support such links at all, so you will need to use some kind of browser sniffing if your pages also must be usable for other clients.
Using a custom URI scheme
Some apps use completely nonstandard URI schemes, which might also work from third-party browsers. However, the Google Drive app does not do that, therefore this solution is not suitable for it (unless someone creates a “bridge” app which just passes requests to the Google Drive app).
Some browsers could also disallow nonstandard URI schemes except some whitelisted ones (such as market:) due to security concerns; I did not try to test this.
How can I determine if a particular Chrome Browser Extension is installed, with no relationship to the Extension Provider?
It is a 'content script' (i.e. javascript running in the context of a web page) and so does not have access to chrome.i18n, chrome.extension, chrome.management objects.
The scenario is, a person has clicked on a link to an RSS feed. But as at current Chrome does not natively support the RSS/atom feed protocol, and presentation of RSS feeds in Google Chrome is best mediated by one or another of several available RSS Feed Reader Extensions.
We're recommending use of "RSS Subscription Extension (by Google)" and would like to offer the suggestion to the user that they install this Chrome Extension - download link and all - - but of course, only in the case they haven't already installed it.
How can I query the list of extensions installed into a running Chrome Browser?
You can try chrome.extension.getViews(object fetchProperties) which will return an array of the JavaScript 'window' objects for each of the pages running inside the current extension or chrome.management.getAll(function callback) which returns a list of information about installed extensions and apps.