dom/push/src/PushServiceLauncher.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/push/src/PushServiceLauncher.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,43 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     1.6 + * You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +"use strict";
     1.9 +
    1.10 +const Cc = Components.classes;
    1.11 +const Ci = Components.interfaces;
    1.12 +const Cu = Components.utils;
    1.13 +const Cr = Components.results;
    1.14 +
    1.15 +Cu.import("resource://gre/modules/XPCOMUtils.jsm");
    1.16 +Cu.import("resource://gre/modules/Services.jsm");
    1.17 +
    1.18 +function PushServiceLauncher() {
    1.19 +};
    1.20 +
    1.21 +PushServiceLauncher.prototype = {
    1.22 +  classID: Components.ID("{4b8caa3b-3c58-4f3c-a7f5-7bd9cb24c11d}"),
    1.23 +
    1.24 +  contractID: "@mozilla.org/push/ServiceLauncher;1",
    1.25 +
    1.26 +  QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver,
    1.27 +                                         Ci.nsISupportsWeakReference]),
    1.28 +
    1.29 +  observe: function observe(subject, topic, data) {
    1.30 +    switch (topic) {
    1.31 +      case "app-startup":
    1.32 +        Services.obs.addObserver(this, "final-ui-startup", true);
    1.33 +        break;
    1.34 +      case "final-ui-startup":
    1.35 +        Services.obs.removeObserver(this, "final-ui-startup");
    1.36 +        if (!Services.prefs.getBoolPref("services.push.enabled")) {
    1.37 +          return;
    1.38 +        }
    1.39 +        Cu.import("resource://gre/modules/PushService.jsm");
    1.40 +        PushService.init();
    1.41 +        break;
    1.42 +    }
    1.43 +  }
    1.44 +};
    1.45 +
    1.46 +this.NSGetFactory = XPCOMUtils.generateNSGetFactory([PushServiceLauncher]);

mercurial