How to detect if Google Cast extension is installed in Chrome? - google-chrome

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.

Related

Browser plugin/extension to track search string

I need to develop some sort of browser plugin/extension to track search string on some search engine web site, ex: google.com, bing.com.
From the research, for chrome extension, I saw somebody suggest content js is the way to go. Is it true? Is there a cross-browser approach?
You can use Content.JS or any other JS library you like for developing an extension but with only JS library you cannot develop an extension.
There is a specific way for each browser. It contains at least 4 files.
(1) Manifest file (2) HTML file (3) JS file (4) CSS file
You also need to refer browsers object model.
You can refer links below may help you to get more information.
(1) Creating a Microsoft Edge extension
(2) Getting Started Tutorial to create an extension for Chrome
(3) Your first extension for FireFox
To support cross browser functionality, You can try to port your chrome extension to Firefox or MS Edge. To get more information on porting an extension, you can refer links below.
(1) Porting an extension from Chrome to Microsoft Edge
(2) Porting a Google Chrome extension
Note:- You also need to refer policy of each browser to access browsing data of users. It can be possible that all browser has some difference in their policies.

Chrome Packaged App Access Chrome APIs

I'm interested in writing a Packaged App that can access data about chrome, namely the chrome.windows.onCreated and chrome.windows.onRemoved events. If I try to add a listener to either of these, I get an error in the console:
Uncaught TypeError: Cannot read property 'onRemoved' of undefined
Is there any way around this?
The other answers are correct that this isn't directly possible from a packaged app, but there is a solution that meets your needs: You can write an extension as well as a packaged app and have them communicate with chrome.runtime.sendMessage.
The user will have to install both app and extension, but you can make this easy by directing them to the chrome web store from within your application. You can read about this here: Communicating between a Chrome packaged app and a Chrome extension?
Edit: and as pointed out in a comment on that thread, there is a Chrome App Sample that helps demonstrate this in action: https://github.com/GoogleChrome/chrome-app-samples/tree/master/messaging
The chrome.windows API is a Chrome extension API, not a packaged apps API. It is used by extensions to interact with browser windows.
If you can write your application as an extension, it will be able to use that API. Packaged apps, however, don't have the ability to manipulate other windows besides their own.
One simple typo here: It is chrome.windows.onRemoved not chrome.windows.OnRemoved ;)
Note the lowercase o.

How to determine if a particular Chrome Browser Extension is installed, with no relationship to the Extension Provider

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.

How to get printers interface in NPAPI plugin for Google Chrome?

how to receive printer interface in NPAPI plug-in for Google Chrome?
I had a difficulty in writing of a plug-in of NPAPI. I can't understand. How to receive the list of all printers and to receive the interface to one of them?
I write Scripting plugins with use of documentation of https://developer.mozilla.org/en-US/docs/Gecko_Plugin_API_Reference/Scripting_plugins . but I didn't find the answer in this documentation there on the question.
I need to get access to the printer and to set to it settings in a plug-in. How it to make?
What you are trying to do cannot be done directly with NPAPI. There is no interface in NPAPI for getting a list of printers -- in fact, NPAPI is completely unaware of the fact that there is a browser that may have settings. All an NPAPI plugin knows about is the page that it has been inserted into and/or the stream for the file that it is handling.
The only thing an NPAPI plugin can do regarding printing is respond to a NPP_Print call, which the browser calls once the user decides to print a page. When that is called, all the plugin receives is a context that it can draw into that will then be printed -- no info about available printers, print settings, etc.
For more information on what an NPAPI plugin is and is not, see http://npapi.com/extensions
What you're trying to do might be possible to do using either system API calls (windows API, mac API, etc) or using an extension. Extensions are completely browser-specific, so you'd have to look at each individual browser that you want to support to see if what you want to do can be done.

Chrome extension API to manipulate other installed Chrome extensions?

I'm writing a Google Chrome extension that needs to do a lot of things with other extensions, such as:
List installed extensions and read their IDs
Request extension installation, update and removal (preferably without bothering the user)
Modify extension settings
and so on. Which of these are possible, and which are not (due to e.g. security considerations)?
P.S. I haven't been able to find answers in the inter-extension messaging section of the official docs (or anywhere else, actually).
You can do most of those things today with chrome.management API. For example:
Get a list of information about installed extensions and apps:
chrome.management.getAll(function callback)
Uninstall a currently installed app or extension:
chrome.management.uninstall(string id, object options, function callback)
Chromium developer Brian Kennish states here suggests writing an NPAPI plugin as the most rational option to achieve the desired effect.
This is not directly possible via the extension API. To be honest, I wouldn't recommend using NPAPI for this either since you'd have to modify files which are in-use by the browser, which is unreliable at best.