summaryrefslogtreecommitdiffstats
path: root/browser/components/selfsupport/SelfSupportService.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /browser/components/selfsupport/SelfSupportService.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'browser/components/selfsupport/SelfSupportService.js')
-rw-r--r--browser/components/selfsupport/SelfSupportService.js78
1 files changed, 78 insertions, 0 deletions
diff --git a/browser/components/selfsupport/SelfSupportService.js b/browser/components/selfsupport/SelfSupportService.js
new file mode 100644
index 000000000..26148c6ff
--- /dev/null
+++ b/browser/components/selfsupport/SelfSupportService.js
@@ -0,0 +1,78 @@
+/* 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 {classes: Cc, interfaces: Ci, utils: Cu} = Components;
+
+Cu.import("resource://gre/modules/XPCOMUtils.jsm");
+Cu.import("resource://gre/modules/Services.jsm");
+Cu.import("resource://gre/modules/Preferences.jsm");
+
+const PREF_FHR_UPLOAD_ENABLED = "datareporting.healthreport.uploadEnabled";
+
+XPCOMUtils.defineLazyModuleGetter(this, "TelemetryArchive",
+ "resource://gre/modules/TelemetryArchive.jsm");
+XPCOMUtils.defineLazyModuleGetter(this, "TelemetryEnvironment",
+ "resource://gre/modules/TelemetryEnvironment.jsm");
+XPCOMUtils.defineLazyModuleGetter(this, "TelemetryController",
+ "resource://gre/modules/TelemetryController.jsm");
+
+function MozSelfSupportInterface() {
+}
+
+MozSelfSupportInterface.prototype = {
+ classDescription: "MozSelfSupport",
+ classID: Components.ID("{d30aae8b-f352-4de3-b936-bb9d875df0bb}"),
+ contractID: "@mozilla.org/mozselfsupport;1",
+ QueryInterface: XPCOMUtils.generateQI([Ci.nsIDOMGlobalPropertyInitializer]),
+
+ _window: null,
+
+ init: function (window) {
+ this._window = window;
+ },
+
+ get healthReportDataSubmissionEnabled() {
+ return Preferences.get(PREF_FHR_UPLOAD_ENABLED, false);
+ },
+
+ set healthReportDataSubmissionEnabled(enabled) {
+ Preferences.set(PREF_FHR_UPLOAD_ENABLED, enabled);
+ },
+
+ resetPref: function(name) {
+ Services.prefs.clearUserPref(name);
+ },
+
+ resetSearchEngines: function() {
+ Services.search.restoreDefaultEngines();
+ Services.search.resetToOriginalDefaultEngine();
+ },
+
+ getTelemetryPingList: function() {
+ return this._wrapPromise(TelemetryArchive.promiseArchivedPingList());
+ },
+
+ getTelemetryPing: function(pingId) {
+ return this._wrapPromise(TelemetryArchive.promiseArchivedPingById(pingId));
+ },
+
+ getCurrentTelemetryEnvironment: function() {
+ const current = TelemetryEnvironment.currentEnvironment;
+ return new this._window.Promise(resolve => resolve(current));
+ },
+
+ getCurrentTelemetrySubsessionPing: function() {
+ const current = TelemetryController.getCurrentPingData(true);
+ return new this._window.Promise(resolve => resolve(current));
+ },
+
+ _wrapPromise: function(promise) {
+ return new this._window.Promise(
+ (resolve, reject) => promise.then(resolve, reject));
+ },
+}
+
+this.NSGetFactory = XPCOMUtils.generateNSGetFactory([MozSelfSupportInterface]);