AppsService.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  3. * You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. "use strict"
  5. function debug(s) {
  6. //dump("-*- AppsService.js: " + s + "\n");
  7. }
  8. const Cc = Components.classes;
  9. const Ci = Components.interfaces;
  10. const Cu = Components.utils;
  11. const Cr = Components.results;
  12. Cu.import("resource://gre/modules/XPCOMUtils.jsm");
  13. Cu.import("resource://gre/modules/Services.jsm");
  14. Cu.import("resource://gre/modules/Promise.jsm");
  15. const APPS_SERVICE_CID = Components.ID("{05072afa-92fe-45bf-ae22-39b69c117058}");
  16. function AppsService()
  17. {
  18. debug("AppsService Constructor");
  19. this.inParent = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime)
  20. .processType == Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
  21. debug("inParent: " + this.inParent);
  22. if (!this.inParent) {
  23. Cu.import("resource://gre/modules/AppsServiceChild.jsm");
  24. }
  25. }
  26. AppsService.prototype = {
  27. isInvalidId: function(localId) {
  28. return (localId == Ci.nsIScriptSecurityManager.NO_APP_ID ||
  29. localId == Ci.nsIScriptSecurityManager.UNKNOWN_APP_ID);
  30. },
  31. getAppByManifestURL: function getAppByManifestURL(aManifestURL) {
  32. debug("GetAppByManifestURL( " + aManifestURL + " )");
  33. throw Cr.NS_ERROR_NOT_IMPLEMENTED;
  34. },
  35. getManifestFor: function getManifestFor(aManifestURL) {
  36. debug("getManifestFor(" + aManifestURL + ")");
  37. if (this.inParent) {
  38. throw Cr.NS_ERROR_NOT_IMPLEMENTED;
  39. } else {
  40. return Promise.reject(
  41. new Error("Calling getManifestFor() from child is not supported"));
  42. }
  43. },
  44. getAppLocalIdByManifestURL: function getAppLocalIdByManifestURL(aManifestURL) {
  45. debug("getAppLocalIdByManifestURL( " + aManifestURL + " )");
  46. throw Cr.NS_ERROR_NOT_IMPLEMENTED;
  47. },
  48. getAppLocalIdByStoreId: function getAppLocalIdByStoreId(aStoreId) {
  49. debug("getAppLocalIdByStoreId( " + aStoreId + " )");
  50. throw Cr.NS_ERROR_NOT_IMPLEMENTED;
  51. },
  52. getAppByLocalId: function getAppByLocalId(aLocalId) {
  53. debug("getAppByLocalId( " + aLocalId + " )");
  54. if (this.isInvalidId(aLocalId)) {
  55. return null;
  56. }
  57. throw Cr.NS_ERROR_NOT_IMPLEMENTED;
  58. },
  59. getManifestURLByLocalId: function getManifestURLByLocalId(aLocalId) {
  60. debug("getManifestURLByLocalId( " + aLocalId + " )");
  61. if (this.isInvalidId(aLocalId)) {
  62. return null;
  63. }
  64. throw Cr.NS_ERROR_NOT_IMPLEMENTED;
  65. },
  66. getCoreAppsBasePath: function getCoreAppsBasePath() {
  67. debug("getCoreAppsBasePath()");
  68. throw Cr.NS_ERROR_NOT_IMPLEMENTED;
  69. },
  70. getWebAppsBasePath: function getWebAppsBasePath() {
  71. debug("getWebAppsBasePath()");
  72. throw Cr.NS_ERROR_NOT_IMPLEMENTED;
  73. },
  74. areAnyAppsInstalled: function() {
  75. throw Cr.NS_ERROR_NOT_IMPLEMENTED;
  76. },
  77. getAppInfo: function getAppInfo(aAppId) {
  78. debug("getAppInfo()");
  79. throw Cr.NS_ERROR_NOT_IMPLEMENTED;
  80. },
  81. getScopeByLocalId: function(aLocalId) {
  82. debug("getScopeByLocalId( " + aLocalId + " )");
  83. if (this.isInvalidId(aLocalId)) {
  84. return null;
  85. }
  86. // TODO : implement properly!
  87. // We just return null for now to not break PushService.jsm
  88. return null;
  89. },
  90. classID : APPS_SERVICE_CID,
  91. QueryInterface : XPCOMUtils.generateQI([Ci.nsIAppsService])
  92. }
  93. this.NSGetFactory = XPCOMUtils.generateNSGetFactory([AppsService])