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

Unified Diff: lib/elemHide.js

Issue 29329336: Issue 3208 - Inject content policy implementation into all processes (Closed)
Patch Set: Created Oct. 22, 2015, 9:03 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
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: (fakeFrame ? fakeFrame.usePrivateBrowsing : message.frames[i].privateBrowsing)
- };
- 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, Policy.type.ELEMHIDE, filter);
+ return Policy.shouldLoad({
+ contentType: "ELEMHIDE",
+ location: filter,
+ frames: message.frames,
+ isPrivate: message.isPrivate
+ }).block;
},
/**
* Will be set to true if apply() is running (reentrance protection).
* @type Boolean
*/
_applying: false,

Powered by Google App Engine
This is Rietveld