summaryrefslogtreecommitdiff
path: root/data/extensions/jid1-KtlZuoiikVfFew@jetpack/node_modules/pathfinder/lib/content
diff options
context:
space:
mode:
authorRuben Rodriguez <ruben@gnu.org>2018-09-13 20:39:48 -0400
committerRuben Rodriguez <ruben@gnu.org>2018-09-13 21:02:13 -0400
commitd26b319fd6f98517cc3421f10bf18698b953e4d2 (patch)
treebc70c4e472a2eaf514d411dba5067d530e5bbea9 /data/extensions/jid1-KtlZuoiikVfFew@jetpack/node_modules/pathfinder/lib/content
parentc3b304c51a3386ea09527a479a883253ea35243a (diff)
Updated extensions list for v60
Diffstat (limited to 'data/extensions/jid1-KtlZuoiikVfFew@jetpack/node_modules/pathfinder/lib/content')
-rw-r--r--data/extensions/jid1-KtlZuoiikVfFew@jetpack/node_modules/pathfinder/lib/content/permissions.js88
-rw-r--r--data/extensions/jid1-KtlZuoiikVfFew@jetpack/node_modules/pathfinder/lib/content/policy.js143
2 files changed, 0 insertions, 231 deletions
diff --git a/data/extensions/jid1-KtlZuoiikVfFew@jetpack/node_modules/pathfinder/lib/content/permissions.js b/data/extensions/jid1-KtlZuoiikVfFew@jetpack/node_modules/pathfinder/lib/content/permissions.js
deleted file mode 100644
index 49cc955..0000000
--- a/data/extensions/jid1-KtlZuoiikVfFew@jetpack/node_modules/pathfinder/lib/content/permissions.js
+++ /dev/null
@@ -1,88 +0,0 @@
-/* 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/. */
-'use strict';
-
-const { Cc, Ci, Cu } = require('chrome');
-const { List, addListItem } = require('sdk/util/list');
-const { URL } = require('sdk/url');
-
-const { Services } = require('../chrome/services');
-
-const { nsIPermissionManager } = Ci;
-
-const UNKNOWN = nsIPermissionManager.UNKNOWN_ACTION; // 0
-const ALLOW = nsIPermissionManager.ALLOW_ACTION; // 1
-const BLOCK = nsIPermissionManager.DENY_ACTION; // 2
-const SESSION = Ci.nsICookiePermission.ACCESS_SESSION; // 8
-
-function getKey(obj, val) {
- for (let key in obj)
- if (obj[key] == val)
- return key;
-
- return undefined;
-}
-
-const PERMISSIONS = {
- 'session': SESSION,
- 'allow': ALLOW,
- 'deny': BLOCK
-};
-
-const TYPES = {
- 'images': 'image',
- 'popups': 'popup',
- 'desktop-notifications': 'desktop-notification',
- 'installs': 'install',
- 'location': 'geo',
- 'fullscreen': 'fullscreen',
- 'pointer-lock': 'pointerLock'
-}
-
-const PM = Cc['@mozilla.org/permissionmanager;1'].
- getService(nsIPermissionManager);
-
-function add(options) {
- let uri = Services.io.newURI(options.url, null, null);
- if (!/^https?/.test(uri.scheme)) {
- throw new Error('invalid content url, only https or http schemes are accepted');
- }
-
- PM.add(uri,
- TYPES[options.type],
- PERMISSIONS[options.permission]);
-}
-
-function remove(options) {
- PM.remove(URL(options.url).host, TYPES[options.type]);
-}
-
-function removeAll() {
- PM.removeAll();
-}
-
-// TODO: cache entries after first request, and observe new additions with the "perm-changed" event
-
-exports.permissions = {
- add: add,
- remove: remove,
- removeAll: removeAll,
- get permissions() {
- let list = List();
- let permissions = PM.enumerator;
- while (permissions.hasMoreElements()) {
- let permission = permissions.getNext().QueryInterface(Ci.nsIPermission);
-
- addListItem(list, {
- type: getKey(TYPES, permission.type),
- host: String(permission.host),
- permission: getKey(PERMISSIONS, Number(permission.capability))
- //'expire-time': Number(permission.expireTime),
- });
- }
- return list;
- },
- TYPES: TYPES,
- PERMISSIONS: PERMISSIONS
-}
diff --git a/data/extensions/jid1-KtlZuoiikVfFew@jetpack/node_modules/pathfinder/lib/content/policy.js b/data/extensions/jid1-KtlZuoiikVfFew@jetpack/node_modules/pathfinder/lib/content/policy.js
deleted file mode 100644
index b764272..0000000
--- a/data/extensions/jid1-KtlZuoiikVfFew@jetpack/node_modules/pathfinder/lib/content/policy.js
+++ /dev/null
@@ -1,143 +0,0 @@
-/* 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/. */
-'use strict';
-
-const { Cc, Ci } = require('chrome');
-const { Class } = require('sdk/core/heritage');
-const CP_NS = require('sdk/core/namespace').ns();
-const { ensure } = require('sdk/system/unload');
-const { validateOptions } = require('sdk/deprecated/api-utils');
-const { id: ADDON_ID } = require('sdk/self');
-const xpcom = require('sdk/platform/xpcom');
-
-const CM = Cc["@mozilla.org/categorymanager;1"]
- .getService(Ci.nsICategoryManager);
-
-const ACCEPT = exports.ACCEPT = Ci.nsIContentPolicy.ACCEPT;
-const REJECT = exports.REJECT = Ci.nsIContentPolicy.REJECT_REQUEST;
-
-const accept = function() ACCEPT;
-
-let ContentPolicy_ID = 0;
-
-const RULES = {
- description: {
- map: function(v) {
- return v ? v : '';
- },
- is: ['string']
- },
- contract: {
- map: function(v) {
- if (v === undefined) {
- v = '@erikvold.com/content-policy.' + ADDON_ID + ';' + ContentPolicy_ID++;
- }
- return v;
- },
- is: ['string']
- },
- entry: {
- is: ['string', 'undefined']
- },
- shouldLoad: {
- is: ['function', 'undefined']
- },
- shouldProcess: {
- is: ['function', 'undefined']
- },
-};
-
-function getType(aType) {
- switch (aType) {
- case Ci.nsIContentPolicy.TYPE_SCRIPT:
- return 'script';
- case Ci.nsIContentPolicy.TYPE_IMAGE:
- return 'image';
- case Ci.nsIContentPolicy.TYPE_STYLESHEET:
- return 'stylesheet';
- case Ci.nsIContentPolicy.TYPE_OBJECT:
- return 'object';
- case Ci.nsIContentPolicy.TYPE_DOCUMENT:
- return 'document';
- case Ci.nsIContentPolicy.TYPE_SUBDOCUMENT:
- return 'subdocument';
- case Ci.nsIContentPolicy.TYPE_REFRESH:
- return 'refresh';
- case Ci.nsIContentPolicy.TYPE_XBL:
- return 'xbl';
- case Ci.nsIContentPolicy.TYPE_XMLHTTPREQUEST:
- return 'xhr';
- case Ci.nsIContentPolicy.TYPE_PING:
- return 'ping';
- // TODO: support more types
- }
- return 'other';
-}
-const getTypeMemod = memoize(getType, 12, 1);
-
-function makeDetails(aContentType, aContentLocation, aRequestOrigin, aContext, aMimeTypeGuess) {
- return {
- type: getTypeMemod(aContentType),
- location: aContentLocation.spec,
- origin: aRequestOrigin.spec,
- context: null, // TODO: support this in a safe way somehow..
- mimeTypeGuess: String(aMimeTypeGuess)
- };
-}
-
-let ContentPolicy = exports.ContentPolicy = Class({
- initialize: function(options) {
- const self = this;
- options = CP_NS(self).options = validateOptions(options, RULES);
- CP_NS(self).shouldLoad = options.shouldLoad || accept;
- CP_NS(self).shouldProcess = options.shouldProcess || accept;
-
- let factory = CP_NS(this).factory = xpcom.Factory({
- Component: getProvider(self),
- description: options.description,
- contract: options.contract
- });
-
- let entry = options.entry || options.contract;
- CM.addCategoryEntry('content-policy', entry, factory.contract, false, true);
- ensure(this, 'destroy');
- },
- destroy: function() {
- // already destroyed?
- if (!CP_NS(this).options)
- return;
-
- let options = CP_NS(this).options;
- CP_NS(this).options = null;
- CP_NS(this).shouldLoad = accept;
- CP_NS(this).shouldProcess = accept;
-
- CM.deleteCategoryEntry('content-policy', options.entry || options.contract, false);
- }
-});
-
-function getProvider(self) {
- return Class({
- extends: xpcom.Unknown,
- interfaces: ['nsIContentPolicy'],
- shouldLoad: function (aContentType, aContentLocation, aRequestOrigin, aContext, aMimeTypeGuess, aExtra) {
- let load = CP_NS(self).shouldLoad(makeDetails.apply(null, arguments));
- return (load == REJECT || (!load && load !== undefined)) ? REJECT : ACCEPT;
- },
- shouldProcess: function (aContentType, aContentLocation, aRequestOrigin, aContext, aMimeTypeGuess, aExtra) {
- let load = CP_NS(self).shouldProcess(makeDetails.apply(null, arguments));
- return (load == REJECT || (!load && load !== undefined)) ? REJECT : ACCEPT;
- }
- });
-}
-
-function memoize(func) {
- let cache = Object.create(null);
- return function(a) {
- let key = a.toString();
- if (key in cache)
- return cache[key];
- return cache[key] = func.call(null, a);
- };
-}