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

Side by Side Diff: chrome/content/watcher.js

Issue 8410038: Removed backwards compatibility code (Closed)
Patch Set: Forgot the metadata change Created Sept. 22, 2012, 2:37 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 | « no previous file | metadata » ('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 Source Code is subject to the terms of the Mozilla Public License 2 * This Source Code is subject to the terms of the Mozilla Public License
3 * version 2.0 (the "License"). You can obtain a copy of the License at 3 * version 2.0 (the "License"). You can obtain a copy of the License at
4 * http://mozilla.org/MPL/2.0/. 4 * http://mozilla.org/MPL/2.0/.
5 */ 5 */
6 6
7 const Cc = Components.classes; 7 const Cc = Components.classes;
8 const Ci = Components.interfaces; 8 const Ci = Components.interfaces;
9 const Cr = Components.results; 9 const Cr = Components.results;
10 const Cu = Components.utils; 10 const Cu = Components.utils;
11 11
12 Cu.import("resource://gre/modules/Services.jsm"); 12 Cu.import("resource://gre/modules/Services.jsm");
13 13
14 function abprequire(module) 14 function abprequire(module)
15 { 15 {
16 let result = {}; 16 let result = {};
17 result.wrappedJSObject = result; 17 result.wrappedJSObject = result;
18 Services.obs.notifyObservers(result, "adblockplus-require", module); 18 Services.obs.notifyObservers(result, "adblockplus-require", module);
19 if ("exports" in result) 19 return result.exports;
20 return result.exports;
21 else
22 return Cu.import("chrome://adblockplus-modules/content/" + module[0].toUpper Case() + module.substr(1) + ".jsm", null);
23 } 20 }
24 21
25 let {Policy} = abprequire("contentPolicy"); 22 let {Policy} = abprequire("contentPolicy");
26 let {RequestNotifier} = abprequire("requestNotifier"); 23 let {RequestNotifier} = abprequire("requestNotifier");
27 let {Filter} = abprequire("filterClasses"); 24 let {Filter} = abprequire("filterClasses");
28 25
29 let policyGlobal = Cu.getGlobalForObject(Policy); 26 let policyGlobal = Cu.getGlobalForObject(Policy);
30 let PolicyPrivate = null; 27 let PolicyPrivate = null;
31 if (policyGlobal == window)
32 {
33 // Work-around for bug 736316 - getGlobalForObject gave us our own window
34 let {XPIProvider} = Cu.import("resource://gre/modules/XPIProvider.jsm", null);
35 let addonID = "{d10d0bf8-f5b5-c8b4-a8b2-2b9879e08c5d}"
36 if (addonID in XPIProvider.bootstrapScopes)
37 policyGlobal = XPIProvider.bootstrapScopes[addonID];
38 }
39 28
40 if ("PolicyPrivate" in policyGlobal) // ABP 2.0.x 29 if ("PolicyImplementation" in policyGlobal) // ABP 2.1+ with scope separation
41 PolicyPrivate = policyGlobal.PolicyPrivate;
42 else if ("PolicyImplementation" in policyGlobal) // ABP 2.1+ with scope separat ion
43 PolicyPrivate = policyGlobal.PolicyImplementation; 30 PolicyPrivate = policyGlobal.PolicyImplementation;
44 else if ("require" in policyGlobal) // ABP 2.1+ without scope sepa ration 31 else if ("require" in policyGlobal) // ABP 2.1+ without scope sepa ration
45 PolicyPrivate = policyGlobal.require.scopes.contentPolicy.PolicyImplementation ; 32 PolicyPrivate = policyGlobal.require.scopes.contentPolicy.PolicyImplementation ;
46 else 33 else
47 window.close(); 34 window.close();
Thomas Greiner 2012/09/26 13:55:04 Could also be written as: let PolicyPrivate = pol
Wladimir Palant 2012/09/27 14:39:29 But the way it is understanding the code is much e
48 35
49 let origShouldLoad = PolicyPrivate.shouldLoad; 36 let origShouldLoad = PolicyPrivate.shouldLoad;
50 let origProcessNode = Policy.processNode; 37 let origProcessNode = Policy.processNode;
51 38
52 let currentData = null; 39 let currentData = null;
53 let processingQueue = []; 40 let processingQueue = [];
54 let notifier = null; 41 let notifier = null;
55 42
56 // Randomize URI to work around bug 719376 43 // Randomize URI to work around bug 719376
57 let stringBundle = Services.strings.createBundle("chrome://abpwatcher/locale/glo bal.properties?" + Math.random()); 44 let stringBundle = Services.strings.createBundle("chrome://abpwatcher/locale/glo bal.properties?" + Math.random());
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 for (let i = 0; i < this.observers.length; i++) 653 for (let i = 0; i < this.observers.length; i++)
667 if (this.observers[i] == observer) 654 if (this.observers[i] == observer)
668 this.observers.splice(i--, 1); 655 this.observers.splice(i--, 1);
669 }, 656 },
670 notifyObservers: function(operation, entry) 657 notifyObservers: function(operation, entry)
671 { 658 {
672 for each (let observer in this.observers) 659 for each (let observer in this.observers)
673 observer(this, operation, entry); 660 observer(this, operation, entry);
674 } 661 }
675 }; 662 };
OLDNEW
« no previous file with comments | « no previous file | metadata » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld