summaryrefslogtreecommitdiff
path: root/b2g/components/SystemMessageGlue.js
blob: f7c0b3677331412ca9e350c41c80038a5ba300c2 (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
/* 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"

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

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

XPCOMUtils.defineLazyModuleGetter(this, "SystemAppProxy",
                                  "resource://gre/modules/SystemAppProxy.jsm");

function SystemMessageGlue() {
}

SystemMessageGlue.prototype = {
  openApp: function(aPageURL, aManifestURL, aType, aTarget, aShowApp,
                    aOnlyShowApp, aExtra) {
    let payload = { url: aPageURL,
                    manifestURL: aManifestURL,
                    isActivity: (aType == "activity"),
                    target: aTarget,
                    showApp: aShowApp,
                    onlyShowApp: aOnlyShowApp,
                    expectingSystemMessage: true,
                    extra: aExtra };

    // |SystemAppProxy| will queue "open-app" events for non-activity system
    // messages without actually sending them until the system app is ready.
    SystemAppProxy._sendCustomEvent("open-app", payload, (aType == "activity"));
  },

  classID: Components.ID("{2846f034-e614-11e3-93cd-74d02b97e723}"),

  QueryInterface: XPCOMUtils.generateQI([Ci.nsISystemMessageGlue])
};

this.NSGetFactory = XPCOMUtils.generateNSGetFactory([SystemMessageGlue]);