Added Windows support (in theory)

This commit is contained in:
Will Bamberg
2016-08-29 14:57:35 -07:00
parent 31b3f1b3ee
commit e21835e0aa
3 changed files with 32 additions and 3 deletions

View File

@@ -4,9 +4,28 @@ The WebExtension, which can be found under "add-on", connects to the native appl
The native application, which can be found under "app", listens for messages from the WebExtension. When it receives a message, the native application sends a response message whose payload is just "pong". The native application is written in Python.
To get this working, there's a little setup to do:
## Setup ##
* edit the "path" property of "app/ping_pong.json" to point to the location of "app/ping_pong.py" on your computer
* copy "app/ping_pong.json" to the correct location on your computer. See [host manifest locations]() to find the correct location for your OS.
To get this working, there's a little setup to do.
### Mac OS/Linux setup ###
* Check that the [file permissions](https://en.wikipedia.org/wiki/File_system_permissions) for "ping_pong.py" include the `execute` permission.
* Edit the "path" property of "ping_pong.json" to point to the location of "ping_pong.py" on your computer.
* copy "ping_pong.json" to the correct location on your computer. See [Host Manifests ](https://wiki.mozilla.org/WebExtensions/Native_Messaging#Host_Manifests) to find the correct location for your OS.
### Windows setup ###
* Check you have Python installed.
* Edit "ping_pong_win.bat" so it contains the path to "ping_pong.py" on your computer.
* Edit the "path" property of "ping_pong_win.json" to point to the location of "ping_pong_win.bat" on your computer.
* Add a registry key containing the path to "ping_pong_win.json" on your computer. See [Host Manifests ](https://wiki.mozilla.org/WebExtensions/Native_Messaging#Host_Manifests) to find details of the registry key to add.
## Testing the example ##
Then just install the add-on as usual, by visiting about:debugging, clicking "Load Temporary Add-on", and selecting the add-on's "manifest.json".
You should see a new browser action icon in the toolbar. Open the console ("Tools/Web Developer/Browser Console" in Firefox), and click the browser action icon. You should see output like this in the console:
Sending: ping
Received: pong

View File

@@ -0,0 +1,3 @@
@echo off
python "path\to\your\ping_pong.py"

View File

@@ -0,0 +1,7 @@
{
"name": "ping_pong",
"description": "Example host for native messaging",
"path": "ping_pong_win.bat",
"type": "stdio",
"allowed_extensions": [ "ping_pong@example.org" ]
}