content_policy_bytype_table: remove 8 (refresh)
[conkeror.git] / modules / content-policy.js
blob6641c2dea5e3647805d7c27478bca93d2be970df
1 /**
2  * (C) Copyright 2010 John J. Foerch
3  *
4  * Use, modification, and distribution are subject to the terms specified in the
5  * COPYING file.
6 **/
8 in_module(null);
10 content_policy_listener.enabled = true;
12 interactive("content-policy-enable",
13     "Enable content-policy processing.",
14     function (I) {
15         if (content_policy_listener.enabled) {
16             I.minibuffer.message("Content-policy already enabled.");
17             return;
18         }
19         content_policy_listener.enabled = true;
20         I.minibuffer.message("Content-policy enabled.");
21     });
23 interactive("content-policy-disable",
24     "Enable content-policy processing.",
25     function (I) {
26         if (! content_policy_listener.enabled) {
27             I.minibuffer.message("Content-policy already disabled.");
28             return;
29         }
30         content_policy_listener.enabled = false;
31         I.minibuffer.message("Content-policy disabled.");
32     });
34 const content_policy_accept = Ci.nsIContentPolicy.ACCEPT;
35 const content_policy_reject = Ci.nsIContentPolicy.REJECT_REQUEST;
38  * By Type Filtering
39  */
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; }
72 /**
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.
76  */
77 function content_policy_bytype (content_type, content_location,
78                                 request_origin, context, mime_type_guess,
79                                 extra) {
80     var rules = content_policy_bytype_table[content_type];
81     if (rules)
82         return rules(content_type, content_location,
83                      request_origin, context, mime_type_guess,
84                      extra);
85     return null;
88 provide("content-policy");