aboutsummaryrefslogtreecommitdiffstats
path: root/js/vapi-background.js
diff options
context:
space:
mode:
authorAlessio Vanni <vannilla@firemail.cc>2019-06-23 13:34:42 +0200
committerAlessio Vanni <vannilla@firemail.cc>2019-06-23 13:34:42 +0200
commit9a5c1c75f96b26041443309a8bfa977da8950c38 (patch)
tree32d17b1a03a37e06e410d29931b5d1171b51ac4d /js/vapi-background.js
parent9bde0c09c312feebe5abc96240214f91aeca198a (diff)
downloadematrix-9a5c1c75f96b26041443309a8bfa977da8950c38.tar.lz
ematrix-9a5c1c75f96b26041443309a8bfa977da8950c38.tar.xz
ematrix-9a5c1c75f96b26041443309a8bfa977da8950c38.zip
Get cookie management out of vapi-background
Diffstat (limited to 'js/vapi-background.js')
-rw-r--r--js/vapi-background.js101
1 files changed, 0 insertions, 101 deletions
diff --git a/js/vapi-background.js b/js/vapi-background.js
index 3035556..1690c06 100644
--- a/js/vapi-background.js
+++ b/js/vapi-background.js
@@ -947,13 +947,6 @@
})();
(function() {
- // It appears that this branch actually works on the latest
- // Basilisk. Maybe we can simply use this one directly instead of
- // making checks like it's done now.
-
- // It was decided to use this branch unconditionally. It's still
- // experimental though.
-
// Add toolbar button for Basilisk
if (Services.appinfo.ID !== "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}") {
return;
@@ -1140,7 +1133,6 @@
})();
// No toolbar button.
-
(function () {
// Just to ensure the number of cleanup tasks is as expected: toolbar
// button code is one single cleanup task regardless of platform.
@@ -1587,97 +1579,4 @@
setOptions: setOptions
};
})();
-
- vAPI.cookies = {};
- // https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsICookieManager2
- // https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsICookie2
- // https://developer.mozilla.org/en-US/docs/Observer_Notifications#Cookies
-
- vAPI.cookies.CookieEntry = function (ffCookie) {
- this.domain = ffCookie.host;
- this.name = ffCookie.name;
- this.path = ffCookie.path;
- this.secure = ffCookie.isSecure === true;
- this.session = ffCookie.expires === 0;
- this.value = ffCookie.value;
- };
-
- vAPI.cookies.start = function () {
- Services.obs.addObserver(this, 'cookie-changed', false);
- Services.obs.addObserver(this, 'private-cookie-changed', false);
- vAPI.addCleanUpTask(this.stop.bind(this));
- };
-
- vAPI.cookies.stop = function () {
- Services.obs.removeObserver(this, 'cookie-changed');
- Services.obs.removeObserver(this, 'private-cookie-changed');
- };
-
- vAPI.cookies.observe = function (subject, topic, reason) {
- //if ( topic !== 'cookie-changed' && topic !== 'private-cookie-changed' ) {
- // return;
- //}
- //
- if (reason === 'cleared' && typeof this.onAllRemoved === 'function') {
- this.onAllRemoved();
- return;
- }
- if (subject === null) {
- return;
- }
- if (subject instanceof Ci.nsICookie2 === false) {
- try {
- subject = subject.QueryInterface(Ci.nsICookie2);
- } catch (ex) {
- return;
- }
- }
- if (reason === 'deleted') {
- if (typeof this.onRemoved === 'function') {
- this.onRemoved(new this.CookieEntry(subject));
- }
- return;
- }
- if (typeof this.onChanged === 'function') {
- this.onChanged(new this.CookieEntry(subject));
- }
- };
-
- vAPI.cookies.getAll = function(callback) {
- // Meant and expected to be asynchronous.
- if (typeof callback !== 'function') {
- return;
- }
-
- let onAsync = function () {
- let out = [];
- let enumerator = Services.cookies.enumerator;
- let ffcookie;
- while (enumerator.hasMoreElements()) {
- ffcookie = enumerator.getNext();
- if (ffcookie instanceof Ci.nsICookie) {
- out.push(new this.CookieEntry(ffcookie));
- }
- }
-
- callback(out);
- };
-
- vAPI.setTimeout(onAsync.bind(this), 0);
- };
-
- vAPI.cookies.remove = function (details, callback) {
- let uri = Services.io.newURI(details.url, null, null);
- let cookies = Services.cookies;
- cookies.remove(uri.asciiHost, details.name, uri.path, false, {});
- cookies.remove( '.' + uri.asciiHost, details.name, uri.path, false, {});
-
- if (typeof callback === 'function') {
- callback({
- domain: uri.asciiHost,
- name: details.name,
- path: uri.path
- });
- }
- };
})();