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

Side by Side Diff: lib/elemHide.js

Issue 29329742: Issue 3251 - Simplify messaging from child scripts to parent (Closed)
Patch Set: Adjusted a caller that was forgotten Created Nov. 9, 2015, 1: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/contentPolicy.js ('k') | lib/requestNotifier.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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 * Inidicates whether the element hiding stylesheet is currently applied. 73 * Inidicates whether the element hiding stylesheet is currently applied.
74 * @type Boolean 74 * @type Boolean
75 */ 75 */
76 applied: false, 76 applied: false,
77 77
78 /** 78 /**
79 * Called on module startup. 79 * Called on module startup.
80 */ 80 */
81 init: function() 81 init: function()
82 { 82 {
83 let messageManager = Cc["@mozilla.org/parentprocessmessagemanager;1"] 83 Utils.addChildMessageListener("AdblockPlus:ElemHideHit", (data) => {
84 .getService(Ci.nsIMessageListenerManager); 84 return ElemHide.shouldHide(data);
85 let hitHandler = (message => {
86 let result = ElemHide.shouldHide(message.data);
87 let target = message.target.QueryInterface(Ci.nsIMessageSender);
88 target.sendAsyncMessage(message.data.responseMessage, result);
89 }); 85 });
90 messageManager.addMessageListener("AdblockPlus:ElemHideHit", hitHandler);
91 onShutdown.add(() => messageManager.removeMessageListener("AdblockPlus:ElemH ideHit", hitHandler));
92 86
93 Prefs.addListener(function(name) 87 Prefs.addListener(function(name)
94 { 88 {
95 if (name == "enabled") 89 if (name == "enabled")
96 ElemHide.apply(); 90 ElemHide.apply();
97 }); 91 });
98 onShutdown.add(() => ElemHide.unapply()); 92 onShutdown.add(() => ElemHide.unapply());
99 93
100 let styleFile = IO.resolveFilePath(Prefs.data_directory); 94 let styleFile = IO.resolveFilePath(Prefs.data_directory);
101 styleFile.append("elemhide.css"); 95 styleFile.append("elemhide.css");
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 let filter = filterByKey[key]; 408 let filter = filterByKey[key];
415 if (specificOnly && (!filter.domains || filter.domains[""])) 409 if (specificOnly && (!filter.domains || filter.domains[""]))
416 continue; 410 continue;
417 411
418 if (filter.isActiveOnDomain(domain) && !this.getException(filter, domain)) 412 if (filter.isActiveOnDomain(domain) && !this.getException(filter, domain))
419 result.push(filter.selector); 413 result.push(filter.selector);
420 } 414 }
421 return result; 415 return result;
422 } 416 }
423 }; 417 };
OLDNEW
« no previous file with comments | « lib/contentPolicy.js ('k') | lib/requestNotifier.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld