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

Side by Side Diff: lib/child/contentPolicy.js

Issue 29329754: Issue 3251 - Delegate processing of element hiding hits to shouldAllowAsync() so that hits show up (Closed)
Patch Set: Rebased Created Nov. 11, 2015, 5:47 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 | lib/child/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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 * Maps numerical content type IDs to strings. 52 * Maps numerical content type IDs to strings.
53 * @type Map.<number,string> 53 * @type Map.<number,string>
54 */ 54 */
55 let types = new Map(); 55 let types = new Map();
56 56
57 /** 57 /**
58 * Checks whether a request should be allowed, hides it if necessary 58 * Checks whether a request should be allowed, hides it if necessary
59 * @param wnd {nsIDOMWindow} 59 * @param wnd {nsIDOMWindow}
60 * @param node {nsIDOMElement} 60 * @param node {nsIDOMElement}
61 * @param contentType {String} 61 * @param contentType {String}
62 * @param location {String} 62 * @param location {String} location of the request, filter key if contentType i s ELEMHIDE
63 * @param [callback] {Function} If present, the request will be sent 63 * @param [callback] {Function} If present, the request will be sent
64 * asynchronously and callback called with the 64 * asynchronously and callback called with the
65 * response 65 * response
66 * @return {Boolean} false if the request should be blocked 66 * @return {Boolean} false if the request should be blocked
67 */ 67 */
68 function shouldAllow(window, node, contentType, location, callback) 68 let shouldAllow = exports.shouldAllow = function(window, node, contentType, loca tion, callback)
69 { 69 {
70 function processResponse(response) 70 function processResponse(response)
71 { 71 {
72 if (typeof response == "undefined") 72 if (typeof response == "undefined")
73 return true; 73 return true;
74 74
75 let {allow, collapse, hits} = response; 75 let {allow, collapse, hits} = response;
76 for (let {frameIndex, contentType, docDomain, thirdParty, location, filter} of hits) 76 for (let {frameIndex, contentType, docDomain, thirdParty, location, filter} of hits)
77 { 77 {
78 let context = node; 78 let context = node;
(...skipping 29 matching lines...) Expand all
108 isPrivate: isPrivate(window) 108 isPrivate: isPrivate(window)
109 }; 109 };
110 if (typeof callback == "function") 110 if (typeof callback == "function")
111 { 111 {
112 sendAsyncMessage("AdblockPlus:ShouldAllow", data, (data) => { 112 sendAsyncMessage("AdblockPlus:ShouldAllow", data, (data) => {
113 callback(processResponse(data)); 113 callback(processResponse(data));
114 }); 114 });
115 } 115 }
116 else 116 else
117 return processResponse(sendSyncMessage("AdblockPlus:ShouldAllow", data)); 117 return processResponse(sendSyncMessage("AdblockPlus:ShouldAllow", data));
118 } 118 };
119 119
120 /** 120 /**
121 * Actual nsIContentPolicy and nsIChannelEventSink implementation 121 * Actual nsIContentPolicy and nsIChannelEventSink implementation
122 * @class 122 * @class
123 */ 123 */
124 var PolicyImplementation = 124 var PolicyImplementation =
125 { 125 {
126 classDescription: "Adblock Plus content policy", 126 classDescription: "Adblock Plus content policy",
127 classID: Components.ID("cfeaabe6-1dd1-11b2-a0c6-cb5c268894c9"), 127 classID: Components.ID("cfeaabe6-1dd1-11b2-a0c6-cb5c268894c9"),
128 contractID: "@adblockplus.org/abp/policy;1", 128 contractID: "@adblockplus.org/abp/policy;1",
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 let property = (hasCols ? "cols" : "rows"); 360 let property = (hasCols ? "cols" : "rows");
361 let weights = parentNode[property].split(","); 361 let weights = parentNode[property].split(",");
362 weights[index] = "0"; 362 weights[index] = "0";
363 parentNode[property] = weights.join(","); 363 parentNode[property] = weights.join(",");
364 } 364 }
365 } 365 }
366 else 366 else
367 node.classList.add(collapsedClass); 367 node.classList.add(collapsedClass);
368 } 368 }
369 } 369 }
OLDNEW
« no previous file with comments | « no previous file | lib/child/elemHide.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld