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

Delta Between Two Patch Sets: ext/content.js

Issue 5646124035604480: Issue 154 - Added UI for devtools panel on Chrome (Closed)
Left Patch Set: Addressed comments Created Feb. 4, 2015, 3:35 p.m.
Right Patch Set: Added new request types Created Jan. 28, 2016, 7:37 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « ext/background.js ('k') | ext/devtools.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
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-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 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 27 matching lines...) Expand all
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 global.ext.backgroundPage = { 47 global.ext.backgroundPage = {
48 _sendRawMessage: function(message)
49 {
50 if (messageQueue)
51 messageQueue.push(message);
52 else
53 backgroundFrame.contentWindow.postMessage(message, "*");
54 },
48 sendMessage: function(message, responseCallback) 55 sendMessage: function(message, responseCallback)
49 { 56 {
50 var rawMessage = { 57 var messageId = ++maxMessageId;
58
59 this._sendRawMessage({
51 type: "message", 60 type: "message",
52 messageId: ++maxMessageId, 61 messageId: messageId,
53 payload: message 62 payload: message
54 }; 63 });
55 if (messageQueue)
56 messageQueue.push(rawMessage);
57 else
58 backgroundFrame.contentWindow.postMessage(rawMessage, "*");
59 64
60 if (responseCallback) 65 if (responseCallback)
61 { 66 {
62 var callbackWrapper = function(event) 67 var callbackWrapper = function(event)
63 { 68 {
64 if (event.data.type == "response" && event.data.messageId == rawMessag e.messageId) 69 if (event.data.type == "response" && event.data.messageId == messageId )
65 { 70 {
66 window.removeEventListener("message", callbackWrapper, false); 71 window.removeEventListener("message", callbackWrapper, false);
67 responseCallback(event.data.payload); 72 responseCallback(event.data.payload);
68 } 73 }
69 }; 74 };
70 window.addEventListener("message", callbackWrapper, false); 75 window.addEventListener("message", callbackWrapper, false);
71 } 76 }
72 } 77 }
73 }; 78 };
74 })(this); 79 })(this);
LEFTRIGHT

Powered by Google App Engine
This is Rietveld