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

Side by Side Diff: lib/contentPolicy.js

Issue 29329884: Issue 3224 - Unbreak filter assistant (Closed)
Patch Set: Created Nov. 9, 2015, 1:45 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/child/requestNotifier.js ('k') | lib/objectTabs.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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 * Checks whether the page loaded in a window is whitelisted for indication in the UI. 259 * Checks whether the page loaded in a window is whitelisted for indication in the UI.
260 * @param wnd {nsIDOMWindow} 260 * @param wnd {nsIDOMWindow}
261 * @return {Filter} matching exception rule or null if not whitelisted 261 * @return {Filter} matching exception rule or null if not whitelisted
262 */ 262 */
263 isWindowWhitelisted: function(wnd) 263 isWindowWhitelisted: function(wnd)
264 { 264 {
265 return this.isWhitelisted(getWindowLocation(wnd)); 265 return this.isWhitelisted(getWindowLocation(wnd));
266 }, 266 },
267 267
268 /** 268 /**
269 * Asynchronously re-checks filters for given nodes. 269 * Deletes nodes that were previously stored with a
270 * @param {Node[]} nodes 270 * RequestNotifier.storeNodesForEntries() call or similar.
271 * @param {string} id unique ID of the nodes
272 */
273 deleteNodes: function(id)
274 {
275 let messageManager = Cc["@mozilla.org/parentprocessmessagemanager;1"]
276 .getService(Ci.nsIMessageBroadcaster);
277 messageManager.broadcastAsyncMessage("AdblockPlus:DeleteNodes", id);
278 },
279
280 /**
281 * Asynchronously re-checks filters for nodes given by an ID previously
282 * returned by a RequestNotifier.storeNodesForEntries() call or similar.
283 * @param {string} id unique ID of the nodes
271 * @param {RequestEntry} entry 284 * @param {RequestEntry} entry
272 */ 285 */
273 refilterNodes: function(nodes, entry) 286 refilterNodes: function(id, entry)
274 { 287 {
275 // Ignore nodes that have been blocked already 288 let messageManager = Cc["@mozilla.org/parentprocessmessagemanager;1"]
276 if (entry.filter && !(entry.filter instanceof WhitelistFilter)) 289 .getService(Ci.nsIMessageBroadcaster);
277 return; 290 messageManager.broadcastAsyncMessage("AdblockPlus:RefilterNodes", {
278 291 nodesID: id,
279 for (let node of nodes) 292 entry: entry
280 Utils.runAsync(() => refilterNode(node, entry)); 293 });
281 } 294 }
282 }; 295 };
283 Policy.init(); 296 Policy.init();
284 297
285 /** 298 /**
286 * Extracts the hostname from a URL (might return null). 299 * Extracts the hostname from a URL (might return null).
287 */ 300 */
288 function getHostname(/**String*/ url) /**String*/ 301 function getHostname(/**String*/ url) /**String*/
289 { 302 {
290 try 303 try
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 { 399 {
387 // EffectiveTLDService throws on IP addresses, just compare the host name 400 // EffectiveTLDService throws on IP addresses, just compare the host name
388 let host = ""; 401 let host = "";
389 try 402 try
390 { 403 {
391 host = uri.host; 404 host = uri.host;
392 } catch (e) {} 405 } catch (e) {}
393 return host != docDomain; 406 return host != docDomain;
394 } 407 }
395 } 408 }
396
397 /**
398 * Re-checks filters on an element.
399 */
400 function refilterNode(/**Node*/ node, /**RequestEntry*/ entry)
401 {
402 let wnd = Utils.getWindow(node);
403 if (!wnd || wnd.closed)
404 return;
405
406 if (entry.type == "OBJECT")
407 {
408 node.removeEventListener("mouseover", objectMouseEventHander, true);
409 node.removeEventListener("mouseout", objectMouseEventHander, true);
410 }
411 Policy.processNode(wnd, node, entry.type, entry.location, true);
412 }
OLDNEW
« no previous file with comments | « lib/child/requestNotifier.js ('k') | lib/objectTabs.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld