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

Side by Side Diff: ext/common.js

Issue 29573905: Issue 4580 - Replace ext.devtools with devtools Base URL: https://hg.adblockplus.org/adblockplusui/
Patch Set: Use Location.pathname Created Oct. 18, 2017, 12:23 a.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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 return; 154 return;
155 155
156 let rawCatalog = JSON.parse(xhr.responseText); 156 let rawCatalog = JSON.parse(xhr.responseText);
157 for (let msgId in rawCatalog) 157 for (let msgId in rawCatalog)
158 { 158 {
159 if (!(msgId in catalog)) 159 if (!(msgId in catalog))
160 catalog[msgId] = parseMessage(rawCatalog[msgId]); 160 catalog[msgId] = parseMessage(rawCatalog[msgId]);
161 } 161 }
162 }; 162 };
163 163
164 /* Polyfills */
Manish Jethani 2017/10/18 00:26:53 So now a lot of this code will move into polyfill.
165
166 if (!("runtime" in chrome))
167 chrome.runtime = {};
168
169 chrome.runtime.onConnect = {
170 addListener(callback)
171 {
172 window.addEventListener("message", event =>
173 {
174 if (event.data.type == "connect")
175 {
176 callback({
177 postMessage(message)
178 {
179 event.source.postMessage({
180 type: "message",
181 messageId: -1,
182 payload: message
183 }, "*");
184 }
185 });
186 }
187 });
188 }
189 };
190
191 if (top.location.pathname == "/devtools-panel.html")
192 {
193 chrome.devtools = {
194 panels: {
195 openResource() {}
196 },
197
198 inspectedWindow: {
199 reload() {}
200 }
201 };
202 }
203
164 chrome.i18n = { 204 chrome.i18n = {
165 getUILanguage() 205 getUILanguage()
166 { 206 {
167 return locales[0].replace(/_/g, "-"); 207 return locales[0].replace(/_/g, "-");
168 }, 208 },
169 getMessage(msgId, substitutions) 209 getMessage(msgId, substitutions)
170 { 210 {
171 while (true) 211 while (true)
172 { 212 {
173 let message = catalog[msgId]; 213 let message = catalog[msgId];
(...skipping 14 matching lines...) Expand all
188 if (locales.length == 0) 228 if (locales.length == 0)
189 return ""; 229 return "";
190 230
191 let locale = locales.shift(); 231 let locale = locales.shift();
192 readCatalog(locale, "common.json"); 232 readCatalog(locale, "common.json");
193 readCatalog(locale, catalogFile); 233 readCatalog(locale, catalogFile);
194 } 234 }
195 } 235 }
196 }; 236 };
197 }()); 237 }());
OLDNEW

Powered by Google App Engine
This is Rietveld