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

Side by Side Diff: ext/content.js

Issue 29573083: Issue 5028 - Use browser namespace (Closed) Base URL: https://hg.adblockplus.org/adblockplusui/
Patch Set: Add polyfill.js to README.md Created Oct. 17, 2017, 12:35 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/common.js ('k') | firstRun.html » ('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-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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 { 54 {
55 if (messageQueue) 55 if (messageQueue)
56 messageQueue.push(message); 56 messageQueue.push(message);
57 else 57 else
58 backgroundFrame.contentWindow.postMessage(message, "*"); 58 backgroundFrame.contentWindow.postMessage(message, "*");
59 } 59 }
60 }; 60 };
61 61
62 /* Polyfills */ 62 /* Polyfills */
63 63
64 if (!("runtime" in chrome)) 64 if (!("runtime" in browser))
65 chrome.runtime = {}; 65 browser.runtime = {};
66 66
67 chrome.runtime.sendMessage = (message, responseCallback) => 67 browser.runtime.sendMessage = (message, responseCallback) =>
68 { 68 {
69 let messageId = ++maxMessageId; 69 let messageId = ++maxMessageId;
70 70
71 ext.backgroundPage._sendRawMessage({ 71 ext.backgroundPage._sendRawMessage({
72 type: "message", 72 type: "message",
73 messageId, 73 messageId,
74 payload: message 74 payload: message
75 }); 75 });
76 76
77 if (responseCallback) 77 if (responseCallback)
78 { 78 {
79 let callbackWrapper = event => 79 let callbackWrapper = event =>
80 { 80 {
81 if (event.data.type == "response" && event.data.messageId == messageId) 81 if (event.data.type == "response" && event.data.messageId == messageId)
82 { 82 {
83 window.removeEventListener("message", callbackWrapper); 83 window.removeEventListener("message", callbackWrapper);
84 responseCallback(event.data.payload); 84 responseCallback(event.data.payload);
85 } 85 }
86 }; 86 };
87 87
88 window.addEventListener("message", callbackWrapper); 88 window.addEventListener("message", callbackWrapper);
89 } 89 }
90 }; 90 };
91 }()); 91 }());
OLDNEW
« no previous file with comments | « ext/common.js ('k') | firstRun.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld