diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2020-07-08 19:58:06 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-08 19:58:06 -0400 |
commit | 6f49f426b518bdbca11c7994246eb088903e6619 (patch) | |
tree | 2ed7618c5eb34de3a90a826c0fac2da2fb72cbd7 /ext/bg | |
parent | 295ffa6e54d04cedef35a4798cabdae71f824ee1 (diff) |
Generalized frame connections (#654)
* Create FrameClient and FrameEndpoint
* Use new Frame* classes for Popup=>frame connection
* Update api.sendMessageToFrame and api.broadcastTab to include the sender's frameId
* Update FrameClient to store the frame's frameId
Diffstat (limited to 'ext/bg')
-rw-r--r-- | ext/bg/js/backend.js | 8 | ||||
-rw-r--r-- | ext/bg/js/search.js | 1 | ||||
-rw-r--r-- | ext/bg/settings-popup-preview.html | 1 |
3 files changed, 7 insertions, 3 deletions
diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js index 4791bfb5..6e594f9b 100644 --- a/ext/bg/js/backend.js +++ b/ext/bg/js/backend.js @@ -538,14 +538,15 @@ class Backend { }); } - _onApiSendMessageToFrame({frameId, action, params}, sender) { + _onApiSendMessageToFrame({frameId: targetFrameId, action, params}, sender) { if (!(sender && sender.tab)) { return false; } const tabId = sender.tab.id; + const frameId = sender.frameId; const callback = () => this._checkLastError(chrome.runtime.lastError); - chrome.tabs.sendMessage(tabId, {action, params}, {frameId}, callback); + chrome.tabs.sendMessage(tabId, {action, params, frameId}, {frameId: targetFrameId}, callback); return true; } @@ -555,8 +556,9 @@ class Backend { } const tabId = sender.tab.id; + const frameId = sender.frameId; const callback = () => this._checkLastError(chrome.runtime.lastError); - chrome.tabs.sendMessage(tabId, {action, params}, callback); + chrome.tabs.sendMessage(tabId, {action, params, frameId}, callback); return true; } diff --git a/ext/bg/js/search.js b/ext/bg/js/search.js index 239027f7..9bbc66f2 100644 --- a/ext/bg/js/search.js +++ b/ext/bg/js/search.js @@ -424,6 +424,7 @@ class DisplaySearch extends Display { async _setupNestedPopups() { await dynamicLoader.loadScripts([ '/mixed/js/text-scanner.js', + '/mixed/js/frame-client.js', '/fg/js/frame-offset-forwarder.js', '/fg/js/popup.js', '/fg/js/popup-factory.js', diff --git a/ext/bg/settings-popup-preview.html b/ext/bg/settings-popup-preview.html index c0c8e3b9..5b3a9692 100644 --- a/ext/bg/settings-popup-preview.html +++ b/ext/bg/settings-popup-preview.html @@ -124,6 +124,7 @@ <script src="/mixed/js/dom.js"></script> <script src="/mixed/js/api.js"></script> <script src="/mixed/js/dynamic-loader.js"></script> + <script src="/mixed/js/frame-client.js"></script> <script src="/mixed/js/text-scanner.js"></script> <script src="/fg/js/document.js"></script> |