Chrome Extension communicating with dev server - google-chrome

Is there a way I can have a Python server send messages to a chrome extension, whether it be the content or background script?
I have a Python script making network requests that needs some cookies stored in my browser. I was trying to find a way to have the Python script send a message to the extension to refresh the page to get new cookies & send them back to the script.

Related

How can I send a message from Desktop application to Google Chrome extension?

I want to send a message from my python app to google chrome extension which will activate the extension. I am able to call my python app from my extension but in that case extension opens the new instance of python app every time but I want my extension to make connection with active instance of the app else extension should wait for the app to be active to connect.
Kindly refer these two questions to understand the problem -
[https://stackoverflow.com/questions/26108698/connecting-chrome-native-messages-to-a-existing-instance-on-windows]
how to use NativeMessaging to connect to a native application(.exe) ,but don't launch the .exe,just send the message background

Sending javascript code to a chrome app via the remote debug protocol

In the context of a unit test I need to send some code to the console of a chrome app I am developing. It's clear that I can do that from the chrome.debug API, but is there a way to do that from outside the browser?
Yes, there is a way; if you can do something with chrome.debug you can do so with remote debugging.
You need to enable remote debugging with command line switches; you can then connect to Chrome with a debugger client instance.
Google lists some existing debugger clients, and you can implement your own by following the debugger protocol (which works over HTTP+WebSockets).
The procedure for a debugger client is to request /json from the debugger port over HTTP, which lists all possible debug targets; the client then connects to the WebSocket associated with that target to work with it.

How can I send a message to a Chrome extension from an App Engine server?

I would like to be able to send messages from an App Engine server to a Chrome extension. When the Chrome extension receives a message, it should increment the badge over the icon. Is it possible to send messages directly, or do I have to poll the server continuously from the extension?
You should look into the Cloud Messaging API, specifically chrome.gcm API.
This would be the best way to notify the extension from the server side, and can be a two-way communication channel.

Access to json/web service from javascript behind windows authenticated web site?

Is it possible to call json service from JavaScript which is behind a windows authenticated web site?
Ultimately, I would like to do this from phonegap but right now trying to do this from browser.
My first attempt was to open a window have the user authenticate against the server and was hoping subsequent JavaScript/ajax requests would send the authentication information with the request. I don't think this is working is desired. I certainly know from phonegap this is not working.

HTTP Server in Chrome Packaged App using Sockets API

I am trying to get a simple web page server from within a Google Chrome Packaged App. There is already a UDP server running within the app and working without any problems.
I am starting the socket.listen on 0.0.0.0:8080 and copying most of the code from
https://github.com/GoogleChrome/chrome-app-samples/tree/master/webserver
. The same issue is replicated in the sample app.
What I am doing is accepting the request and sending a single HTML file to all requests which have some data in the request (request.data.length > 0). The flow of the app is similar to the sample app with near-equivalent functions.
To test this I am using Socket Test 3.0 (from SourceForge). Creating a socket to 127.0.0.1:8080 and sending it GET / HTTP/1.1 as the content. As intended the Chrome App responds with the html file and correct headers. I can repeat this multiple times without restarting the App. The problem arises when the App is sent a request through Chrome. On first look it works as intended, but then it Time Out on refresh. This is also replicated in the sample app.
On debugging I found that every thing was being handles. The write socket being destroyed and a socket.accept(serverSocket, ...) being issued. I also made sure that it was done inside the callback function of the socket.write. The first request as intended is for the page requested (GET / HTTP/1.1 for localhost:8080). Second was for favicon.ico as GET /favicon.ico HTTP/1.1. And then a third connection with none in data (which is then ignored and socket destroyed). Unlike in the SocketTest where every request was answered back.
I have created a video showing the screencast while reproducing the error on YouTube. Also the repo for the project that I'm working on is at GitHub.
I had the same issues with Google's sample web server. I wrote a more robust socket server app that does not hang. The source is on GitHub at https://github.com/kzahel/web-server-chrome and you can install it from the Chrome web store at https://chrome.google.com/webstore/detail/web-server-for-chrome/ofhbbkphhbklhfoeikjpcbhemlocgigb