2 * (C) Copyright 2010 John J. Foerch
4 * Use, modification, and distribution are subject to the terms specified in the
8 const Cc = Components.classes;
9 const Ci = Components.interfaces;
10 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
12 var content_policy_listener;
14 function content_policy () {
15 this.conkeror = Cc["@conkeror.mozdev.org/application;1"]
18 this.conkeror.define_hook("content_policy_hook", "RUN_HOOK_UNTIL_SUCCESS");
19 this.conkeror.content_policy_listener = this;
21 content_policy.prototype = {
22 QueryInterface: XPCOMUtils.generateQI([Ci.nsIContentPolicy,
23 Ci.nsIObserverService]),
24 contractID: "@conkeror.org/content-policy-listener;1",
25 classID: Components.ID("{2926dd11-4d76-4965-bcdc-4aaad70ada04}"),
26 classDescription: "content_policy",
28 createInstance: function (outer, iid) {
30 throw Cr.NS_ERROR_NO_AGGREGATION;
31 if (! content_policy_listener)
32 content_policy_listener = new content_policy();
33 return content_policy_listener;
36 _xpcom_categories: [{category: "content-policy"}],
39 shouldLoad: function (content_type, //unsigned long
40 content_location, //nsIURI
41 request_origin, //nsIURI
42 context, //nsISupports
43 mime_type_guess, //ACString
48 action = this.conkeror.content_policy_hook.run(
49 content_type, content_location, request_origin,
50 context, mime_type_guess, extra);
51 return (action || Ci.nsIContentPolicy.ACCEPT);
53 shouldProcess: function (content_type, //unsigned long
54 content_location, //nsIURI
55 request_origin, //nsIURI
56 context, //nsISupports
60 return Ci.nsIContentPolicy.ACCEPT;
64 if (XPCOMUtils.generateNSGetFactory)
65 var NSGetFactory = XPCOMUtils.generateNSGetFactory([content_policy]); //XULRunner 2.0
67 var NSGetModule = XPCOMUtils.generateNSGetModule([content_policy]);