diff options
Diffstat (limited to 'ext/bg')
-rw-r--r-- | ext/bg/js/backend.js | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js index 877161c7..fb680304 100644 --- a/ext/bg/js/backend.js +++ b/ext/bg/js/backend.js @@ -42,7 +42,7 @@ class Backend { this.onOptionsUpdated('background'); if (chrome.commands !== null && typeof chrome.commands === 'object') { - chrome.commands.onCommand.addListener(this.onCommand.bind(this)); + chrome.commands.onCommand.addListener((command) => this._runCommand(command)); } chrome.runtime.onMessage.addListener(this.onMessage.bind(this)); @@ -67,10 +67,6 @@ class Backend { }); } - onCommand(command) { - apiCommandExec(command); - } - onMessage({action, params}, sender, callback) { const handler = Backend._messageHandlers.get(action); if (typeof handler !== 'function') { return false; } @@ -184,6 +180,14 @@ class Backend { // NOP } + _runCommand(command, params) { + const handler = Backend._commandHandlers.get(command); + if (typeof handler !== 'function') { return false; } + + handler(this, params); + return true; + } + // Message handlers _onApiOptionsGet({optionsContext}) { @@ -398,10 +402,7 @@ class Backend { } async _onApiCommandExec({command, params}) { - const handler = Backend._commandHandlers.get(command); - if (typeof handler !== 'function') { return false; } - - handler(this, params); + return this._runCommand(command, params); } async _onApiAudioGetUrl({definition, source, optionsContext}) { |