summaryrefslogtreecommitdiffstats
path: root/dom/apps/AppsService.js
blob: e0a7ea041c361d12591407dba5aeefb8af5506b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/* 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) {
  //dump("-*- AppsService.js: " + s + "\n");
}

const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
const Cr = Components.results;

Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/Promise.jsm");

const APPS_SERVICE_CID = Components.ID("{05072afa-92fe-45bf-ae22-39b69c117058}");

function AppsService()
{
  debug("AppsService Constructor");
  this.inParent = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime)
                    .processType == Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
  debug("inParent: " + this.inParent);
  if (!this.inParent) {
    Cu.import("resource://gre/modules/AppsServiceChild.jsm");
  }
}

AppsService.prototype = {

  isInvalidId: function(localId) {
    return (localId == Ci.nsIScriptSecurityManager.NO_APP_ID ||
            localId == Ci.nsIScriptSecurityManager.UNKNOWN_APP_ID);
  },

  getAppByManifestURL: function getAppByManifestURL(aManifestURL) {
    debug("GetAppByManifestURL( " + aManifestURL + " )");
    throw Cr.NS_ERROR_NOT_IMPLEMENTED;
  },

  getManifestFor: function getManifestFor(aManifestURL) {
    debug("getManifestFor(" + aManifestURL + ")");
    if (this.inParent) {
      throw Cr.NS_ERROR_NOT_IMPLEMENTED;
    } else {
      return Promise.reject(
        new Error("Calling getManifestFor() from child is not supported"));
    }
  },

  getAppLocalIdByManifestURL: function getAppLocalIdByManifestURL(aManifestURL) {
    debug("getAppLocalIdByManifestURL( " + aManifestURL + " )");
    throw Cr.NS_ERROR_NOT_IMPLEMENTED;
  },

  getAppLocalIdByStoreId: function getAppLocalIdByStoreId(aStoreId) {
    debug("getAppLocalIdByStoreId( " + aStoreId + " )");
    throw Cr.NS_ERROR_NOT_IMPLEMENTED;
  },

  getAppByLocalId: function getAppByLocalId(aLocalId) {
    debug("getAppByLocalId( " + aLocalId + " )");
    if (this.isInvalidId(aLocalId)) {
      return null;
    }
    throw Cr.NS_ERROR_NOT_IMPLEMENTED;
  },

  getManifestURLByLocalId: function getManifestURLByLocalId(aLocalId) {
    debug("getManifestURLByLocalId( " + aLocalId + " )");
    if (this.isInvalidId(aLocalId)) {
      return null;
    }
    throw Cr.NS_ERROR_NOT_IMPLEMENTED;
  },

  getCoreAppsBasePath: function getCoreAppsBasePath() {
    debug("getCoreAppsBasePath()");
    throw Cr.NS_ERROR_NOT_IMPLEMENTED;
  },

  getWebAppsBasePath: function getWebAppsBasePath() {
    debug("getWebAppsBasePath()");
    throw Cr.NS_ERROR_NOT_IMPLEMENTED;
  },

  areAnyAppsInstalled: function() {
    throw Cr.NS_ERROR_NOT_IMPLEMENTED;
  },

  getAppInfo: function getAppInfo(aAppId) {
    debug("getAppInfo()");
    throw Cr.NS_ERROR_NOT_IMPLEMENTED;
  },

  getScopeByLocalId: function(aLocalId) {
    debug("getScopeByLocalId( " + aLocalId + " )");
    if (this.isInvalidId(aLocalId)) {
      return null;
    }
    // TODO : implement properly!
    // We just return null for now to not break PushService.jsm
    return null;
  },

  classID : APPS_SERVICE_CID,
  QueryInterface : XPCOMUtils.generateQI([Ci.nsIAppsService])
}

this.NSGetFactory = XPCOMUtils.generateNSGetFactory([AppsService])