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

Side by Side Diff: lib/synchronizer.js

Issue 11239001: Use XMLHttpRequest constructor in JS modules (Closed)
Patch Set: Created July 25, 2013, 12:36 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 | « lib/objectTabs.js ('k') | lib/ui.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 <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2013 Eyeo GmbH 3 * Copyright (C) 2006-2013 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 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 284
285 let fallbackURL = Prefs.subscriptions_fallbackurl; 285 let fallbackURL = Prefs.subscriptions_fallbackurl;
286 let {addonVersion} = require("info"); 286 let {addonVersion} = require("info");
287 fallbackURL = fallbackURL.replace(/%VERSION%/g, encodeURIComponent(addon Version)); 287 fallbackURL = fallbackURL.replace(/%VERSION%/g, encodeURIComponent(addon Version));
288 fallbackURL = fallbackURL.replace(/%SUBSCRIPTION%/g, encodeURIComponent( subscription.url)); 288 fallbackURL = fallbackURL.replace(/%SUBSCRIPTION%/g, encodeURIComponent( subscription.url));
289 fallbackURL = fallbackURL.replace(/%URL%/g, encodeURIComponent(downloadU RL)); 289 fallbackURL = fallbackURL.replace(/%URL%/g, encodeURIComponent(downloadU RL));
290 fallbackURL = fallbackURL.replace(/%ERROR%/g, encodeURIComponent(error)) ; 290 fallbackURL = fallbackURL.replace(/%ERROR%/g, encodeURIComponent(error)) ;
291 fallbackURL = fallbackURL.replace(/%CHANNELSTATUS%/g, encodeURIComponent (channelStatus)); 291 fallbackURL = fallbackURL.replace(/%CHANNELSTATUS%/g, encodeURIComponent (channelStatus));
292 fallbackURL = fallbackURL.replace(/%RESPONSESTATUS%/g, encodeURIComponen t(responseStatus)); 292 fallbackURL = fallbackURL.replace(/%RESPONSESTATUS%/g, encodeURIComponen t(responseStatus));
293 293
294 let request = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstan ce(Ci.nsIXMLHttpRequest); 294 let request = new XMLHttpRequest();
295 request.mozBackgroundRequest = true; 295 request.mozBackgroundRequest = true;
296 request.open("GET", fallbackURL); 296 request.open("GET", fallbackURL);
297 request.overrideMimeType("text/plain"); 297 request.overrideMimeType("text/plain");
298 request.channel.loadFlags = request.channel.loadFlags | 298 request.channel.loadFlags = request.channel.loadFlags |
299 request.channel.INHIBIT_CACHING | 299 request.channel.INHIBIT_CACHING |
300 request.channel.VALIDATE_ALWAYS; 300 request.channel.VALIDATE_ALWAYS;
301 request.addEventListener("load", function(ev) 301 request.addEventListener("load", function(ev)
302 { 302 {
303 if (onShutdown.done) 303 if (onShutdown.done)
304 return; 304 return;
305 305
306 if (!(subscription.url in FilterStorage.knownSubscriptions)) 306 if (!(subscription.url in FilterStorage.knownSubscriptions))
307 return; 307 return;
308 308
309 let match = /^(\d+)(?:\s+(\S+))?$/.exec(request.responseText); 309 let match = /^(\d+)(?:\s+(\S+))?$/.exec(request.responseText);
310 if (match && match[1] == "301" && match[2] && /^https?:\/\//i.test(mat ch[2])) // Moved permanently 310 if (match && match[1] == "301" && match[2] && /^https?:\/\//i.test(mat ch[2])) // Moved permanently
311 redirectCallback(match[2]); 311 redirectCallback(match[2]);
312 else if (match && match[1] == "410") // Gone 312 else if (match && match[1] == "410") // Gone
313 { 313 {
314 let data = "[Adblock]\n" + subscription.filters.map(function(f) f.te xt).join("\n"); 314 let data = "[Adblock]\n" + subscription.filters.map(function(f) f.te xt).join("\n");
315 redirectCallback("data:text/plain," + encodeURIComponent(data)); 315 redirectCallback("data:text/plain," + encodeURIComponent(data));
316 } 316 }
317 }, false); 317 }, false);
318 request.send(null); 318 request.send(null);
319 } 319 }
320 } 320 }
321 }, 321 },
322 }; 322 };
323 Synchronizer.init(); 323 Synchronizer.init();
OLDNEW
« no previous file with comments | « lib/objectTabs.js ('k') | lib/ui.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld