simplify protocol handler api (#96)

* simplify protocol handler api

* update registerProtocolHandler doc

* more documentation updates
This commit is contained in:
Lynn 2017-05-23 08:06:18 -07:00 committed by GitHub
parent d494e23d4e
commit c4a3f6c024
3 changed files with 14 additions and 24 deletions

View File

@ -10,7 +10,6 @@ const cmds = keyMirror({
activate: null,
registerBoundsChange: null,
registerProtocolHandler: null,
checkProtocolAction: null,
registerActivityDetection: null,
});

View File

@ -70,13 +70,9 @@ electron.ipcMain.on(apiName, (event, arg) => {
return;
}
if (arg.cmd === apiCmds.checkProtocolAction) {
protocolHandler.checkProtocolAction();
return;
}
if (arg.cmd === apiCmds.registerProtocolHandler) {
protocolHandler.setProtocolWindow(event.sender);
protocolHandler.checkProtocolAction();
}
if (arg.cmd === apiCmds.badgeDataUrl && typeof arg.dataUrl === 'string' &&

View File

@ -32,13 +32,6 @@ const throttledSetBadgeCount = throttle(1000, function(count) {
});
});
// check to see if the app was opened via a url
const checkProtocolAction = function () {
local.ipcRenderer.send(apiName, {
cmd: apiCmds.checkProtocolAction
});
};
createAPI();
// creates API exposed from electron.
@ -83,13 +76,6 @@ function createAPI() {
throttledSetBadgeCount(count);
},
/**
* checks to see if the app was opened from a url.
*/
checkProtocolAction: function () {
checkProtocolAction();
},
/**
* provides api similar to html5 Notification, see details
* in notify/notifyImpl.js
@ -149,11 +135,21 @@ function createAPI() {
},
/**
* allows JS to register a protocol handler that can be used by the electron main process.
* @param protocolHandler {Object} protocolHandler a callback to register the protocol handler
* allows JS to register a protocol handler that can be used by the
* electron main process.
*
* @param protocolHandler {Function} callback will be called when app is
* invoked with registered protocol (e.g., symphony). The callback
* receives a single string argument: full uri that the app was
* invoked with e.g., symphony://?streamId=xyz123&streamType=chatroom
*
* Note: this function should only be called after client app is fully
* able for protocolHandler callback to be invoked. It is possible
* the app was started using protocol handler, in this case as soon as
* this registration func is invoked then the protocolHandler callback
* will be immediately called.
*/
registerProtocolHandler: function (protocolHandler) {
if (typeof protocolHandler === 'function') {
local.processProtocolAction = protocolHandler;
@ -163,7 +159,6 @@ function createAPI() {
});
}
},
/**