Provide sample API message, add a menu item for api.json

This commit is contained in:
Thomas Wilburn 2013-12-02 15:38:12 -08:00
parent 3f992a3e43
commit d31049046d
4 changed files with 15 additions and 4 deletions

View file

@ -1 +1,8 @@
{}
{
"sampleMessage": {
"id": "extension id goes here",
"message": {
"data": "message can be any JSON object passable to chrome.runtime.sendMessageExternal"
}
}
}

View file

@ -72,6 +72,7 @@
{ "label": "User Preferences", "command": "session:open-settings-file", "argument": "user" },
{ "label": "Keyboard", "command": "session:open-settings-file", "argument": "keys" },
{ "label": "Menus", "command": "session:open-settings-file", "argument": "menus" },
{ "label": "External Commands", "command": "session:open-settings-file", "argument": "api" },
"divider",
{ "label": "View Defaults",
"sub": [

View file

@ -8,10 +8,13 @@ define(["command", "settings!api"], function(command, Settings) {
command.on("api:execute", function(id) {
if (!id in targets) return;
var config = targets[id];
chrome.runtime.sendMessage(config.id, config.message);
chrome.runtime.sendMessage(config.id, config.message, null, function() {
if (chrome.runtime.lastError) {
console.error(chrome.runtime.lastError);
}
});
});
//External apps can send messages by matching Caret's command/argument config objects
chrome.runtime.onMessageExternal.addListener(function(message, sender, c) {
command.fire(message.command, message.argument, c);

View file

@ -1,7 +1,7 @@
{
"name": "Caret",
"description": "Professional text editing for Chrome and Chrome OS",
"version": "1.2.11",
"version": "1.2.12",
"manifest_version": 2,
"icons": {
"128": "icon-128.png"