Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: ext/content.js

Issue 29573905: Issue 4580 - Replace ext.devtools with devtools Base URL: https://hg.adblockplus.org/adblockplusui/
Patch Set: Use Location.pathname Created Oct. 18, 2017, 12:23 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« ext/common.js ('K') | « ext/common.js ('k') | ext/devtools.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ext/content.js
===================================================================
--- a/ext/content.js
+++ b/ext/content.js
@@ -44,40 +44,40 @@
for (let message of queue)
backgroundFrame.contentWindow.postMessage(message, "*");
}
window.removeEventListener("message", loadHandler);
}
};
window.addEventListener("message", loadHandler);
- ext.backgroundPage = {
- _sendRawMessage(message)
- {
- if (messageQueue)
- messageQueue.push(message);
- else
- backgroundFrame.contentWindow.postMessage(message, "*");
- }
- };
-
/* Polyfills */
if (!("runtime" in chrome))
chrome.runtime = {};
+ function sendRawMessage(message)
+ {
+ if (messageQueue)
+ messageQueue.push(message);
+ else
+ backgroundFrame.contentWindow.postMessage(message, "*");
+ }
+
+ chrome.runtime.connect = () =>
+ {
+ sendRawMessage({type: "connect"});
+ return {onMessage: ext.onMessage};
+ };
+
chrome.runtime.sendMessage = (message, responseCallback) =>
{
let messageId = ++maxMessageId;
- ext.backgroundPage._sendRawMessage({
- type: "message",
- messageId,
- payload: message
- });
+ sendRawMessage({type: "message", messageId, payload: message});
if (responseCallback)
{
let callbackWrapper = event =>
{
if (event.data.type == "response" && event.data.messageId == messageId)
{
window.removeEventListener("message", callbackWrapper);
« ext/common.js ('K') | « ext/common.js ('k') | ext/devtools.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld