mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 22:28:00 +01:00
Disable sending incompatibility reports via the ACR.
This commit is contained in:
23
common/bootstrap.js
vendored
23
common/bootstrap.js
vendored
@@ -14,9 +14,15 @@ const Ci = Components.interfaces;
|
||||
const Cu = Components.utils;
|
||||
const Cr = Components.results;
|
||||
|
||||
Cu.import("resource://gre/modules/AddonManager.jsm");
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
function module(uri) {
|
||||
let obj = {};
|
||||
Cu.import(uri, obj);
|
||||
return obj;
|
||||
}
|
||||
|
||||
const { AddonManager } = module("resource://gre/modules/AddonManager.jsm");
|
||||
const { XPCOMUtils } = module("resource://gre/modules/XPCOMUtils.jsm");
|
||||
const { Services } = module("resource://gre/modules/Services.jsm");
|
||||
|
||||
const resourceProto = Services.io.getProtocolHandler("resource")
|
||||
.QueryInterface(Ci.nsIResProtocolHandler);
|
||||
@@ -95,6 +101,7 @@ function startup(data, reason) {
|
||||
else
|
||||
getURI = function getURI(path)
|
||||
Services.io.newURI("jar:" + Services.io.newFileURI(basePath).spec + "!/" + path, null, null);
|
||||
|
||||
try {
|
||||
init();
|
||||
}
|
||||
@@ -163,6 +170,11 @@ function init() {
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
module("resource://dactyl-local-content/disable-acr.jsm").init();
|
||||
}
|
||||
catch (e) {}
|
||||
|
||||
if (JSMLoader && JSMLoader.bump != 3) // Temporary hack
|
||||
Services.scriptloader.loadSubScript("resource://dactyl" + suffix + "/bootstrap.jsm",
|
||||
Cu.import("resource://dactyl/bootstrap.jsm", global));
|
||||
@@ -186,6 +198,11 @@ function init() {
|
||||
function shutdown(data, reason) {
|
||||
dump("dactyl: bootstrap: shutdown " + reasonToString(reason) + "\n");
|
||||
if (reason != APP_SHUTDOWN) {
|
||||
try {
|
||||
module("resource://dactyl-local-content/disable-acr.jsm").cleanup();
|
||||
}
|
||||
catch (e) {}
|
||||
|
||||
if ([ADDON_UPGRADE, ADDON_DOWNGRADE, ADDON_UNINSTALL].indexOf(reason) >= 0)
|
||||
Services.obs.notifyObservers(null, "dactyl-purge", null);
|
||||
|
||||
|
||||
84
pentadactyl/content/disable-acr.jsm
Normal file
84
pentadactyl/content/disable-acr.jsm
Normal file
@@ -0,0 +1,84 @@
|
||||
// By Kris Maglione. Public Domain.
|
||||
// Please feel free to copy and use at will.
|
||||
|
||||
const ADDON_ID = "pentadactyl@dactyl.googlecode.com";
|
||||
|
||||
const OVERLAY_URLS = [
|
||||
"about:addons",
|
||||
"chrome://mozapps/content/extensions/extensions.xul"
|
||||
];
|
||||
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
const Cr = Components.results;
|
||||
const Cu = Components.utils;
|
||||
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
function observe(subject, topic, data) {
|
||||
if (topic in observers)
|
||||
observers[topic](subject, data);
|
||||
}
|
||||
function init(disable) {
|
||||
for (let observer in observers)
|
||||
Services.obs[disable ? "removeObserver" : "addObserver"](observe, observer, false);
|
||||
for (let doc in chromeDocuments)
|
||||
checkDocument(doc, disable);
|
||||
}
|
||||
function cleanup() { init(true); }
|
||||
var observers = {
|
||||
"chrome-document-global-created": function (window, uri) {
|
||||
checkDocument(window.document);
|
||||
}
|
||||
}
|
||||
|
||||
function checkPopup(event) {
|
||||
try {
|
||||
let doc = event.originalTarget.ownerDocument;
|
||||
let binding = doc.getBindingParent(event.originalTarget);
|
||||
if (binding && binding.addon && binding.addon.guid == ADDON_ID && !binding.addon.compatible) {
|
||||
let elem = doc.getAnonymousElementByAttribute(binding, "anonid", "stillworks");
|
||||
if (elem && elem.nextSibling) {
|
||||
elem.nextSibling.disabled = true;
|
||||
elem.nextSibling.setAttribute("tooltiptext", "Developer has opted out of incompatibility reports");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
Cu.reportError(e);
|
||||
}
|
||||
}
|
||||
|
||||
function checkDocument(doc, disable, force) {
|
||||
if (["interactive", "complete"].indexOf(doc.readyState) >= 0 || force && doc.readyState === "uninitialized") {
|
||||
if (OVERLAY_URLS.indexOf(doc.documentURI) >= 0)
|
||||
doc[disable ? "removeEventListener" : "addEventListener"]("popupshowing", checkPopup, false);
|
||||
}
|
||||
else {
|
||||
doc.addEventListener("DOMContentLoaded", function listener() {
|
||||
try {
|
||||
doc.removeEventListener("DOMContentLoaded", listener, false);
|
||||
checkDocument(doc, disable, true);
|
||||
}
|
||||
catch (e) {
|
||||
Cu.reportError(e);
|
||||
}
|
||||
}, false);
|
||||
}
|
||||
}
|
||||
|
||||
function chromeDocuments() {
|
||||
let windows = Services.ww.getXULWindowEnumerator(null);
|
||||
while (windows.hasMoreElements()) {
|
||||
let window = windows.getNext().QueryInterface(Ci.nsIXULWindow);
|
||||
let docShells = window.docShell.getDocShellEnumerator(Ci.nsIDocShell.typeChrome,
|
||||
Ci.nsIDocShell.ENUMERATE_FORWARDS);
|
||||
while (docShells.hasMoreElements())
|
||||
yield docShells.getNext().containedDocShells.DOMDocument;
|
||||
}
|
||||
}
|
||||
|
||||
var EXPORTED_SYMBOLS = ["cleanup", "init"];
|
||||
|
||||
// vim: set fdm=marker sw=4 ts=4 et:
|
||||
Reference in New Issue
Block a user