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

Unified Diff: lib/elemHide.js

Issue 29329571: Issue 3208 - Separate contentPolicy module into a parent and child part (Closed)
Patch Set: Moved collapsedClass variable Created Nov. 12, 2015, 12:27 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« lib/contentPolicy.js ('K') | « lib/contentPolicy.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/elemHide.js
===================================================================
--- a/lib/elemHide.js
+++ b/lib/elemHide.js
@@ -204,47 +204,23 @@ let ElemHide = exports.ElemHide =
* @return {Boolean}
*/
shouldHide: function(message)
{
let filter = ElemHide.getFilterByKey(message.key);
if (!filter || !message.frames.length)
return false;
- let fakeFrame = null;
- for (let i = message.frames.length - 1; i >= 0; i--)
- {
- fakeFrame = {
- parent: fakeFrame,
- location: {
- href: message.frames[i].location
- },
- document: {
- documentElement: {}
- },
- QueryInterface: function() {return this;},
- getInterface: function() {return this;},
- usePrivateBrowsing: message.isPrivate
- };
- fakeFrame.top = fakeFrame.parent || fakeFrame;
- if (!fakeFrame.parent)
- fakeFrame.parent = fakeFrame;
-
- let sitekey = message.frames[i].sitekey || null;
- fakeFrame.document.documentElement.getAttribute = function(attr)
- {
- if (attr == "data-adblockkey")
- return sitekey;
- else
- return null;
- };
- }
-
let {Policy} = require("contentPolicy");
- return !Policy.processNode(fakeFrame, fakeFrame.document, "ELEMHIDE", filter);
+ return !Policy.shouldAllow({
+ contentType: "ELEMHIDE",
+ location: filter,
+ frames: message.frames,
+ isPrivate: message.isPrivate
+ }).allow;
},
/**
* Will be set to true if apply() is running (reentrance protection).
* @type Boolean
*/
_applying: false,
« lib/contentPolicy.js ('K') | « lib/contentPolicy.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld