diff options
Diffstat (limited to 'toolkit/mozapps')
20 files changed, 82 insertions, 1137 deletions
diff --git a/toolkit/mozapps/downloads/nsHelperAppDlg.js b/toolkit/mozapps/downloads/nsHelperAppDlg.js index 58697cc77..27c0fede0 100644 --- a/toolkit/mozapps/downloads/nsHelperAppDlg.js +++ b/toolkit/mozapps/downloads/nsHelperAppDlg.js @@ -253,10 +253,7 @@ nsUnknownContentTypeDialog.prototype = { if (!aForcePrompt) { // Check to see if the user wishes to auto save to the default download // folder without prompting. Note that preference might not be set. - let autodownload = false; - try { - autodownload = prefs.getBoolPref(PREF_BD_USEDOWNLOADDIR); - } catch (e) { } + let autodownload = prefs.getBoolPref(PREF_BD_USEDOWNLOADDIR, false); if (autodownload) { // Retrieve the user's default download directory diff --git a/toolkit/mozapps/extensions/AddonManager.jsm b/toolkit/mozapps/extensions/AddonManager.jsm index 4cd2c3d0a..a48e0034f 100644 --- a/toolkit/mozapps/extensions/AddonManager.jsm +++ b/toolkit/mozapps/extensions/AddonManager.jsm @@ -135,12 +135,7 @@ var PrefObserver = { Services.obs.removeObserver(this, "xpcom-shutdown"); } else if (aTopic == NS_PREFBRANCH_PREFCHANGE_TOPIC_ID) { - let debugLogEnabled = false; - try { - debugLogEnabled = Services.prefs.getBoolPref(PREF_LOGGING_ENABLED); - } - catch (e) { - } + let debugLogEnabled = Services.prefs.getBoolPref(PREF_LOGGING_ENABLED, false); if (debugLogEnabled) { parentLogger.level = Log.Level.Debug; } @@ -791,11 +786,7 @@ var AddonManagerInternal = { } catch (e) { } - let oldPlatformVersion = null; - try { - oldPlatformVersion = Services.prefs.getCharPref(PREF_EM_LAST_PLATFORM_VERSION); - } - catch (e) { } + let oldPlatformVersion = Services.prefs.getCharPref(PREF_EM_LAST_PLATFORM_VERSION, ""); if (appChanged !== false) { logger.debug("Application has been upgraded"); @@ -808,40 +799,30 @@ var AddonManagerInternal = { this.validateBlocklist(); } - try { - gCheckCompatibility = Services.prefs.getBoolPref(PREF_EM_CHECK_COMPATIBILITY); - } catch (e) {} + gCheckCompatibility = Services.prefs.getBoolPref(PREF_EM_CHECK_COMPATIBILITY, + gCheckCompatibility); Services.prefs.addObserver(PREF_EM_CHECK_COMPATIBILITY, this, false); - try { - gStrictCompatibility = Services.prefs.getBoolPref(PREF_EM_STRICT_COMPATIBILITY); - } catch (e) {} + gStrictCompatibility = Services.prefs.getBoolPref(PREF_EM_STRICT_COMPATIBILITY, + gStrictCompatibility); Services.prefs.addObserver(PREF_EM_STRICT_COMPATIBILITY, this, false); - try { - let defaultBranch = Services.prefs.getDefaultBranch(""); - gCheckUpdateSecurityDefault = defaultBranch.getBoolPref(PREF_EM_CHECK_UPDATE_SECURITY); - } catch(e) {} + let defaultBranch = Services.prefs.getDefaultBranch(""); + gCheckUpdateSecurityDefault = defaultBranch.getBoolPref(PREF_EM_CHECK_UPDATE_SECURITY, + gCheckUpdateSecurityDefault); - try { - gCheckUpdateSecurity = Services.prefs.getBoolPref(PREF_EM_CHECK_UPDATE_SECURITY); - } catch (e) {} + gCheckUpdateSecurity = Services.prefs.getBoolPref(PREF_EM_CHECK_UPDATE_SECURITY, + gCheckUpdateSecurity); Services.prefs.addObserver(PREF_EM_CHECK_UPDATE_SECURITY, this, false); - try { - gUpdateEnabled = Services.prefs.getBoolPref(PREF_EM_UPDATE_ENABLED); - } catch (e) {} + gUpdateEnabled = Services.prefs.getBoolPref(PREF_EM_UPDATE_ENABLED, gUpdateEnabled); Services.prefs.addObserver(PREF_EM_UPDATE_ENABLED, this, false); - try { - gAutoUpdateDefault = Services.prefs.getBoolPref(PREF_EM_AUTOUPDATE_DEFAULT); - } catch (e) {} + gAutoUpdateDefault = Services.prefs.getBoolPref(PREF_EM_AUTOUPDATE_DEFAULT, + gAutoUpdateDefault); Services.prefs.addObserver(PREF_EM_AUTOUPDATE_DEFAULT, this, false); - let defaultProvidersEnabled = true; - try { - defaultProvidersEnabled = Services.prefs.getBoolPref(PREF_DEFAULT_PROVIDERS_ENABLED); - } catch (e) {} + let defaultProvidersEnabled = Services.prefs.getBoolPref(PREF_DEFAULT_PROVIDERS_ENABLED, true); AddonManagerPrivate.recordSimpleMeasure("default_providers", defaultProvidersEnabled); // Ensure all default providers have had a chance to register themselves @@ -1167,11 +1148,7 @@ var AddonManagerInternal = { switch (aData) { case PREF_EM_CHECK_COMPATIBILITY: { let oldValue = gCheckCompatibility; - try { - gCheckCompatibility = Services.prefs.getBoolPref(PREF_EM_CHECK_COMPATIBILITY); - } catch(e) { - gCheckCompatibility = true; - } + gCheckCompatibility = Services.prefs.getBoolPref(PREF_EM_CHECK_COMPATIBILITY, true); this.callManagerListeners("onCompatibilityModeChanged"); @@ -1182,11 +1159,7 @@ var AddonManagerInternal = { } case PREF_EM_STRICT_COMPATIBILITY: { let oldValue = gStrictCompatibility; - try { - gStrictCompatibility = Services.prefs.getBoolPref(PREF_EM_STRICT_COMPATIBILITY); - } catch(e) { - gStrictCompatibility = true; - } + gStrictCompatibility = Services.prefs.getBoolPref(PREF_EM_STRICT_COMPATIBILITY, true); this.callManagerListeners("onCompatibilityModeChanged"); @@ -1197,11 +1170,7 @@ var AddonManagerInternal = { } case PREF_EM_CHECK_UPDATE_SECURITY: { let oldValue = gCheckUpdateSecurity; - try { - gCheckUpdateSecurity = Services.prefs.getBoolPref(PREF_EM_CHECK_UPDATE_SECURITY); - } catch(e) { - gCheckUpdateSecurity = true; - } + gCheckUpdateSecurity = Services.prefs.getBoolPref(PREF_EM_CHECK_UPDATE_SECURITY, true); this.callManagerListeners("onCheckUpdateSecurityChanged"); @@ -1212,22 +1181,14 @@ var AddonManagerInternal = { } case PREF_EM_UPDATE_ENABLED: { let oldValue = gUpdateEnabled; - try { - gUpdateEnabled = Services.prefs.getBoolPref(PREF_EM_UPDATE_ENABLED); - } catch(e) { - gUpdateEnabled = true; - } + gUpdateEnabled = Services.prefs.getBoolPref(PREF_EM_UPDATE_ENABLED, true); this.callManagerListeners("onUpdateModeChanged"); break; } case PREF_EM_AUTOUPDATE_DEFAULT: { let oldValue = gAutoUpdateDefault; - try { - gAutoUpdateDefault = Services.prefs.getBoolPref(PREF_EM_AUTOUPDATE_DEFAULT); - } catch(e) { - gAutoUpdateDefault = true; - } + gAutoUpdateDefault = Services.prefs.getBoolPref(PREF_EM_AUTOUPDATE_DEFAULT, true); this.callManagerListeners("onUpdateModeChanged"); break; diff --git a/toolkit/mozapps/extensions/DeferredSave.jsm b/toolkit/mozapps/extensions/DeferredSave.jsm index 89f82b265..f1537fe4b 100644 --- a/toolkit/mozapps/extensions/DeferredSave.jsm +++ b/toolkit/mozapps/extensions/DeferredSave.jsm @@ -64,12 +64,7 @@ var PrefObserver = { Services.obs.removeObserver(this, "xpcom-shutdown"); } else if (aTopic == NS_PREFBRANCH_PREFCHANGE_TOPIC_ID) { - let debugLogEnabled = false; - try { - debugLogEnabled = Services.prefs.getBoolPref(PREF_LOGGING_ENABLED); - } - catch (e) { - } + let debugLogEnabled = Services.prefs.getBoolPref(PREF_LOGGING_ENABLED, false); if (debugLogEnabled) { parentLogger.level = Log.Level.Debug; } diff --git a/toolkit/mozapps/extensions/GMPInstallManager.jsm b/toolkit/mozapps/extensions/GMPInstallManager.jsm index b9ebe5d7e..fe4e2de10 100644 --- a/toolkit/mozapps/extensions/GMPInstallManager.jsm +++ b/toolkit/mozapps/extensions/GMPInstallManager.jsm @@ -38,8 +38,8 @@ XPCOMUtils.defineLazyGetter(this, "gCertUtils", function() { return temp; }); -XPCOMUtils.defineLazyModuleGetter(this, "UpdateChannel", - "resource://gre/modules/UpdateChannel.jsm"); +XPCOMUtils.defineLazyModuleGetter(this, "UpdateUtils", + "resource://gre/modules/UpdateUtils.jsm"); /** * Number of milliseconds after which we need to cancel `checkForAddons`. @@ -190,33 +190,6 @@ XPCOMUtils.defineLazyGetter(this, "gOSVersion", function aus_gOSVersion() { return osVersion; }); -// This is copied directly from nsUpdateService.js -// It is used for calculating the URL string w/ var replacement. -// TODO: refactor this out somewhere else -XPCOMUtils.defineLazyGetter(this, "gABI", function aus_gABI() { - let abi = null; - try { - abi = Services.appinfo.XPCOMABI; - } - catch (e) { - LOG("gABI - XPCOM ABI unknown: updates are not possible."); - } -#ifdef XP_MACOSX - // Mac universal build should report a different ABI than either macppc - // or mactel. - let macutils = Cc["@mozilla.org/xpcom/mac-utils;1"]. - getService(Ci.nsIMacUtils); - - if (macutils.isUniversalBinary) - abi += "-u-" + macutils.architecturesInBinary; -#ifdef MOZ_SHARK - // Disambiguate optimised and shark nightlies - abi += "-shark" -#endif -#endif - return abi; -}); - /** * Provides an easy API for downloading and installing GMP Addons */ @@ -241,24 +214,7 @@ GMPInstallManager.prototype = { log.info("Using url: " + url); } - url = - url.replace(/%PRODUCT%/g, Services.appinfo.name) - .replace(/%VERSION%/g, Services.appinfo.version) - .replace(/%BUILD_ID%/g, Services.appinfo.appBuildID) - .replace(/%BUILD_TARGET%/g, Services.appinfo.OS + "_" + gABI) - .replace(/%OS_VERSION%/g, gOSVersion); - if (/%LOCALE%/.test(url)) { - // TODO: Get the real local, does it actually matter for GMP plugins? - url = url.replace(/%LOCALE%/g, "en-US"); - } - url = - url.replace(/%CHANNEL%/g, UpdateChannel.get()) - .replace(/%PLATFORM_VERSION%/g, Services.appinfo.platformVersion) - .replace(/%DISTRIBUTION%/g, - GMPPrefs.get(GMPPrefs.KEY_APP_DISTRIBUTION)) - .replace(/%DISTRIBUTION_VERSION%/g, - GMPPrefs.get(GMPPrefs.KEY_APP_DISTRIBUTION_VERSION)) - .replace(/\+/g, "%2B"); + url = UpdateUtils.formatUpdateURL(url); log.info("Using url (with replacement): " + url); return url; }, diff --git a/toolkit/mozapps/extensions/GMPUtils.jsm b/toolkit/mozapps/extensions/GMPUtils.jsm index 9e41a7a61..a199b4d86 100644 --- a/toolkit/mozapps/extensions/GMPUtils.jsm +++ b/toolkit/mozapps/extensions/GMPUtils.jsm @@ -154,13 +154,7 @@ this.GMPPrefs = { get: function(aKey, aDefaultValue, aPlugin) { if (aKey === this.KEY_APP_DISTRIBUTION || aKey === this.KEY_APP_DISTRIBUTION_VERSION) { - let prefValue = "default"; - try { - prefValue = Services.prefs.getDefaultBranch(null).getCharPref(aKey); - } catch (e) { - // use default when pref not found - } - return prefValue; + return Services.prefs.getDefaultBranch(null).getCharPref(aKey, "default"); } return Preferences.get(this.getPrefKey(aKey, aPlugin), aDefaultValue); }, diff --git a/toolkit/mozapps/extensions/LightweightThemeManager.jsm b/toolkit/mozapps/extensions/LightweightThemeManager.jsm index 372a9f3b8..a4cbf3833 100644 --- a/toolkit/mozapps/extensions/LightweightThemeManager.jsm +++ b/toolkit/mozapps/extensions/LightweightThemeManager.jsm @@ -49,12 +49,7 @@ this.__defineGetter__("_prefs", function prefsGetter() { this.__defineGetter__("_maxUsedThemes", function maxUsedThemesGetter() { delete this._maxUsedThemes; - try { - this._maxUsedThemes = _prefs.getIntPref("maxUsedThemes"); - } - catch (e) { - this._maxUsedThemes = DEFAULT_MAX_USED_THEMES_COUNT; - } + this._maxUsedThemes = _prefs.getIntPref("maxUsedThemes", DEFAULT_MAX_USED_THEMES_COUNT); return this._maxUsedThemes; }); @@ -719,12 +714,8 @@ var _previewTimerCallback = { function _prefObserver(aSubject, aTopic, aData) { switch (aData) { case "maxUsedThemes": - try { - _maxUsedThemes = _prefs.getIntPref(aData); - } - catch (e) { - _maxUsedThemes = DEFAULT_MAX_USED_THEMES_COUNT; - } + _maxUsedThemes = _prefs.getIntPref(aData, DEFAULT_MAX_USED_THEMES_COUNT); + // Update the theme list to remove any themes over the number we keep _updateUsedThemes(LightweightThemeManager.usedThemes); break; diff --git a/toolkit/mozapps/extensions/amWebInstallListener.js b/toolkit/mozapps/extensions/amWebInstallListener.js index 088f56640..9b9c53f44 100644 --- a/toolkit/mozapps/extensions/amWebInstallListener.js +++ b/toolkit/mozapps/extensions/amWebInstallListener.js @@ -172,10 +172,6 @@ Installer.prototype = { args.wrappedJSObject = args; try { - Cc["@mozilla.org/base/telemetry;1"]. - getService(Ci.nsITelemetry). - getHistogramById("SECURITY_UI"). - add(Ci.nsISecurityUITelemetry.WARNING_CONFIRM_ADDON_INSTALL); let parentWindow = null; if (this.browser) { parentWindow = this.browser.ownerDocument.defaultView; diff --git a/toolkit/mozapps/extensions/content/xpinstallConfirm.js b/toolkit/mozapps/extensions/content/xpinstallConfirm.js index 5660cdaaf..29be5f5e9 100644 --- a/toolkit/mozapps/extensions/content/xpinstallConfirm.js +++ b/toolkit/mozapps/extensions/content/xpinstallConfirm.js @@ -179,10 +179,6 @@ XPInstallConfirm.init = function() XPInstallConfirm.onOK = function() { - Components.classes["@mozilla.org/base/telemetry;1"]. - getService(Components.interfaces.nsITelemetry). - getHistogramById("SECURITY_UI"). - add(Components.interfaces.nsISecurityUITelemetry.WARNING_CONFIRM_ADDON_INSTALL_CLICK_THROUGH); // Perform the install or cancel after the window has unloaded XPInstallConfirm._installOK = true; return true; diff --git a/toolkit/mozapps/extensions/internal/AddonLogging.jsm b/toolkit/mozapps/extensions/internal/AddonLogging.jsm index f05a6fe6c..ffa92c791 100644 --- a/toolkit/mozapps/extensions/internal/AddonLogging.jsm +++ b/toolkit/mozapps/extensions/internal/AddonLogging.jsm @@ -179,12 +179,7 @@ var PrefObserver = { Services.obs.removeObserver(this, "xpcom-shutdown"); } else if (aTopic == NS_PREFBRANCH_PREFCHANGE_TOPIC_ID) { - try { - gDebugLogEnabled = Services.prefs.getBoolPref(PREF_LOGGING_ENABLED); - } - catch (e) { - gDebugLogEnabled = false; - } + gDebugLogEnabled = Services.prefs.getBoolPref(PREF_LOGGING_ENABLED, false); } } }; diff --git a/toolkit/mozapps/extensions/internal/AddonRepository.jsm b/toolkit/mozapps/extensions/internal/AddonRepository.jsm index 76a7528c7..9750e9944 100644 --- a/toolkit/mozapps/extensions/internal/AddonRepository.jsm +++ b/toolkit/mozapps/extensions/internal/AddonRepository.jsm @@ -486,14 +486,7 @@ this.AddonRepository = { } let preference = PREF_GETADDONS_CACHE_ENABLED; - let enabled = false; - try { - enabled = Services.prefs.getBoolPref(preference); - } catch(e) { - logger.warn("cacheEnabled: Couldn't get pref: " + preference); - } - - return enabled; + return Services.prefs.getBoolPref(preference, false); }, // A cache of the add-ons stored in the database @@ -541,11 +534,7 @@ this.AddonRepository = { metadataAge: function() { let now = Math.round(Date.now() / 1000); - - let lastUpdate = 0; - try { - lastUpdate = Services.prefs.getIntPref(PREF_METADATA_LASTUPDATE); - } catch (e) {} + let lastUpdate = Services.prefs.getIntPref(PREF_METADATA_LASTUPDATE, 0); // Handle clock jumps if (now < lastUpdate) { @@ -555,10 +544,8 @@ this.AddonRepository = { }, isMetadataStale: function AddonRepo_isMetadataStale() { - let threshold = DEFAULT_METADATA_UPDATETHRESHOLD_SEC; - try { - threshold = Services.prefs.getIntPref(PREF_METADATA_UPDATETHRESHOLD_SEC); - } catch (e) {} + let threshold = Services.prefs.getIntPref(PREF_METADATA_UPDATETHRESHOLD_SEC, + DEFAULT_METADATA_UPDATETHRESHOLD_SEC); return (this.metadataAge() > threshold); }, @@ -1543,10 +1530,8 @@ this.AddonRepository = { // Create url from preference, returning null if preference does not exist _formatURLPref: function AddonRepo_formatURLPref(aPreference, aSubstitutions) { - let url = null; - try { - url = Services.prefs.getCharPref(aPreference); - } catch(e) { + let url = Services.prefs.getCharPref(aPreference, ""); + if (!url) { logger.warn("_formatURLPref: Couldn't get pref: " + aPreference); return null; } @@ -1639,10 +1624,7 @@ var AddonDatabase = { // Create a blank addons.json file this._saveDBToDisk(); - let dbSchema = 0; - try { - dbSchema = Services.prefs.getIntPref(PREF_GETADDONS_DB_SCHEMA); - } catch (e) {} + let dbSchema = Services.prefs.getIntPref(PREF_GETADDONS_DB_SCHEMA, 0); if (dbSchema < DB_MIN_JSON_SCHEMA) { let results = yield new Promise((resolve, reject) => { diff --git a/toolkit/mozapps/extensions/internal/AddonUpdateChecker.jsm b/toolkit/mozapps/extensions/internal/AddonUpdateChecker.jsm index c06dca1d5..a475f7f1f 100644 --- a/toolkit/mozapps/extensions/internal/AddonUpdateChecker.jsm +++ b/toolkit/mozapps/extensions/internal/AddonUpdateChecker.jsm @@ -608,12 +608,7 @@ function UpdateParser(aId, aUpdateKey, aUrl, aObserver) { this.observer = aObserver; this.url = aUrl; - let requireBuiltIn = true; - try { - requireBuiltIn = Services.prefs.getBoolPref(PREF_UPDATE_REQUIREBUILTINCERTS); - } - catch (e) { - } + let requireBuiltIn = Services.prefs.getBoolPref(PREF_UPDATE_REQUIREBUILTINCERTS, true); logger.debug("Requesting " + aUrl); try { @@ -651,12 +646,7 @@ UpdateParser.prototype = { this.request = null; this._doneAt = new Error("place holder"); - let requireBuiltIn = true; - try { - requireBuiltIn = Services.prefs.getBoolPref(PREF_UPDATE_REQUIREBUILTINCERTS); - } - catch (e) { - } + let requireBuiltIn = Services.prefs.getBoolPref(PREF_UPDATE_REQUIREBUILTINCERTS, true); try { CertUtils.checkCert(request.channel, !requireBuiltIn); diff --git a/toolkit/mozapps/extensions/internal/XPIProviderUtils.js b/toolkit/mozapps/extensions/internal/XPIProviderUtils.js index f2420bd1a..69d774e4a 100644 --- a/toolkit/mozapps/extensions/internal/XPIProviderUtils.js +++ b/toolkit/mozapps/extensions/internal/XPIProviderUtils.js @@ -1410,10 +1410,7 @@ this.XPIDatabase = { // when a lightweight theme is applied for example) text += "\r\n[ThemeDirs]\r\n"; - let dssEnabled = false; - try { - dssEnabled = Services.prefs.getBoolPref(PREF_EM_DSS_ENABLED); - } catch (e) {} + let dssEnabled = Services.prefs.getBoolPref(PREF_EM_DSS_ENABLED, false); let themes = []; if (dssEnabled) { diff --git a/toolkit/mozapps/installer/package-name.mk b/toolkit/mozapps/installer/package-name.mk index 1a8728088..680590b3c 100644 --- a/toolkit/mozapps/installer/package-name.mk +++ b/toolkit/mozapps/installer/package-name.mk @@ -30,10 +30,6 @@ endif ifndef MOZ_PKG_PLATFORM MOZ_PKG_PLATFORM := $(TARGET_OS)-$(TARGET_CPU) -ifdef MOZ_FENNEC -MOZ_PKG_PLATFORM := android-$(TARGET_CPU) -endif - # TARGET_OS/TARGET_CPU may be unintuitive, so we hardcode some special formats ifeq ($(OS_ARCH),WINNT) ifeq ($(TARGET_CPU),x86_64) diff --git a/toolkit/mozapps/installer/upload-files-APK.mk b/toolkit/mozapps/installer/upload-files-APK.mk index f9bfd6735..bf2fa4f9f 100644 --- a/toolkit/mozapps/installer/upload-files-APK.mk +++ b/toolkit/mozapps/installer/upload-files-APK.mk @@ -23,21 +23,6 @@ GECKO_APP_AP_PATH = $(topobjdir)/mobile/android/base ifdef ENABLE_TESTS INNER_ROBOCOP_PACKAGE=true -ifdef MOZ_FENNEC -UPLOAD_EXTRA_FILES += robocop.apk - -# Robocop/Robotium tests, Android Background tests, and Fennec need to -# be signed with the same key, which means release signing them all. - -ifndef MOZ_BUILD_MOBILE_ANDROID_WITH_GRADLE -robocop_apk := $(topobjdir)/mobile/android/tests/browser/robocop/robocop-debug-unsigned-unaligned.apk -else -robocop_apk := $(topobjdir)/gradle/build/mobile/android/app/outputs/apk/app-automation-debug-androidTest-unaligned.apk -endif - -INNER_ROBOCOP_PACKAGE= \ - $(call RELEASE_SIGN_ANDROID_APK,$(robocop_apk),$(ABS_DIST)/robocop.apk) -endif else INNER_ROBOCOP_PACKAGE=echo 'Testing is disabled - No Android Robocop for you' endif diff --git a/toolkit/mozapps/update/UpdateTelemetry.jsm b/toolkit/mozapps/update/UpdateTelemetry.jsm deleted file mode 100644 index d64085143..000000000 --- a/toolkit/mozapps/update/UpdateTelemetry.jsm +++ /dev/null @@ -1,488 +0,0 @@ -/* 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"; - -this.EXPORTED_SYMBOLS = [ - "AUSTLMY" -]; - -const {classes: Cc, interfaces: Ci, results: Cr, utils: Cu} = Components; - -Cu.import("resource://gre/modules/Services.jsm", this); - -this.AUSTLMY = { - // Telemetry for the application update background update check occurs when - // the background update timer fires after the update interval which is - // determined by the app.update.interval preference and its telemetry - // histogram IDs have the suffix '_NOTIFY'. - // Telemetry for the externally initiated background update check occurs when - // a call is made to |checkForBackgroundUpdates| which is typically initiated - // by an application when it has determined that the application should have - // received an update. This has separate telemetry so it is possible to - // analyze using the telemetry data systems that have not been updating when - // they should have. - - // The update check was performed by the call to checkForBackgroundUpdates in - // nsUpdateService.js. - EXTERNAL: "EXTERNAL", - // The update check was performed by the call to notify in nsUpdateService.js. - NOTIFY: "NOTIFY", - - /** - * Values for the UPDATE_CHECK_CODE_NOTIFY and UPDATE_CHECK_CODE_EXTERNAL - * Telemetry histograms. - */ - // No update found (no notification) - CHK_NO_UPDATE_FOUND: 0, - // Update will be downloaded in the background (background download) - CHK_DOWNLOAD_UPDATE: 1, - // Showing prompt due to the update.xml specifying showPrompt - // (update notification) - CHK_SHOWPROMPT_SNIPPET: 2, - // Showing prompt due to preference (update notification) - CHK_SHOWPROMPT_PREF: 3, - // Already has an active update in progress (no notification) - CHK_HAS_ACTIVEUPDATE: 8, - // A background download is already in progress (no notification) - CHK_IS_DOWNLOADING: 9, - // An update is already staged (no notification) - CHK_IS_STAGED: 10, - // An update is already downloaded (no notification) - CHK_IS_DOWNLOADED: 11, - // Background checks disabled by preference (no notification) - CHK_PREF_DISABLED: 12, - // Update checks disabled by admin locked preference (no notification) - CHK_ADMIN_DISABLED: 13, - // Unable to check for updates per hasUpdateMutex() (no notification) - CHK_NO_MUTEX: 14, - // Unable to check for updates per gCanCheckForUpdates (no notification). This - // should be covered by other codes and is recorded just in case. - CHK_UNABLE_TO_CHECK: 15, - // Background checks disabled for the current session (no notification) - CHK_DISABLED_FOR_SESSION: 16, - // Unable to perform a background check while offline (no notification) - CHK_OFFLINE: 17, - // Note: codes 18 - 21 were removed along with the certificate checking code. - // General update check failure and threshold reached - // (check failure notification) - CHK_GENERAL_ERROR_PROMPT: 22, - // General update check failure and threshold not reached (no notification) - CHK_GENERAL_ERROR_SILENT: 23, - // No compatible update found though there were updates (no notification) - CHK_NO_COMPAT_UPDATE_FOUND: 24, - // Update found for a previous version (no notification) - CHK_UPDATE_PREVIOUS_VERSION: 25, - // Update found for a version with the never preference set (no notification) - CHK_UPDATE_NEVER_PREF: 26, - // Update found without a type attribute (no notification) - CHK_UPDATE_INVALID_TYPE: 27, - // The system is no longer supported (system unsupported notification) - CHK_UNSUPPORTED: 28, - // Unable to apply updates (manual install to update notification) - CHK_UNABLE_TO_APPLY: 29, - // Unable to check for updates due to no OS version (no notification) - CHK_NO_OS_VERSION: 30, - // Unable to check for updates due to no OS ABI (no notification) - CHK_NO_OS_ABI: 31, - // Invalid url for app.update.url default preference (no notification) - CHK_INVALID_DEFAULT_URL: 32, - // Update elevation failures or cancelations threshold reached for this - // version, OSX only (no notification) - CHK_ELEVATION_DISABLED_FOR_VERSION: 35, - // User opted out of elevated updates for the available update version, OSX - // only (no notification) - CHK_ELEVATION_OPTOUT_FOR_VERSION: 36, - - /** - * Submit a telemetry ping for the update check result code or a telemetry - * ping for a count type histogram count when no update was found. The no - * update found ping is separate since it is the typical result, is less - * interesting than the other result codes, and it is easier to analyze the - * other codes without including it. - * - * @param aSuffix - * The histogram id suffix for histogram IDs: - * UPDATE_CHECK_CODE_EXTERNAL - * UPDATE_CHECK_CODE_NOTIFY - * UPDATE_CHECK_NO_UPDATE_EXTERNAL - * UPDATE_CHECK_NO_UPDATE_NOTIFY - * @param aCode - * An integer value as defined by the values that start with CHK_ in - * the above section. - */ - pingCheckCode: function UT_pingCheckCode(aSuffix, aCode) { - try { - if (aCode == this.CHK_NO_UPDATE_FOUND) { - let id = "UPDATE_CHECK_NO_UPDATE_" + aSuffix; - // count type histogram - Services.telemetry.getHistogramById(id).add(); - } else { - let id = "UPDATE_CHECK_CODE_" + aSuffix; - // enumerated type histogram - Services.telemetry.getHistogramById(id).add(aCode); - } - } catch (e) { - Cu.reportError(e); - } - }, - - /** - * Submit a telemetry ping for a failed update check's unhandled error code - * when the pingCheckCode is CHK_GENERAL_ERROR_SILENT. The histogram is a - * keyed count type with key names that are prefixed with 'AUS_CHECK_EX_ERR_'. - * - * @param aSuffix - * The histogram id suffix for histogram IDs: - * UPDATE_CHK_EXTENDED_ERROR_EXTERNAL - * UPDATE_CHK_EXTENDED_ERROR_NOTIFY - * @param aCode - * The extended error value return by a failed update check. - */ - pingCheckExError: function UT_pingCheckExError(aSuffix, aCode) { - try { - let id = "UPDATE_CHECK_EXTENDED_ERROR_" + aSuffix; - let val = "AUS_CHECK_EX_ERR_" + aCode; - // keyed count type histogram - Services.telemetry.getKeyedHistogramById(id).add(val); - } catch (e) { - Cu.reportError(e); - } - }, - - // The state code and if present the status error code were read on startup. - STARTUP: "STARTUP", - // The state code and status error code if present were read after staging. - STAGE: "STAGE", - - // Patch type Complete - PATCH_COMPLETE: "COMPLETE", - // Patch type partial - PATCH_PARTIAL: "PARTIAL", - // Patch type unknown - PATCH_UNKNOWN: "UNKNOWN", - - /** - * Values for the UPDATE_DOWNLOAD_CODE_COMPLETE and - * UPDATE_DOWNLOAD_CODE_PARTIAL Telemetry histograms. - */ - DWNLD_SUCCESS: 0, - DWNLD_RETRY_OFFLINE: 1, - DWNLD_RETRY_NET_TIMEOUT: 2, - DWNLD_RETRY_CONNECTION_REFUSED: 3, - DWNLD_RETRY_NET_RESET: 4, - DWNLD_ERR_NO_UPDATE: 5, - DWNLD_ERR_NO_UPDATE_PATCH: 6, - DWNLD_ERR_NO_PATCH_FILE: 7, - DWNLD_ERR_PATCH_SIZE_LARGER: 8, - DWNLD_ERR_PATCH_SIZE_NOT_EQUAL: 9, - DWNLD_ERR_BINDING_ABORTED: 10, - DWNLD_ERR_ABORT: 11, - DWNLD_ERR_DOCUMENT_NOT_CACHED: 12, - DWNLD_ERR_VERIFY_NO_REQUEST: 13, - DWNLD_ERR_VERIFY_PATCH_SIZE_NOT_EQUAL: 14, - DWNLD_ERR_VERIFY_NO_HASH_MATCH: 15, - - /** - * Submit a telemetry ping for the update download result code. - * - * @param aIsComplete - * If true the histogram is for a patch type complete, if false the - * histogram is for a patch type partial, and when undefined the - * histogram is for an unknown patch type. This is used to determine - * the histogram ID out of the following histogram IDs: - * UPDATE_DOWNLOAD_CODE_COMPLETE - * UPDATE_DOWNLOAD_CODE_PARTIAL - * @param aCode - * An integer value as defined by the values that start with DWNLD_ in - * the above section. - */ - pingDownloadCode: function UT_pingDownloadCode(aIsComplete, aCode) { - let patchType = this.PATCH_UNKNOWN; - if (aIsComplete === true) { - patchType = this.PATCH_COMPLETE; - } else if (aIsComplete === false) { - patchType = this.PATCH_PARTIAL; - } - try { - let id = "UPDATE_DOWNLOAD_CODE_" + patchType; - // enumerated type histogram - Services.telemetry.getHistogramById(id).add(aCode); - } catch (e) { - Cu.reportError(e); - } - }, - - /** - * Submit a telemetry ping for the update status state code. - * - * @param aSuffix - * The histogram id suffix for histogram IDs: - * UPDATE_STATE_CODE_COMPLETE_STARTUP - * UPDATE_STATE_CODE_PARTIAL_STARTUP - * UPDATE_STATE_CODE_UNKNOWN_STARTUP - * UPDATE_STATE_CODE_COMPLETE_STAGE - * UPDATE_STATE_CODE_PARTIAL_STAGE - * UPDATE_STATE_CODE_UNKNOWN_STAGE - * @param aCode - * An integer value as defined by the values that start with STATE_ in - * the above section for the update state from the update.status file. - */ - pingStateCode: function UT_pingStateCode(aSuffix, aCode) { - try { - let id = "UPDATE_STATE_CODE_" + aSuffix; - // enumerated type histogram - Services.telemetry.getHistogramById(id).add(aCode); - } catch (e) { - Cu.reportError(e); - } - }, - - /** - * Submit a telemetry ping for the update status error code. This does not - * submit a success value which can be determined from the state code. - * - * @param aSuffix - * The histogram id suffix for histogram IDs: - * UPDATE_STATUS_ERROR_CODE_COMPLETE_STARTUP - * UPDATE_STATUS_ERROR_CODE_PARTIAL_STARTUP - * UPDATE_STATUS_ERROR_CODE_UNKNOWN_STARTUP - * UPDATE_STATUS_ERROR_CODE_COMPLETE_STAGE - * UPDATE_STATUS_ERROR_CODE_PARTIAL_STAGE - * UPDATE_STATUS_ERROR_CODE_UNKNOWN_STAGE - * @param aCode - * An integer value for the error code from the update.status file. - */ - pingStatusErrorCode: function UT_pingStatusErrorCode(aSuffix, aCode) { - try { - let id = "UPDATE_STATUS_ERROR_CODE_" + aSuffix; - // enumerated type histogram - Services.telemetry.getHistogramById(id).add(aCode); - } catch (e) { - Cu.reportError(e); - } - }, - - /** - * Submit the interval in days since the last notification for this background - * update check or a boolean if the last notification is in the future. - * - * @param aSuffix - * The histogram id suffix for histogram IDs: - * UPDATE_INVALID_LASTUPDATETIME_EXTERNAL - * UPDATE_INVALID_LASTUPDATETIME_NOTIFY - * UPDATE_LAST_NOTIFY_INTERVAL_DAYS_EXTERNAL - * UPDATE_LAST_NOTIFY_INTERVAL_DAYS_NOTIFY - */ - pingLastUpdateTime: function UT_pingLastUpdateTime(aSuffix) { - const PREF_APP_UPDATE_LASTUPDATETIME = "app.update.lastUpdateTime.background-update-timer"; - if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_LASTUPDATETIME)) { - let lastUpdateTimeSeconds = Services.prefs.getIntPref(PREF_APP_UPDATE_LASTUPDATETIME); - if (lastUpdateTimeSeconds) { - let currentTimeSeconds = Math.round(Date.now() / 1000); - if (lastUpdateTimeSeconds > currentTimeSeconds) { - try { - let id = "UPDATE_INVALID_LASTUPDATETIME_" + aSuffix; - // count type histogram - Services.telemetry.getHistogramById(id).add(); - } catch (e) { - Cu.reportError(e); - } - } else { - let intervalDays = (currentTimeSeconds - lastUpdateTimeSeconds) / - (60 * 60 * 24); - try { - let id = "UPDATE_LAST_NOTIFY_INTERVAL_DAYS_" + aSuffix; - // exponential type histogram - Services.telemetry.getHistogramById(id).add(intervalDays); - } catch (e) { - Cu.reportError(e); - } - } - } - } - }, - - /** - * Submit a telemetry ping for the last page displayed by the update wizard. - * - * @param aPageID - * The page id for the last page displayed. - */ - pingWizLastPageCode: function UT_pingWizLastPageCode(aPageID) { - let pageMap = { invalid: 0, - dummy: 1, - checking: 2, - pluginupdatesfound: 3, - noupdatesfound: 4, - manualUpdate: 5, - unsupported: 6, - updatesfoundbasic: 8, - updatesfoundbillboard: 9, - downloading: 12, - errors: 13, - errorextra: 14, - errorpatching: 15, - finished: 16, - finishedBackground: 17, - installed: 18 }; - try { - let id = "UPDATE_WIZ_LAST_PAGE_CODE"; - // enumerated type histogram - Services.telemetry.getHistogramById(id).add(pageMap[aPageID] || - pageMap.invalid); - } catch (e) { - Cu.reportError(e); - } - }, - - /** - * Submit a telemetry ping for a boolean type histogram that indicates if the - * service is installed and a telemetry ping for a boolean type histogram that - * indicates if the service was at some point installed and is now - * uninstalled. - * - * @param aSuffix - * The histogram id suffix for histogram IDs: - * UPDATE_SERVICE_INSTALLED_EXTERNAL - * UPDATE_SERVICE_INSTALLED_NOTIFY - * UPDATE_SERVICE_MANUALLY_UNINSTALLED_EXTERNAL - * UPDATE_SERVICE_MANUALLY_UNINSTALLED_NOTIFY - * @param aInstalled - * Whether the service is installed. - */ - pingServiceInstallStatus: function UT_PSIS(aSuffix, aInstalled) { - // Report the error but don't throw since it is more important to - // successfully update than to throw. - if (!("@mozilla.org/windows-registry-key;1" in Cc)) { - Cu.reportError(Cr.NS_ERROR_NOT_AVAILABLE); - return; - } - - try { - let id = "UPDATE_SERVICE_INSTALLED_" + aSuffix; - // boolean type histogram - Services.telemetry.getHistogramById(id).add(aInstalled); - } catch (e) { - Cu.reportError(e); - } - - let attempted = 0; - try { - let wrk = Cc["@mozilla.org/windows-registry-key;1"]. - createInstance(Ci.nsIWindowsRegKey); - wrk.open(wrk.ROOT_KEY_LOCAL_MACHINE, - "SOFTWARE\\Mozilla\\MaintenanceService", - wrk.ACCESS_READ | wrk.WOW64_64); - // Was the service at some point installed, but is now uninstalled? - attempted = wrk.readIntValue("Attempted"); - wrk.close(); - } catch (e) { - // Since this will throw if the registry key doesn't exist (e.g. the - // service has never been installed) don't report an error. - } - - try { - let id = "UPDATE_SERVICE_MANUALLY_UNINSTALLED_" + aSuffix; - if (!aInstalled && attempted) { - // count type histogram - Services.telemetry.getHistogramById(id).add(); - } - } catch (e) { - Cu.reportError(e); - } - }, - - /** - * Submit a telemetry ping for a count type histogram when the expected value - * does not equal the boolean value of a pref or if the pref isn't present - * when the expected value does not equal default value. This lessens the - * amount of data submitted to telemetry. - * - * @param aID - * The histogram ID to report to. - * @param aPref - * The preference to check. - * @param aDefault - * The default value when the preference isn't present. - * @param aExpected (optional) - * If specified and the value is the same as the value that will be - * added the value won't be added to telemetry. - */ - pingBoolPref: function UT_pingBoolPref(aID, aPref, aDefault, aExpected) { - try { - let val = aDefault; - if (Services.prefs.getPrefType(aPref) != Ci.nsIPrefBranch.PREF_INVALID) { - val = Services.prefs.getBoolPref(aPref); - } - if (val != aExpected) { - // count type histogram - Services.telemetry.getHistogramById(aID).add(); - } - } catch (e) { - Cu.reportError(e); - } - }, - - /** - * Submit a telemetry ping for a histogram with the integer value of a - * preference when it is not the expected value or the default value when it - * is not the expected value. This lessens the amount of data submitted to - * telemetry. - * - * @param aID - * The histogram ID to report to. - * @param aPref - * The preference to check. - * @param aDefault - * The default value when the pref is not set. - * @param aExpected (optional) - * If specified and the value is the same as the value that will be - * added the value won't be added to telemetry. - */ - pingIntPref: function UT_pingIntPref(aID, aPref, aDefault, aExpected) { - try { - let val = aDefault; - if (Services.prefs.getPrefType(aPref) != Ci.nsIPrefBranch.PREF_INVALID) { - val = Services.prefs.getIntPref(aPref); - } - if (aExpected === undefined || val != aExpected) { - // enumerated or exponential type histogram - Services.telemetry.getHistogramById(aID).add(val); - } - } catch (e) { - Cu.reportError(e); - } - }, - - /** - * Submit a telemetry ping for all histogram types that take a single - * parameter to the telemetry add function and the count type histogram when - * the aExpected parameter is specified. If the aExpected parameter is - * specified and it equals the value specified by the aValue - * parameter the telemetry submission will be skipped. - * - * @param aID - * The histogram ID to report to. - * @param aValue - * The value to add when aExpected is not defined or the value to - * check if it is equal to when aExpected is defined. - * @param aExpected (optional) - * If specified and the value is the same as the value specified by - * aValue parameter the submission will be skipped. - */ - pingGeneric: function UT_pingGeneric(aID, aValue, aExpected) { - try { - if (aExpected === undefined) { - Services.telemetry.getHistogramById(aID).add(aValue); - } else if (aValue != aExpected) { - // count type histogram - Services.telemetry.getHistogramById(aID).add(); - } - } catch (e) { - Cu.reportError(e); - } - } -}; -Object.freeze(AUSTLMY); diff --git a/toolkit/mozapps/update/common/updatedefines.h b/toolkit/mozapps/update/common/updatedefines.h index 760d2c4c4..5790cf996 100644 --- a/toolkit/mozapps/update/common/updatedefines.h +++ b/toolkit/mozapps/update/common/updatedefines.h @@ -96,11 +96,7 @@ static inline int mywcsprintf(WCHAR* dest, size_t count, const WCHAR* fmt, ...) # include <sys/wait.h> # include <unistd.h> -#ifdef SOLARIS -# include <sys/stat.h> -#else # include <fts.h> -#endif # include <dirent.h> #ifdef XP_MACOSX diff --git a/toolkit/mozapps/update/content/updates.js b/toolkit/mozapps/update/content/updates.js index 6e8de7275..3e05566f1 100644 --- a/toolkit/mozapps/update/content/updates.js +++ b/toolkit/mozapps/update/content/updates.js @@ -11,10 +11,9 @@ // so we have to use different names. const {classes: CoC, interfaces: CoI, results: CoR, utils: CoU} = Components; -/* globals DownloadUtils, Services, AUSTLMY */ +/* globals DownloadUtils, Services */ CoU.import("resource://gre/modules/DownloadUtils.jsm", this); CoU.import("resource://gre/modules/Services.jsm", this); -CoU.import("resource://gre/modules/UpdateTelemetry.jsm", this); const XMLNS_XUL = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; @@ -85,28 +84,6 @@ function openUpdateURL(event) { } /** - * Gets a preference value, handling the case where there is no default. - * @param func - * The name of the preference function to call, on nsIPrefBranch - * @param preference - * The name of the preference - * @param defaultValue - * The default value to return in the event the preference has - * no setting - * @returns The value of the preference, or undefined if there was no - * user or default value. - */ -function getPref(func, preference, defaultValue) { - try { - return Services.prefs[func](preference); - } - catch (e) { - LOG("General", "getPref - failed to get preference: " + preference); - } - return defaultValue; -} - -/** * A set of shared data and control functions for the wizard as a whole. */ var gUpdates = { @@ -138,15 +115,6 @@ var gUpdates = { _runUnload: true, /** - * Submit on close telemtry values for the update wizard. - * @param pageID - * The page id for the last page displayed. - */ - _submitTelemetry: function(aPageID) { - AUSTLMY.pingWizLastPageCode(aPageID); - }, - - /** * Helper function for setButtons * Resets button to original label & accesskey if string is null. */ @@ -264,7 +232,6 @@ var gUpdates = { var pageid = document.documentElement.currentPage.pageid; if ("onWizardFinish" in this._pages[pageid]) this._pages[pageid].onWizardFinish(); - this._submitTelemetry(pageid); }, /** @@ -276,7 +243,6 @@ var gUpdates = { var pageid = document.documentElement.currentPage.pageid; if ("onWizardCancel" in this._pages[pageid]) this._pages[pageid].onWizardCancel(); - this._submitTelemetry(pageid); }, /** @@ -320,7 +286,7 @@ var gUpdates = { onLoad: function() { this.wiz = document.documentElement; - gLogEnabled = getPref("getBoolPref", PREF_APP_UPDATE_LOG, false); + gLogEnabled = Services.prefs.getBoolPref(PREF_APP_UPDATE_LOG, false); this.strings = document.getElementById("updateStrings"); var brandStrings = document.getElementById("brandStrings"); @@ -601,7 +567,7 @@ var gNoUpdatesPage = { LOG("gNoUpdatesPage", "onPageShow - could not select an appropriate " + "update. Either there were no updates or |selectUpdate| failed"); - if (getPref("getBoolPref", PREF_APP_UPDATE_ENABLED, true)) + if (Services.prefs.getBoolPref(PREF_APP_UPDATE_ENABLED, true)) document.getElementById("noUpdatesAutoEnabled").hidden = false; else document.getElementById("noUpdatesAutoDisabled").hidden = false; @@ -1309,7 +1275,7 @@ var gFinishedPage = { moreElevatedLinkLabel.setAttribute("hidden", "false"); } - if (getPref("getBoolPref", PREF_APP_UPDATE_TEST_LOOP, false)) { + if (Services.prefs.getBoolPref(PREF_APP_UPDATE_TEST_LOOP, false)) { setTimeout(function () { gUpdates.wiz.getButton("finish").click(); }, UPDATE_TEST_LOOP_INTERVAL); } diff --git a/toolkit/mozapps/update/moz.build b/toolkit/mozapps/update/moz.build index 78a6996b7..5f1d56764 100644 --- a/toolkit/mozapps/update/moz.build +++ b/toolkit/mozapps/update/moz.build @@ -23,10 +23,6 @@ EXTRA_COMPONENTS += [ 'nsUpdateServiceStub.js', ] -EXTRA_JS_MODULES += [ - 'UpdateTelemetry.jsm', -] - JAR_MANIFESTS += ['jar.mn'] with Files('**'): diff --git a/toolkit/mozapps/update/nsUpdateService.js b/toolkit/mozapps/update/nsUpdateService.js index 4e2d66a5c..dca0a007e 100644 --- a/toolkit/mozapps/update/nsUpdateService.js +++ b/toolkit/mozapps/update/nsUpdateService.js @@ -12,7 +12,6 @@ Cu.import("resource://gre/modules/XPCOMUtils.jsm", this); Cu.import("resource://gre/modules/FileUtils.jsm", this); Cu.import("resource://gre/modules/Services.jsm", this); Cu.import("resource://gre/modules/ctypes.jsm", this); -Cu.import("resource://gre/modules/UpdateTelemetry.jsm", this); Cu.import("resource://gre/modules/AppConstants.jsm", this); Cu.importGlobalProperties(["XMLHttpRequest"]); @@ -164,7 +163,7 @@ XPCOMUtils.defineLazyModuleGetter(this, "UpdateUtils", "resource://gre/modules/UpdateUtils.jsm"); XPCOMUtils.defineLazyGetter(this, "gLogEnabled", function aus_gLogEnabled() { - return getPref("getBoolPref", PREF_APP_UPDATE_LOG, false); + return Services.prefs.getBoolPref(PREF_APP_UPDATE_LOG, false); }); XPCOMUtils.defineLazyGetter(this, "gUpdateBundle", function aus_gUpdateBundle() { @@ -494,7 +493,7 @@ XPCOMUtils.defineLazyGetter(this, "gCanStageUpdatesSession", function aus_gCSUS( */ function getCanStageUpdates() { // If staging updates are disabled, then just bail out! - if (!getPref("getBoolPref", PREF_APP_UPDATE_STAGING_ENABLED, false)) { + if (!Services.prefs.getBoolPref(PREF_APP_UPDATE_STAGING_ENABLED, false)) { LOG("getCanStageUpdates - staging updates is disabled by preference " + PREF_APP_UPDATE_STAGING_ENABLED); return false; @@ -514,7 +513,7 @@ XPCOMUtils.defineLazyGetter(this, "gCanCheckForUpdates", function aus_gCanCheckF // If the administrator has disabled app update and locked the preference so // users can't check for updates. This preference check is ok in this lazy // getter since locked prefs don't change until the application is restarted. - var enabled = getPref("getBoolPref", PREF_APP_UPDATE_ENABLED, true); + var enabled = Services.prefs.getBoolPref(PREF_APP_UPDATE_ENABLED, true); if (!enabled && Services.prefs.prefIsLocked(PREF_APP_UPDATE_ENABLED)) { LOG("gCanCheckForUpdates - unable to automatically check for updates, " + "the preference is disabled and admistratively locked."); @@ -551,27 +550,6 @@ function LOG(string) { } /** - * Gets a preference value, handling the case where there is no default. - * @param func - * The name of the preference function to call, on nsIPrefBranch - * @param preference - * The name of the preference - * @param defaultValue - * The default value to return in the event the preference has - * no setting - * @return The value of the preference, or undefined if there was no - * user or default value. - */ -function getPref(func, preference, defaultValue) { - try { - return Services.prefs[func](preference); - } - catch (e) { - } - return defaultValue; -} - -/** * Convert a string containing binary values to hex. */ function binaryToHex(input) { @@ -898,16 +876,15 @@ function handleUpdateFailure(update, errorCode) { } if (update.errorCode == ELEVATION_CANCELED) { - let cancelations = getPref("getIntPref", PREF_APP_UPDATE_CANCELATIONS, 0); + let cancelations = Services.prefs.getIntPref(PREF_APP_UPDATE_CANCELATIONS, 0); cancelations++; Services.prefs.setIntPref(PREF_APP_UPDATE_CANCELATIONS, cancelations); if (AppConstants.platform == "macosx") { - let osxCancelations = getPref("getIntPref", - PREF_APP_UPDATE_CANCELATIONS_OSX, 0); + let osxCancelations = Services.prefs.getIntPref(PREF_APP_UPDATE_CANCELATIONS_OSX, 0); osxCancelations++; Services.prefs.setIntPref(PREF_APP_UPDATE_CANCELATIONS_OSX, osxCancelations); - let maxCancels = getPref("getIntPref", + let maxCancels = Services.prefs.getIntPref( PREF_APP_UPDATE_CANCELATIONS_OSX_MAX, DEFAULT_CANCELATIONS_OSX_MAX); // Prevent the preference from setting a value greater than 5. @@ -971,66 +948,6 @@ function handleFallbackToCompleteUpdate(update, postStaging) { update.setProperty("patchingFailed", oldType); } -function pingStateAndStatusCodes(aUpdate, aStartup, aStatus) { - let patchType = AUSTLMY.PATCH_UNKNOWN; - if (aUpdate && aUpdate.selectedPatch && aUpdate.selectedPatch.type) { - if (aUpdate.selectedPatch.type == "complete") { - patchType = AUSTLMY.PATCH_COMPLETE; - } else if (aUpdate.selectedPatch.type == "partial") { - patchType = AUSTLMY.PATCH_PARTIAL; - } - } - - let suffix = patchType + "_" + (aStartup ? AUSTLMY.STARTUP : AUSTLMY.STAGE); - let stateCode = 0; - let parts = aStatus.split(":"); - if (parts.length > 0) { - switch (parts[0]) { - case STATE_NONE: - stateCode = 2; - break; - case STATE_DOWNLOADING: - stateCode = 3; - break; - case STATE_PENDING: - stateCode = 4; - break; - case STATE_APPLYING: - stateCode = 6; - break; - case STATE_APPLIED: - stateCode = 7; - break; - case STATE_APPLIED_OS: - stateCode = 8; - break; - case STATE_SUCCEEDED: - stateCode = 10; - break; - case STATE_DOWNLOAD_FAILED: - stateCode = 11; - break; - case STATE_FAILED: - stateCode = 12; - break; - case STATE_PENDING_ELEVATE: - stateCode = 13; - break; - default: - stateCode = 1; - } - - if (parts.length > 1) { - let statusErrorCode = INVALID_UPDATER_STATE_CODE; - if (parts[0] == STATE_FAILED) { - statusErrorCode = parseInt(parts[1]) || INVALID_UPDATER_STATUS_CODE; - } - AUSTLMY.pingStatusErrorCode(suffix, statusErrorCode); - } - } - AUSTLMY.pingStateCode(suffix, stateCode); -} - /** * Update Patch * @param patch @@ -1177,8 +1094,8 @@ function Update(update) { this.showNeverForVersion = false; this.unsupported = false; this.channel = "default"; - this.promptWaitTime = getPref("getIntPref", PREF_APP_UPDATE_PROMPTWAITTIME, 43200); - this.backgroundInterval = getPref("getIntPref", PREF_APP_UPDATE_BACKGROUNDINTERVAL, + this.promptWaitTime = Services.prefs.getIntPref(PREF_APP_UPDATE_PROMPTWAITTIME, 43200); + this.backgroundInterval = Services.prefs.getIntPref(PREF_APP_UPDATE_BACKGROUNDINTERVAL, DOWNLOAD_BACKGROUND_INTERVAL); // Null <update>, assume this is a message container and do no @@ -1558,7 +1475,7 @@ UpdateService.prototype = { break; case "nsPref:changed": if (data == PREF_APP_UPDATE_LOG) { - gLogEnabled = getPref("getBoolPref", PREF_APP_UPDATE_LOG, false); + gLogEnabled = Services.prefs.getBoolPref(PREF_APP_UPDATE_LOG, false); } break; case "profile-change-net-teardown": // fall thru @@ -1618,7 +1535,6 @@ UpdateService.prototype = { getService(Ci.nsIUpdateManager); var update = um.activeUpdate; var status = readStatusFile(getUpdatesDir()); - pingStateAndStatusCodes(update, true, status); // STATE_NONE status typically means that the update.status file is present // but a background download error occurred. if (status == STATE_NONE) { @@ -1786,28 +1702,20 @@ UpdateService.prototype = { if (update.errorCode == NETWORK_ERROR_OFFLINE) { // Register an online observer to try again this._registerOnlineObserver(); - if (this._pingSuffix) { - AUSTLMY.pingCheckCode(this._pingSuffix, AUSTLMY.CHK_OFFLINE); - } return; } - // Send the error code to telemetry - AUSTLMY.pingCheckExError(this._pingSuffix, update.errorCode); update.errorCode = BACKGROUNDCHECK_MULTIPLE_FAILURES; - let errCount = getPref("getIntPref", PREF_APP_UPDATE_BACKGROUNDERRORS, 0); + let errCount = Services.prefs.getIntPref(PREF_APP_UPDATE_BACKGROUNDERRORS, 0); errCount++; Services.prefs.setIntPref(PREF_APP_UPDATE_BACKGROUNDERRORS, errCount); // Don't allow the preference to set a value greater than 20 for max errors. - let maxErrors = Math.min(getPref("getIntPref", PREF_APP_UPDATE_BACKGROUNDMAXERRORS, 10), 20); + let maxErrors = Math.min(Services.prefs.getIntPref(PREF_APP_UPDATE_BACKGROUNDMAXERRORS, 10), 20); if (errCount >= maxErrors) { let prompter = Cc["@mozilla.org/updates/update-prompt;1"]. createInstance(Ci.nsIUpdatePrompt); prompter.showUpdateError(update); - AUSTLMY.pingCheckCode(this._pingSuffix, AUSTLMY.CHK_GENERAL_ERROR_PROMPT); - } else { - AUSTLMY.pingCheckCode(this._pingSuffix, AUSTLMY.CHK_GENERAL_ERROR_SILENT); } }, @@ -1852,11 +1760,6 @@ UpdateService.prototype = { this._checkForBackgroundUpdates(false); }, - // The suffix used for background update check telemetry histogram ID's. - get _pingSuffix() { - return this._isNotify ? AUSTLMY.NOTIFY : AUSTLMY.EXTERNAL; - }, - /** * Checks for updates in the background. * @param isNotify @@ -1866,119 +1769,10 @@ UpdateService.prototype = { _checkForBackgroundUpdates: function AUS__checkForBackgroundUpdates(isNotify) { this._isNotify = isNotify; - // Histogram IDs: - // UPDATE_PING_COUNT_EXTERNAL - // UPDATE_PING_COUNT_NOTIFY - AUSTLMY.pingGeneric("UPDATE_PING_COUNT_" + this._pingSuffix, - true, false); - - // Histogram IDs: - // UPDATE_UNABLE_TO_APPLY_EXTERNAL - // UPDATE_UNABLE_TO_APPLY_NOTIFY - AUSTLMY.pingGeneric("UPDATE_UNABLE_TO_APPLY_" + this._pingSuffix, - getCanApplyUpdates(), true); - // Histogram IDs: - // UPDATE_CANNOT_STAGE_EXTERNAL - // UPDATE_CANNOT_STAGE_NOTIFY - AUSTLMY.pingGeneric("UPDATE_CANNOT_STAGE_" + this._pingSuffix, - getCanStageUpdates(), true); - // Histogram IDs: - // UPDATE_INVALID_LASTUPDATETIME_EXTERNAL - // UPDATE_INVALID_LASTUPDATETIME_NOTIFY - // UPDATE_LAST_NOTIFY_INTERVAL_DAYS_EXTERNAL - // UPDATE_LAST_NOTIFY_INTERVAL_DAYS_NOTIFY - AUSTLMY.pingLastUpdateTime(this._pingSuffix); - // Histogram IDs: - // UPDATE_NOT_PREF_UPDATE_ENABLED_EXTERNAL - // UPDATE_NOT_PREF_UPDATE_ENABLED_NOTIFY - AUSTLMY.pingBoolPref("UPDATE_NOT_PREF_UPDATE_ENABLED_" + this._pingSuffix, - PREF_APP_UPDATE_ENABLED, true, true); - // Histogram IDs: - // UPDATE_NOT_PREF_UPDATE_AUTO_EXTERNAL - // UPDATE_NOT_PREF_UPDATE_AUTO_NOTIFY - AUSTLMY.pingBoolPref("UPDATE_NOT_PREF_UPDATE_AUTO_" + this._pingSuffix, - PREF_APP_UPDATE_AUTO, true, true); - // Histogram IDs: - // UPDATE_NOT_PREF_UPDATE_STAGING_ENABLED_EXTERNAL - // UPDATE_NOT_PREF_UPDATE_STAGING_ENABLED_NOTIFY - AUSTLMY.pingBoolPref("UPDATE_NOT_PREF_UPDATE_STAGING_ENABLED_" + - this._pingSuffix, - PREF_APP_UPDATE_STAGING_ENABLED, true, true); - if (AppConstants.platform == "win" || AppConstants.platform == "macosx") { - // Histogram IDs: - // UPDATE_PREF_UPDATE_CANCELATIONS_EXTERNAL - // UPDATE_PREF_UPDATE_CANCELATIONS_NOTIFY - AUSTLMY.pingIntPref("UPDATE_PREF_UPDATE_CANCELATIONS_" + this._pingSuffix, - PREF_APP_UPDATE_CANCELATIONS, 0, 0); - } - if (AppConstants.platform == "macosx") { - // Histogram IDs: - // UPDATE_PREF_UPDATE_CANCELATIONS_OSX_EXTERNAL - // UPDATE_PREF_UPDATE_CANCELATIONS_OSX_NOTIFY - AUSTLMY.pingIntPref("UPDATE_PREF_UPDATE_CANCELATIONS_OSX_" + - this._pingSuffix, - PREF_APP_UPDATE_CANCELATIONS_OSX, 0, 0); - } - let prefType = Services.prefs.getPrefType(PREF_APP_UPDATE_URL_OVERRIDE); - let overridePrefHasValue = prefType != Ci.nsIPrefBranch.PREF_INVALID; - // Histogram IDs: - // UPDATE_HAS_PREF_URL_OVERRIDE_EXTERNAL - // UPDATE_HAS_PREF_URL_OVERRIDE_NOTIFY - AUSTLMY.pingGeneric("UPDATE_HAS_PREF_URL_OVERRIDE_" + this._pingSuffix, - overridePrefHasValue, false); - - // If a download is in progress or the patch has been staged do nothing. - if (this.isDownloading) { - AUSTLMY.pingCheckCode(this._pingSuffix, AUSTLMY.CHK_IS_DOWNLOADING); - return; - } - if (this._downloader && this._downloader.patchIsStaged) { - let readState = readStatusFile(getUpdatesDir()); - if (readState == STATE_PENDING || - readState == STATE_PENDING_ELEVATE) { - AUSTLMY.pingCheckCode(this._pingSuffix, AUSTLMY.CHK_IS_DOWNLOADED); - } else { - AUSTLMY.pingCheckCode(this._pingSuffix, AUSTLMY.CHK_IS_STAGED); - } return; } - let validUpdateURL = true; - try { - this.backgroundChecker.getUpdateURL(false); - } catch (e) { - validUpdateURL = false; - } - // The following checks are done here so they can be differentiated from - // foreground checks. - if (!UpdateUtils.OSVersion) { - AUSTLMY.pingCheckCode(this._pingSuffix, AUSTLMY.CHK_NO_OS_VERSION); - } else if (!UpdateUtils.ABI) { - AUSTLMY.pingCheckCode(this._pingSuffix, AUSTLMY.CHK_NO_OS_ABI); - } else if (!validUpdateURL) { - if (overridePrefHasValue) { - if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_URL_OVERRIDE)) { - AUSTLMY.pingCheckCode(this._pingSuffix, - AUSTLMY.CHK_INVALID_USER_OVERRIDE_URL); - } else { - AUSTLMY.pingCheckCode(this._pingSuffix, - AUSTLMY.CHK_INVALID_DEFAULT_OVERRIDE_URL); - } - } else { - AUSTLMY.pingCheckCode(this._pingSuffix, - AUSTLMY.CHK_INVALID_DEFAULT_URL); - } - } else if (!getPref("getBoolPref", PREF_APP_UPDATE_ENABLED, true)) { - AUSTLMY.pingCheckCode(this._pingSuffix, AUSTLMY.CHK_PREF_DISABLED); - } else if (!hasUpdateMutex()) { - AUSTLMY.pingCheckCode(this._pingSuffix, AUSTLMY.CHK_NO_MUTEX); - } else if (!gCanCheckForUpdates) { - AUSTLMY.pingCheckCode(this._pingSuffix, AUSTLMY.CHK_UNABLE_TO_CHECK); - } else if (!this.backgroundChecker._enabled) { - AUSTLMY.pingCheckCode(this._pingSuffix, AUSTLMY.CHK_DISABLED_FOR_SESSION); - } - this.backgroundChecker.checkForUpdates(this, false); }, @@ -1992,7 +1786,6 @@ UpdateService.prototype = { */ selectUpdate: function AUS_selectUpdate(updates) { if (updates.length == 0) { - AUSTLMY.pingCheckCode(this._pingSuffix, AUSTLMY.CHK_NO_UPDATE_FOUND); return null; } @@ -2005,7 +1798,6 @@ UpdateService.prototype = { var majorUpdate = null; var minorUpdate = null; var vc = Services.vc; - let lastCheckCode = AUSTLMY.CHK_NO_COMPAT_UPDATE_FOUND; updates.forEach(function(aUpdate) { // Ignore updates for older versions of the applications and updates for @@ -2018,7 +1810,6 @@ UpdateService.prototype = { LOG("UpdateService:selectUpdate - skipping update because the " + "update's application version is less than or equal to " + "the current application version."); - lastCheckCode = AUSTLMY.CHK_UPDATE_PREVIOUS_VERSION; return; } @@ -2027,10 +1818,9 @@ UpdateService.prototype = { // (see bug 350636). let neverPrefName = PREFBRANCH_APP_UPDATE_NEVER + aUpdate.appVersion; if (aUpdate.showNeverForVersion && - getPref("getBoolPref", neverPrefName, false)) { + Services.prefs.getBoolPref(neverPrefName, false)) { LOG("UpdateService:selectUpdate - skipping update because the " + "preference " + neverPrefName + " is true"); - lastCheckCode = AUSTLMY.CHK_UPDATE_NEVER_PREF; return; } @@ -2050,7 +1840,6 @@ UpdateService.prototype = { default: LOG("UpdateService:selectUpdate - skipping unknown update type: " + aUpdate.type); - lastCheckCode = AUSTLMY.CHK_UPDATE_INVALID_TYPE; break; } }); @@ -2058,9 +1847,9 @@ UpdateService.prototype = { let update = minorUpdate || majorUpdate; if (AppConstants.platform == "macosx" && update) { if (getElevationRequired()) { - let installAttemptVersion = getPref("getCharPref", + let installAttemptVersion = Services.prefs.getCharPref( PREF_APP_UPDATE_ELEVATE_VERSION, - null); + ""); if (vc.compare(installAttemptVersion, update.appVersion) != 0) { Services.prefs.setCharPref(PREF_APP_UPDATE_ELEVATE_VERSION, update.appVersion); @@ -2072,28 +1861,20 @@ UpdateService.prototype = { Services.prefs.clearUserPref(PREF_APP_UPDATE_ELEVATE_NEVER); } } else { - let numCancels = getPref("getIntPref", - PREF_APP_UPDATE_CANCELATIONS_OSX, 0); - let rejectedVersion = getPref("getCharPref", - PREF_APP_UPDATE_ELEVATE_NEVER, ""); - let maxCancels = getPref("getIntPref", - PREF_APP_UPDATE_CANCELATIONS_OSX_MAX, + let numCancels = Services.prefs.getIntPref(PREF_APP_UPDATE_CANCELATIONS_OSX, 0); + let rejectedVersion = Services.prefs.getCharPref(PREF_APP_UPDATE_ELEVATE_NEVER, ""); + let maxCancels = Services.prefs.getIntPref(PREF_APP_UPDATE_CANCELATIONS_OSX_MAX, DEFAULT_CANCELATIONS_OSX_MAX); if (numCancels >= maxCancels) { LOG("UpdateService:selectUpdate - the user requires elevation to " + "install this update, but the user has exceeded the max " + "number of elevation attempts."); update.elevationFailure = true; - AUSTLMY.pingCheckCode( - this._pingSuffix, - AUSTLMY.CHK_ELEVATION_DISABLED_FOR_VERSION); } else if (vc.compare(rejectedVersion, update.appVersion) == 0) { LOG("UpdateService:selectUpdate - the user requires elevation to " + "install this update, but elevation is disabled for this " + "version."); update.elevationFailure = true; - AUSTLMY.pingCheckCode(this._pingSuffix, - AUSTLMY.CHK_ELEVATION_OPTOUT_FOR_VERSION); } else { LOG("UpdateService:selectUpdate - the user requires elevation to " + "install the update."); @@ -2113,8 +1894,6 @@ UpdateService.prototype = { Services.prefs.clearUserPref(PREF_APP_UPDATE_ELEVATE_NEVER); } } - } else if (!update) { - AUSTLMY.pingCheckCode(this._pingSuffix, lastCheckCode); } return update; @@ -2132,13 +1911,11 @@ UpdateService.prototype = { var um = Cc["@mozilla.org/updates/update-manager;1"]. getService(Ci.nsIUpdateManager); if (um.activeUpdate) { - AUSTLMY.pingCheckCode(this._pingSuffix, AUSTLMY.CHK_HAS_ACTIVEUPDATE); return; } - var updateEnabled = getPref("getBoolPref", PREF_APP_UPDATE_ENABLED, true); + var updateEnabled = Services.prefs.getBoolPref(PREF_APP_UPDATE_ENABLED, true); if (!updateEnabled) { - AUSTLMY.pingCheckCode(this._pingSuffix, AUSTLMY.CHK_PREF_DISABLED); LOG("UpdateService:_selectAndInstallUpdate - not prompting because " + "update is disabled"); return; @@ -2152,12 +1929,11 @@ UpdateService.prototype = { if (update.unsupported) { LOG("UpdateService:_selectAndInstallUpdate - update not supported for " + "this system"); - if (!getPref("getBoolPref", PREF_APP_UPDATE_NOTIFIEDUNSUPPORTED, false)) { + if (!Services.prefs.getBoolPref(PREF_APP_UPDATE_NOTIFIEDUNSUPPORTED, false)) { LOG("UpdateService:_selectAndInstallUpdate - notifying that the " + "update is not supported for this system"); this._showPrompt(update); } - AUSTLMY.pingCheckCode(this._pingSuffix, AUSTLMY.CHK_UNSUPPORTED); return; } @@ -2165,7 +1941,6 @@ UpdateService.prototype = { LOG("UpdateService:_selectAndInstallUpdate - the user is unable to " + "apply updates... prompting"); this._showPrompt(update); - AUSTLMY.pingCheckCode(this._pingSuffix, AUSTLMY.CHK_UNABLE_TO_APPLY); return; } @@ -2188,15 +1963,13 @@ UpdateService.prototype = { if (update.showPrompt) { LOG("UpdateService:_selectAndInstallUpdate - prompting because the " + "update snippet specified showPrompt"); - AUSTLMY.pingCheckCode(this._pingSuffix, AUSTLMY.CHK_SHOWPROMPT_SNIPPET); this._showPrompt(update); return; } - if (!getPref("getBoolPref", PREF_APP_UPDATE_AUTO, true)) { + if (!Services.prefs.getBoolPref(PREF_APP_UPDATE_AUTO, true)) { LOG("UpdateService:_selectAndInstallUpdate - prompting because silent " + "install is disabled"); - AUSTLMY.pingCheckCode(this._pingSuffix, AUSTLMY.CHK_SHOWPROMPT_PREF); this._showPrompt(update); return; } @@ -2206,7 +1979,6 @@ UpdateService.prototype = { if (status == STATE_NONE) { cleanupActiveUpdate(); } - AUSTLMY.pingCheckCode(this._pingSuffix, AUSTLMY.CHK_DOWNLOAD_UPDATE); }, _showPrompt: function AUS__showPrompt(update) { @@ -2370,8 +2142,6 @@ UpdateService.prototype = { if (!osApplyToDir) { LOG("UpdateService:applyOsUpdate - Error: osApplyToDir is not defined" + "in the nsIUpdate!"); - pingStateAndStatusCodes(aUpdate, false, - STATE_FAILED + ": " + FOTA_FILE_OPERATION_ERROR); handleUpdateFailure(aUpdate, FOTA_FILE_OPERATION_ERROR); return; } @@ -2381,8 +2151,6 @@ UpdateService.prototype = { if (!updateFile.exists()) { LOG("UpdateService:applyOsUpdate - Error: OS update is not found at " + updateFile.path); - pingStateAndStatusCodes(aUpdate, false, - STATE_FAILED + ": " + FOTA_FILE_OPERATION_ERROR); handleUpdateFailure(aUpdate, FOTA_FILE_OPERATION_ERROR); return; } @@ -2397,8 +2165,6 @@ UpdateService.prototype = { } catch (e) { LOG("UpdateService:applyOsUpdate - Error: Couldn't reboot into recovery" + " to apply FOTA update " + updateFile.path); - pingStateAndStatusCodes(aUpdate, false, - STATE_FAILED + ": " + FOTA_RECOVERY_ERROR); writeStatusFile(getUpdatesDir(), aUpdate.state = STATE_APPLIED); handleUpdateFailure(aUpdate, FOTA_RECOVERY_ERROR); } @@ -2700,7 +2466,6 @@ UpdateManager.prototype = { return; } var status = readStatusFile(getUpdatesDir()); - pingStateAndStatusCodes(update, false, status); var parts = status.split(":"); update.state = parts[0]; if (update.state == STATE_FAILED && parts[1]) { @@ -2733,7 +2498,7 @@ UpdateManager.prototype = { Services.obs.notifyObservers(null, "update-staged", update.state); // Only prompt when the UI isn't already open. - let windowType = getPref("getCharPref", PREF_APP_UPDATE_ALTWINDOWTYPE, null); + let windowType = Services.prefs.getCharPref(PREF_APP_UPDATE_ALTWINDOWTYPE, ""); if (Services.wm.getMostRecentWindow(UPDATE_WINDOW_NAME) || windowType && Services.wm.getMostRecentWindow(windowType)) { return; @@ -2813,15 +2578,12 @@ Checker.prototype = { this._forced = force; // Use the override URL if specified. - let url = getPref("getCharPref", PREF_APP_UPDATE_URL_OVERRIDE, null); + let url = Services.prefs.getCharPref(PREF_APP_UPDATE_URL_OVERRIDE, ""); // Otherwise, construct the update URL from component parts. if (!url) { - try { - url = Services.prefs.getDefaultBranch(null). - getCharPref(PREF_APP_UPDATE_URL); - } catch (e) { - } + url = Services.prefs.getDefaultBranch(null). + getCharPref(PREF_APP_UPDATE_URL, ""); } if (!url || url == "") { @@ -3016,7 +2778,7 @@ Checker.prototype = { */ _enabled: true, get enabled() { - return getPref("getBoolPref", PREF_APP_UPDATE_ENABLED, true) && + return Services.prefs.getBoolPref(PREF_APP_UPDATE_ENABLED, true) && gCanCheckForUpdates && hasUpdateMutex() && this._enabled; }, @@ -3115,8 +2877,6 @@ Downloader.prototype = { _verifyDownload: function Downloader__verifyDownload() { LOG("Downloader:_verifyDownload called"); if (!this._request) { - AUSTLMY.pingDownloadCode(this.isCompleteUpdate, - AUSTLMY.DWNLD_ERR_VERIFY_NO_REQUEST); return false; } @@ -3125,8 +2885,6 @@ Downloader.prototype = { // Ensure that the file size matches the expected file size. if (destination.fileSize != this._patch.size) { LOG("Downloader:_verifyDownload downloaded size != expected size."); - AUSTLMY.pingDownloadCode(this.isCompleteUpdate, - AUSTLMY.DWNLD_ERR_VERIFY_PATCH_SIZE_NOT_EQUAL); return false; } @@ -3171,8 +2929,6 @@ Downloader.prototype = { } LOG("Downloader:_verifyDownload hashes do not match. "); - AUSTLMY.pingDownloadCode(this.isCompleteUpdate, - AUSTLMY.DWNLD_ERR_VERIFY_NO_HASH_MATCH); return false; }, @@ -3299,7 +3055,6 @@ Downloader.prototype = { downloadUpdate: function Downloader_downloadUpdate(update) { LOG("UpdateService:_downloadUpdate"); if (!update) { - AUSTLMY.pingDownloadCode(undefined, AUSTLMY.DWNLD_ERR_NO_UPDATE); throw Cr.NS_ERROR_NULL_POINTER; } @@ -3312,7 +3067,6 @@ Downloader.prototype = { this._patch = this._selectPatch(update, updateDir); if (!this._patch) { LOG("Downloader:downloadUpdate - no patch to download"); - AUSTLMY.pingDownloadCode(undefined, AUSTLMY.DWNLD_ERR_NO_UPDATE_PATCH); return readStatusFile(updateDir); } this.isCompleteUpdate = this._patch.type == "complete"; @@ -3324,8 +3078,6 @@ Downloader.prototype = { patchFile = this._getUpdateArchiveFile(); } if (!patchFile) { - AUSTLMY.pingDownloadCode(this.isCompleteUpdate, - AUSTLMY.DWNLD_ERR_NO_PATCH_FILE); return STATE_NONE; } @@ -3429,8 +3181,6 @@ Downloader.prototype = { // It's important that we use a different code than // NS_ERROR_CORRUPTED_CONTENT so that tests can verify the difference // between a hash error and a wrong download error. - AUSTLMY.pingDownloadCode(this.isCompleteUpdate, - AUSTLMY.DWNLD_ERR_PATCH_SIZE_LARGER); this.cancel(Cr.NS_ERROR_UNEXPECTED); return; } @@ -3441,8 +3191,6 @@ Downloader.prototype = { // It's important that we use a different code than // NS_ERROR_CORRUPTED_CONTENT so that tests can verify the difference // between a hash error and a wrong download error. - AUSTLMY.pingDownloadCode(this.isCompleteUpdate, - AUSTLMY.DWNLD_ERR_PATCH_SIZE_NOT_EQUAL); this.cancel(Cr.NS_ERROR_UNEXPECTED); return; } @@ -3502,11 +3250,11 @@ Downloader.prototype = { var shouldRegisterOnlineObserver = false; var shouldRetrySoon = false; var deleteActiveUpdate = false; - var retryTimeout = getPref("getIntPref", PREF_APP_UPDATE_SOCKET_RETRYTIMEOUT, + var retryTimeout = Services.prefs.getIntPref(PREF_APP_UPDATE_SOCKET_RETRYTIMEOUT, DEFAULT_SOCKET_RETRYTIMEOUT); // Prevent the preference from setting a value greater than 10000. retryTimeout = Math.min(retryTimeout, 10000); - var maxFail = getPref("getIntPref", PREF_APP_UPDATE_SOCKET_MAXERRORS, + var maxFail = Services.prefs.getIntPref(PREF_APP_UPDATE_SOCKET_MAXERRORS, DEFAULT_SOCKET_MAX_ERRORS); // Prevent the preference from setting a value greater than 20. maxFail = Math.min(maxFail, 20); @@ -3523,7 +3271,6 @@ Downloader.prototype = { if (this.background) { shouldShowPrompt = !getCanStageUpdates(); } - AUSTLMY.pingDownloadCode(this.isCompleteUpdate, AUSTLMY.DWNLD_SUCCESS); // Tell the updater.exe we're ready to apply. writeStatusFile(getUpdatesDir(), state); @@ -3553,8 +3300,6 @@ Downloader.prototype = { // calling downloadUpdate on the active update which continues // downloading the file from where it was. LOG("Downloader:onStopRequest - offline, register online observer: true"); - AUSTLMY.pingDownloadCode(this.isCompleteUpdate, - AUSTLMY.DWNLD_RETRY_OFFLINE); shouldRegisterOnlineObserver = true; deleteActiveUpdate = false; // Each of NS_ERROR_NET_TIMEOUT, ERROR_CONNECTION_REFUSED, @@ -3568,25 +3313,11 @@ Downloader.prototype = { status == Cr.NS_ERROR_DOCUMENT_NOT_CACHED) && this.updateService._consecutiveSocketErrors < maxFail) { LOG("Downloader:onStopRequest - socket error, shouldRetrySoon: true"); - let dwnldCode = AUSTLMY.DWNLD_RETRY_CONNECTION_REFUSED; - if (status == Cr.NS_ERROR_NET_TIMEOUT) { - dwnldCode = AUSTLMY.DWNLD_RETRY_NET_TIMEOUT; - } else if (status == Cr.NS_ERROR_NET_RESET) { - dwnldCode = AUSTLMY.DWNLD_RETRY_NET_RESET; - } else if (status == Cr.NS_ERROR_DOCUMENT_NOT_CACHED) { - dwnldCode = AUSTLMY.DWNLD_ERR_DOCUMENT_NOT_CACHED; - } - AUSTLMY.pingDownloadCode(this.isCompleteUpdate, dwnldCode); shouldRetrySoon = true; deleteActiveUpdate = false; } else if (status != Cr.NS_BINDING_ABORTED && status != Cr.NS_ERROR_ABORT) { LOG("Downloader:onStopRequest - non-verification failure"); - let dwnldCode = AUSTLMY.DWNLD_ERR_BINDING_ABORTED; - if (status == Cr.NS_ERROR_ABORT) { - dwnldCode = AUSTLMY.DWNLD_ERR_ABORT; - } - AUSTLMY.pingDownloadCode(this.isCompleteUpdate, dwnldCode); // Some sort of other failure, log this in the |statusText| property state = STATE_DOWNLOAD_FAILED; @@ -3762,20 +3493,20 @@ UpdatePrompt.prototype = { * See nsIUpdateService.idl */ showUpdateAvailable: function UP_showUpdateAvailable(update) { - if (getPref("getBoolPref", PREF_APP_UPDATE_SILENT, false) || + if (Services.prefs.getBoolPref(PREF_APP_UPDATE_SILENT, false) || this._getUpdateWindow() || this._getAltUpdateWindow()) { return; } - this._showUnobtrusiveUI(null, URI_UPDATE_PROMPT_DIALOG, null, - UPDATE_WINDOW_NAME, "updatesavailable", update); + this._showUI(null, URI_UPDATE_PROMPT_DIALOG, null, + UPDATE_WINDOW_NAME, "updatesavailable", update); }, /** * See nsIUpdateService.idl */ showUpdateDownloaded: function UP_showUpdateDownloaded(update, background) { - if (background && getPref("getBoolPref", PREF_APP_UPDATE_SILENT, false)) { + if (background && Services.prefs.getBoolPref(PREF_APP_UPDATE_SILENT, false)) { return; } // Trigger the display of the hamburger menu badge. @@ -3784,20 +3515,15 @@ UpdatePrompt.prototype = { if (this._getAltUpdateWindow()) return; - if (background) { - this._showUnobtrusiveUI(null, URI_UPDATE_PROMPT_DIALOG, null, - UPDATE_WINDOW_NAME, "finishedBackground", update); - } else { - this._showUI(null, URI_UPDATE_PROMPT_DIALOG, null, - UPDATE_WINDOW_NAME, "finishedBackground", update); - } + this._showUI(null, URI_UPDATE_PROMPT_DIALOG, null, + UPDATE_WINDOW_NAME, "finishedBackground", update); }, /** * See nsIUpdateService.idl */ showUpdateError: function UP_showUpdateError(update) { - if (getPref("getBoolPref", PREF_APP_UPDATE_SILENT, false) || + if (Services.prefs.getBoolPref(PREF_APP_UPDATE_SILENT, false) || this._getAltUpdateWindow()) return; @@ -3840,7 +3566,7 @@ UpdatePrompt.prototype = { * See nsIUpdateService.idl */ showUpdateElevationRequired: function UP_showUpdateElevationRequired() { - if (getPref("getBoolPref", PREF_APP_UPDATE_SILENT, false) || + if (Services.prefs.getBoolPref(PREF_APP_UPDATE_SILENT, false) || this._getAltUpdateWindow()) { return; } @@ -3864,7 +3590,7 @@ UpdatePrompt.prototype = { * application update user interface window. */ _getAltUpdateWindow: function UP__getAltUpdateWindow() { - let windowType = getPref("getCharPref", PREF_APP_UPDATE_ALTWINDOWTYPE, null); + let windowType = Services.prefs.getCharPref(PREF_APP_UPDATE_ALTWINDOWTYPE, ""); if (!windowType) return null; return Services.wm.getMostRecentWindow(windowType); @@ -3916,7 +3642,7 @@ UpdatePrompt.prototype = { var idleService = Cc["@mozilla.org/widget/idleservice;1"]. getService(Ci.nsIIdleService); // Don't allow the preference to set a value greater than 600 seconds for the idle time. - const IDLE_TIME = Math.min(getPref("getIntPref", PREF_APP_UPDATE_IDLETIME, 60), 600); + const IDLE_TIME = Math.min(Services.prefs.getIntPref(PREF_APP_UPDATE_IDLETIME, 60), 600); if (idleService.idleTime / 1000 >= IDLE_TIME) { this._showUI(parent, uri, features, name, page, update); return; @@ -3961,7 +3687,7 @@ UpdatePrompt.prototype = { getService(Ci.nsIIdleService); // Don't allow the preference to set a value greater than 600 seconds for the idle time. - const IDLE_TIME = Math.min(getPref("getIntPref", PREF_APP_UPDATE_IDLETIME, 60), 600); + const IDLE_TIME = Math.min(Services.prefs.getIntPref(PREF_APP_UPDATE_IDLETIME, 60), 600); if (idleService.idleTime / 1000 >= IDLE_TIME) { this._showUI(parent, uri, features, name, page, update); } else { diff --git a/toolkit/mozapps/update/updater/updater.cpp b/toolkit/mozapps/update/updater/updater.cpp index c0b01bfbc..8025deaaf 100644 --- a/toolkit/mozapps/update/updater/updater.cpp +++ b/toolkit/mozapps/update/updater/updater.cpp @@ -3648,88 +3648,6 @@ int add_dir_entries(const NS_tchar *dirpath, ActionList *list) return rv; } -#elif defined(SOLARIS) -int add_dir_entries(const NS_tchar *dirpath, ActionList *list) -{ - int rv = OK; - NS_tchar foundpath[MAXPATHLEN]; - struct { - dirent dent_buffer; - char chars[MAXNAMLEN]; - } ent_buf; - struct dirent* ent; - mozilla::UniquePtr<NS_tchar[]> searchpath(get_full_path(dirpath)); - - DIR* dir = opendir(searchpath.get()); - if (!dir) { - LOG(("add_dir_entries error on opendir: " LOG_S ", err: %d", searchpath.get(), - errno)); - return UNEXPECTED_FILE_OPERATION_ERROR; - } - - while (readdir_r(dir, (dirent *)&ent_buf, &ent) == 0 && ent) { - if ((strcmp(ent->d_name, ".") == 0) || - (strcmp(ent->d_name, "..") == 0)) - continue; - - NS_tsnprintf(foundpath, sizeof(foundpath)/sizeof(foundpath[0]), - NS_T("%s%s"), searchpath.get(), ent->d_name); - struct stat64 st_buf; - int test = stat64(foundpath, &st_buf); - if (test) { - closedir(dir); - return UNEXPECTED_FILE_OPERATION_ERROR; - } - if (S_ISDIR(st_buf.st_mode)) { - NS_tsnprintf(foundpath, sizeof(foundpath)/sizeof(foundpath[0]), - NS_T("%s/"), foundpath); - // Recurse into the directory. - rv = add_dir_entries(foundpath, list); - if (rv) { - LOG(("add_dir_entries error: " LOG_S ", err: %d", foundpath, rv)); - closedir(dir); - return rv; - } - } else { - // Add the file to be removed to the ActionList. - NS_tchar *quotedpath = get_quoted_path(get_relative_path(foundpath)); - if (!quotedpath) { - closedir(dir); - return PARSE_ERROR; - } - - Action *action = new RemoveFile(); - rv = action->Parse(quotedpath); - if (rv) { - LOG(("add_dir_entries Parse error on recurse: " LOG_S ", err: %d", - quotedpath, rv)); - closedir(dir); - return rv; - } - - list->Append(action); - } - } - closedir(dir); - - // Add the directory to be removed to the ActionList. - NS_tchar *quotedpath = get_quoted_path(get_relative_path(dirpath)); - if (!quotedpath) - return PARSE_ERROR; - - Action *action = new RemoveDir(); - rv = action->Parse(quotedpath); - if (rv) { - LOG(("add_dir_entries Parse error on close: " LOG_S ", err: %d", - quotedpath, rv)); - } - else { - list->Append(action); - } - - return rv; -} - #else int add_dir_entries(const NS_tchar *dirpath, ActionList *list) |