Created
January 22, 2013 19:46
-
-
Save lduros/4597791 to your computer and use it in GitHub Desktop.
ochameau's nsIContentPolicy in addon-sdk module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { Cc, Ci } = require("chrome"); | |
const xpcom = require("xpcom"); | |
const { Class } = require("api-utils/heritage"); | |
exports.preventCrossRequest = Class({ | |
extends: xpcom.Unknown, | |
interfaces: ["nsIContentPolicy"], | |
shouldLoad: function (contType, contLoc, reqOrig, ctx, typeGuess, extra) { | |
return Ci.nsIContentPolicy.REJECT; | |
}, | |
shouldProcess: function (contType, contLoc, reqOrig, ctx, mimeType, extra) { | |
return Ci.nsIContentPolicy.ACCEPT; | |
} | |
}); | |
let factory = xpcom.Factory({ | |
Component: exports.preventCrossRequest, | |
description: "Implements content policy to prevent cross requests", | |
contract: "@lduros.net/PreventCrossRequest-policy" | |
}); | |
var catman = Cc["@mozilla.org/categorymanager;1"].getService(Ci.nsICategoryManager); | |
catman.addCategoryEntry("content-policy", "prevent-cross-request.preventCrossRequest", factory.contract, false, true); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hi Lduros :
I have some kind of problem:
In shouldLoad method, contLoc is where resource will be loaded, there is any possiblities to redirect this?
for example, contLoc is A.js and I want to load B.js.
Thanks!