From 840ecb5262c7330f98f37460b9a209d80407d91c Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Wed, 5 Feb 2020 13:52:28 -0500 Subject: Issue #65 - Remove AppConstants from toolkit/profile --- toolkit/profile/content/createProfileWizard.js | 14 ++++++-------- toolkit/profile/content/profileSelection.js | 6 +++--- toolkit/profile/jar.mn | 4 ++-- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/toolkit/profile/content/createProfileWizard.js b/toolkit/profile/content/createProfileWizard.js index 14d006b31..f13eb8faa 100644 --- a/toolkit/profile/content/createProfileWizard.js +++ b/toolkit/profile/content/createProfileWizard.js @@ -5,8 +5,6 @@ const C = Components.classes; const I = Components.interfaces; -Components.utils.import("resource://gre/modules/AppConstants.jsm"); - const ToolkitProfileService = "@mozilla.org/toolkit/profile-service;1"; var gProfileService; @@ -118,12 +116,12 @@ function checkCurrentInput(currentInput) if (!errorMessage) { finishText.className = ""; - if (AppConstants.platform == "macosx") { - finishText.firstChild.data = gProfileManagerBundle.getString("profileFinishTextMac"); - } - else { - finishText.firstChild.data = gProfileManagerBundle.getString("profileFinishText"); - } + finishText.firstChild.data = gProfileManagerBundle +#ifdef XP_MACOSX + .getString("profileFinishTextMac"); +#else + .getString("profileFinishText"); +#endif canAdvance = true; } else { diff --git a/toolkit/profile/content/profileSelection.js b/toolkit/profile/content/profileSelection.js index 02b9d6873..65a2ba13f 100644 --- a/toolkit/profile/content/profileSelection.js +++ b/toolkit/profile/content/profileSelection.js @@ -4,7 +4,6 @@ * 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/. */ -Components.utils.import("resource://gre/modules/AppConstants.jsm"); Components.utils.import("resource://gre/modules/Services.jsm"); const C = Components.classes; @@ -134,9 +133,10 @@ function onProfilesKey(aEvent) { switch ( aEvent.keyCode ) { +#ifndef XP_MACOSX case KeyEvent.DOM_VK_BACK_SPACE: - if (AppConstants.platform != "macosx") - break; + break; +#endif case KeyEvent.DOM_VK_DELETE: ConfirmDelete(); break; diff --git a/toolkit/profile/jar.mn b/toolkit/profile/jar.mn index 9b7c22266..1c4afac4c 100644 --- a/toolkit/profile/jar.mn +++ b/toolkit/profile/jar.mn @@ -3,7 +3,7 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. toolkit.jar: - content/mozapps/profile/createProfileWizard.js (content/createProfileWizard.js) +* content/mozapps/profile/createProfileWizard.js (content/createProfileWizard.js) * content/mozapps/profile/createProfileWizard.xul (content/createProfileWizard.xul) - content/mozapps/profile/profileSelection.js (content/profileSelection.js) +* content/mozapps/profile/profileSelection.js (content/profileSelection.js) content/mozapps/profile/profileSelection.xul (content/profileSelection.xul) -- cgit v1.2.3 From 43f91872bdaea906e6b30b44d265da3ad202991a Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Wed, 5 Feb 2020 14:31:58 -0500 Subject: Issue #65 - Remove AppConstants from toolkit/mozapps/update --- toolkit/mozapps/update/moz.build | 3 +- toolkit/mozapps/update/nsUpdateService.js | 292 +++++++++++++++--------------- 2 files changed, 152 insertions(+), 143 deletions(-) diff --git a/toolkit/mozapps/update/moz.build b/toolkit/mozapps/update/moz.build index 5f1d56764..f80e5bf5c 100644 --- a/toolkit/mozapps/update/moz.build +++ b/toolkit/mozapps/update/moz.build @@ -18,11 +18,12 @@ XPIDL_SOURCES += [ TEST_DIRS += ['tests'] EXTRA_COMPONENTS += [ - 'nsUpdateService.js', 'nsUpdateService.manifest', 'nsUpdateServiceStub.js', ] +EXTRA_PP_COMPONENTS += ['nsUpdateService.js'] + JAR_MANIFESTS += ['jar.mn'] with Files('**'): diff --git a/toolkit/mozapps/update/nsUpdateService.js b/toolkit/mozapps/update/nsUpdateService.js index dca0a007e..84c92c6f4 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/AppConstants.jsm", this); Cu.importGlobalProperties(["XMLHttpRequest"]); const UPDATESERVICE_CID = Components.ID("{B3C290A6-3943-4B89-8BBE-C01EB7B3B311}"); @@ -219,10 +218,7 @@ function closeHandle(handle) { * @return The Win32 handle to the mutex. */ function createMutex(aName, aAllowExisting = true) { - if (AppConstants.platform != "win") { - throw Cr.NS_ERROR_NOT_IMPLEMENTED; - } - +#ifdef XP_WIN const INITIAL_OWN = 1; const ERROR_ALREADY_EXISTS = 0xB7; let lib = ctypes.open("kernel32.dll"); @@ -246,6 +242,9 @@ function createMutex(aName, aAllowExisting = true) { } return handle; +#else + throw Cr.NS_ERROR_NOT_IMPLEMENTED; +#endif } /** @@ -257,10 +256,7 @@ function createMutex(aName, aAllowExisting = true) { * @return Global mutex path */ function getPerInstallationMutexName(aGlobal = true) { - if (AppConstants.platform != "win") { - throw Cr.NS_ERROR_NOT_IMPLEMENTED; - } - +#ifdef XP_WIN let hasher = Cc["@mozilla.org/security/hash;1"]. createInstance(Ci.nsICryptoHash); hasher.init(hasher.SHA1); @@ -274,6 +270,9 @@ function getPerInstallationMutexName(aGlobal = true) { hasher.update(data, data.length); return (aGlobal ? "Global\\" : "") + "MozillaUpdateMutex-" + hasher.finish(true); +#else + throw Cr.NS_ERROR_NOT_IMPLEMENTED; +#endif } /** @@ -285,13 +284,14 @@ function getPerInstallationMutexName(aGlobal = true) { * @return true if this instance holds the update mutex */ function hasUpdateMutex() { - if (AppConstants.platform != "win") { - return true; - } +#ifdef XP_WIN if (!gUpdateMutexHandle) { gUpdateMutexHandle = createMutex(getPerInstallationMutexName(true), false); } return !!gUpdateMutexHandle; +#else + return true; +#endif } /** @@ -322,10 +322,7 @@ function areDirectoryEntriesWriteable(aDir) { * @return true if elevation is required, false otherwise */ function getElevationRequired() { - if (AppConstants.platform != "macosx") { - return false; - } - +#ifdef XP_MACOSX try { // Recursively check that the application bundle (and its descendants) can // be written to. @@ -344,6 +341,7 @@ function getElevationRequired() { } LOG("getElevationRequired - able to write to application bundle, elevation " + "not required"); +#endif return false; } @@ -355,85 +353,86 @@ function getElevationRequired() { * @return true if an update can be applied, false otherwise */ function getCanApplyUpdates() { - if (AppConstants.platform != "macosx") { - try { - let updateTestFile = getUpdateFile([FILE_UPDATE_TEST]); - LOG("getCanApplyUpdates - testing write access " + updateTestFile.path); - testWriteAccess(updateTestFile, false); - if (AppConstants.platform == "win") { - // Example windowsVersion: Windows XP == 5.1 - let windowsVersion = Services.sysinfo.getProperty("version"); - LOG("getCanApplyUpdates - windowsVersion = " + windowsVersion); - - /** - * For Vista, updates can be performed to a location requiring admin - * privileges by requesting elevation via the UAC prompt when launching - * updater.exe if the appDir is under the Program Files directory - * (e.g. C:\Program Files\) and UAC is turned on and we can elevate - * (e.g. user has a split token). - * - * Note: this does note attempt to handle the case where UAC is turned on - * and the installation directory is in a restricted location that - * requires admin privileges to update other than Program Files. - */ - let userCanElevate = false; - - if (parseFloat(windowsVersion) >= 6) { - try { - // KEY_UPDROOT will fail and throw an exception if - // appDir is not under the Program Files, so we rely on that - let dir = Services.dirsvc.get(KEY_UPDROOT, Ci.nsIFile); - // appDir is under Program Files, so check if the user can elevate - userCanElevate = Services.appinfo.QueryInterface(Ci.nsIWinAppHelper). - userCanElevate; - LOG("getCanApplyUpdates - on Vista, userCanElevate: " + userCanElevate); - } - catch (ex) { - // When the installation directory is not under Program Files, - // fall through to checking if write access to the - // installation directory is available. - LOG("getCanApplyUpdates - on Vista, appDir is not under Program Files"); - } - } +#ifndef XP_MACOSX + try { + let updateTestFile = getUpdateFile([FILE_UPDATE_TEST]); + LOG("getCanApplyUpdates - testing write access " + updateTestFile.path); + testWriteAccess(updateTestFile, false); - /** - * On Windows, we no longer store the update under the app dir. - * - * If we are on Windows (including Vista, if we can't elevate) we need to - * to check that we can create and remove files from the actual app - * directory (like C:\Program Files\Mozilla Firefox). If we can't - * (because this user is not an adminstrator, for example) canUpdate() - * should return false. - * - * For Vista, we perform this check to enable updating the application - * when the user has write access to the installation directory under the - * following scenarios: - * 1) the installation directory is not under Program Files - * (e.g. C:\Program Files) - * 2) UAC is turned off - * 3) UAC is turned on and the user is not an admin - * (e.g. the user does not have a split token) - * 4) UAC is turned on and the user is already elevated, so they can't be - * elevated again - */ - if (!userCanElevate) { - // if we're unable to create the test file this will throw an exception. - let appDirTestFile = getAppBaseDir(); - appDirTestFile.append(FILE_UPDATE_TEST); - LOG("getCanApplyUpdates - testing write access " + appDirTestFile.path); - if (appDirTestFile.exists()) { - appDirTestFile.remove(false); - } - appDirTestFile.create(Ci.nsILocalFile.NORMAL_FILE_TYPE, FileUtils.PERMS_FILE); - appDirTestFile.remove(false); - } +#ifdef XP_WIN + // Example windowsVersion: Windows XP == 5.1 + let windowsVersion = Services.sysinfo.getProperty("version"); + LOG("getCanApplyUpdates - windowsVersion = " + windowsVersion); + + /** + * For Vista, updates can be performed to a location requiring admin + * privileges by requesting elevation via the UAC prompt when launching + * updater.exe if the appDir is under the Program Files directory + * (e.g. C:\Program Files\) and UAC is turned on and we can elevate + * (e.g. user has a split token). + * + * Note: this does note attempt to handle the case where UAC is turned on + * and the installation directory is in a restricted location that + * requires admin privileges to update other than Program Files. + */ + let userCanElevate = false; + + if (parseFloat(windowsVersion) >= 6) { + try { + // KEY_UPDROOT will fail and throw an exception if + // appDir is not under the Program Files, so we rely on that + let dir = Services.dirsvc.get(KEY_UPDROOT, Ci.nsIFile); + // appDir is under Program Files, so check if the user can elevate + userCanElevate = Services.appinfo.QueryInterface(Ci.nsIWinAppHelper). + userCanElevate; + LOG("getCanApplyUpdates - on Vista, userCanElevate: " + userCanElevate); + } + catch (ex) { + // When the installation directory is not under Program Files, + // fall through to checking if write access to the + // installation directory is available. + LOG("getCanApplyUpdates - on Vista, appDir is not under Program Files"); } - } catch (e) { - LOG("getCanApplyUpdates - unable to apply updates. Exception: " + e); - // No write privileges to install directory - return false; } - } + + /** + * On Windows, we no longer store the update under the app dir. + * + * If we are on Windows (including Vista, if we can't elevate) we need to + * to check that we can create and remove files from the actual app + * directory (like C:\Program Files\Mozilla Firefox). If we can't + * (because this user is not an adminstrator, for example) canUpdate() + * should return false. + * + * For Vista, we perform this check to enable updating the application + * when the user has write access to the installation directory under the + * following scenarios: + * 1) the installation directory is not under Program Files + * (e.g. C:\Program Files) + * 2) UAC is turned off + * 3) UAC is turned on and the user is not an admin + * (e.g. the user does not have a split token) + * 4) UAC is turned on and the user is already elevated, so they can't be + * elevated again + */ + if (!userCanElevate) { + // if we're unable to create the test file this will throw an exception. + let appDirTestFile = getAppBaseDir(); + appDirTestFile.append(FILE_UPDATE_TEST); + LOG("getCanApplyUpdates - testing write access " + appDirTestFile.path); + if (appDirTestFile.exists()) { + appDirTestFile.remove(false); + } + appDirTestFile.create(Ci.nsILocalFile.NORMAL_FILE_TYPE, FileUtils.PERMS_FILE); + appDirTestFile.remove(false); + } +#endif // XP_WIN + } catch (e) { + LOG("getCanApplyUpdates - unable to apply updates. Exception: " + e); + // No write privileges to install directory + return false; + } +#endif // !XP_MACOSX LOG("getCanApplyUpdates - able to apply updates"); return true; @@ -454,27 +453,29 @@ XPCOMUtils.defineLazyGetter(this, "gCanStageUpdatesSession", function aus_gCSUS( try { let updateTestFile; - if (AppConstants.platform == "macosx") { - updateTestFile = getUpdateFile([FILE_UPDATE_TEST]); - } else { - updateTestFile = getInstallDirRoot(); - updateTestFile.append(FILE_UPDATE_TEST); - } +#ifdef XP_MACOSX + updateTestFile = getUpdateFile([FILE_UPDATE_TEST]); +#else + updateTestFile = getInstallDirRoot(); + updateTestFile.append(FILE_UPDATE_TEST); +#endif + LOG("gCanStageUpdatesSession - testing write access " + updateTestFile.path); testWriteAccess(updateTestFile, true); - if (AppConstants.platform != "macosx") { - // On all platforms except Mac, we need to test the parent directory as - // well, as we need to be able to move files in that directory during the - // replacing step. - updateTestFile = getInstallDirRoot().parent; - updateTestFile.append(FILE_UPDATE_TEST); - LOG("gCanStageUpdatesSession - testing write access " + - updateTestFile.path); - updateTestFile.createUnique(Ci.nsILocalFile.DIRECTORY_TYPE, - FileUtils.PERMS_DIRECTORY); - updateTestFile.remove(false); - } + +#ifndef XP_MACOSX + // On all platforms except Mac, we need to test the parent directory as + // well, as we need to be able to move files in that directory during the + // replacing step. + updateTestFile = getInstallDirRoot().parent; + updateTestFile.append(FILE_UPDATE_TEST); + LOG("gCanStageUpdatesSession - testing write access " + + updateTestFile.path); + updateTestFile.createUnique(Ci.nsILocalFile.DIRECTORY_TYPE, + FileUtils.PERMS_DIRECTORY); + updateTestFile.remove(false); +#endif // !XP_MACOSX } catch (e) { LOG("gCanStageUpdatesSession - unable to stage updates. Exception: " + e); @@ -593,10 +594,10 @@ function getAppBaseDir() { */ function getInstallDirRoot() { let dir = getAppBaseDir(); - if (AppConstants.platform == "macosx") { - // On Mac, we store the Updated.app directory inside the bundle directory. - dir = dir.parent.parent; - } +#ifdef XP_MACOSX + // On Mac, we store the Updated.app directory inside the bundle directory. + dir = dir.parent.parent; +#endif return dir; } @@ -879,31 +880,33 @@ function handleUpdateFailure(update, errorCode) { 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 = Services.prefs.getIntPref(PREF_APP_UPDATE_CANCELATIONS_OSX, 0); - osxCancelations++; - Services.prefs.setIntPref(PREF_APP_UPDATE_CANCELATIONS_OSX, - osxCancelations); - 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. - maxCancels = Math.min(maxCancels, 5); - if (osxCancelations >= maxCancels) { - cleanupActiveUpdate(); - } else { - writeStatusFile(getUpdatesDir(), - update.state = STATE_PENDING_ELEVATE); - } - update.statusText = gUpdateBundle.GetStringFromName("elevationFailure"); - update.QueryInterface(Ci.nsIWritablePropertyBag); - update.setProperty("patchingFailed", "elevationFailure"); - let prompter = Cc["@mozilla.org/updates/update-prompt;1"]. - createInstance(Ci.nsIUpdatePrompt); - prompter.showUpdateError(update); + +#ifdef XP_MACOSX + let osxCancelations = Services.prefs.getIntPref(PREF_APP_UPDATE_CANCELATIONS_OSX, 0); + osxCancelations++; + Services.prefs.setIntPref(PREF_APP_UPDATE_CANCELATIONS_OSX, + osxCancelations); + 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. + maxCancels = Math.min(maxCancels, 5); + if (osxCancelations >= maxCancels) { + cleanupActiveUpdate(); } else { - writeStatusFile(getUpdatesDir(), update.state = STATE_PENDING); + writeStatusFile(getUpdatesDir(), + update.state = STATE_PENDING_ELEVATE); } + update.statusText = gUpdateBundle.GetStringFromName("elevationFailure"); + update.QueryInterface(Ci.nsIWritablePropertyBag); + update.setProperty("patchingFailed", "elevationFailure"); + let prompter = Cc["@mozilla.org/updates/update-prompt;1"]. + createInstance(Ci.nsIUpdatePrompt); + prompter.showUpdateError(update); +#else + writeStatusFile(getUpdatesDir(), update.state = STATE_PENDING); +#endif + return true; } @@ -1483,12 +1486,15 @@ UpdateService.prototype = { Services.obs.removeObserver(this, topic); Services.prefs.removeObserver(PREF_APP_UPDATE_LOG, this); - if (AppConstants.platform == "win" && gUpdateMutexHandle) { +#ifdef XP_WIN + if (gUpdateMutexHandle) { // If we hold the update mutex, let it go! // The OS would clean this up sometime after shutdown, // but that would have no guarantee on timing. closeHandle(gUpdateMutexHandle); } +#endif + if (this._retryTimer) { this._retryTimer.cancel(); } @@ -1845,7 +1851,8 @@ UpdateService.prototype = { }); let update = minorUpdate || majorUpdate; - if (AppConstants.platform == "macosx" && update) { +#ifdef XP_MACOSX + if (update) { if (getElevationRequired()) { let installAttemptVersion = Services.prefs.getCharPref( PREF_APP_UPDATE_ELEVATE_VERSION, @@ -1895,6 +1902,7 @@ UpdateService.prototype = { } } } +#endif return update; }, @@ -2890,11 +2898,11 @@ Downloader.prototype = { LOG("Downloader:_verifyDownload downloaded size == expected size."); +#ifdef MOZ_VERIFY_MAR_SIGNATURE // The hash check is not necessary when mar signatures are used to verify // the downloaded mar file. - if (AppConstants.MOZ_VERIFY_MAR_SIGNATURE) { - return true; - } + return true; +#endif let fileStream = Cc["@mozilla.org/network/file-input-stream;1"]. createInstance(Ci.nsIFileInputStream); -- cgit v1.2.3 From 758618b6054d9332a8a0bd79f73623abfd5e1d3c Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Thu, 6 Feb 2020 06:07:37 -0500 Subject: Issue #65 - Remove AppConstants from toolkit/mozapps/extensions --- toolkit/mozapps/extensions/GMPUtils.jsm | 17 ++++++++++------- toolkit/mozapps/extensions/moz.build | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/toolkit/mozapps/extensions/GMPUtils.jsm b/toolkit/mozapps/extensions/GMPUtils.jsm index 814ae4914..3c691610d 100644 --- a/toolkit/mozapps/extensions/GMPUtils.jsm +++ b/toolkit/mozapps/extensions/GMPUtils.jsm @@ -15,7 +15,6 @@ this.EXPORTED_SYMBOLS = [ "GMP_PLUGIN_IDS", Cu.import("resource://gre/modules/Preferences.jsm"); Cu.import("resource://gre/modules/Services.jsm"); -Cu.import("resource://gre/modules/AppConstants.jsm"); // GMP IDs const OPEN_H264_ID = "gmp-gmpopenh264"; @@ -71,21 +70,25 @@ this.GMPUtils = { return true; } if (aPlugin.id == WIDEVINE_ID) { + +#if defined(XP_WIN) || defined(XP_LINUX) || defined(XP_MACOSX) // The Widevine plugin is available for Windows versions Vista and later, // Mac OSX, and Linux. - return AppConstants.isPlatformAndVersionAtLeast("win", "6") || - AppConstants.platform == "macosx" || - AppConstants.platform == "linux"; + return true; +#else + return false; +#endif } return true; }, _is32bitModeMacOS: function() { - if (AppConstants.platform != "macosx") { - return false; - } +#ifdef XP_MACOSX return Services.appinfo.XPCOMABI.split("-")[0] == "x86"; +#else + return false; +#endif }, /** diff --git a/toolkit/mozapps/extensions/moz.build b/toolkit/mozapps/extensions/moz.build index 104e8d734..b65ce4c68 100644 --- a/toolkit/mozapps/extensions/moz.build +++ b/toolkit/mozapps/extensions/moz.build @@ -29,13 +29,13 @@ EXTRA_PP_COMPONENTS += [ EXTRA_JS_MODULES += [ 'ChromeManifestParser.jsm', 'DeferredSave.jsm', - 'GMPUtils.jsm', 'LightweightThemeManager.jsm', ] EXTRA_PP_JS_MODULES += [ 'AddonManager.jsm', 'GMPInstallManager.jsm', + 'GMPUtils.jsm', ] # Additional debugging info is exposed in debug builds -- cgit v1.2.3 From 2e6782afb5a340c777d3dab1c5e82f3e4af06ad2 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Thu, 6 Feb 2020 06:32:11 -0500 Subject: Issue #65 - Remove AppConstants from toolkit/mozapps/downloads --- .../mozapps/downloads/DownloadTaskbarProgress.jsm | 68 ++++---- toolkit/mozapps/downloads/content/downloads.js | 30 ++-- toolkit/mozapps/downloads/jar.mn | 2 +- toolkit/mozapps/downloads/moz.build | 3 +- toolkit/mozapps/downloads/nsHelperAppDlg.js | 176 +++++++++++---------- 5 files changed, 141 insertions(+), 138 deletions(-) diff --git a/toolkit/mozapps/downloads/DownloadTaskbarProgress.jsm b/toolkit/mozapps/downloads/DownloadTaskbarProgress.jsm index bccbeda56..e015ded2a 100644 --- a/toolkit/mozapps/downloads/DownloadTaskbarProgress.jsm +++ b/toolkit/mozapps/downloads/DownloadTaskbarProgress.jsm @@ -16,7 +16,6 @@ const Cu = Components.utils; const Cr = Components.results; Cu.import("resource://gre/modules/XPCOMUtils.jsm"); -Cu.import("resource://gre/modules/AppConstants.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "Services", "resource://gre/modules/Services.jsm"); @@ -177,33 +176,33 @@ var DownloadTaskbarProgressUpdater = */ _setActiveWindow: function DTPU_setActiveWindow(aWindow, aIsDownloadWindow) { - if (AppConstants.platform == "win") { - // Clear out the taskbar for the old active window. (If there was no active - // window, this is a no-op.) - this._clearTaskbar(); - - this._activeWindowIsDownloadWindow = aIsDownloadWindow; - if (aWindow) { - // Get the taskbar progress for this window - let docShell = aWindow.QueryInterface(Ci.nsIInterfaceRequestor). - getInterface(Ci.nsIWebNavigation). - QueryInterface(Ci.nsIDocShellTreeItem).treeOwner. - QueryInterface(Ci.nsIInterfaceRequestor). - getInterface(Ci.nsIXULWindow).docShell; - let taskbarProgress = this._taskbar.getTaskbarProgress(docShell); - this._activeTaskbarProgress = taskbarProgress; - - this._updateTaskbar(); - // _onActiveWindowUnload is idempotent, so we don't need to check whether - // we've already set this before or not. - aWindow.addEventListener("unload", function () { - DownloadTaskbarProgressUpdater._onActiveWindowUnload(taskbarProgress); - }, false); - } - else { - this._activeTaskbarProgress = null; - } +#ifdef XP_WIN + // Clear out the taskbar for the old active window. (If there was no active + // window, this is a no-op.) + this._clearTaskbar(); + + this._activeWindowIsDownloadWindow = aIsDownloadWindow; + if (aWindow) { + // Get the taskbar progress for this window + let docShell = aWindow.QueryInterface(Ci.nsIInterfaceRequestor). + getInterface(Ci.nsIWebNavigation). + QueryInterface(Ci.nsIDocShellTreeItem).treeOwner. + QueryInterface(Ci.nsIInterfaceRequestor). + getInterface(Ci.nsIXULWindow).docShell; + let taskbarProgress = this._taskbar.getTaskbarProgress(docShell); + this._activeTaskbarProgress = taskbarProgress; + + this._updateTaskbar(); + // _onActiveWindowUnload is idempotent, so we don't need to check whether + // we've already set this before or not. + aWindow.addEventListener("unload", function () { + DownloadTaskbarProgressUpdater._onActiveWindowUnload(taskbarProgress); + }, false); + } + else { + this._activeTaskbarProgress = null; } +#endif }, // / Current state displayed on the active window's taskbar item @@ -213,14 +212,15 @@ var DownloadTaskbarProgressUpdater = _shouldSetState: function DTPU_shouldSetState() { - if (AppConstants.platform == "win") { - // If the active window is not the download manager window, set the state - // only if it is normal or indeterminate. - return this._activeWindowIsDownloadWindow || - (this._taskbarState == Ci.nsITaskbarProgress.STATE_NORMAL || - this._taskbarState == Ci.nsITaskbarProgress.STATE_INDETERMINATE); - } +#ifdef XP_WIN + // If the active window is not the download manager window, set the state + // only if it is normal or indeterminate. + return this._activeWindowIsDownloadWindow || + (this._taskbarState == Ci.nsITaskbarProgress.STATE_NORMAL || + this._taskbarState == Ci.nsITaskbarProgress.STATE_INDETERMINATE); +#else return true; +#endif }, /** diff --git a/toolkit/mozapps/downloads/content/downloads.js b/toolkit/mozapps/downloads/content/downloads.js index 2fdb19a74..66230592f 100644 --- a/toolkit/mozapps/downloads/content/downloads.js +++ b/toolkit/mozapps/downloads/content/downloads.js @@ -19,7 +19,6 @@ var Cu = Components.utils; Cu.import("resource://gre/modules/XPCOMUtils.jsm"); Cu.import("resource://gre/modules/DownloadUtils.jsm"); Cu.import("resource://gre/modules/Services.jsm"); -Cu.import("resource://gre/modules/AppConstants.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "PluralForm", "resource://gre/modules/PluralForm.jsm"); @@ -253,18 +252,18 @@ function openDownload(aDownload) dontAsk = !pref.getBoolPref(PREF_BDM_CONFIRMOPENEXE); } catch (e) { } - if (AppConstants.platform == "win") { - // On Vista and above, we rely on native security prompting for - // downloaded content unless it's disabled. - try { - var sysInfo = Cc["@mozilla.org/system-info;1"]. - getService(Ci.nsIPropertyBag2); - if (parseFloat(sysInfo.getProperty("version")) >= 6 && - pref.getBoolPref(PREF_BDM_SCANWHENDONE)) { - dontAsk = true; - } - } catch (ex) { } - } +#ifdef XP_WIN + // On Vista and above, we rely on native security prompting for + // downloaded content unless it's disabled. + try { + var sysInfo = Cc["@mozilla.org/system-info;1"]. + getService(Ci.nsIPropertyBag2); + if (parseFloat(sysInfo.getProperty("version")) >= 6 && + pref.getBoolPref(PREF_BDM_SCANWHENDONE)) { + dontAsk = true; + } + } catch (ex) { } +#endif if (!dontAsk) { var strings = document.getElementById("downloadStrings"); @@ -478,10 +477,11 @@ var gDownloadObserver = { removeFromView(dl); break; case "browser-lastwindow-close-granted": - if (AppConstants.platform != "macosx" && - gDownloadManager.activeDownloadCount == 0) { +#ifndef XP_MACOSX + if (gDownloadManager.activeDownloadCount == 0) { setTimeout(gCloseDownloadManager, 0); } +#endif break; } } diff --git a/toolkit/mozapps/downloads/jar.mn b/toolkit/mozapps/downloads/jar.mn index eb761b0d9..29a3d0ee2 100644 --- a/toolkit/mozapps/downloads/jar.mn +++ b/toolkit/mozapps/downloads/jar.mn @@ -6,7 +6,7 @@ toolkit.jar: % content mozapps %content/mozapps/ * content/mozapps/downloads/unknownContentType.xul (content/unknownContentType.xul) * content/mozapps/downloads/downloads.xul (content/downloads.xul) - content/mozapps/downloads/downloads.js (content/downloads.js) +* content/mozapps/downloads/downloads.js (content/downloads.js) content/mozapps/downloads/DownloadProgressListener.js (content/DownloadProgressListener.js) content/mozapps/downloads/downloads.css (content/downloads.css) content/mozapps/downloads/download.xml (content/download.xml) diff --git a/toolkit/mozapps/downloads/moz.build b/toolkit/mozapps/downloads/moz.build index 1850ea7de..9ad081475 100644 --- a/toolkit/mozapps/downloads/moz.build +++ b/toolkit/mozapps/downloads/moz.build @@ -17,8 +17,9 @@ EXTRA_PP_COMPONENTS += [ EXTRA_JS_MODULES += [ 'DownloadLastDir.jsm', 'DownloadPaths.jsm', - 'DownloadTaskbarProgress.jsm', 'DownloadUtils.jsm', ] +EXTRA_PP_JS_MODULES += ['DownloadTaskbarProgress.jsm'] + JAR_MANIFESTS += ['jar.mn'] \ No newline at end of file diff --git a/toolkit/mozapps/downloads/nsHelperAppDlg.js b/toolkit/mozapps/downloads/nsHelperAppDlg.js index 27c0fede0..243db1c2f 100644 --- a/toolkit/mozapps/downloads/nsHelperAppDlg.js +++ b/toolkit/mozapps/downloads/nsHelperAppDlg.js @@ -4,7 +4,6 @@ const {utils: Cu, interfaces: Ci, classes: Cc, results: Cr} = Components; Cu.import("resource://gre/modules/Services.jsm"); -Cu.import("resource://gre/modules/AppConstants.jsm"); Cu.import("resource://gre/modules/XPCOMUtils.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "EnableDelayHelper", "resource://gre/modules/SharedPromptUtils.jsm"); @@ -408,22 +407,22 @@ nsUnknownContentTypeDialog.prototype = { // is now caught properly in the caller of validateLeafName. var createdFile = DownloadPaths.createNiceUniqueFile(aLocalFolder); - if (AppConstants.platform == "win") { - let ext; - try { - // We can fail here if there's no primary extension set - ext = "." + this.mLauncher.MIMEInfo.primaryExtension; - } catch (e) { } - - // Append a file extension if it's an executable that doesn't have one - // but make sure we actually have an extension to add - let leaf = createdFile.leafName; - if (ext && leaf.slice(-ext.length) != ext && createdFile.isExecutable()) { - createdFile.remove(false); - aLocalFolder.leafName = leaf + ext; - createdFile = DownloadPaths.createNiceUniqueFile(aLocalFolder); - } +#ifdef XP_WIN + let ext; + try { + // We can fail here if there's no primary extension set + ext = "." + this.mLauncher.MIMEInfo.primaryExtension; + } catch (e) { } + + // Append a file extension if it's an executable that doesn't have one + // but make sure we actually have an extension to add + let leaf = createdFile.leafName; + if (ext && leaf.slice(-ext.length) != ext && createdFile.isExecutable()) { + createdFile.remove(false); + aLocalFolder.leafName = leaf + ext; + createdFile = DownloadPaths.createNiceUniqueFile(aLocalFolder); } +#endif return createdFile; }, @@ -639,22 +638,22 @@ nsUnknownContentTypeDialog.prototype = { // Returns true if opening the default application makes sense. openWithDefaultOK: function() { - // The checking is different on Windows... - if (AppConstants.platform == "win") { - // Windows presents some special cases. - // We need to prevent use of "system default" when the file is - // executable (so the user doesn't launch nasty programs downloaded - // from the web), and, enable use of "system default" if it isn't - // executable (because we will prompt the user for the default app - // in that case). - - // Default is Ok if the file isn't executable (and vice-versa). - return !this.mLauncher.targetFileIsExecutable; - } +#ifdef XP_WIN + // Windows presents some special cases. + // We need to prevent use of "system default" when the file is + // executable (so the user doesn't launch nasty programs downloaded + // from the web), and, enable use of "system default" if it isn't + // executable (because we will prompt the user for the default app + // in that case). + + // Default is Ok if the file isn't executable (and vice-versa). + return !this.mLauncher.targetFileIsExecutable; +#else // On other platforms, default is Ok if there is a default app. // Note that nsIMIMEInfo providers need to ensure that this holds true // on each platform. return this.mLauncher.MIMEInfo.hasDefaultHandler; +#endif }, // Set "default" application description field. @@ -675,10 +674,11 @@ nsUnknownContentTypeDialog.prototype = { // getPath: getPath: function (aFile) { - if (AppConstants.platform == "macosx") { - return aFile.leafName || aFile.path; - } +#ifdef XP_MACOSX + return aFile.leafName || aFile.path; +#else return aFile.path; +#endif }, // initAppAndSaveToDiskValues: @@ -980,19 +980,20 @@ nsUnknownContentTypeDialog.prototype = { // Retrieve the pretty description from the file getFileDisplayName: function getFileDisplayName(file) { - if (AppConstants.platform == "win") { - if (file instanceof Components.interfaces.nsILocalFileWin) { - try { - return file.getVersionInfoField("FileDescription"); - } catch (e) {} - } - } else if (AppConstants.platform == "macosx") { - if (file instanceof Components.interfaces.nsILocalFileMac) { - try { - return file.bundleDisplayName; - } catch (e) {} - } +#ifdef XP_WIN + if (file instanceof Components.interfaces.nsILocalFileWin) { + try { + return file.getVersionInfoField("FileDescription"); + } catch (e) {} + } +#elifdef XP_MACOSX + if (file instanceof Components.interfaces.nsILocalFileMac) { + try { + return file.bundleDisplayName; + } catch (e) {} } +#endif + return file.leafName; }, @@ -1006,10 +1007,11 @@ nsUnknownContentTypeDialog.prototype = { var otherHandler = this.dialogElement("otherHandler"); otherHandler.removeAttribute("hidden"); otherHandler.setAttribute("path", this.getPath(this.chosenApp.executable)); - if (AppConstants.platform == "win") - otherHandler.label = this.getFileDisplayName(this.chosenApp.executable); - else - otherHandler.label = this.chosenApp.name; +#ifdef XP_WIN + otherHandler.label = this.getFileDisplayName(this.chosenApp.executable); +#else + otherHandler.label = this.chosenApp.name; +#endif this.dialogElement("openHandler").selectedIndex = 1; this.dialogElement("openHandler").setAttribute("lastSelectedItemID", "otherHandler"); @@ -1025,50 +1027,49 @@ nsUnknownContentTypeDialog.prototype = { }, // chooseApp: Open file picker and prompt user for application. chooseApp: function() { - if (AppConstants.platform == "win") { - // Protect against the lack of an extension - var fileExtension = ""; - try { - fileExtension = this.mLauncher.MIMEInfo.primaryExtension; - } catch(ex) { - } +#ifdef XP_WIN + // Protect against the lack of an extension + var fileExtension = ""; + try { + fileExtension = this.mLauncher.MIMEInfo.primaryExtension; + } catch(ex) { + } - // Try to use the pretty description of the type, if one is available. - var typeString = this.mLauncher.MIMEInfo.description; - - if (!typeString) { - // If there is none, use the extension to - // identify the file, e.g. "ZIP file" - if (fileExtension) { - typeString = - this.dialogElement("strings"). - getFormattedString("fileType", [fileExtension.toUpperCase()]); - } else { - // If we can't even do that, just give up and show the MIME type. - typeString = this.mLauncher.MIMEInfo.MIMEType; - } + // Try to use the pretty description of the type, if one is available. + var typeString = this.mLauncher.MIMEInfo.description; + + if (!typeString) { + // If there is none, use the extension to + // identify the file, e.g. "ZIP file" + if (fileExtension) { + typeString = + this.dialogElement("strings"). + getFormattedString("fileType", [fileExtension.toUpperCase()]); + } else { + // If we can't even do that, just give up and show the MIME type. + typeString = this.mLauncher.MIMEInfo.MIMEType; } + } - var params = {}; - params.title = - this.dialogElement("strings").getString("chooseAppFilePickerTitle"); - params.description = typeString; - params.filename = this.mLauncher.suggestedFileName; - params.mimeInfo = this.mLauncher.MIMEInfo; - params.handlerApp = null; - - this.mDialog.openDialog("chrome://global/content/appPicker.xul", null, - "chrome,modal,centerscreen,titlebar,dialog=yes", - params); - - if (params.handlerApp && - params.handlerApp.executable && - params.handlerApp.executable.isFile()) { - // Remember the file they chose to run. - this.chosenApp = params.handlerApp; - } + var params = {}; + params.title = + this.dialogElement("strings").getString("chooseAppFilePickerTitle"); + params.description = typeString; + params.filename = this.mLauncher.suggestedFileName; + params.mimeInfo = this.mLauncher.MIMEInfo; + params.handlerApp = null; + + this.mDialog.openDialog("chrome://global/content/appPicker.xul", null, + "chrome,modal,centerscreen,titlebar,dialog=yes", + params); + + if (params.handlerApp && + params.handlerApp.executable && + params.handlerApp.executable.isFile()) { + // Remember the file they chose to run. + this.chosenApp = params.handlerApp; } - else { +#else #if MOZ_WIDGET_GTK == 3 var nsIApplicationChooser = Components.interfaces.nsIApplicationChooser; var appChooser = Components.classes["@mozilla.org/applicationchooser;1"] @@ -1103,6 +1104,7 @@ nsUnknownContentTypeDialog.prototype = { this.chosenApp = localHandlerApp; } #endif // MOZ_WIDGET_GTK == 3 +#endif // XP_WIN } this.finishChooseApp(); }, -- cgit v1.2.3 From 180543f6c37887cdb19c07cf47491b52154f1157 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Thu, 6 Feb 2020 08:31:14 -0500 Subject: Issue #65 - Remove AppConstants from toolkit/components/jsdownloads --- .../jsdownloads/src/DownloadIntegration.jsm | 10 ++++++---- .../jsdownloads/src/DownloadUIHelper.jsm | 23 +++++++++++----------- toolkit/components/jsdownloads/src/moz.build | 2 +- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/toolkit/components/jsdownloads/src/DownloadIntegration.jsm b/toolkit/components/jsdownloads/src/DownloadIntegration.jsm index a6875ec48..995cc0669 100644 --- a/toolkit/components/jsdownloads/src/DownloadIntegration.jsm +++ b/toolkit/components/jsdownloads/src/DownloadIntegration.jsm @@ -28,8 +28,7 @@ Cu.import("resource://gre/modules/XPCOMUtils.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "AsyncShutdown", "resource://gre/modules/AsyncShutdown.jsm"); -XPCOMUtils.defineLazyModuleGetter(this, "AppConstants", - "resource://gre/modules/AppConstants.jsm"); + XPCOMUtils.defineLazyModuleGetter(this, "DeferredTask", "resource://gre/modules/DeferredTask.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "Downloads", @@ -696,8 +695,11 @@ this.DownloadIntegration = { fileExtension = match[1]; } - let isWindowsExe = AppConstants.platform == "win" && - fileExtension.toLowerCase() == "exe"; +#ifdef XP_WIN + let isWindowsExe = fileExtension.toLowerCase() == "exe"; +#else + let isWindowsExe = false; +#endif // Ask for confirmation if the file is executable, except for .exe on // Windows where the operating system will show the prompt based on the diff --git a/toolkit/components/jsdownloads/src/DownloadUIHelper.jsm b/toolkit/components/jsdownloads/src/DownloadUIHelper.jsm index ce165205b..d4ce248e3 100644 --- a/toolkit/components/jsdownloads/src/DownloadUIHelper.jsm +++ b/toolkit/components/jsdownloads/src/DownloadUIHelper.jsm @@ -22,7 +22,6 @@ const Cu = Components.utils; const Cr = Components.results; Cu.import("resource://gre/modules/XPCOMUtils.jsm"); -Cu.import("resource://gre/modules/AppConstants.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "OS", "resource://gre/modules/osfile.jsm"); @@ -186,17 +185,17 @@ this.DownloadPrompter.prototype = { switch (aPromptType) { case this.ON_QUIT: title = s.quitCancelDownloadsAlertTitle; - if (AppConstants.platform != "macosx") { - message = aDownloadsCount > 1 - ? s.quitCancelDownloadsAlertMsgMultiple(aDownloadsCount) - : s.quitCancelDownloadsAlertMsg; - cancelButton = s.dontQuitButtonWin; - } else { - message = aDownloadsCount > 1 - ? s.quitCancelDownloadsAlertMsgMacMultiple(aDownloadsCount) - : s.quitCancelDownloadsAlertMsgMac; - cancelButton = s.dontQuitButtonMac; - } +#ifdef XP_MACOSX + message = aDownloadsCount > 1 + ? s.quitCancelDownloadsAlertMsgMacMultiple(aDownloadsCount) + : s.quitCancelDownloadsAlertMsgMac; + cancelButton = s.dontQuitButtonMac; +#else + message = aDownloadsCount > 1 + ? s.quitCancelDownloadsAlertMsgMultiple(aDownloadsCount) + : s.quitCancelDownloadsAlertMsg; + cancelButton = s.dontQuitButtonWin; +#endif break; case this.ON_OFFLINE: title = s.offlineCancelDownloadsAlertTitle; diff --git a/toolkit/components/jsdownloads/src/moz.build b/toolkit/components/jsdownloads/src/moz.build index 87abed62e..ac3768208 100644 --- a/toolkit/components/jsdownloads/src/moz.build +++ b/toolkit/components/jsdownloads/src/moz.build @@ -19,11 +19,11 @@ EXTRA_JS_MODULES += [ 'DownloadList.jsm', 'Downloads.jsm', 'DownloadStore.jsm', - 'DownloadUIHelper.jsm', ] EXTRA_PP_JS_MODULES += [ 'DownloadIntegration.jsm', + 'DownloadUIHelper.jsm', ] FINAL_LIBRARY = 'xul' -- cgit v1.2.3 From c09eca89e42978ebaacb7b618ba2994bce062502 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Thu, 6 Feb 2020 09:11:39 -0500 Subject: Issue #65 - Remove AppConstants from toolkit/components/satchel --- toolkit/components/satchel/FormHistory.jsm | 7 +++-- toolkit/components/satchel/moz.build | 6 +++-- toolkit/components/satchel/nsFormHistory.js | 42 ++++++++++++++--------------- 3 files changed, 29 insertions(+), 26 deletions(-) diff --git a/toolkit/components/satchel/FormHistory.jsm b/toolkit/components/satchel/FormHistory.jsm index 3d4a9fc43..ca9a28f1f 100644 --- a/toolkit/components/satchel/FormHistory.jsm +++ b/toolkit/components/satchel/FormHistory.jsm @@ -91,7 +91,6 @@ const Cr = Components.results; Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); Components.utils.import("resource://gre/modules/Services.jsm"); -Components.utils.import("resource://gre/modules/AppConstants.jsm"); XPCOMUtils.defineLazyServiceGetter(this, "uuidService", "@mozilla.org/uuid-generator;1", @@ -102,7 +101,11 @@ const DAY_IN_MS = 86400000; // 1 day in milliseconds const MAX_SEARCH_TOKENS = 10; const NOOP = function noop() {}; -var supportsDeletedTable = AppConstants.platform == "android"; +#ifdef MOZ_WIDGET_ANDROID +var supportsDeletedTable = true; +#else +var supportsDeletedTable = false; +#endif var Prefs = { initialized: false, diff --git a/toolkit/components/satchel/moz.build b/toolkit/components/satchel/moz.build index 239f412bc..883ee9f23 100644 --- a/toolkit/components/satchel/moz.build +++ b/toolkit/components/satchel/moz.build @@ -28,17 +28,19 @@ LOCAL_INCLUDES += [ EXTRA_COMPONENTS += [ 'FormHistoryStartup.js', 'nsFormAutoComplete.js', - 'nsFormHistory.js', 'nsInputListAutoComplete.js', 'satchel.manifest', ] +EXTRA_PP_COMPONENTS += ['nsFormHistory.js'] + EXTRA_JS_MODULES += [ 'AutoCompletePopup.jsm', - 'FormHistory.jsm', 'nsFormAutoCompleteResult.jsm', ] +EXTRA_PP_JS_MODULES += ['FormHistory.jsm'] + FINAL_LIBRARY = 'xul' JAR_MANIFESTS += ['jar.mn'] diff --git a/toolkit/components/satchel/nsFormHistory.js b/toolkit/components/satchel/nsFormHistory.js index d68be2d58..9d67f0729 100644 --- a/toolkit/components/satchel/nsFormHistory.js +++ b/toolkit/components/satchel/nsFormHistory.js @@ -12,8 +12,6 @@ Components.utils.import("resource://gre/modules/Services.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "Deprecated", "resource://gre/modules/Deprecated.jsm"); -XPCOMUtils.defineLazyModuleGetter(this, "AppConstants", - "resource://gre/modules/AppConstants.jsm"); const DB_VERSION = 4; const DAY_IN_MS = 86400000; // 1 day in milliseconds @@ -351,26 +349,26 @@ FormHistory.prototype = { }, moveToDeletedTable : function moveToDeletedTable(values, params) { - if (AppConstants.platform == "android") { - this.log("Moving entries to deleted table."); - - let stmt; - - try { - // Move the entries to the deleted items table. - let query = "INSERT INTO moz_deleted_formhistory (guid, timeDeleted) "; - if (values) query += values; - stmt = this.dbCreateStatement(query, params); - stmt.execute(); - } catch (e) { - this.log("Moving deleted entries failed: " + e); - throw e; - } finally { - if (stmt) { - stmt.reset(); - } - } - } +#ifdef MOZ_WIDGET_ANDROID + this.log("Moving entries to deleted table."); + + let stmt; + + try { + // Move the entries to the deleted items table. + let query = "INSERT INTO moz_deleted_formhistory (guid, timeDeleted) "; + if (values) query += values; + stmt = this.dbCreateStatement(query, params); + stmt.execute(); + } catch (e) { + this.log("Moving deleted entries failed: " + e); + throw e; + } finally { + if (stmt) { + stmt.reset(); + } + } +#endif }, get dbConnection() { -- cgit v1.2.3 From 7a0b23aab862a5a04f1f71a91e76fc2e03d93672 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Thu, 6 Feb 2020 09:31:03 -0500 Subject: Issue #65 - Remove AppConstants from toolkit/components/printing --- toolkit/components/printing/content/printPreviewBindings.xml | 8 ++++++-- toolkit/components/printing/jar.mn | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/toolkit/components/printing/content/printPreviewBindings.xml b/toolkit/components/printing/content/printPreviewBindings.xml index 182ecc199..c33b22e36 100644 --- a/toolkit/components/printing/content/printPreviewBindings.xml +++ b/toolkit/components/printing/content/printPreviewBindings.xml @@ -161,10 +161,14 @@ let $ = id => document.getAnonymousElementByAttribute(this, "anonid", id); let ltr = document.documentElement.matches(":root:-moz-locale-dir(ltr)"); +#ifdef XP_WIN // Windows 7 doesn't support ⏮ and ⏭ by default, and fallback doesn't // always work (bug 1343330). - let {AppConstants} = Components.utils.import("resource://gre/modules/AppConstants.jsm", {}); - let useCompatCharacters = AppConstants.isPlatformAndVersionAtMost("win", "6.1"); + let useCompatCharacters = Services.vc.compare(Services.sysinfo.getProperty("version"), "6.1") <= 0; +#else + let useCompatCharacters = false; +#endif + let leftEnd = useCompatCharacters ? "⏪" : "⏮"; let rightEnd = useCompatCharacters ? "⏩" : "⏭"; $("navigateHome").label = ltr ? leftEnd : rightEnd; diff --git a/toolkit/components/printing/jar.mn b/toolkit/components/printing/jar.mn index 40f9acf2b..a0e951030 100644 --- a/toolkit/components/printing/jar.mn +++ b/toolkit/components/printing/jar.mn @@ -13,7 +13,7 @@ toolkit.jar: #endif content/global/printPageSetup.js (content/printPageSetup.js) content/global/printPageSetup.xul (content/printPageSetup.xul) - content/global/printPreviewBindings.xml (content/printPreviewBindings.xml) +* content/global/printPreviewBindings.xml (content/printPreviewBindings.xml) content/global/printPreviewProgress.js (content/printPreviewProgress.js) content/global/printPreviewProgress.xul (content/printPreviewProgress.xul) content/global/printProgress.js (content/printProgress.js) -- cgit v1.2.3 From 0ab5c6474c6018c9f0b1910904038848e6cdcc18 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Thu, 6 Feb 2020 09:34:25 -0500 Subject: Issue #65 - Remove AppConstants from toolkit/components/thumbnails --- toolkit/components/thumbnails/PageThumbUtils.jsm | 5 +++-- toolkit/components/thumbnails/moz.build | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/toolkit/components/thumbnails/PageThumbUtils.jsm b/toolkit/components/thumbnails/PageThumbUtils.jsm index dda3a81b3..fb5d67ddb 100644 --- a/toolkit/components/thumbnails/PageThumbUtils.jsm +++ b/toolkit/components/thumbnails/PageThumbUtils.jsm @@ -14,7 +14,6 @@ const { classes: Cc, interfaces: Ci, utils: Cu } = Components; Cu.import("resource://gre/modules/XPCOMUtils.jsm", this); Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/Promise.jsm", this); -Cu.import("resource://gre/modules/AppConstants.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "BrowserUtils", "resource://gre/modules/BrowserUtils.jsm"); @@ -72,15 +71,17 @@ this.PageThumbUtils = { let windowScale = aWindow ? aWindow.devicePixelRatio : systemScale; let scale = Math.max(systemScale, windowScale); +#ifdef XP_MACOSX /** * * On retina displays, we can sometimes go down this path * without a window object. In those cases, force 2x scaling * as the system scale doesn't represent the 2x scaling * on OS X. */ - if (AppConstants.platform == "macosx" && !aWindow) { + if (!aWindow) { scale = 2; } +#endif /** * * THESE VALUES ARE DEFINED IN newtab.css and hard coded. diff --git a/toolkit/components/thumbnails/moz.build b/toolkit/components/thumbnails/moz.build index e4a178998..bd7c1d344 100644 --- a/toolkit/components/thumbnails/moz.build +++ b/toolkit/components/thumbnails/moz.build @@ -15,11 +15,11 @@ EXTRA_COMPONENTS += [ EXTRA_JS_MODULES += [ 'PageThumbs.jsm', 'PageThumbsWorker.js', - 'PageThumbUtils.jsm', ] EXTRA_PP_JS_MODULES += [ 'BackgroundPageThumbs.jsm', + 'PageThumbUtils.jsm', ] -- cgit v1.2.3 From cd87677798bd001320937c237ca2d2d236c0f89f Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Thu, 6 Feb 2020 09:38:29 -0500 Subject: Issue #65 - Remove AppConstants from toolkit/components/apppicker --- toolkit/components/apppicker/content/appPicker.js | 40 +++++++++++------------ toolkit/components/apppicker/jar.mn | 2 +- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/toolkit/components/apppicker/content/appPicker.js b/toolkit/components/apppicker/content/appPicker.js index 469a6ca23..21a007632 100644 --- a/toolkit/components/apppicker/content/appPicker.js +++ b/toolkit/components/apppicker/content/appPicker.js @@ -2,8 +2,6 @@ * 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/. */ -Components.utils.import("resource://gre/modules/AppConstants.jsm"); - function AppPicker() {} AppPicker.prototype = @@ -115,19 +113,19 @@ AppPicker.prototype = * Retrieve the pretty description from the file */ getFileDisplayName: function getFileDisplayName(file) { - if (AppConstants.platform == "win") { - if (file instanceof Components.interfaces.nsILocalFileWin) { - try { - return file.getVersionInfoField("FileDescription"); - } catch (e) {} - } - } else if (AppConstants.platform == "macosx") { - if (file instanceof Components.interfaces.nsILocalFileMac) { - try { - return file.bundleDisplayName; - } catch (e) {} - } +#ifdef XP_WIN + if (file instanceof Components.interfaces.nsILocalFileWin) { + try { + return file.getVersionInfoField("FileDescription"); + } catch (e) {} + } +#elifdef XP_MACOSX + if (file instanceof Components.interfaces.nsILocalFileMac) { + try { + return file.bundleDisplayName; + } catch (e) {} } +#endif return file.leafName; }, @@ -183,13 +181,13 @@ AppPicker.prototype = var fileLoc = Components.classes["@mozilla.org/file/directory_service;1"] .getService(Components.interfaces.nsIProperties); var startLocation; - if (AppConstants.platform == "win") { - startLocation = "ProgF"; // Program Files - } else if (AppConstants.platform == "macosx") { - startLocation = "LocApp"; // Local Applications - } else { - startLocation = "Home"; - } +#ifdef XP_WIN + startLocation = "ProgF"; // Program Files +#elifdef XP_MACOSX + startLocation = "LocApp"; // Local Applications +#else + startLocation = "Home"; +#endif fp.displayDirectory = fileLoc.get(startLocation, Components.interfaces.nsILocalFile); diff --git a/toolkit/components/apppicker/jar.mn b/toolkit/components/apppicker/jar.mn index 60e029d8a..d8431c3fe 100644 --- a/toolkit/components/apppicker/jar.mn +++ b/toolkit/components/apppicker/jar.mn @@ -4,5 +4,5 @@ toolkit.jar: content/global/appPicker.xul (content/appPicker.xul) - content/global/appPicker.js (content/appPicker.js) +* content/global/appPicker.js (content/appPicker.js) -- cgit v1.2.3 From 0749a35be9b6c699211ddb54dbbf8406d4aadf6e Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Thu, 6 Feb 2020 09:43:27 -0500 Subject: Issue #65 - Remove AppConstants from toolkit/components/places --- toolkit/components/places/PlacesUtils.jsm | 7 +++++-- toolkit/components/places/moz.build | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/toolkit/components/places/PlacesUtils.jsm b/toolkit/components/places/PlacesUtils.jsm index 5f6e81f18..259fb7aa7 100644 --- a/toolkit/components/places/PlacesUtils.jsm +++ b/toolkit/components/places/PlacesUtils.jsm @@ -30,7 +30,6 @@ const { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components; Cu.importGlobalProperties(["URL"]); Cu.import("resource://gre/modules/XPCOMUtils.jsm"); -Cu.import("resource://gre/modules/AppConstants.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "Services", "resource://gre/modules/Services.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "NetUtil", @@ -64,7 +63,11 @@ const MIN_TRANSACTIONS_FOR_BATCH = 5; // On Mac OSX, the transferable system converts "\r\n" to "\n\n", where // we really just want "\n". On other platforms, the transferable system // converts "\r\n" to "\n". -const NEWLINE = AppConstants.platform == "macosx" ? "\n" : "\r\n"; +#ifdef XP_MACOSX +const NEWLINE = "\n"; +#else +const NEWLINE = "\r\n"; +#endif function QI_node(aNode, aIID) { var result = null; diff --git a/toolkit/components/places/moz.build b/toolkit/components/places/moz.build index 85e1e93e1..478b18e02 100644 --- a/toolkit/components/places/moz.build +++ b/toolkit/components/places/moz.build @@ -72,9 +72,10 @@ if CONFIG['MOZ_PLACES']: 'PlacesSearchAutocompleteProvider.jsm', 'PlacesSyncUtils.jsm', 'PlacesTransactions.jsm', - 'PlacesUtils.jsm', ] + EXTRA_PP_JS_MODULES += ['PlacesUtils.jsm'] + EXTRA_COMPONENTS += [ 'ColorAnalyzer.js', 'nsLivemarkService.js', -- cgit v1.2.3 From 741abd440e4f4c4d91799f06c826e0f879c5c837 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Thu, 6 Feb 2020 09:47:45 -0500 Subject: Issue #65 - Remove AppConstants from toolkit/components/alerts --- toolkit/components/alerts/jar.mn | 2 +- toolkit/components/alerts/resources/content/alert.js | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/toolkit/components/alerts/jar.mn b/toolkit/components/alerts/jar.mn index c45939078..c9bd127dd 100644 --- a/toolkit/components/alerts/jar.mn +++ b/toolkit/components/alerts/jar.mn @@ -5,4 +5,4 @@ toolkit.jar: content/global/alerts/alert.css (resources/content/alert.css) content/global/alerts/alert.xul (resources/content/alert.xul) - content/global/alerts/alert.js (resources/content/alert.js) +* content/global/alerts/alert.js (resources/content/alert.js) diff --git a/toolkit/components/alerts/resources/content/alert.js b/toolkit/components/alerts/resources/content/alert.js index 12068b548..e9725bedb 100644 --- a/toolkit/components/alerts/resources/content/alert.js +++ b/toolkit/components/alerts/resources/content/alert.js @@ -4,7 +4,6 @@ var {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components; -Cu.import("resource://gre/modules/AppConstants.jsm"); Cu.import("resource://gre/modules/Services.jsm"); /* @@ -26,10 +25,15 @@ const NS_ALERT_HORIZONTAL = 1; const NS_ALERT_LEFT = 2; const NS_ALERT_TOP = 4; -const WINDOW_MARGIN = AppConstants.platform == "win" ? 0 : 10; -const BODY_TEXT_LIMIT = 200; -const WINDOW_SHADOW_SPREAD = AppConstants.platform == "win" ? 10 : 0; +#ifdef XP_WIN +const WINDOW_MARGIN = 0; +const WINDOW_SHADOW_SPREAD = 10; +#else +const WINDOW_MARGIN = 10; +const WINDOW_SHADOW_SPREAD = 0; +#endif +const BODY_TEXT_LIMIT = 200; var gOrigin = 0; // Default value: alert from bottom right. var gReplacedWindow = null; -- cgit v1.2.3 From cf4ad4e969bf553c4e7bcf79e8f3a98783584070 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Thu, 6 Feb 2020 10:39:22 -0500 Subject: Issue #65 - Remove AppConstants from toolkit/components/passwordmgr --- toolkit/components/passwordmgr/OSCrypto.jsm | 11 +++++------ toolkit/components/passwordmgr/content/passwordManager.js | 9 ++++++--- toolkit/components/passwordmgr/moz.build | 5 +++-- toolkit/components/passwordmgr/nsLoginManager.js | 13 ++++++------- 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/toolkit/components/passwordmgr/OSCrypto.jsm b/toolkit/components/passwordmgr/OSCrypto.jsm index 04254f66f..3d2b27c4e 100644 --- a/toolkit/components/passwordmgr/OSCrypto.jsm +++ b/toolkit/components/passwordmgr/OSCrypto.jsm @@ -8,15 +8,14 @@ "use strict"; -Components.utils.import("resource://gre/modules/AppConstants.jsm"); Components.utils.import("resource://gre/modules/Services.jsm"); this.EXPORTED_SYMBOLS = ["OSCrypto"]; var OSCrypto = {}; -if (AppConstants.platform == "win") { - Services.scriptloader.loadSubScript("resource://gre/modules/OSCrypto_win.js", this); -} else { - throw new Error("OSCrypto.jsm isn't supported on this platform"); -} +#ifdef XP_WIN +Services.scriptloader.loadSubScript("resource://gre/modules/OSCrypto_win.js", this); +#else +throw new Error("OSCrypto.jsm isn't supported on this platform"); +#endif diff --git a/toolkit/components/passwordmgr/content/passwordManager.js b/toolkit/components/passwordmgr/content/passwordManager.js index 327ebbdf8..662f21279 100644 --- a/toolkit/components/passwordmgr/content/passwordManager.js +++ b/toolkit/components/passwordmgr/content/passwordManager.js @@ -5,7 +5,6 @@ /** * =================== SAVED SIGNONS CODE =================== ***/ const { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components; -Cu.import("resource://gre/modules/AppConstants.jsm"); Cu.import("resource://gre/modules/XPCOMUtils.jsm"); Cu.import("resource://gre/modules/Services.jsm"); @@ -486,9 +485,13 @@ function HandleSignonKeyPress(e) { if (signonsTree.getAttribute("editing")) { return; } + +#ifdef XP_MACOSX if (e.keyCode == KeyboardEvent.DOM_VK_DELETE || - (AppConstants.platform == "macosx" && - e.keyCode == KeyboardEvent.DOM_VK_BACK_SPACE)) { + e.keyCode == KeyboardEvent.DOM_VK_BACK_SPACE) { +#else + if (e.keyCode == KeyboardEvent.DOM_VK_DELETE) { +#endif DeleteSignon(); } } diff --git a/toolkit/components/passwordmgr/moz.build b/toolkit/components/passwordmgr/moz.build index e54e6ba2d..af9a4ab03 100644 --- a/toolkit/components/passwordmgr/moz.build +++ b/toolkit/components/passwordmgr/moz.build @@ -32,11 +32,11 @@ XPIDL_MODULE = 'loginmgr' EXTRA_COMPONENTS += [ 'crypto-SDR.js', 'nsLoginInfo.js', - 'nsLoginManager.js', 'nsLoginManagerPrompter.js', ] EXTRA_PP_COMPONENTS += [ + 'nsLoginManager.js', 'passwordmgr.manifest', ] @@ -46,9 +46,10 @@ EXTRA_JS_MODULES += [ 'LoginManagerContent.jsm', 'LoginManagerParent.jsm', 'LoginRecipes.jsm', - 'OSCrypto.jsm', ] +EXTRA_PP_JS_MODULES += ['OSCrypto.jsm'] + if CONFIG['OS_TARGET'] == 'Android': EXTRA_COMPONENTS += [ 'storage-mozStorage.js', diff --git a/toolkit/components/passwordmgr/nsLoginManager.js b/toolkit/components/passwordmgr/nsLoginManager.js index 514351fa5..87466fe5c 100644 --- a/toolkit/components/passwordmgr/nsLoginManager.js +++ b/toolkit/components/passwordmgr/nsLoginManager.js @@ -8,7 +8,6 @@ const { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components; const PERMISSION_SAVE_LOGINS = "login-saving"; -Cu.import("resource://gre/modules/AppConstants.jsm"); Cu.import("resource://gre/modules/XPCOMUtils.jsm"); Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/Timer.jsm"); @@ -113,12 +112,12 @@ LoginManager.prototype = { _initStorage() { - let contractID; - if (AppConstants.platform == "android") { - contractID = "@mozilla.org/login-manager/storage/mozStorage;1"; - } else { - contractID = "@mozilla.org/login-manager/storage/json;1"; - } +#ifdef MOZ_WIDGET_ANDROID + let contractID = "@mozilla.org/login-manager/storage/mozStorage;1"; +#else + let contractID = "@mozilla.org/login-manager/storage/json;1"; +#endif + try { let catMan = Cc["@mozilla.org/categorymanager;1"]. getService(Ci.nsICategoryManager); -- cgit v1.2.3 From b4ac6a7dcb9ce4449c0dc1afc30d4aaee74c9a6a Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Fri, 7 Feb 2020 04:51:00 -0500 Subject: Issue #65 - Correct fallthough case in profileSelection.js --- toolkit/profile/content/profileSelection.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/toolkit/profile/content/profileSelection.js b/toolkit/profile/content/profileSelection.js index 65a2ba13f..05ef6f5ed 100644 --- a/toolkit/profile/content/profileSelection.js +++ b/toolkit/profile/content/profileSelection.js @@ -133,8 +133,8 @@ function onProfilesKey(aEvent) { switch ( aEvent.keyCode ) { -#ifndef XP_MACOSX case KeyEvent.DOM_VK_BACK_SPACE: +#ifndef XP_MACOSX break; #endif case KeyEvent.DOM_VK_DELETE: -- cgit v1.2.3 From fa52fa60b70c5883acd4a8edd8e1f89c3d5f3920 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Fri, 7 Feb 2020 04:55:10 -0500 Subject: Issue #65 - Don't split in the middle of assignment statements in createProfileWizard.js --- toolkit/profile/content/createProfileWizard.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/toolkit/profile/content/createProfileWizard.js b/toolkit/profile/content/createProfileWizard.js index f13eb8faa..aa87eacd7 100644 --- a/toolkit/profile/content/createProfileWizard.js +++ b/toolkit/profile/content/createProfileWizard.js @@ -116,11 +116,10 @@ function checkCurrentInput(currentInput) if (!errorMessage) { finishText.className = ""; - finishText.firstChild.data = gProfileManagerBundle #ifdef XP_MACOSX - .getString("profileFinishTextMac"); + finishText.firstChild.data = gProfileManagerBundle.getString("profileFinishTextMac"); #else - .getString("profileFinishText"); + finishText.firstChild.data = gProfileManagerBundle.getString("profileFinishText"); #endif canAdvance = true; } -- cgit v1.2.3