|
|
@ -16,6 +16,8 @@ export default class ContentMessageListener { |
|
|
|
this.linkController = new LinkController(); |
|
|
|
this.linkController = new LinkController(); |
|
|
|
this.backgroundOperationController = new OperationController(); |
|
|
|
this.backgroundOperationController = new OperationController(); |
|
|
|
this.markController = new MarkController(); |
|
|
|
this.markController = new MarkController(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.consolePorts = {}; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
run() { |
|
|
|
run() { |
|
|
@ -38,6 +40,7 @@ export default class ContentMessageListener { |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
browser.runtime.onConnect.addListener(this.onConnected.bind(this)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
onMessage(message, sender) { |
|
|
|
onMessage(message, sender) { |
|
|
@ -65,6 +68,8 @@ export default class ContentMessageListener { |
|
|
|
return this.onMarkSetGlobal(message.key, message.x, message.y); |
|
|
|
return this.onMarkSetGlobal(message.key, message.x, message.y); |
|
|
|
case messages.MARK_JUMP_GLOBAL: |
|
|
|
case messages.MARK_JUMP_GLOBAL: |
|
|
|
return this.onMarkJumpGlobal(message.key); |
|
|
|
return this.onMarkJumpGlobal(message.key); |
|
|
|
|
|
|
|
case messages.CONSOLE_FRAME_MESSAGE: |
|
|
|
|
|
|
|
return this.onConsoleFrameMessage(sender.tab.id, message.message); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -116,4 +121,21 @@ export default class ContentMessageListener { |
|
|
|
onMarkJumpGlobal(key) { |
|
|
|
onMarkJumpGlobal(key) { |
|
|
|
return this.markController.jumpGlobal(key); |
|
|
|
return this.markController.jumpGlobal(key); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onConsoleFrameMessage(tabId, message) { |
|
|
|
|
|
|
|
let port = this.consolePorts[tabId]; |
|
|
|
|
|
|
|
if (!port) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
port.postMessage(message); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onConnected(port) { |
|
|
|
|
|
|
|
if (port.name !== 'vimvixen-console') { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let id = port.sender.tab.id; |
|
|
|
|
|
|
|
this.consolePorts[id] = port; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|