1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-02-15 12:55:47 +01:00

Move the ACR disabler to common/, pass it an add-on ID.

--HG--
rename : pentadactyl/content/disable-acr.jsm => common/content/disable-acr.jsm
This commit is contained in:
Kris Maglione
2011-02-06 17:32:42 -05:00
parent 4d9c196b6c
commit a1f291a9ec
3 changed files with 17 additions and 16 deletions

12
common/bootstrap.js vendored
View File

@@ -169,9 +169,11 @@ function init() {
}
try {
module("resource://dactyl-local-content/disable-acr.jsm").init();
module("resource://dactyl-content/disable-acr.jsm").init(addon.id);
}
catch (e) {
reportError(e);
}
catch (e) {}
if (JSMLoader && JSMLoader.bump != 3) // Temporary hack
Services.scriptloader.loadSubScript("resource://dactyl" + suffix + "/bootstrap.jsm",
@@ -197,9 +199,11 @@ 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();
module("resource://dactyl-content/disable-acr.jsm").init(addon.id);
}
catch (e) {
reportError(e);
}
catch (e) {}
if ([ADDON_UPGRADE, ADDON_DOWNGRADE, ADDON_UNINSTALL].indexOf(reason) >= 0)
Services.obs.notifyObservers(null, "dactyl-purge", null);

View File

@@ -0,0 +1,72 @@
// By Kris Maglione. Public Domain.
// Please feel free to copy and use at will.
var ADDON_ID;
const OVERLAY_URLS = [
"about:addons",
"chrome://mozapps/content/extensions/extensions.xul"
];
const Ci = Components.interfaces;
const Cu = Components.utils;
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
function observe(window, topic, url) {
if (topic === "chrome-document-global-created")
checkDocument(window.document);
}
function init(id) {
if (id)
ADDON_ID = id;
Services.obs[id ? "addObserver" : "removeObserver"](observe, "chrome-document-global-created", false);
for (let doc in chromeDocuments)
checkDocument(doc, !id);
}
function cleanup() { init(null); }
function checkPopup(event) {
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\n"+
"Development versions are available with updated support");
}
}
}
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() {
doc.removeEventListener("DOMContentLoaded", listener, false);
checkDocument(doc, disable, true);
}, false);
}
}
function chromeDocuments() {
let windows = services.windowMediator.getXULWindowEnumerator(null);
while (windows.hasMoreElements()) {
let window = windows.getNext().QueryInterface(Ci.nsIXULWindow);
for each (let type in ["typeChrome", "typeContent"]) {
let docShells = window.docShell.getDocShellEnumerator(Ci.nsIDocShellTreeItem[type],
Ci.nsIDocShell.ENUMERATE_FORWARDS);
while (docShells.hasMoreElements())
yield docShells.getNext().QueryInterface(Ci.nsIDocShell).contentViewer.DOMDocument;
}
}
}
var EXPORTED_SYMBOLS = ["cleanup", "init"];
// vim: set fdm=marker sw=4 ts=4 et:

View File

@@ -249,13 +249,7 @@ var Overlay = Module("Overlay", {
defineModule.loadLog.push(" from: " + util.fixURI(frame.filename) + ":" + frame.lineNumber);
let obj = defineModule.time(module.className, "init", module);
try {
delete modules[module.className];
modules[module.className] = obj;
}
catch (e) {
Class.replaceProperty(modules, module.className, obj);
}
Class.replaceProperty(modules, module.className, obj);
loaded[module.className] = true;
frob(module.className);