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

Side by Side Diff: ext/content.js

Issue 29573905: Issue 4580 - Replace ext.devtools with devtools Base URL: https://hg.adblockplus.org/adblockplusui/
Patch Set: Remove devtools.onCreated Created Oct. 11, 2017, 11:34 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH 3 * Copyright (C) 2006-present eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 if (queue) 42 if (queue)
43 { 43 {
44 for (let message of queue) 44 for (let message of queue)
45 backgroundFrame.contentWindow.postMessage(message, "*"); 45 backgroundFrame.contentWindow.postMessage(message, "*");
46 } 46 }
47 window.removeEventListener("message", loadHandler); 47 window.removeEventListener("message", loadHandler);
48 } 48 }
49 }; 49 };
50 window.addEventListener("message", loadHandler); 50 window.addEventListener("message", loadHandler);
51 51
52 ext.backgroundPage = {
Manish Jethani 2017/10/11 23:37:33 ext.backgroundPage is no longer necessary.
53 _sendRawMessage(message)
54 {
55 if (messageQueue)
56 messageQueue.push(message);
57 else
58 backgroundFrame.contentWindow.postMessage(message, "*");
59 }
60 };
61
62 /* Polyfills */ 52 /* Polyfills */
63 53
64 if (!("runtime" in chrome)) 54 if (!("runtime" in chrome))
65 chrome.runtime = {}; 55 chrome.runtime = {};
66 56
67 chrome.runtime.sendMessage = (message, responseCallback) => 57 chrome.runtime.sendMessage = (message, responseCallback) =>
68 { 58 {
69 let messageId = ++maxMessageId; 59 let messageId = ++maxMessageId;
70 60
71 ext.backgroundPage._sendRawMessage({ 61 let rawMessage = {type: "message", messageId, payload: message};
72 type: "message", 62
73 messageId, 63 if (messageQueue)
74 payload: message 64 messageQueue.push(rawMessage);
75 }); 65 else
66 backgroundFrame.contentWindow.postMessage(rawMessage, "*");
76 67
77 if (responseCallback) 68 if (responseCallback)
78 { 69 {
79 let callbackWrapper = event => 70 let callbackWrapper = event =>
80 { 71 {
81 if (event.data.type == "response" && event.data.messageId == messageId) 72 if (event.data.type == "response" && event.data.messageId == messageId)
82 { 73 {
83 window.removeEventListener("message", callbackWrapper); 74 window.removeEventListener("message", callbackWrapper);
84 responseCallback(event.data.payload); 75 responseCallback(event.data.payload);
85 } 76 }
86 }; 77 };
87 78
88 window.addEventListener("message", callbackWrapper); 79 window.addEventListener("message", callbackWrapper);
89 } 80 }
90 }; 81 };
91 }()); 82 }());
OLDNEW

Powered by Google App Engine
This is Rietveld