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

Side by Side Diff: lib/contentPolicy.js

Issue 29329565: Issue 3208 - Initialize types map in PolicyImplementation, not Policy (Closed)
Patch Set: Created Oct. 30, 2015, 10:52 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 | no next file » | 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 * Map containing all schemes that should be ignored by content policy. 74 * Map containing all schemes that should be ignored by content policy.
75 * @type Set 75 * @type Set
76 */ 76 */
77 whitelistSchemes: new Set(), 77 whitelistSchemes: new Set(),
78 78
79 /** 79 /**
80 * Called on module startup, initializes various exported properties. 80 * Called on module startup, initializes various exported properties.
81 */ 81 */
82 init: function() 82 init: function()
83 { 83 {
84 // Populate types map
85 let iface = Ci.nsIContentPolicy;
86 for (let name in iface)
87 if (name.indexOf("TYPE_") == 0 && name != "TYPE_DATAREQUEST")
88 types.set(iface[name], name.substr(5));
89
90 // whitelisted URL schemes 84 // whitelisted URL schemes
91 for (let scheme of Prefs.whitelistschemes.toLowerCase().split(" ")) 85 for (let scheme of Prefs.whitelistschemes.toLowerCase().split(" "))
92 this.whitelistSchemes.add(scheme); 86 this.whitelistSchemes.add(scheme);
93 87
94 // Generate class identifier used to collapse node and register correspondin g 88 // Generate class identifier used to collapse node and register correspondin g
95 // stylesheet. 89 // stylesheet.
96 let offset = "a".charCodeAt(0); 90 let offset = "a".charCodeAt(0);
97 for (let i = 0; i < 20; i++) 91 for (let i = 0; i < 20; i++)
98 collapsedClass += String.fromCharCode(offset + Math.random() * 26); 92 collapsedClass += String.fromCharCode(offset + Math.random() * 26);
99 93
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 classDescription: "Adblock Plus content policy", 333 classDescription: "Adblock Plus content policy",
340 classID: Components.ID("cfeaabe6-1dd1-11b2-a0c6-cb5c268894c9"), 334 classID: Components.ID("cfeaabe6-1dd1-11b2-a0c6-cb5c268894c9"),
341 contractID: "@adblockplus.org/abp/policy;1", 335 contractID: "@adblockplus.org/abp/policy;1",
342 xpcom_categories: ["content-policy", "net-channel-event-sinks"], 336 xpcom_categories: ["content-policy", "net-channel-event-sinks"],
343 337
344 /** 338 /**
345 * Registers the content policy on startup. 339 * Registers the content policy on startup.
346 */ 340 */
347 init: function() 341 init: function()
348 { 342 {
343 // Populate types map
344 let iface = Ci.nsIContentPolicy;
345 for (let name in iface)
346 if (name.indexOf("TYPE_") == 0 && name != "TYPE_DATAREQUEST")
347 types.set(iface[name], name.substr(5));
348
349 let registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar); 349 let registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
350 registrar.registerFactory(this.classID, this.classDescription, this.contract ID, this); 350 registrar.registerFactory(this.classID, this.classDescription, this.contract ID, this);
351 351
352 let catMan = Utils.categoryManager; 352 let catMan = Utils.categoryManager;
353 for (let category of this.xpcom_categories) 353 for (let category of this.xpcom_categories)
354 catMan.addCategoryEntry(category, this.contractID, this.contractID, false, true); 354 catMan.addCategoryEntry(category, this.contractID, this.contractID, false, true);
355 355
356 Services.obs.addObserver(this, "content-document-global-created", true); 356 Services.obs.addObserver(this, "content-document-global-created", true);
357 357
358 onShutdown.add(() => 358 onShutdown.add(() =>
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 if (!wnd || wnd.closed) 685 if (!wnd || wnd.closed)
686 return; 686 return;
687 687
688 if (entry.type == "OBJECT") 688 if (entry.type == "OBJECT")
689 { 689 {
690 node.removeEventListener("mouseover", objectMouseEventHander, true); 690 node.removeEventListener("mouseover", objectMouseEventHander, true);
691 node.removeEventListener("mouseout", objectMouseEventHander, true); 691 node.removeEventListener("mouseout", objectMouseEventHander, true);
692 } 692 }
693 Policy.processNode(wnd, node, entry.type, entry.location, true); 693 Policy.processNode(wnd, node, entry.type, entry.location, true);
694 } 694 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld