Isolate from custom extensions.js
This commit is contained in:
parent
81e2c10ed5
commit
c35e239555
@ -100,6 +100,7 @@ TreeStyleTabWindowHelper.overrideExtensionsBeforeBrowserInit = function TSTWH_ov
|
||||
|
||||
TreeStyleTabWindowHelper.overrideExtensionsAfterBrowserInit = function TSTWH_overrideExtensionsAfterBrowserInit() {
|
||||
var sv = this.service;
|
||||
var { AddonManager } = Component.utils.import('resource://gre/modules/AddonManager.jsm', {});
|
||||
|
||||
// Selection Links
|
||||
// https://addons.mozilla.org/firefox/addon/selection-links/
|
||||
@ -244,11 +245,12 @@ TreeStyleTabWindowHelper.overrideExtensionsAfterBrowserInit = function TSTWH_ove
|
||||
// Focus Last Selected Tab 0.9.5.x
|
||||
// http://www.gozer.org/mozilla/extensions/
|
||||
if (TreeStyleTabUtils.getTreePref('compatibility.FocusLastSelectedTab')) {
|
||||
sv.extensions.isAvailable('focuslastselectedtab@gozer.org', { ok : function() {
|
||||
AddonManager.getAddonById('focuslastselectedtab@gozer.org', function(aAddon) {
|
||||
if (aAddon && aAddon.isAvailable)
|
||||
TreeStyleTabService.registerTabFocusAllowance(function(aTabBrowser) {
|
||||
return !aTabBrowser.selectedTab.hasAttribute('lastselected');
|
||||
});
|
||||
}});
|
||||
});
|
||||
}
|
||||
|
||||
// LastTab
|
||||
@ -443,9 +445,10 @@ TreeStyleTabWindowHelper.overrideExtensionsAfterBrowserInit = function TSTWH_ove
|
||||
// Remove New Tab Button
|
||||
// https://addons.mozilla.org/firefox/addon/remove-new-tab-button/
|
||||
if (TreeStyleTabUtils.getTreePref('compatibility.RemoveNewTabButton')) {
|
||||
sv.extensions.isAvailable('remove-new-tab-button@forerunnerdesigns.com', { ok : function() {
|
||||
AddonManager.getAddonById('remove-new-tab-button@forerunnerdesigns.com', function(aAddon) {
|
||||
if (aAddon && aAddon.isAvailable)
|
||||
document.documentElement.setAttribute(TreeStyleTabService.kHIDE_NEWTAB, true);
|
||||
}});
|
||||
});
|
||||
}
|
||||
|
||||
// InstaClick
|
||||
@ -554,13 +557,6 @@ TreeStyleTabWindowHelper.overrideExtensionsDelayed = function TSTWH_overrideExte
|
||||
var t = gBrowser.treeStyleTab.getFirstTab(gBrowser);
|
||||
gBrowser.treeStyleTab.initTabAttributes(t);
|
||||
gBrowser.treeStyleTab.initTabContentsOrder(t);
|
||||
|
||||
gBrowser.__treestyletab__openInverseLink = gBrowser.openInverseLink;
|
||||
gBrowser.openInverseLink = function(...aArgs) {
|
||||
TreeStyleTabService.readyToOpenChildTabNow(gBrowser);
|
||||
return this.__treestyletab__openInverseLink(...aArgs);
|
||||
};
|
||||
|
||||
gBrowser.treeStyleTab.internallyTabMovingCount--;
|
||||
}
|
||||
|
||||
|
@ -54,10 +54,6 @@ XPCOMUtils.defineLazyGetter(this, 'prefs', function() {
|
||||
Cu.import('resource://treestyletab-modules/lib/prefs.js');
|
||||
return window['piro.sakura.ne.jp'].prefs;
|
||||
});
|
||||
XPCOMUtils.defineLazyGetter(this, 'extensions', function() {
|
||||
Cu.import('resource://treestyletab-modules/lib/extensions.js', {});
|
||||
return window['piro.sakura.ne.jp'].extensions;
|
||||
});
|
||||
XPCOMUtils.defineLazyGetter(this, 'animationManager', function() {
|
||||
Cu.import('resource://treestyletab-modules/lib/animationManager.js', {});
|
||||
return window['piro.sakura.ne.jp'].animationManager;
|
||||
@ -117,7 +113,6 @@ var TreeStyleTabBase = inherit(TreeStyleTabConstants, {
|
||||
return SessionStore;
|
||||
},
|
||||
|
||||
get extensions() { return extensions; },
|
||||
get animationManager() { return animationManager; },
|
||||
get autoScroll() { return autoScroll; },
|
||||
get AeroPeek() { return AeroPeek; }, // for Windows
|
||||
|
@ -50,6 +50,7 @@ Cu.import('resource://treestyletab-modules/ReferenceCounter.js');
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, 'Services', 'resource://gre/modules/Services.jsm');
|
||||
XPCOMUtils.defineLazyModuleGetter(this, 'Promise', 'resource://gre/modules/Promise.jsm');
|
||||
XPCOMUtils.defineLazyModuleGetter(this, 'AddonManager', 'resource://gre/modules/AddonManager.jsm');
|
||||
XPCOMUtils.defineLazyModuleGetter(this, 'utils', 'resource://treestyletab-modules/utils.js', 'TreeStyleTabUtils');
|
||||
XPCOMUtils.defineLazyModuleGetter(this, 'FullTooltipManager', 'resource://treestyletab-modules/fullTooltip.js');
|
||||
XPCOMUtils.defineLazyModuleGetter(this, 'TabbarDNDObserver', 'resource://treestyletab-modules/tabbarDNDObserver.js');
|
||||
@ -2970,16 +2971,15 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
|
||||
prefs.getPref('extensions.informationaltab.thumbnail.enabled') &&
|
||||
prefs.getPref('extensions.informationaltab.thumbnail.position') < 100
|
||||
) {
|
||||
let self = this;
|
||||
this.extensions.isAvailable('informationaltab@piro.sakura.ne.jp', {
|
||||
ok : function() {
|
||||
AddonManager.getAddonByID('informationaltab@piro.sakura.ne.jp', (function(aAddon) {
|
||||
if (aAddon) {
|
||||
aStyle = 'retro';
|
||||
self.setTabbrowserAttribute(self.kTWISTY_STYLE, aStyle);
|
||||
},
|
||||
ng : function() {
|
||||
self.setTabbrowserAttribute(self.kTWISTY_STYLE, aStyle);
|
||||
this.setTabbrowserAttribute(this.kTWISTY_STYLE, aStyle);
|
||||
}
|
||||
});
|
||||
else {
|
||||
this.setTabbrowserAttribute(this.kTWISTY_STYLE, aStyle);
|
||||
}
|
||||
}).bind(this));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1,161 +0,0 @@
|
||||
/*
|
||||
Extensions Compatibility Library
|
||||
|
||||
Usage:
|
||||
var extensions = window['piro.sakura.ne.jp'].extensions;
|
||||
extensions.isAvailable('my.extension.id@example.com', {
|
||||
ok : function() { extensions.goToOptions('my.extension.id@example.com'); },
|
||||
ng : function() { alert('NOT INSTALLED'); }
|
||||
});
|
||||
extensions.isInstalled('my.extension.id@example.com', {
|
||||
ok : function(aDir) {
|
||||
var dir = aDir; // nsILocalFile
|
||||
}
|
||||
});
|
||||
|
||||
license: The MIT License, Copyright (c) 2009-2016 YUKI "Piro" Hiroshi
|
||||
original:
|
||||
http://github.com/piroor/fxaddonlib-extensions
|
||||
*/
|
||||
|
||||
/* To work as a JS Code Module */
|
||||
if (typeof window == 'undefined' ||
|
||||
(window && typeof window.constructor == 'function')) {
|
||||
this.EXPORTED_SYMBOLS = ['extensions'];
|
||||
|
||||
// If namespace.jsm is available, export symbols to the shared namespace.
|
||||
// See: http://github.com/piroor/fxaddonlibs/blob/master/namespace.jsm
|
||||
try {
|
||||
let ns = {};
|
||||
Components.utils.import('resource://treestyletab-modules/lib/namespace.jsm', ns);
|
||||
/* var */ window = ns.getNamespaceFor('piro.sakura.ne.jp');
|
||||
}
|
||||
catch(e) {
|
||||
window = {};
|
||||
}
|
||||
}
|
||||
|
||||
(function() {
|
||||
const currentRevision = 13;
|
||||
|
||||
if (!('piro.sakura.ne.jp' in window)) window['piro.sakura.ne.jp'] = {};
|
||||
|
||||
var loadedRevision = 'extensions' in window['piro.sakura.ne.jp'] ?
|
||||
window['piro.sakura.ne.jp'].extensions.revision :
|
||||
0 ;
|
||||
if (loadedRevision && loadedRevision > currentRevision) {
|
||||
return;
|
||||
}
|
||||
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
|
||||
var { AddonManager } = Components.utils.import('resource://gre/modules/AddonManager.jsm', {});
|
||||
|
||||
window['piro.sakura.ne.jp'].extensions = {
|
||||
revision : currentRevision,
|
||||
|
||||
_formatCallbacks : function(aOKCallback, aNGCallback)
|
||||
{
|
||||
var callbacks = {
|
||||
ok : aOKCallback,
|
||||
ng : aNGCallback
|
||||
};
|
||||
if (typeof aOKCallback != 'function')
|
||||
callbacks = aOKCallback;
|
||||
|
||||
if (!('ok' in callbacks) || typeof callbacks.ok != 'function')
|
||||
callbacks.ok = function() {};
|
||||
if (!('ng' in callbacks) || typeof callbacks.ng != 'function')
|
||||
callbacks.ng = function() {};
|
||||
|
||||
return callbacks;
|
||||
},
|
||||
|
||||
|
||||
isAvailable : function(aId, aOKCallback, aNGCallback)
|
||||
{
|
||||
return this.isEnabled(aId, aOKCallback, aNGCallback);
|
||||
},
|
||||
|
||||
|
||||
isInstalled : function(aId, aOKCallback, aNGCallback)
|
||||
{
|
||||
var callbacks = this._formatCallbacks(aOKCallback, aNGCallback);
|
||||
AddonManager.getAddonByID(aId, function(aAddon) {
|
||||
callbacks[aAddon ? 'ok' : 'ng']();
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
isEnabled : function(aId, aOKCallback, aNGCallback)
|
||||
{
|
||||
var callbacks = this._formatCallbacks(aOKCallback, aNGCallback);
|
||||
AddonManager.getAddonByID(aId, function(aAddon) {
|
||||
callbacks[aAddon && aAddon.isActive ? 'ok' : 'ng']();
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
getInstalledLocation : function(aId, aCallback)
|
||||
{
|
||||
AddonManager.getAddonByID(aId, function(aAddon) {
|
||||
var location = null;
|
||||
if (aAddon)
|
||||
location = aAddon.getResourceURI('/').QueryInterface(Ci.nsIFileURL).file.clone();
|
||||
aCallback(location);
|
||||
});
|
||||
},
|
||||
|
||||
getVersion : function(aId, aCallback)
|
||||
{
|
||||
AddonManager.getAddonByID(aId, function(aAddon) {
|
||||
aCallback(aAddon ? aAddon.version : null );
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
goToOptions : function(aId, aOwnerWindow)
|
||||
{
|
||||
var self = this;
|
||||
var callback = function(aURI) {
|
||||
self.goToOptionsInternal(aURI, aOwnerWindow);
|
||||
};
|
||||
AddonManager.getAddonByID(aId, function(aAddon) {
|
||||
callback(aAddon && aAddon.isActive ? aAddon.optionsURL : null );
|
||||
});
|
||||
},
|
||||
goToOptionsInternal : function(aURI, aOwnerWindow)
|
||||
{
|
||||
if (!aURI) return;
|
||||
|
||||
var windows = this._WindowMediator.getEnumerator(null);
|
||||
while (windows.hasMoreElements())
|
||||
{
|
||||
let win = windows.getNext();
|
||||
if (win.location.href == aURI) {
|
||||
win.focus();
|
||||
return;
|
||||
}
|
||||
}
|
||||
var instantApply = false;
|
||||
try {
|
||||
instantApply = Cc['@mozilla.org/preferences;1']
|
||||
.getService(Ci.nsIPrefBranch)
|
||||
.getBoolPref('browser.preferences.instantApply');
|
||||
}
|
||||
catch(e) {
|
||||
}
|
||||
(aOwnerWindow || window).openDialog(
|
||||
aURI,
|
||||
'',
|
||||
'chrome,titlebar,toolbar,centerscreen,' + (instantApply ? 'dialog=no' : 'modal' )
|
||||
);
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
if (window != this) { // work as a JS Code Module
|
||||
this.extensions = window['piro.sakura.ne.jp'].extensions;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user