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: Addressed comments Created March 13, 2015, 1:07 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
« no previous file with comments | « ext/background.js ('k') | ext/devtools.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 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 this._sendRawMessage({
51 type: "message", 58 type: "message",
52 messageId: ++maxMessageId, 59 messageId: ++maxMessageId,
53 payload: message 60 payload: message
54 }; 61 });
55 if (messageQueue)
56 messageQueue.push(rawMessage);
57 else
58 backgroundFrame.contentWindow.postMessage(rawMessage, "*");
59 62
60 if (responseCallback) 63 if (responseCallback)
61 { 64 {
62 var callbackWrapper = function(event) 65 var callbackWrapper = function(event)
63 { 66 {
64 if (event.data.type == "response" && event.data.messageId == rawMessag e.messageId) 67 if (event.data.type == "response" && event.data.messageId == rawMessag e.messageId)
65 { 68 {
66 window.removeEventListener("message", callbackWrapper, false); 69 window.removeEventListener("message", callbackWrapper, false);
67 responseCallback(event.data.payload); 70 responseCallback(event.data.payload);
68 } 71 }
69 }; 72 };
70 window.addEventListener("message", callbackWrapper, false); 73 window.addEventListener("message", callbackWrapper, false);
71 } 74 }
72 } 75 }
73 }; 76 };
74 })(this); 77 })(this);
OLDNEW
« no previous file with comments | « ext/background.js ('k') | ext/devtools.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld