2012-05-16 10:40:47 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
"use strict"
|
|
|
|
|
|
|
|
function debug(s) {
|
2012-08-28 02:43:57 +00:00
|
|
|
//dump("-*- AppsService.js: " + s + "\n");
|
2012-05-16 10:40:47 +00:00
|
|
|
}
|
|
|
|
|
2012-07-26 16:30:38 +00:00
|
|
|
const Cc = Components.classes;
|
2012-05-16 10:40:47 +00:00
|
|
|
const Ci = Components.interfaces;
|
|
|
|
const Cu = Components.utils;
|
|
|
|
|
|
|
|
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
|
|
|
|
2012-07-26 16:30:38 +00:00
|
|
|
const APPS_SERVICE_CID = Components.ID("{05072afa-92fe-45bf-ae22-39b69c117058}");
|
2012-05-16 10:40:47 +00:00
|
|
|
|
|
|
|
function AppsService()
|
|
|
|
{
|
|
|
|
debug("AppsService Constructor");
|
2012-08-28 02:43:57 +00:00
|
|
|
let inParent = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime)
|
|
|
|
.processType == Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
|
|
|
|
debug("inParent: " + inParent);
|
|
|
|
Cu.import(inParent ? "resource://gre/modules/Webapps.jsm" :
|
|
|
|
"resource://gre/modules/AppsServiceChild.jsm");
|
2012-05-16 10:40:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
AppsService.prototype = {
|
2012-10-19 10:43:17 +00:00
|
|
|
|
|
|
|
getCSPByLocalId: function getCSPByLocalId(localId) {
|
|
|
|
debug("GetCSPByLocalId( " + localId + " )");
|
|
|
|
return DOMApplicationRegistry.getCSPByLocalId(localId);
|
|
|
|
},
|
|
|
|
|
2012-05-16 10:40:47 +00:00
|
|
|
getAppByManifestURL: function getAppByManifestURL(aManifestURL) {
|
|
|
|
debug("GetAppByManifestURL( " + aManifestURL + " )");
|
2012-08-28 02:43:57 +00:00
|
|
|
return DOMApplicationRegistry.getAppByManifestURL(aManifestURL);
|
2012-05-16 10:40:47 +00:00
|
|
|
},
|
|
|
|
|
2012-07-09 10:25:41 +00:00
|
|
|
getAppLocalIdByManifestURL: function getAppLocalIdByManifestURL(aManifestURL) {
|
|
|
|
debug("getAppLocalIdByManifestURL( " + aManifestURL + " )");
|
2012-08-28 02:43:57 +00:00
|
|
|
return DOMApplicationRegistry.getAppLocalIdByManifestURL(aManifestURL);
|
2012-07-09 10:25:41 +00:00
|
|
|
},
|
|
|
|
|
2012-08-08 16:41:47 +00:00
|
|
|
getAppByLocalId: function getAppByLocalId(aLocalId) {
|
|
|
|
debug("getAppByLocalId( " + aLocalId + " )");
|
2012-08-28 02:43:57 +00:00
|
|
|
return DOMApplicationRegistry.getAppByLocalId(aLocalId);
|
2012-08-08 16:41:47 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
getManifestURLByLocalId: function getManifestURLByLocalId(aLocalId) {
|
|
|
|
debug("getManifestURLByLocalId( " + aLocalId + " )");
|
2012-08-28 02:43:57 +00:00
|
|
|
return DOMApplicationRegistry.getManifestURLByLocalId(aLocalId);
|
2012-08-08 16:41:47 +00:00
|
|
|
},
|
|
|
|
|
2012-08-31 14:34:28 +00:00
|
|
|
getAppFromObserverMessage: function getAppFromObserverMessage(aMessage) {
|
|
|
|
debug("getAppFromObserverMessage( " + aMessage + " )");
|
|
|
|
return DOMApplicationRegistry.getAppFromObserverMessage(aMessage);
|
|
|
|
},
|
|
|
|
|
2012-12-22 13:56:21 +00:00
|
|
|
getCoreAppsBasePath: function getCoreAppsBasePath() {
|
|
|
|
debug("getCoreAppsBasePath()");
|
|
|
|
return DOMApplicationRegistry.getCoreAppsBasePath();
|
|
|
|
},
|
|
|
|
|
|
|
|
getWebAppsBasePath: function getWebAppsBasePath() {
|
|
|
|
debug("getWebAppsBasePath()");
|
|
|
|
return DOMApplicationRegistry.getWebAppsBasePath();
|
|
|
|
},
|
|
|
|
|
2012-05-16 10:40:47 +00:00
|
|
|
classID : APPS_SERVICE_CID,
|
2012-07-26 16:30:38 +00:00
|
|
|
QueryInterface : XPCOMUtils.generateQI([Ci.nsIAppsService])
|
2012-05-16 10:40:47 +00:00
|
|
|
}
|
|
|
|
|
2012-10-31 16:13:28 +00:00
|
|
|
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([AppsService])
|