Custom protocol handler in Chrome? - google-chrome

We have a mobile product, which runs in a WebView, and talks to our iOS / Android SDK's over a custom scheme:// (inserting an iframe with this in the URL). This is notoriously difficult to debug, and I'm trying to figure out if it's possible to catch these calls in a custom Chrome extension. I understand I can "redirect" using navigator.registerProtocolHandler, but I'd like to be able to "respond" (in the case of our SDK that means injecting Javascript into the page) to these calls. Is this possible?

Related

Embedding a chrome native app into an existing tab with content scripts

I am not so certain this is even the right approach. Essentially, I would like to control some WiFi lights (Milight/LimitlessLED brand) so that I can fade out and fade in lights when videos are played on YouTube, Netflix, and other similar services.
The only way to communicate with the lights is by sending UDP messages, and it seems the only way I can access a UDP socket in chrome is either through a chrome app, or a native app.
Native apps seem better, as I can bundle them along with an extension while I don't seem to be able to do that with a chrome app. But in the examples I've seen in documentation, a portable native app (PNaCl), is embedded into a page using <embed>.
Well, a content script can create an tag, but then how could I load the native app without violating the same origin policy? Or would there be a better solution to what I'm trying to do?
I'd create the embed in a background page. Then have your content script eavesdrop on the event that causes the video to start playing, have it send a message to the background script. Then the background script can control the embed by triggering appropriate events.

Chrome webview application to load extension

Is it possible to have a webview application for a web page and load extensions in the application?
I have created a frameless wrapper for one of our web pages, so we can hide the chrome header. I am also using the stylebot extension to alter some elements in the page. It works fine inside chrome, but when I run the application the stylebot extension is not loaded.
Any idea how can I add the extension to the application?
Greatly appreciate your help on this
Thanks, Laszlo
A Google chrome extension have to be load in Google Chrome (or Chromium based browsers). The Google chrome extension API is not included in the webview engine.
You can open a frameless window with create method of the Google window API. You should add an handler to browser action click and create a window of with "popup" type and the url you want. It's not exactly what you are looking for but I don't know a better way to do it on Mac. Perhaps some one more familliar with that environement could help you.
An other far more complicated solution is to fork the Crhomium project and do what you want. But it demand a large developpement I think.

How can I cast an HTML page with the Google Cast Chrome extension?

I'm building a simple web application that I want to be able to display on a TV screen using the Google Cast SDK, the Chrome browser and a Chromecast. I know with the Chromecast extension for Chrome Browser, I can cast a tab to a Chromecast device, which, from my laptop works perfectly. However, I want this exact same functionality, but available from iOS devices (iPads and iPhones) running the Chrome Browser.
It seems since Chrome v36 the Cast ability is baked into the iOS versions of Chrome. I have pulled in the Google Cast SDK per these instructions: https://developers.google.com/cast/docs/chrome_sender. I am able to get my iPad to connect to the Chromecast, but when I try to pass in a URL to a web page...
var mediaInfo = new chrome.cast.media.MediaInfo('http://google.com');
var request = new chrome.cast.media.LoadRequest(mediaInfo);
session.loadMedia(request, onMediaDiscovered.bind(this, 'loadMedia'), onMediaError);
I get an error...
invalid_parameter
I have found other, somewhat dated examples, saying I can build a custom Cast Receiver that holds an iFrame and renders the page in there, but I do not want to build a custom Cast Receiver.
Can I accomplish this with just a Cast Sender?
You always need a receiver on the chromecast; that is what gets loaded there. In general, you can either use a default/styled receiver or a custom one. The Default or Styled receivers can only handle media so you are left with the Custom option and having an iframe is the way to go.
Chrome on iOS doesn't support casting. There's a post from early 2016 saying this on the google product forums. (But my reputation is too low to post more than two links).
If it DID work, then all you would need to do is go to this site and choose the ChromeCast option and press Launch after typing in your website. This does work on Chrome on desktop.
The source for this sender/receiver is here: https://github.com/boombatower/chromecast-dashboard
I've used the boombatower.github.io receiver with my own code as sender in an iOS app. I'm also looking at whether an app extension would work, but I suspect not because of app extension limitations.

How to use chrome extension methods in my asp.net page?

I have page where RSS icon is present. I want that when user clicks on RSS icon it will check in chrome browser that, whether that RSS reader chrome extension is installed or not
I am trying to achieve this by using chrome extension methods, mentioned here.
I tried something like this but it is not working:
var port = chrome.extension.connect("nlbjncdgjeocebhnmkbbbdekmmmcbfjd");
To use this API you need to be either an extension or a web application having the necessary permissions - normal web pages cannot access it. However, detecting whether an extension is installed in Chrome is still easy:
<script src="chrome-extension://nlbjncdgjeocebhnmkbbbdekmmmcbfjd/manifest.json"
onload="alert('installed')" onerror="alert('not installed')"></script>
This uses the fact that the extension's manifest.json file is located under a predictable URL and that web pages are allowed to load this URL. Of course, this isn't an officially documented approach but rather a loophole and a privacy issue. So be prepared for it to stop working in some future Chrome version. At the moment it works however.

How can I get notification of page load events in Chrome?

I need to be able to monitor navigation events (such as page loads or switching between active tabs) in browsers running on a Windows PC. So far, I can get this to work in IE and Firefox by loading a DLL into all running apps via a call to SetWindowsHookEx, then asking for either the IHTMLDocument2 (in IE) or nsIWebProgress (in Firefox) interface from the application. I can use the appropriate interface to request a callback from the application when an event of interest happens.
Is there a way to do this in Chrome? I have read a little about Chrome extensions, but I have not found any documentation on an API exposed by Chrome that is analogous to COM in IE or XPCOM in Firefox. Will a similar approach work or will I need to do something completely different? (I am working in C++.)
I would appreciate it if someone could at least point me in the right direction.
Thanks.
With Chrome extensions API you can register some events handlers for changing state of tab like when document state is changed (loading or loaded), when new tab is added/removed from window or when user switch between tabs.
More about tabs events You find on http://code.google.com/chrome/extensions/tabs.html#event-onActiveChanged