This repository has been archived by the owner on Oct 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap.js
109 lines (86 loc) · 2.97 KB
/
bootstrap.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cr = Components.results;
const Cu = Components.utils;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
function CookiePromptService() {
}
CookiePromptService.prototype = {
cookieDialog: function (aParent, aCookie, aHostname, aCookiesFromHost,
aChangingCookie, aRememberDecision) {
aRememberDecision.value = false;
let bodytext;
if (aChangingCookie) {
bodytext = "The site " + aHostname + "wants to modify an existing cookie";
} else if (aCookiesFromHost > 1) {
bodytext = "The site " + aHostname + "wants to set another cookie";
} else if (aCookiesFromHost == 1) {
bodytext = "The site " + aHostname + "wants to set a second cookie";
} else {
bodytext = "The site " + aHostname + "wants to set a cookie";
}
let selectStrings = ["Deny",
"Deny (Remember Decision)",
"Allow",
"Allow (Remember Decision)",
"Allow for Session",
"Allow for Session (Remember Decision)"];
let state = {};
if (Services.prompt.select(aParent,
"Confirm settings cookie",
bodytext,
selectStrings.length,
selectStrings,
state)) {
if (state.value % 2 == 1) {
aRememberDecision.value = true;
}
return state.value / 2;
}
return Ci.nsICookiePromptService.DENY_COOKIE;
},
QueryInterface: XPCOMUtils.generateQI([Ci.nsICookiePromptService]),
classDescription: "cookie dialog for android",
contractID: "@mozilla.org/embedcomp/cookieprompt-service;1",
classID: Components.ID("{ae127e4b-7c35-4426-8a9d-9f3d94552e7c}"),
};
var prompt = new CookiePromptService;
var factory = {
createInstance: function(outer, iid) {
if (outer)
throw Cr.NS_ERROR_NO_AGGREGATION;
return prompt.QueryInterface(iid);
},
};
function registerComponents()
{
let registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
registrar.registerFactory(prompt.classID,
prompt.classDescription,
prompt.contractID,
factory);
};
function UnregisterComponents()
{
let registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
registrar.unregisterFactory(prompt.classID, factory);
}
// export functions
function startup(aData, aReason)
{
registerComponents();
}
function shutdown(aData, aReason)
{
UnregisterComponents();
}
function install(aData, aReason)
{
}
function uninstall(aData, aReason)
{
}