2 * (C) Copyright 2010 John J. Foerch
4 * Use, modification, and distribution are subject to the terms specified in the
10 content_policy_listener.enabled = true;
12 interactive("content-policy-enable",
13 "Enable content-policy processing.",
15 if (content_policy_listener.enabled) {
16 I.minibuffer.message("Content-policy already enabled.");
19 content_policy_listener.enabled = true;
20 I.minibuffer.message("Content-policy enabled.");
23 interactive("content-policy-disable",
24 "Enable content-policy processing.",
26 if (! content_policy_listener.enabled) {
27 I.minibuffer.message("Content-policy already disabled.");
30 content_policy_listener.enabled = false;
31 I.minibuffer.message("Content-policy disabled.");
34 const content_policy_accept = Ci.nsIContentPolicy.ACCEPT;
35 const content_policy_reject = Ci.nsIContentPolicy.REJECT_REQUEST;
41 var content_policy_bytype_table = {
42 1: null, get other () { return this[1]; },
43 set other (x) { return this[1] = x; },
44 2: null, get script () { return this[2]; },
45 set script (x) { return this[2] = x; },
46 3: null, get image () { return this[3]; },
47 set image (x) { return this[3] = x; },
48 4: null, get stylesheet () { return this[4]; },
49 set stylesheet (x) { return this[4] = x; },
50 5: null, get object () { return this[5]; },
51 set object (x) { return this[5] = x; },
52 6: null, get document () { return this[6]; },
53 set document (x) { return this[6] = x; },
54 7: null, get subdocument () { return this[7]; },
55 set subdocument (x) { return this[7] = x; },
56 9: null, get xbl () { return this[9]; },
57 set xbl (x) { return this[9] = x; },
58 10: null, get ping () { return this[10]; },
59 set ping (x) { return this[10] = x; },
60 11: null, get xmlhttprequest () { return this[11]; },
61 set xmlhttprequest (x) { return this[11] = x; },
62 12: null, get object_subrequest () { return this[12]; },
63 set object_subrequest (x) { return this[12] = x; },
64 13: null, get dtd () { return this[13]; },
65 set dtd (x) { return this[13] = x; },
66 14: null, get font () { return this[14]; },
67 set font (x) { return this[14] = x; },
68 15: null, get media () { return this[15]; },
69 set media (x) { return this[15] = x; }
73 * content_policy_bytype is a function for content_policy_hook, which uses
74 * content_type as the primary key in determining the policy for requests.
75 * its configuration is in content_policy_bytype_table.
77 function content_policy_bytype (content_type, content_location,
78 request_origin, context, mime_type_guess,
80 var rules = content_policy_bytype_table[content_type];
82 return rules(content_type, content_location,
83 request_origin, context, mime_type_guess,
88 provide("content-policy");