アドオンマネージャの仕様変更に追従( https://bugzilla.mozilla.org/show_bug.cgi?id=550048 )
git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@6650 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
parent
ffd677bef9
commit
aee349e41c
@ -8,14 +8,15 @@
|
|||||||
// if (window['piro.sakura.ne.jp'].extensions.isInstalled('my.extension.id@example.com') &&
|
// if (window['piro.sakura.ne.jp'].extensions.isInstalled('my.extension.id@example.com') &&
|
||||||
// window['piro.sakura.ne.jp'].extensions.isEnabled('my.extension.id@example.com'))
|
// window['piro.sakura.ne.jp'].extensions.isEnabled('my.extension.id@example.com'))
|
||||||
// window['piro.sakura.ne.jp'].extensions.goToOptions('my.extension.id@example.com');
|
// window['piro.sakura.ne.jp'].extensions.goToOptions('my.extension.id@example.com');
|
||||||
|
var dir = window['piro.sakura.ne.jp'].extensions.getInstalledLocation('my.extension.id@example.com');
|
||||||
|
|
||||||
lisence: The MIT License, Copyright (c) 2009 SHIMODA "Piro" Hiroshi
|
lisence: The MIT License, Copyright (c) 2009-2010 SHIMODA "Piro" Hiroshi
|
||||||
http://www.cozmixng.org/repos/piro/fx3-compatibility-lib/trunk/license.txt
|
http://www.cozmixng.org/repos/piro/fx3-compatibility-lib/trunk/license.txt
|
||||||
original:
|
original:
|
||||||
http://www.cozmixng.org/repos/piro/fx3-compatibility-lib/trunk/extensions.js
|
http://www.cozmixng.org/repos/piro/fx3-compatibility-lib/trunk/extensions.js
|
||||||
*/
|
*/
|
||||||
(function() {
|
(function() {
|
||||||
const currentRevision = 2;
|
const currentRevision = 5;
|
||||||
|
|
||||||
if (!('piro.sakura.ne.jp' in window)) window['piro.sakura.ne.jp'] = {};
|
if (!('piro.sakura.ne.jp' in window)) window['piro.sakura.ne.jp'] = {};
|
||||||
|
|
||||||
@ -26,29 +27,78 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Cc = Components.classes;
|
||||||
|
const Ci = Components.interfaces;
|
||||||
|
|
||||||
|
// Firefox 3.7 or later
|
||||||
|
var AM = {};
|
||||||
|
if ('@mozilla.org/addons/integration;1' in Components.classes)
|
||||||
|
Components.utils.import('resource://gre/modules/AddonManager.jsm', AM);
|
||||||
|
|
||||||
window['piro.sakura.ne.jp'].extensions = {
|
window['piro.sakura.ne.jp'].extensions = {
|
||||||
revision : currentRevision,
|
revision : currentRevision,
|
||||||
|
|
||||||
ExtensionManager : Components.classes['@mozilla.org/extensions/manager;1']
|
// Firefox 3.7 or later
|
||||||
.getService(Components.interfaces.nsIExtensionManager),
|
getInstalledAddon : function(aId)
|
||||||
RDF : Components.classes['@mozilla.org/rdf/rdf-service;1']
|
{
|
||||||
.getService(Components.interfaces.nsIRDFService),
|
var addon;
|
||||||
WindowMediator : Components.classes['@mozilla.org/appshell/window-mediator;1']
|
AM.AddonManager.getAddonByID(aId, function(aAddon) {
|
||||||
.getService(Components.interfaces.nsIWindowMediator),
|
addon = aAddon;
|
||||||
Prefs : Components.classes['@mozilla.org/preferences;1']
|
});
|
||||||
.getService(Components.interfaces.nsIPrefBranch),
|
var thread = Components.classes['@mozilla.org/thread-manager;1']
|
||||||
|
.getService()
|
||||||
|
.mainThread;
|
||||||
|
while (addon === void(0)) {
|
||||||
|
thread.processNextEvent(true);
|
||||||
|
}
|
||||||
|
return addon;
|
||||||
|
},
|
||||||
|
|
||||||
|
// Firefox 3.6 or older
|
||||||
|
ExtensionManager : ('@mozilla.org/extensions/manager;1' in Cc) ?
|
||||||
|
Cc['@mozilla.org/extensions/manager;1']
|
||||||
|
.getService(Ci.nsIExtensionManager) :
|
||||||
|
null,
|
||||||
|
RDF : Cc['@mozilla.org/rdf/rdf-service;1']
|
||||||
|
.getService(Ci.nsIRDFService),
|
||||||
|
WindowMediator : Cc['@mozilla.org/appshell/window-mediator;1']
|
||||||
|
.getService(Ci.nsIWindowMediator),
|
||||||
|
Prefs : Cc['@mozilla.org/preferences;1']
|
||||||
|
.getService(Ci.nsIPrefBranch),
|
||||||
|
|
||||||
isAvailable : function(aId)
|
isAvailable : function(aId)
|
||||||
{
|
{
|
||||||
return this.isInstalled(aId) && this.isEnabled(aId);
|
return this.ExtensionManager ? this.isAvailable_EM(aId) : this.isAvailable_AM(aId) ;
|
||||||
|
},
|
||||||
|
isAvailable_EM : function(aId)
|
||||||
|
{
|
||||||
|
return (this.isInstalled_EM(aId) && this.isEnabled_EM(aId)) ? true : false ;
|
||||||
|
},
|
||||||
|
isAvailable_AM : function(aId)
|
||||||
|
{
|
||||||
|
var addon = this.getInstalledAddon(aId);
|
||||||
|
if (!addon) return false;
|
||||||
|
return addon.isActive;
|
||||||
},
|
},
|
||||||
|
|
||||||
isInstalled : function(aId)
|
isInstalled : function(aId)
|
||||||
{
|
{
|
||||||
return this.ExtensionManager.getInstallLocation(aId);
|
return this.ExtensionManager ? this.isInstalled_EM(aId) : this.isInstalled_AM(aId) ;
|
||||||
|
},
|
||||||
|
isInstalled_EM : function(aId)
|
||||||
|
{
|
||||||
|
return this.ExtensionManager.getInstallLocation(aId) ? true : false ;
|
||||||
|
},
|
||||||
|
isInstalled_AM : function(aId)
|
||||||
|
{
|
||||||
|
return this.getInstalledAddon(aId) ? true : false ;
|
||||||
},
|
},
|
||||||
|
|
||||||
isEnabled : function(aId)
|
isEnabled : function(aId)
|
||||||
|
{
|
||||||
|
return this.ExtensionManager ? this.isEnabled_EM(aId) : this.isEnabled_AM(aId) ;
|
||||||
|
},
|
||||||
|
isEnabled_EM : function(aId)
|
||||||
{
|
{
|
||||||
var res = this.RDF.GetResource('urn:mozilla:item:'+aId);
|
var res = this.RDF.GetResource('urn:mozilla:item:'+aId);
|
||||||
var appDisabled = false;
|
var appDisabled = false;
|
||||||
@ -57,7 +107,7 @@
|
|||||||
res,
|
res,
|
||||||
this.RDF.GetResource('http://www.mozilla.org/2004/em-rdf#appDisabled'),
|
this.RDF.GetResource('http://www.mozilla.org/2004/em-rdf#appDisabled'),
|
||||||
true
|
true
|
||||||
).QueryInterface(Components.interfaces.nsIRDFLiteral)
|
).QueryInterface(Ci.nsIRDFLiteral)
|
||||||
.Value == 'true';
|
.Value == 'true';
|
||||||
}
|
}
|
||||||
catch(e) {
|
catch(e) {
|
||||||
@ -68,7 +118,7 @@
|
|||||||
res,
|
res,
|
||||||
this.RDF.GetResource('http://www.mozilla.org/2004/em-rdf#userDisabled'),
|
this.RDF.GetResource('http://www.mozilla.org/2004/em-rdf#userDisabled'),
|
||||||
true
|
true
|
||||||
).QueryInterface(Components.interfaces.nsIRDFLiteral)
|
).QueryInterface(Ci.nsIRDFLiteral)
|
||||||
.Value == 'true';
|
.Value == 'true';
|
||||||
}
|
}
|
||||||
catch(e) {
|
catch(e) {
|
||||||
@ -76,21 +126,14 @@
|
|||||||
|
|
||||||
return !appDisabled && !userDisabled;
|
return !appDisabled && !userDisabled;
|
||||||
},
|
},
|
||||||
|
isEnabled_AM : function(aId)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
|
||||||
goToOptions : function(aId)
|
goToOptions : function(aId)
|
||||||
{
|
{
|
||||||
var res = this.RDF.GetResource('urn:mozilla:item:'+aId);
|
var uri = this.ExtensionManager ? this.getOptionsURI_EM(aId) : this.getOptionsURI_AM(aId) ;
|
||||||
var uri;
|
|
||||||
try {
|
|
||||||
uri = this.ExtensionManager.datasource.GetTarget(
|
|
||||||
res,
|
|
||||||
this.RDF.GetResource('http://www.mozilla.org/2004/em-rdf#optionsURL'),
|
|
||||||
true
|
|
||||||
).QueryInterface(Components.interfaces.nsIRDFLiteral)
|
|
||||||
.Value;
|
|
||||||
}
|
|
||||||
catch(e) {
|
|
||||||
}
|
|
||||||
if (!uri) return;
|
if (!uri) return;
|
||||||
|
|
||||||
var windows = this.WindowMediator.getEnumerator(null);
|
var windows = this.WindowMediator.getEnumerator(null);
|
||||||
@ -113,6 +156,28 @@
|
|||||||
'',
|
'',
|
||||||
'chrome,titlebar,toolbar,centerscreen,' + (instantApply ? 'dialog=no' : 'modal' )
|
'chrome,titlebar,toolbar,centerscreen,' + (instantApply ? 'dialog=no' : 'modal' )
|
||||||
);
|
);
|
||||||
|
},
|
||||||
|
getOptionsURI_EM : function(aId)
|
||||||
|
{
|
||||||
|
var res = this.RDF.GetResource('urn:mozilla:item:'+aId);
|
||||||
|
var uri;
|
||||||
|
try {
|
||||||
|
uri = this.ExtensionManager.datasource.GetTarget(
|
||||||
|
res,
|
||||||
|
this.RDF.GetResource('http://www.mozilla.org/2004/em-rdf#optionsURL'),
|
||||||
|
true
|
||||||
|
).QueryInterface(Ci.nsIRDFLiteral)
|
||||||
|
.Value;
|
||||||
|
}
|
||||||
|
catch(e) {
|
||||||
|
}
|
||||||
|
return uri;
|
||||||
|
},
|
||||||
|
getOptionsURI_AM : function(aId)
|
||||||
|
{
|
||||||
|
var addon = this.getInstalledAddon(aId);
|
||||||
|
if (!addon || !addon.isActive) return null;
|
||||||
|
return addon.optionsURL;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user