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

Side by Side Diff: ext/content.js

Issue 5646124035604480: Issue 154 - Added UI for devtools panel on Chrome (Closed)
Patch Set: Rebased and adapted for API changes Created March 12, 2015, 4:08 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-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 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 26 matching lines...) Expand all
37 var queue = messageQueue; 37 var queue = messageQueue;
38 messageQueue = null; 38 messageQueue = null;
39 if (queue) 39 if (queue)
40 for (var i = 0; i < queue.length; i++) 40 for (var i = 0; i < queue.length; i++)
41 backgroundFrame.contentWindow.postMessage(queue[i], "*"); 41 backgroundFrame.contentWindow.postMessage(queue[i], "*");
42 window.removeEventListener("message", loadHandler, false); 42 window.removeEventListener("message", loadHandler, false);
43 } 43 }
44 } 44 }
45 window.addEventListener("message", loadHandler, false); 45 window.addEventListener("message", loadHandler, false);
46 46
47
Thomas Greiner 2015/03/13 11:11:05 That extra line is not really adding any value.
Sebastian Noack 2015/03/13 13:07:38 Done.
47 global.ext.backgroundPage = { 48 global.ext.backgroundPage = {
49 _sendRawMessage: function(message)
50 {
51 if (messageQueue)
52 messageQueue.push(message);
53 else
54 backgroundFrame.contentWindow.postMessage(message, "*");
55 },
48 sendMessage: function(message, responseCallback) 56 sendMessage: function(message, responseCallback)
49 { 57 {
50 var rawMessage = { 58 this._sendRawMessage({
51 type: "message", 59 type: "message",
52 messageId: ++maxMessageId, 60 messageId: ++maxMessageId,
53 payload: message 61 payload: message
54 }; 62 });
55 if (messageQueue)
56 messageQueue.push(rawMessage);
57 else
58 backgroundFrame.contentWindow.postMessage(rawMessage, "*");
59 63
60 if (responseCallback) 64 if (responseCallback)
61 { 65 {
62 var callbackWrapper = function(event) 66 var callbackWrapper = function(event)
63 { 67 {
64 if (event.data.type == "response" && event.data.messageId == rawMessag e.messageId) 68 if (event.data.type == "response" && event.data.messageId == rawMessag e.messageId)
65 { 69 {
66 window.removeEventListener("message", callbackWrapper, false); 70 window.removeEventListener("message", callbackWrapper, false);
67 responseCallback(event.data.payload); 71 responseCallback(event.data.payload);
68 } 72 }
69 }; 73 };
70 window.addEventListener("message", callbackWrapper, false); 74 window.addEventListener("message", callbackWrapper, false);
71 } 75 }
72 } 76 }
73 }; 77 };
74 })(this); 78 })(this);
OLDNEW
« devtools-panel.js ('K') | « ext/background.js ('k') | ext/devtools.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld