kludge issue 513
[conkeror.git] / modules / cookie.js
blobf2f13d3d0fee2ea56969f610793d906e41cf5b12
1 /**
2 * (C) Copyright 2008 Jeremy Maitin-Shepard
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"]
9 .getService(Ci.nsICookieManager2);
11 function clear_cookies () {
12 cookie_manager.removeAll();
14 interactive("clear-cookies", "Permanently delete all existing cookies.",
15 function (I) {
16 clear_cookies();
17 I.minibuffer.message("Cookies cleared.");
18 });
20 define_label("COOKIE_LIFETIME_DEFAULT");
21 define_label("COOKIE_LIFETIME_SESSION");
22 define_label("COOKIE_LIFETIME_DAYS", "days");
23 define_label("COOKIE_LIFETIME_PROMPT");
25 define_special_variable("cookie_lifetime_policy",
26 function () {
27 switch (get_pref("network.cookie.lifetimePolicy")) {
28 case 0:
29 return COOKIE_LIFETIME_DEFAULT;
30 case 1:
31 return COOKIE_LIFETIME_PROMPT;
32 case 2:
33 return COOKIE_LIFETIME_SESSION;
34 case 3:
35 return COOKIE_LIFETIME_DAYS(get_pref("network.cookie.lifetime.days"));
36 default:
37 return undefined;
40 function (value) {
41 switch (label_id(value)) {
42 case COOKIE_LIFETIME_DEFAULT:
43 session_pref("network.cookie.lifetimePolicy", 0);
44 break;
45 case COOKIE_LIFETIME_PROMPT:
46 session_pref("network.cookie.lifetimePolicy", 1);
47 break;
48 case COOKIE_LIFETIME_SESSION:
49 session_pref("network.cookie.lifetimePolicy", 2);
50 break;
51 case COOKIE_LIFETIME_DAYS:
52 session_pref("network.cookie.lifetimePolicy", 3);
53 session_pref("network.cookie.lifetime.days", value.days);
54 break;
57 "Specifies the default cookie lifetime policy.");
59 provide("cookie");