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

Side by Side Diff: lib/contentPolicy.js

Issue 29329742: Issue 3251 - Simplify messaging from child scripts to parent (Closed)
Patch Set: Rebased, no return value stringification Created Nov. 9, 2015, 11:01 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
« no previous file with comments | « lib/child/elemHide.js ('k') | lib/elemHide.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 <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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 71
72 /** 72 /**
73 * Called on module startup, initializes various exported properties. 73 * Called on module startup, initializes various exported properties.
74 */ 74 */
75 init: function() 75 init: function()
76 { 76 {
77 // whitelisted URL schemes 77 // whitelisted URL schemes
78 for (let scheme of Prefs.whitelistschemes.toLowerCase().split(" ")) 78 for (let scheme of Prefs.whitelistschemes.toLowerCase().split(" "))
79 this.whitelistSchemes.add(scheme); 79 this.whitelistSchemes.add(scheme);
80 80
81 let messageManager = Cc["@mozilla.org/parentprocessmessagemanager;1"] 81 Utils.addChildMessageListener("AdblockPlus:ShouldAllow", this.shouldAllow.bi nd(this));
82 .getService(Ci.nsIMessageListenerManager) 82 Utils.addChildMessageListener("AdblockPlus:GetCollapsedClass", () => collaps edClass);
83 .QueryInterface(Ci.nsIMessageBroadcaster);
84 let handler = (message => this.shouldAllow(message.data));
85 messageManager.addMessageListener("AdblockPlus:ShouldAllow", handler);
86 onShutdown.add(() => messageManager.removeMessageListener("AdblockPlus:Shoul dAllow", handler));
87
88 let handler2 = () => collapsedClass;
89 messageManager.addMessageListener("AdblockPlus:GetCollapsedClass", handler2) ;
90 onShutdown.add(() => messageManager.removeMessageListener("AdblockPlus:GetCo llapsedClass", handler2));
91 83
92 // Generate class identifier used to collapse node and register correspondin g 84 // Generate class identifier used to collapse node and register correspondin g
93 // stylesheet. 85 // stylesheet.
94 let offset = "a".charCodeAt(0); 86 let offset = "a".charCodeAt(0);
95 for (let i = 0; i < 20; i++) 87 for (let i = 0; i < 20; i++)
96 collapsedClass += String.fromCharCode(offset + Math.random() * 26); 88 collapsedClass += String.fromCharCode(offset + Math.random() * 26);
97 89
98 let collapseStyle = Services.io.newURI("data:text/css," + 90 let collapseStyle = Services.io.newURI("data:text/css," +
99 encodeURIComponent("." + collapsedClass + 91 encodeURIComponent("." + collapsedClass +
100 "{-moz-binding: url(chrome://global/content/bindings/general.xml#foobarb azdummy) !important;}"), null, null); 92 "{-moz-binding: url(chrome://global/content/bindings/general.xml#foobarb azdummy) !important;}"), null, null);
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 if (!wnd || wnd.closed) 403 if (!wnd || wnd.closed)
412 return; 404 return;
413 405
414 if (entry.type == "OBJECT") 406 if (entry.type == "OBJECT")
415 { 407 {
416 node.removeEventListener("mouseover", objectMouseEventHander, true); 408 node.removeEventListener("mouseover", objectMouseEventHander, true);
417 node.removeEventListener("mouseout", objectMouseEventHander, true); 409 node.removeEventListener("mouseout", objectMouseEventHander, true);
418 } 410 }
419 Policy.processNode(wnd, node, entry.type, entry.location, true); 411 Policy.processNode(wnd, node, entry.type, entry.location, true);
420 } 412 }
OLDNEW
« no previous file with comments | « lib/child/elemHide.js ('k') | lib/elemHide.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld