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

Delta Between Two Patch Sets: lib/child/contentPolicy.js

Issue 29329571: Issue 3208 - Separate contentPolicy module into a parent and child part (Closed)
Left Patch Set: Removed duplicate type conversion Created Nov. 2, 2015, 7:12 p.m.
Right Patch Set: Fixed JSDoc comment Created Nov. 12, 2015, 3:13 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 | « no previous file | lib/child/main.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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 { 65 {
66 let response = sendSyncMessage("AdblockPlus:ShouldAllow", { 66 let response = sendSyncMessage("AdblockPlus:ShouldAllow", {
67 contentType: contentType, 67 contentType: contentType,
68 location: location, 68 location: location,
69 frames: getFrames(window), 69 frames: getFrames(window),
70 isPrivate: isPrivate(window) 70 isPrivate: isPrivate(window)
71 }); 71 });
72 if (response.length == 0) 72 if (response.length == 0)
73 return true; 73 return true;
74 74
75 let {allow, collapse, hits} = JSON.parse(response[0]); 75 let {allow, collapse, hits} = response[0];
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;
79 if (typeof frameIndex == "number") 79 if (typeof frameIndex == "number")
80 { 80 {
81 context = window; 81 context = window;
82 for (let i = 0; i < frameIndex; i++) 82 for (let i = 0; i < frameIndex; i++)
83 context = context.parent; 83 context = context.parent;
84 context = context.document; 84 context = context.document;
85 } 85 }
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 return; 245 return;
246 246
247 let wnd = Utils.getRequestWindow(newChannel); 247 let wnd = Utils.getRequestWindow(newChannel);
248 if (!wnd) 248 if (!wnd)
249 return; 249 return;
250 250
251 if (contentType == Ci.nsIContentPolicy.TYPE_DOCUMENT) 251 if (contentType == Ci.nsIContentPolicy.TYPE_DOCUMENT)
252 { 252 {
253 if (wnd.history.length <= 1 && wnd.opener) 253 if (wnd.history.length <= 1 && wnd.opener)
254 { 254 {
255 // Special treatment for pop-up windows. Note that we might not have 255 // Special treatment for pop-up windows - this will close the window
256 // rather than preventing the redirect. Note that we might not have
256 // seen the original channel yet because the redirect happened before 257 // seen the original channel yet because the redirect happened before
257 // the async code in observe() had a chance to run. 258 // the async code in observe() had a chance to run.
258 this.observe(wnd, "content-document-global-created", null, oldChannel. URI.spec); 259 this.observe(wnd, "content-document-global-created", null, oldChannel. URI.spec);
259 this.observe(wnd, "content-document-global-created", null, newChannel. URI.spec); 260 this.observe(wnd, "content-document-global-created", null, newChannel. URI.spec);
260 } 261 }
261 return; 262 return;
262 } 263 }
263 264
264 if (!shouldAllow(wnd, wnd.document, types.get(contentType), newChannel.URI .spec)) 265 if (!shouldAllow(wnd, wnd.document, types.get(contentType), newChannel.URI .spec))
265 result = Cr.NS_BINDING_ABORTED; 266 result = Cr.NS_BINDING_ABORTED;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 /** 312 /**
312 * Processes nodes scheduled for post-processing (typically hides them). 313 * Processes nodes scheduled for post-processing (typically hides them).
313 */ 314 */
314 function postProcessNodes() 315 function postProcessNodes()
315 { 316 {
316 if (!collapsedClass) 317 if (!collapsedClass)
317 { 318 {
318 let response = sendSyncMessage("AdblockPlus:GetCollapsedClass"); 319 let response = sendSyncMessage("AdblockPlus:GetCollapsedClass");
319 if (response.length) 320 if (response.length)
320 collapsedClass = response[0]; 321 collapsedClass = response[0];
321
322 if (!collapsedClass)
323 {
324 Utils.runAsync(postProcessNodes);
325 return;
326 }
327 } 322 }
328 323
329 let nodes = scheduledNodes; 324 let nodes = scheduledNodes;
330 scheduledNodes = null; 325 scheduledNodes = null;
326
327 if (!collapsedClass)
328 return;
331 329
332 for (let node of nodes) 330 for (let node of nodes)
333 { 331 {
334 // adjust frameset's cols/rows for frames 332 // adjust frameset's cols/rows for frames
335 let parentNode = node.parentNode; 333 let parentNode = node.parentNode;
336 if (parentNode && parentNode instanceof Ci.nsIDOMHTMLFrameSetElement) 334 if (parentNode && parentNode instanceof Ci.nsIDOMHTMLFrameSetElement)
337 { 335 {
338 let hasCols = (parentNode.cols && parentNode.cols.indexOf(",") > 0); 336 let hasCols = (parentNode.cols && parentNode.cols.indexOf(",") > 0);
339 let hasRows = (parentNode.rows && parentNode.rows.indexOf(",") > 0); 337 let hasRows = (parentNode.rows && parentNode.rows.indexOf(",") > 0);
340 if ((hasCols || hasRows) && !(hasCols && hasRows)) 338 if ((hasCols || hasRows) && !(hasCols && hasRows))
341 { 339 {
342 let index = -1; 340 let index = -1;
343 for (let frame = node; frame; frame = frame.previousSibling) 341 for (let frame = node; frame; frame = frame.previousSibling)
344 if (frame instanceof Ci.nsIDOMHTMLFrameElement || frame instanceof Ci. nsIDOMHTMLFrameSetElement) 342 if (frame instanceof Ci.nsIDOMHTMLFrameElement || frame instanceof Ci. nsIDOMHTMLFrameSetElement)
345 index++; 343 index++;
346 344
347 let property = (hasCols ? "cols" : "rows"); 345 let property = (hasCols ? "cols" : "rows");
348 let weights = parentNode[property].split(","); 346 let weights = parentNode[property].split(",");
349 weights[index] = "0"; 347 weights[index] = "0";
350 parentNode[property] = weights.join(","); 348 parentNode[property] = weights.join(",");
351 } 349 }
352 } 350 }
353 else 351 else
354 node.classList.add(collapsedClass); 352 node.classList.add(collapsedClass);
355 } 353 }
356 } 354 }
LEFTRIGHT
« no previous file | lib/child/main.js » ('j') | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld