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

Delta Between Two Patch Sets: lib/contentPolicy.js

Issue 29329742: Issue 3251 - Simplify messaging from child scripts to parent (Closed)
Left Patch Set: Rebased Created Nov. 11, 2015, 5:45 p.m.
Right Patch Set: Rebased Created Nov. 12, 2015, 12:29 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « lib/child/elemHide.js ('k') | lib/elemHide.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 15 matching lines...) Expand all
26 26
27 let {Utils} = require("utils"); 27 let {Utils} = require("utils");
28 let {Prefs} = require("prefs"); 28 let {Prefs} = require("prefs");
29 let {FilterStorage} = require("filterStorage"); 29 let {FilterStorage} = require("filterStorage");
30 let {BlockingFilter, WhitelistFilter, RegExpFilter} = require("filterClasses"); 30 let {BlockingFilter, WhitelistFilter, RegExpFilter} = require("filterClasses");
31 let {defaultMatcher} = require("matcher"); 31 let {defaultMatcher} = require("matcher");
32 let {objectMouseEventHander} = require("objectTabs"); 32 let {objectMouseEventHander} = require("objectTabs");
33 let {ElemHide} = require("elemHide"); 33 let {ElemHide} = require("elemHide");
34 34
35 /** 35 /**
36 * Randomly generated class name, to be applied to collapsed nodes.
37 * @type string
38 */
39 let collapsedClass = "";
40
41 /**
42 * Public policy checking functions and auxiliary objects 36 * Public policy checking functions and auxiliary objects
43 * @class 37 * @class
44 */ 38 */
45 var Policy = exports.Policy = 39 var Policy = exports.Policy =
46 { 40 {
47 /** 41 /**
48 * Set of explicitly supported content types 42 * Set of explicitly supported content types
49 * @type Set.<string> 43 * @type Set.<string>
50 */ 44 */
51 contentTypes: new Set([ 45 contentTypes: new Set([
(...skipping 20 matching lines...) Expand all
72 /** 66 /**
73 * Called on module startup, initializes various exported properties. 67 * Called on module startup, initializes various exported properties.
74 */ 68 */
75 init: function() 69 init: function()
76 { 70 {
77 // whitelisted URL schemes 71 // whitelisted URL schemes
78 for (let scheme of Prefs.whitelistschemes.toLowerCase().split(" ")) 72 for (let scheme of Prefs.whitelistschemes.toLowerCase().split(" "))
79 this.whitelistSchemes.add(scheme); 73 this.whitelistSchemes.add(scheme);
80 74
81 Utils.addChildMessageListener("AdblockPlus:ShouldAllow", this.shouldAllow.bi nd(this)); 75 Utils.addChildMessageListener("AdblockPlus:ShouldAllow", this.shouldAllow.bi nd(this));
82 Utils.addChildMessageListener("AdblockPlus:GetCollapsedClass", () => collaps edClass); 76
83 77 // Generate class identifier used to collapse nodes and register
84 // Generate class identifier used to collapse node and register correspondin g 78 // corresponding stylesheet.
85 // stylesheet. 79 let collapsedClass = "";
86 let offset = "a".charCodeAt(0); 80 let offset = "a".charCodeAt(0);
87 for (let i = 0; i < 20; i++) 81 for (let i = 0; i < 20; i++)
88 collapsedClass += String.fromCharCode(offset + Math.random() * 26); 82 collapsedClass += String.fromCharCode(offset + Math.random() * 26);
83 Utils.addChildMessageListener("AdblockPlus:GetCollapsedClass", () => collaps edClass);
89 84
90 let collapseStyle = Services.io.newURI("data:text/css," + 85 let collapseStyle = Services.io.newURI("data:text/css," +
91 encodeURIComponent("." + collapsedClass + 86 encodeURIComponent("." + collapsedClass +
92 "{-moz-binding: url(chrome://global/content/bindings/general.xml#foobarb azdummy) !important;}"), null, null); 87 "{-moz-binding: url(chrome://global/content/bindings/general.xml#foobarb azdummy) !important;}"), null, null);
93 Utils.styleService.loadAndRegisterSheet(collapseStyle, Ci.nsIStyleSheetServi ce.USER_SHEET); 88 Utils.styleService.loadAndRegisterSheet(collapseStyle, Ci.nsIStyleSheetServi ce.USER_SHEET);
94 onShutdown.add(() => 89 onShutdown.add(() =>
95 { 90 {
96 Utils.styleService.unregisterSheet(collapseStyle, Ci.nsIStyleSheetService. USER_SHEET); 91 Utils.styleService.unregisterSheet(collapseStyle, Ci.nsIStyleSheetService. USER_SHEET);
97 }); 92 });
98 }, 93 },
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 if (!wnd || wnd.closed) 399 if (!wnd || wnd.closed)
405 return; 400 return;
406 401
407 if (entry.type == "OBJECT") 402 if (entry.type == "OBJECT")
408 { 403 {
409 node.removeEventListener("mouseover", objectMouseEventHander, true); 404 node.removeEventListener("mouseover", objectMouseEventHander, true);
410 node.removeEventListener("mouseout", objectMouseEventHander, true); 405 node.removeEventListener("mouseout", objectMouseEventHander, true);
411 } 406 }
412 Policy.processNode(wnd, node, entry.type, entry.location, true); 407 Policy.processNode(wnd, node, entry.type, entry.location, true);
413 } 408 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld