New man-page location: mentioned in debian/changelog, adapted debian/rules
[conkeror.git] / modules / cookie.js
blob2cf03348bde604b26ff9bce755250f1174cb1e59
1 /**
2  * (C) Copyright 2008 Jeremy Maitin-Shepard
3  *
4  * Use, modification, and distribution are subject to the terms specified in the
5  * COPYING file.
6 **/
8 var cookie_manager = Cc["@mozilla.org/cookiemanager;1"].getService(Ci.nsICookieManager2);
10 function clear_cookies() {
11     cookie_manager.removeAll();
13 interactive("clear-cookies", "Permanently delete all existing cookies.",
14           function (I) {
15               clear_cookies();
16               I.minibuffer.message("Cookies cleared.");
17           });
19 define_label("COOKIE_LIFETIME_DEFAULT");
20 define_label("COOKIE_LIFETIME_SESSION");
21 define_label("COOKIE_LIFETIME_DAYS", "days");
22 define_label("COOKIE_LIFETIME_PROMPT");
24 define_special_variable("cookie_lifetime_policy",
25                         function () {
26                             switch (get_pref("network.cookie.lifetimePolicy")) {
27                             case 0:
28                                 return COOKIE_LIFETIME_DEFAULT;
29                             case 1:
30                                 return COOKIE_LIFETIME_PROMPT;
31                             case 2:
32                                   return COOKIE_LIFETIME_SESSION;
33                             case 3:
34                                 return COOKIE_LIFETIME_DAYS(get_pref("network.cookie.lifetime.days"));
35                             default:
36                                 return undefined;
37                             }
38                         },
39                         function (value) {
40                             switch (label_id(value)) {
41                             case COOKIE_LIFETIME_DEFAULT:
42                                 session_pref("network.cookie.lifetimePolicy", 0);
43                                 break;
44                             case COOKIE_LIFETIME_PROMPT:
45                                 session_pref("network.cookie.lifetimePolicy", 1);
46                                 break;
47                             case COOKIE_LIFETIME_SESSION:
48                                 session_pref("network.cookie.lifetimePolicy", 2);
49                                 break;
50                             case COOKIE_LIFETIME_DAYS:
51                                 session_pref("network.cookie.lifetimePolicy", 3);
52                                 session_pref("network.cookie.lifetime.days", value.days);
53                                 break;
54                             }
55                         },
56                         "Specifies the default cookie lifetime policy.");