/usr/share/xul-ext/greasemonkey/modules/installPolicy.js is in xul-ext-greasemonkey 3.8-1~deb8u1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 110 111 | // This module is responsible for detecting user scripts that are loaded by
// some means OTHER than HTTP (which the http-on-modify-request observer
// handles), i.e. local files.
var EXPORTED_SYMBOLS = [];
var Cc = Components.classes;
var Ci = Components.interfaces;
var Cu = Components.utils;
var Cr = Components.results;
Cu.import('resource://gre/modules/Services.jsm');
Cu.import('resource://gre/modules/XPCOMUtils.jsm');
Cu.import('chrome://greasemonkey-modules/content/util.js');
var gHaveDoneInit = false;
var gScriptEndingRegexp = new RegExp('\\.user\\.js$');
XPCOMUtils.defineLazyServiceGetter(
this, 'cpmm',
'@mozilla.org/childprocessmessagemanager;1', 'nsIMessageSender');
////////////////////////////////////////////////////////////////////////////////
var InstallPolicy = {
_classDescription: 'Greasemonkey Script Install Policy',
_classID: Components.ID('c03c575c-e87e-4a0f-b88d-8be090116a0c'),
_contractID: '@greasemonkey.mozdev.org/greasemonkey-install-policy;1',
init: function() {
try {
var registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
registrar.registerFactory(
this._classID, this._classDescription, this._contractID, this);
} catch (e) {
if ('NS_ERROR_FACTORY_EXISTS' == e.name) {
// No-op, ignore these. But why do they happen!?
} else {
dump('Error registering InstallPolicy factory:\n' + e + '\n');
}
return;
}
var catMan = Cc["@mozilla.org/categorymanager;1"]
.getService(Ci.nsICategoryManager);
catMan.addCategoryEntry(
'content-policy', this._contractID, this._contractID, false, true);
},
QueryInterface: XPCOMUtils.generateQI([
Ci.nsIContentPolicy,
Ci.nsIFactory,
Ci.nsISupportsWeakReference
]),
/////////////////////////////// nsIContentPolicy ///////////////////////////////
shouldLoad: function(aContentType, aContentURI, aOriginURI, aContext) {
var ACCEPT = Ci.nsIContentPolicy.ACCEPT;
var REJECT = Ci.nsIContentPolicy.REJECT_REQUEST;
// Ignore everything that isn't a file:// .
if ('file' != aContentURI.scheme) {
return ACCEPT;
}
// Ignore everything that isn't a top-level document navigation.
if (aContentType != Ci.nsIContentPolicy.TYPE_DOCUMENT) {
return ACCEPT;
}
// Ignore everything when GM is not enabled.
if (!GM_util.getEnabled()) {
return ACCEPT;
}
// Ignore everything that isn't a user script.
if (!aContentURI.spec.match(gScriptEndingRegexp)) {
return ACCEPT;
}
// Ignore temporary files, e.g. "Show script source".
var tmpResult = cpmm.sendSyncMessage(
'greasemonkey:url-is-temp-file', {'url': aContentURI.spec});
if (tmpResult.length && tmpResult[0]) {
return ACCEPT;
}
cpmm.sendAsyncMessage(
'greasemonkey:script-install', {'url': aContentURI.spec});
return REJECT;
},
shouldProcess: function() {
return Ci.nsIContentPolicy.ACCEPT;
},
////////////////////////////////// nsIFactory //////////////////////////////////
createInstance: function(outer, iid) {
if (outer) {
throw Cr.NS_ERROR_NO_AGGREGATION;
}
return this.QueryInterface(iid);
},
};
////////////////////////////////////////////////////////////////////////////////
if (!gHaveDoneInit) {
gHaveDoneInit = true;
InstallPolicy.init();
}
|