fix focus problem http://bugs.conkeror.org/issue263
[conkeror.git] / modules / extension.js
blob8a0beda1ae7bf79a43a19fcb2a272b48997c7090
1 /**
2  * (C) Copyright 2004-2007 Shawn Betts
3  * (C) Copyright 2007-2009 John J. Foerch
4  * (C) Copyright 2007-2008 Jeremy Maitin-Shepard
5  *
6  * Use, modification, and distribution are subject to the terms specified in the
7  * COPYING file.
8 **/
10 in_module(null);
12 const PREFIX_ITEM_URI = "urn:mozilla:item:";
13 const PREFIX_NS_EM = "http://www.mozilla.org/2004/em-rdf#";
15 var extension_manager = Cc["@mozilla.org/extensions/manager;1"]
16     .getService(Ci.nsIExtensionManager);
18 function get_extension_rdf_property (id, name, type) {
19     const rdf_service = Cc["@mozilla.org/rdf/rdf-service;1"]
20         .getService(Ci.nsIRDFService);
21     var value = extension_manager.datasource.GetTarget(
22         rdf_service.GetResource(PREFIX_ITEM_URI + id),
23         rdf_service.GetResource(PREFIX_NS_EM + name),
24         true);
25     if (value == null)
26         return null;
27     return value.QueryInterface(type || Ci.nsIRDFLiteral).Value;
30 function get_extension_update_item (id) {
31     return extension_manager.getItemForID(id);
34 function extension_info (id) {
35     this.id = id;
37 extension_info.prototype = {
38     // Returns the nsIUpdateItem object associated with this extension
39     get update_item () { return get_extension_update_item(this.id); },
41     get_rdf_property : function (name, type) {
42         return get_extension_rdf_property(this.id, name, type);
43     },
45     // RDF properties
46     get isDisabled () { return this.get_rdf_property("isDisabled"); },
47     get aboutURL () { return this.get_rdf_property("aboutURL"); },
48     get addonID () { return this.get_rdf_property("addonID"); },
49     get availableUpdateURL () { return this.get_rdf_property("availableUpdateURL"); },
50     get availableUpdateVersion () { return this.get_rdf_property("availableUpdateVersion"); },
51     get blocklisted () { return this.get_rdf_property("blocklisted"); },
52     get compatible () { return this.get_rdf_property("compatible"); },
53     get description () { return this.get_rdf_property("description"); },
54     get downloadURL () { return this.get_rdf_property("downloadURL"); },
55     get isDisabled () { return this.get_rdf_property("isDisabled"); },
56     get hidden () { return this.get_rdf_property("hidden"); },
57     get homepageURL () { return this.get_rdf_property("homepageURL"); },
58     get iconURL () { return this.get_rdf_property("iconURL"); },
59     get internalName () { return this.get_rdf_property("internalName"); },
60     get locked () { return this.get_rdf_property("locked"); },
61     get name () { return this.get_rdf_property("name"); },
62     get optionsURL () { return this.get_rdf_property("optionsURL"); },
63     get opType () { return this.get_rdf_property("opType"); },
64     get plugin () { return this.get_rdf_property("plugin"); },
65     get previewImage () { return this.get_rdf_property("previewImage"); },
66     get satisfiesDependencies () { return this.get_rdf_property("satisfiesDependencies"); },
67     get providesUpdatesSecurely () { return this.get_rdf_property("providesUpdatesSecurely"); },
68     get type () { return this.get_rdf_property("type", Ci.nsIRDFInt); },
69     get updateable () { return this.get_rdf_property("updateable"); },
70     get updateURL () { return this.get_rdf_property("updateURL"); },
71     get version () { return this.get_rdf_property("version"); }
74 function extension_is_enabled (id) {
75     var info = new extension_info(id);
76     return info.update_item && (info.isDisabled == "false");
79 provide("extension");