Use the Preprocessor instead of AppConstants.

This commit is contained in:
Fedor 2020-03-12 20:42:04 +03:00
parent b9103cf06e
commit 6caf738b11
75 changed files with 951 additions and 882 deletions

View File

@ -449,12 +449,14 @@
var cancel = false;
let { AppConstants } =
Components.utils.import("resource://gre/modules/AppConstants.jsm", {});
// Catch any keys that could potentially move the caret. Ctrl can be
// used in combination with these keys on Windows and Linux; and Alt
// can be used on OS X, so make sure the unused one isn't used.
let metaKey = AppConstants.platform == "macosx" ? aEvent.ctrlKey : aEvent.altKey;
#ifdef XP_MACOSX
let metaKey = aEvent.ctrlKey;
#else
let metaKey = aEvent.altKey;
#endif
if (!this.disableKeyNavigation && !metaKey) {
switch (aEvent.keyCode) {
case KeyEvent.DOM_VK_LEFT:
@ -492,11 +494,11 @@
cancel = this.mController.handleEscape();
break;
case KeyEvent.DOM_VK_RETURN:
if (AppConstants.platform == "macosx") {
// Prevent the default action, since it will beep on Mac
if (aEvent.metaKey)
aEvent.preventDefault();
}
#ifdef XP_MACOSX
// Prevent the default action, since it will beep on Mac
if (aEvent.metaKey)
aEvent.preventDefault();
#endif
this.mEnterEvent = aEvent;
if (this.mController.selection) {
this._selectionDetails = {
@ -507,15 +509,19 @@
cancel = this.handleEnter();
break;
case KeyEvent.DOM_VK_DELETE:
if (AppConstants.platform == "macosx" && !aEvent.shiftKey) {
#ifdef XP_MACOSX
if (!aEvent.shiftKey) {
break;
}
#endif
cancel = this.handleDelete();
break;
case KeyEvent.DOM_VK_BACK_SPACE:
if (AppConstants.platform == "macosx" && aEvent.shiftKey) {
#ifdef XP_MACOSX
if (aEvent.shiftKey) {
cancel = this.handleDelete();
}
#endif
break;
case KeyEvent.DOM_VK_DOWN:
case KeyEvent.DOM_VK_UP:
@ -523,9 +529,9 @@
this.toggleHistoryPopup();
break;
case KeyEvent.DOM_VK_F4:
if (AppConstants.platform != "macosx") {
this.toggleHistoryPopup();
}
#ifndef XP_MACOSX
this.toggleHistoryPopup();
#endif
break;
}

View File

@ -8,7 +8,6 @@ this.EXPORTED_SYMBOLS = ["ShellService"];
const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
Cu.import("resource://gre/modules/AppConstants.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "WindowsRegistry",
@ -26,20 +25,17 @@ var ShellServiceInternal = {
* environments.
*/
get canSetDesktopBackground() {
if (AppConstants.platform == "win" ||
AppConstants.platform == "macosx") {
return true;
#ifdef XP_LINUX
if (this.shellService) {
let linuxShellService = this.shellService
.QueryInterface(Ci.nsIGNOMEShellService);
return linuxShellService.canSetDesktopBackground;
}
if (AppConstants.platform == "linux") {
if (this.shellService) {
let linuxShellService = this.shellService
.QueryInterface(Ci.nsIGNOMEShellService);
return linuxShellService.canSetDesktopBackground;
}
}
#elif defined(XP_WIN) || defined(XP_MACOSX)
return true;
#else
return false;
#endif
},
/**
@ -60,18 +56,18 @@ var ShellServiceInternal = {
return false;
}
if (AppConstants.platform == "win") {
let optOutValue = WindowsRegistry.readRegKey(Ci.nsIWindowsRegKey.ROOT_KEY_CURRENT_USER,
"Software\\Mozilla\\PaleMoon",
"DefaultBrowserOptOut");
WindowsRegistry.removeRegKey(Ci.nsIWindowsRegKey.ROOT_KEY_CURRENT_USER,
"Software\\Mozilla\\PaleMoon",
"DefaultBrowserOptOut");
if (optOutValue == "True") {
Services.prefs.setBoolPref("browser.shell.checkDefaultBrowser", false);
return false;
}
#ifdef XP_WIN
let optOutValue = WindowsRegistry.readRegKey(Ci.nsIWindowsRegKey.ROOT_KEY_CURRENT_USER,
"Software\\Mozilla\\PaleMoon",
"DefaultBrowserOptOut");
WindowsRegistry.removeRegKey(Ci.nsIWindowsRegKey.ROOT_KEY_CURRENT_USER,
"Software\\Mozilla\\PaleMoon",
"DefaultBrowserOptOut");
if (optOutValue == "True") {
Services.prefs.setBoolPref("browser.shell.checkDefaultBrowser", false);
return false;
}
#endif
return true;
},

View File

@ -2,13 +2,16 @@
* 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");
var Ci = Components.interfaces;
var gSetBackground = {
_position : AppConstants.platform == "macosx" ? "STRETCH" : "",
_backgroundColor : AppConstants.platform != "macosx" ? 0 : undefined,
#ifdef XP_MACOSX
_position : "STRETCH",
_backgroundColor : undefined,
#else
_position : "",
_backgroundColor : 0,
#endif
_screenWidth : 0,
_screenHeight : 0,
_image : null,
@ -25,23 +28,23 @@ var gSetBackground = {
this._canvas = document.getElementById("screen");
this._screenWidth = screen.width;
this._screenHeight = screen.height;
if (AppConstants.platform == "macosx") {
document.documentElement.getButton("accept").hidden = true;
}
#ifdef XP_MACOSX
document.documentElement.getButton("accept").hidden = true;
#endif
if (this._screenWidth / this._screenHeight >= 1.6)
document.getElementById("monitor").setAttribute("aspectratio", "16:10");
if (AppConstants.platform == "win") {
// Hide fill + fit options if < Win7 since they don't work.
var version = Components.classes["@mozilla.org/system-info;1"]
.getService(Ci.nsIPropertyBag2)
.getProperty("version");
var isWindows7OrHigher = (parseFloat(version) >= 6.1);
if (!isWindows7OrHigher) {
document.getElementById("fillPosition").hidden = true;
document.getElementById("fitPosition").hidden = true;
}
#ifdef XP_WIN
// Hide fill + fit options if < Win7 since they don't work.
var version = Components.classes["@mozilla.org/system-info;1"]
.getService(Ci.nsIPropertyBag2)
.getProperty("version");
var isWindows7OrHigher = (parseFloat(version) >= 6.1);
if (!isWindows7OrHigher) {
document.getElementById("fillPosition").hidden = true;
document.getElementById("fitPosition").hidden = true;
}
#endif
// make sure that the correct dimensions will be used
setTimeout(function(self) {
@ -60,28 +63,25 @@ var gSetBackground = {
var ctx = this._canvas.getContext("2d");
ctx.scale(this._canvas.clientWidth / this._screenWidth, this._canvas.clientHeight / this._screenHeight);
if (AppConstants.platform != "macosx") {
this._initColor();
} else {
// Make sure to reset the button state in case the user has already
// set an image as their desktop background.
var setDesktopBackground = document.getElementById("setDesktopBackground");
setDesktopBackground.hidden = false;
var bundle = document.getElementById("backgroundBundle");
setDesktopBackground.label = bundle.getString("DesktopBackgroundSet");
setDesktopBackground.disabled = false;
#ifdef XP_MACOSX
// Make sure to reset the button state in case the user has already
// set an image as their desktop background.
var setDesktopBackground = document.getElementById("setDesktopBackground");
setDesktopBackground.hidden = false;
var bundle = document.getElementById("backgroundBundle");
setDesktopBackground.label = bundle.getString("DesktopBackgroundSet");
setDesktopBackground.disabled = false;
document.getElementById("showDesktopPreferences").hidden = true;
}
document.getElementById("showDesktopPreferences").hidden = true;
#else
this._initColor();
#endif
this.updatePosition();
},
setDesktopBackground: function ()
{
if (AppConstants.platform != "macosx") {
document.persist("menuPosition", "value");
this._shell.desktopBackgroundColor = this._hexStringToLong(this._backgroundColor);
} else {
#ifdef XP_MACOSX
Components.classes["@mozilla.org/observer-service;1"]
.getService(Ci.nsIObserverService)
.addObserver(this, "shell:desktop-background-changed", false);
@ -90,7 +90,10 @@ var gSetBackground = {
var setDesktopBackground = document.getElementById("setDesktopBackground");
setDesktopBackground.disabled = true;
setDesktopBackground.label = bundle.getString("DesktopBackgroundDownloading");
}
#else
document.persist("menuPosition", "value");
this._shell.desktopBackgroundColor = this._hexStringToLong(this._backgroundColor);
#endif
this._shell.setDesktopBackground(this._image,
Ci.nsIShellService["BACKGROUND_" + this._position]);
},
@ -100,9 +103,9 @@ var gSetBackground = {
var ctx = this._canvas.getContext("2d");
ctx.clearRect(0, 0, this._screenWidth, this._screenHeight);
if (AppConstants.platform != "macosx") {
this._position = document.getElementById("menuPosition").value;
}
#ifndef XP_MACOSX
this._position = document.getElementById("menuPosition").value;
#endif
switch (this._position) {
case "TILE":
@ -158,57 +161,57 @@ var gSetBackground = {
}
};
if (AppConstants.platform != "macosx") {
gSetBackground["_initColor"] = function ()
{
var color = this._shell.desktopBackgroundColor;
#ifdef XP_MACOSX
gSetBackground["observe"] = function (aSubject, aTopic, aData)
{
if (aTopic == "shell:desktop-background-changed") {
document.getElementById("setDesktopBackground").hidden = true;
document.getElementById("showDesktopPreferences").hidden = false;
const rMask = 4294901760;
const gMask = 65280;
const bMask = 255;
var r = (color & rMask) >> 16;
var g = (color & gMask) >> 8;
var b = (color & bMask);
this.updateColor(this._rgbToHex(r, g, b));
Components.classes["@mozilla.org/observer-service;1"]
.getService(Ci.nsIObserverService)
.removeObserver(this, "shell:desktop-background-changed");
}
};
var colorpicker = document.getElementById("desktopColor");
colorpicker.color = this._backgroundColor;
};
gSetBackground["showDesktopPrefs"] = function()
{
this._shell.openApplication(Ci.nsIMacShellService.APPLICATION_DESKTOP);
};
#else
gSetBackground["_initColor"] = function ()
{
var color = this._shell.desktopBackgroundColor;
gSetBackground["updateColor"] = function (aColor)
{
this._backgroundColor = aColor;
this._canvas.style.backgroundColor = aColor;
};
const rMask = 4294901760;
const gMask = 65280;
const bMask = 255;
var r = (color & rMask) >> 16;
var g = (color & gMask) >> 8;
var b = (color & bMask);
this.updateColor(this._rgbToHex(r, g, b));
// Converts a color string in the format "#RRGGBB" to an integer.
gSetBackground["_hexStringToLong"] = function (aString)
{
return parseInt(aString.substring(1, 3), 16) << 16 |
parseInt(aString.substring(3, 5), 16) << 8 |
parseInt(aString.substring(5, 7), 16);
};
var colorpicker = document.getElementById("desktopColor");
colorpicker.color = this._backgroundColor;
};
gSetBackground["_rgbToHex"] = function (aR, aG, aB)
{
return "#" + [aR, aG, aB].map(aInt => aInt.toString(16).replace(/^(.)$/, "0$1"))
.join("").toUpperCase();
};
} else {
gSetBackground["observe"] = function (aSubject, aTopic, aData)
{
if (aTopic == "shell:desktop-background-changed") {
document.getElementById("setDesktopBackground").hidden = true;
document.getElementById("showDesktopPreferences").hidden = false;
gSetBackground["updateColor"] = function (aColor)
{
this._backgroundColor = aColor;
this._canvas.style.backgroundColor = aColor;
};
Components.classes["@mozilla.org/observer-service;1"]
.getService(Ci.nsIObserverService)
.removeObserver(this, "shell:desktop-background-changed");
}
};
// Converts a color string in the format "#RRGGBB" to an integer.
gSetBackground["_hexStringToLong"] = function (aString)
{
return parseInt(aString.substring(1, 3), 16) << 16 |
parseInt(aString.substring(3, 5), 16) << 8 |
parseInt(aString.substring(5, 7), 16);
};
gSetBackground["showDesktopPrefs"] = function()
{
this._shell.openApplication(Ci.nsIMacShellService.APPLICATION_DESKTOP);
};
}
gSetBackground["_rgbToHex"] = function (aR, aG, aB)
{
return "#" + [aR, aG, aB].map(aInt => aInt.toString(16).replace(/^(.)$/, "0$1"))
.join("").toUpperCase();
};
#endif

View File

@ -4,4 +4,4 @@
browser.jar:
* content/browser/setDesktopBackground.xul (content/setDesktopBackground.xul)
content/browser/setDesktopBackground.js (content/setDesktopBackground.js)
* content/browser/setDesktopBackground.js (content/setDesktopBackground.js)

View File

@ -32,7 +32,7 @@ EXTRA_COMPONENTS += [
'nsSetDefaultBrowser.manifest',
]
EXTRA_JS_MODULES += ['ShellService.jsm']
EXTRA_PP_JS_MODULES += ['ShellService.jsm']
for var in ('MOZ_APP_NAME', 'MOZ_APP_VERSION'):
DEFINES[var] = '"%s"' % CONFIG[var]

View File

@ -13,8 +13,6 @@ XPCOMUtils.defineLazyModuleGetter(this, "PeerConnectionIdp",
"resource://gre/modules/media/PeerConnectionIdp.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "convertToRTCStatsReport",
"resource://gre/modules/media/RTCStatsReport.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "AppConstants",
"resource://gre/modules/AppConstants.jsm");
const PC_CONTRACT = "@mozilla.org/dom/peerconnection;1";
const PC_OBS_CONTRACT = "@mozilla.org/dom/peerconnectionobserver;1";

View File

@ -9,7 +9,6 @@ const Ci = Components.interfaces;
const Cu = Components.utils;
const Cr = Components.results;
Cu.import("resource://gre/modules/AppConstants.jsm");
Cu.import("resource://gre/modules/Preferences.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
@ -145,13 +144,14 @@ PushRecord.prototype = {
return Date.now();
}
if (AppConstants.MOZ_ANDROID_HISTORY) {
let result = yield Messaging.sendRequestForResult({
type: "History:GetPrePathLastVisitedTimeMilliseconds",
prePath: this.uri.prePath,
});
return result == 0 ? -Infinity : result;
}
#ifdef MOZ_ANDROID_HISTORY
let result = yield Messaging.sendRequestForResult({
type: "History:GetPrePathLastVisitedTimeMilliseconds",
prePath: this.uri.prePath,
});
return result == 0 ? -Infinity : result;
#endif
// Places History transition types that can fire a
// `pushsubscriptionchange` event when the user visits a site with expired push

View File

@ -10,7 +10,6 @@ const Ci = Components.interfaces;
const Cu = Components.utils;
const Cr = Components.results;
Cu.import("resource://gre/modules/AppConstants.jsm");
Cu.import("resource://gre/modules/Preferences.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/Timer.jsm");
@ -24,14 +23,14 @@ const {
const {PushDB} = Cu.import("resource://gre/modules/PushDB.jsm");
const CONNECTION_PROTOCOLS = (function() {
if ('android' != AppConstants.MOZ_WIDGET_TOOLKIT) {
#ifdef MOZ_WIDGET_ANDROID
const {PushServiceAndroidGCM} = Cu.import("resource://gre/modules/PushServiceAndroidGCM.jsm");
return [PushServiceAndroidGCM];
#else
const {PushServiceWebSocket} = Cu.import("resource://gre/modules/PushServiceWebSocket.jsm");
const {PushServiceHttp2} = Cu.import("resource://gre/modules/PushServiceHttp2.jsm");
return [PushServiceWebSocket, PushServiceHttp2];
} else {
const {PushServiceAndroidGCM} = Cu.import("resource://gre/modules/PushServiceAndroidGCM.jsm");
return [PushServiceAndroidGCM];
}
#endif
})();
XPCOMUtils.defineLazyServiceGetter(this, "gPushNotifier",

View File

@ -10,7 +10,6 @@ const Ci = Components.interfaces;
const Cu = Components.utils;
const Cr = Components.results;
Cu.import("resource://gre/modules/AppConstants.jsm");
Cu.import("resource://gre/modules/Preferences.jsm");
Cu.import("resource://gre/modules/Promise.jsm");
Cu.import("resource://gre/modules/Services.jsm");

View File

@ -12,6 +12,9 @@ EXTRA_COMPONENTS += [
EXTRA_JS_MODULES += [
'PushCrypto.jsm',
'PushDB.jsm',
]
EXTRA_PP_JS_MODULES += [
'PushRecord.jsm',
'PushService.jsm',
]

View File

@ -10,7 +10,6 @@ const Ci = Components.interfaces;
const Cc = Components.classes;
const Cu = Components.utils;
Cu.import("resource://gre/modules/AppConstants.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
@ -144,13 +143,14 @@ this.UserAgentUpdates = {
// try to load next one if the previous load failed
return prevLoad ? prevLoad.then(null, tryNext) : tryNext();
}, null).then(null, (ex) => {
if (AppConstants.platform !== "android") {
// All previous (non-Android) load attempts have failed, so we bail.
throw new Error("UserAgentUpdates: Failed to load " + FILE_UPDATES +
ex + "\n" + ex.stack);
}
#ifdef MOZ_WIDGET_ANDROID
// Make one last attempt to read from the Fennec APK root.
return readChannel("resource://android/" + FILE_UPDATES);
#else
// All previous (non-Android) load attempts have failed, so we bail.
throw new Error("UserAgentUpdates: Failed to load " + FILE_UPDATES +
ex + "\n" + ex.stack);
#endif
}).then((update) => {
// Apply update if loading was successful
this._applyUpdate(update);

View File

@ -99,10 +99,9 @@ IPDL_SOURCES += [
'PHttpChannel.ipdl',
]
EXTRA_JS_MODULES += [
'UserAgentOverrides.jsm',
'UserAgentUpdates.jsm',
]
EXTRA_JS_MODULES += ['UserAgentOverrides.jsm']
EXTRA_PP_JS_MODULES += ['UserAgentUpdates.jsm']
include('/ipc/chromium/chromium-config.mozbuild')

View File

@ -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)

View File

@ -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;

View File

@ -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);

View File

@ -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)

View File

@ -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

View File

@ -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;

View File

@ -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'

View File

@ -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

View File

@ -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();
}
}

View File

@ -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',

View File

@ -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);

View File

@ -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;

View File

@ -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',

View File

@ -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;

View File

@ -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)

View File

@ -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,

View File

@ -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']

View File

@ -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.");
#ifdef MOZ_WIDGET_ANDROID
this.log("Moving entries to deleted table.");
let stmt;
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();
}
}
}
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() {

View File

@ -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.

View File

@ -15,11 +15,11 @@ EXTRA_COMPONENTS += [
EXTRA_JS_MODULES += [
'PageThumbs.jsm',
'PageThumbsWorker.js',
'PageThumbUtils.jsm',
]
EXTRA_PP_JS_MODULES += [
'BackgroundPageThumbs.jsm',
'PageThumbUtils.jsm',
]

View File

@ -28,8 +28,6 @@ Cu.import("resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "AddonManager",
"resource://gre/modules/AddonManager.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "AppConstants",
"resource://gre/modules/AppConstants.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "ExtensionAPIs",
"resource://gre/modules/ExtensionAPI.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "ExtensionStorage",
@ -667,10 +665,9 @@ this.Extension = class extends ExtensionData {
readManifest() {
return super.readManifest().then(manifest => {
if (AppConstants.RELEASE_OR_BETA) {
#ifdef RELEASE_OR_BETA
return manifest;
}
#else
// Load Experiments APIs that this extension depends on.
return Promise.all(
Array.from(this.apiNames, api => ExtensionAPIs.load(api))
@ -681,6 +678,7 @@ this.Extension = class extends ExtensionData {
return manifest;
});
#endif
});
}

View File

@ -25,7 +25,6 @@ const Cr = Components.results;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/AppConstants.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "ExtensionManagement",
"resource://gre/modules/ExtensionManagement.jsm");

View File

@ -11,7 +11,6 @@ const Cc = Components.classes;
const Cu = Components.utils;
const Cr = Components.results;
Cu.import("resource://gre/modules/AppConstants.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");

View File

@ -20,8 +20,6 @@ Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "AddonManager",
"resource://gre/modules/AddonManager.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "AppConstants",
"resource://gre/modules/AppConstants.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "MessageChannel",
"resource://gre/modules/MessageChannel.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "NativeApp",
@ -52,9 +50,9 @@ const CATEGORY_EXTENSION_SCRIPTS = "webextension-scripts";
let schemaURLs = new Set();
if (!AppConstants.RELEASE_OR_BETA) {
#ifndef RELEASE_OR_BETA
schemaURLs.add("chrome://extensions/content/schemas/experiments.json");
}
#endif
let GlobalManager;
let ParentAPIManager;

View File

@ -21,8 +21,6 @@ Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "AddonManager",
"resource://gre/modules/AddonManager.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "AppConstants",
"resource://gre/modules/AppConstants.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Extension",
"resource://gre/modules/Extension.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "ExtensionParent",

View File

@ -18,8 +18,6 @@ Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "AddonManager",
"resource://gre/modules/AddonManager.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "AppConstants",
"resource://gre/modules/AppConstants.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "ConsoleAPI",
"resource://gre/modules/Console.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "LanguageDetector",
@ -891,10 +889,19 @@ function flushJarCache(jarFile) {
const PlatformInfo = Object.freeze({
os: (function() {
let os = AppConstants.platform;
if (os == "macosx") {
os = "mac";
}
#ifdef MOZ_WIDGET_GTK
let os = "linux";
#elif XP_WIN
let os = "win";
#elif XP_MACOSX
let os = "mac";
#elif MOZ_WIDGET_ANDROID
let os = "android";
#elif XP_LINUX
let os = "linux";
#else
let os = "other";
#endif
return os;
})(),
arch: (function() {

View File

@ -13,8 +13,6 @@ Cu.import("resource://gre/modules/XPCOMUtils.jsm");
const {EventEmitter} = Cu.import("resource://devtools/shared/event-emitter.js", {});
XPCOMUtils.defineLazyModuleGetter(this, "AppConstants",
"resource://gre/modules/AppConstants.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "AsyncShutdown",
"resource://gre/modules/AsyncShutdown.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "ExtensionChild",
@ -67,7 +65,19 @@ this.HostManifestManager = {
init() {
if (!this._initializePromise) {
let platform = AppConstants.platform;
#ifdef MOZ_WIDGET_GTK
let platform = "linux";
#elif XP_WIN
let platform = "win";
#elif XP_MACOSX
let platform = "macosx";
#elif MOZ_WIDGET_ANDROID
let platform = "android";
#elif XP_LINUX
let platform = "linux";
#else
let platform = "other";
#endif
if (platform == "win") {
this._lookup = this._winLookup;
} else if (platform == "macosx" || platform == "linux") {
@ -77,7 +87,7 @@ this.HostManifestManager = {
];
this._lookup = (application, context) => this._tryPaths(application, dirs, context);
} else {
throw new Error(`Native messaging is not supported on ${AppConstants.platform}`);
throw new Error(`Native messaging is not supported on ${platform}`);
}
this._initializePromise = Schemas.load(HOST_MANIFEST_SCHEMA);
}
@ -191,13 +201,13 @@ this.NativeApp = class extends EventEmitter {
}
let command = hostInfo.manifest.path;
if (AppConstants.platform == "win") {
#if XP_WIN
// OS.Path.join() ignores anything before the last absolute path
// it sees, so if command is already absolute, it remains unchanged
// here. If it is relative, we get the proper absolute path here.
command = OS.Path.join(OS.Path.dirname(hostInfo.path), command);
}
#endif
let subprocessOpts = {
command: command,
arguments: [hostInfo.path],

View File

@ -5,21 +5,24 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
EXTRA_JS_MODULES += [
'Extension.jsm',
'ExtensionAPI.jsm',
'ExtensionChild.jsm',
'ExtensionCommon.jsm',
'ExtensionContent.jsm',
'ExtensionManagement.jsm',
'ExtensionParent.jsm',
'ExtensionStorage.jsm',
'ExtensionUtils.jsm',
'LegacyExtensionsUtils.jsm',
'MessageChannel.jsm',
'NativeMessaging.jsm',
'Schemas.jsm',
]
EXTRA_PP_JS_MODULES += [
'Extension.jsm',
'ExtensionParent.jsm',
'ExtensionUtils.jsm',
'NativeMessaging.jsm',
]
EXTRA_COMPONENTS += [
'extensions-toolkit.manifest',
]

View File

@ -8,7 +8,6 @@ const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
Cu.import('resource://gre/modules/Services.jsm');
Cu.import('resource://gre/modules/XPCOMUtils.jsm');
Cu.import('resource://gre/modules/AppConstants.jsm');
XPCOMUtils.defineLazyServiceGetter(
this,
@ -130,12 +129,13 @@ function display(profileData) {
if (dir) {
td.appendChild(document.createTextNode(' '));
let button = document.createElement('button');
#ifdef XP_WIN
let string = 'winOpenDir2';
#elifdef XP_MACOSX
let string = 'macOpenDir';
#else
let string = 'openDir';
if (AppConstants.platform == "win") {
string = 'winOpenDir2';
} else if (AppConstants.platform == "macosx") {
string = 'macOpenDir';
}
#endif
let buttonText = document.createTextNode(bundle.GetStringFromName(string));
button.appendChild(buttonText);
td.appendChild(button);

View File

@ -10,7 +10,6 @@ Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/Troubleshoot.jsm");
Cu.import("resource://gre/modules/ResetProfile.jsm");
Cu.import("resource://gre/modules/AppConstants.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "PluralForm",
"resource://gre/modules/PluralForm.jsm");
@ -42,7 +41,7 @@ var snapshotFormatters = {
$("os-box").textContent = data.osVersion;
$("binary-box").textContent = Services.dirsvc.get("XREExeF", Ci.nsIFile).path;
$("supportLink").href = data.supportURL;
let version = AppConstants.MOZ_APP_VERSION_DISPLAY;
let version = Services.appinfo.version;
if (data.versionArch) {
version += " (" + data.versionArch + ")";
}
@ -197,23 +196,23 @@ var snapshotFormatters = {
delete data.info;
}
if (AppConstants.NIGHTLY_BUILD) {
let windowUtils = window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils);
let gpuProcessPid = windowUtils.gpuProcessPid;
#ifdef NIGHTLY_BUILD
let windowUtils = window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils);
let gpuProcessPid = windowUtils.gpuProcessPid;
if (gpuProcessPid != -1) {
let gpuProcessKillButton = $.new("button");
if (gpuProcessPid != -1) {
let gpuProcessKillButton = $.new("button");
gpuProcessKillButton.addEventListener("click", function() {
windowUtils.terminateGPUProcess();
});
gpuProcessKillButton.addEventListener("click", function() {
windowUtils.terminateGPUProcess();
});
gpuProcessKillButton.textContent = strings.GetStringFromName("gpuProcessKillButton");
addRow("diagnostics", "GPUProcessPid", gpuProcessPid);
addRow("diagnostics", "GPUProcess", [gpuProcessKillButton]);
}
gpuProcessKillButton.textContent = strings.GetStringFromName("gpuProcessKillButton");
addRow("diagnostics", "GPUProcessPid", gpuProcessPid);
addRow("diagnostics", "GPUProcess", [gpuProcessKillButton]);
}
#endif
// graphics-failures-tbody tbody
if ("failures" in data) {
@ -583,15 +582,15 @@ function copyRawDataToClipboard(button) {
Cc["@mozilla.org/widget/clipboard;1"].
getService(Ci.nsIClipboard).
setData(transferable, null, Ci.nsIClipboard.kGlobalClipboard);
if (AppConstants.platform == "android") {
// Present a toast notification.
let message = {
type: "Toast:Show",
message: stringBundle().GetStringFromName("rawDataCopied"),
duration: "short"
};
Services.androidBridge.handleGeckoMessage(message);
}
#ifdef MOZ_WIDGET_ANDROID
// Present a toast notification.
let message = {
type: "Toast:Show",
message: stringBundle().GetStringFromName("rawDataCopied"),
duration: "short"
};
Services.androidBridge.handleGeckoMessage(message);
#endif
});
}
catch (err) {
@ -637,15 +636,15 @@ function copyContentsToClipboard() {
.getService(Ci.nsIClipboard);
clipboard.setData(transferable, null, clipboard.kGlobalClipboard);
if (AppConstants.platform == "android") {
// Present a toast notification.
let message = {
type: "Toast:Show",
message: stringBundle().GetStringFromName("textCopied"),
duration: "short"
};
Services.androidBridge.handleGeckoMessage(message);
}
#ifdef MOZ_WIDGET_ANDROID
// Present a toast notification.
let message = {
type: "Toast:Show",
message: stringBundle().GetStringFromName("textCopied"),
duration: "short"
};
Services.androidBridge.handleGeckoMessage(message);
#endif
}
// Return the plain text representation of an element. Do a little bit
@ -654,10 +653,10 @@ function createTextForElement(elem) {
let serializer = new Serializer();
let text = serializer.serialize(elem);
#ifdef XP_WIN
// Actual CR/LF pairs are needed for some Windows text editors.
if (AppConstants.platform == "win") {
text = text.replace(/\n/g, "\r\n");
}
text = text.replace(/\n/g, "\r\n");
#endif
return text;
}

View File

@ -19,9 +19,6 @@ Cu.import("resource://gre/modules/Preferences.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Task.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "AppConstants",
"resource://gre/modules/AppConstants.jsm");
const Telemetry = Services.telemetry;
const bundle = Services.strings.createBundle(
"chrome://global/locale/aboutTelemetry.properties");
@ -236,17 +233,17 @@ var Settings = {
let elements = document.getElementsByClassName("change-data-choices-link");
for (let el of elements) {
el.addEventListener("click", function() {
if (AppConstants.platform == "android") {
Cu.import("resource://gre/modules/Messaging.jsm");
Messaging.sendRequest({
type: "Settings:Show",
resource: "preferences_privacy",
});
} else {
// Show the data choices preferences on desktop.
let mainWindow = getMainWindowWithPreferencesPane();
mainWindow.openAdvancedPreferences("dataChoicesTab");
}
#ifdef MOZ_WIDGET_ANDROID
Cu.import("resource://gre/modules/Messaging.jsm");
Messaging.sendRequest({
type: "Settings:Show",
resource: "preferences_privacy",
});
#else
// Show the data choices preferences on desktop.
let mainWindow = getMainWindowWithPreferencesPane();
mainWindow.openAdvancedPreferences("dataChoicesTab");
#endif
}, false);
}
},

View File

@ -7,7 +7,6 @@ var Ci = Components.interfaces;
var Cu = Components.utils;
var Cr = Components.results;
Cu.import("resource://gre/modules/AppConstants.jsm");
Cu.import("resource://gre/modules/BrowserUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import('resource://gre/modules/XPCOMUtils.jsm');

View File

@ -24,8 +24,6 @@ XPCOMUtils.defineLazyModuleGetter(this, "Task",
"resource://gre/modules/Task.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Deprecated",
"resource://gre/modules/Deprecated.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "AppConstants",
"resource://gre/modules/AppConstants.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "NetUtil",
"resource://gre/modules/NetUtil.jsm");
@ -1161,10 +1159,10 @@ function getNormalizedLeafName(aFile, aDefaultExtension)
if (!aDefaultExtension)
return aFile;
if (AppConstants.platform == "win") {
// Remove trailing dots and spaces on windows
aFile = aFile.replace(/[\s.]+$/, "");
}
#ifdef XP_WIN
// Remove trailing dots and spaces on windows
aFile = aFile.replace(/[\s.]+$/, "");
#endif
// Remove leading dots
aFile = aFile.replace(/^\.+/, "");

View File

@ -12,7 +12,6 @@ var gToolboxSheet = false;
var gPaletteBox = null;
Components.utils.import("resource://gre/modules/Services.jsm");
Components.utils.import("resource://gre/modules/AppConstants.jsm");
function onLoad()
{
@ -213,10 +212,10 @@ function wrapToolbarItems()
{
forEachCustomizableToolbar(function (toolbar) {
Array.forEach(toolbar.childNodes, function (item) {
if (AppConstants.platform == "macosx") {
if (item.firstChild && item.firstChild.localName == "menubar")
return;
}
#ifdef XP_MACOSX
if (item.firstChild && item.firstChild.localName == "menubar")
return;
#endif
if (isToolbarItem(item)) {
let wrapper = wrapToolbarItem(item);
cleanupItemForToolbar(item, wrapper);

View File

@ -4,32 +4,32 @@
function closeWindow(aClose, aPromptFunction)
{
let { AppConstants } = Components.utils.import("resource://gre/modules/AppConstants.jsm");
#ifdef XP_MACOSX
// Closing the last window doesn't quit the application on OS X.
if (AppConstants.platform != "macosx") {
var windowCount = 0;
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator);
var e = wm.getEnumerator(null);
while (e.hasMoreElements()) {
var w = e.getNext();
if (w.closed) {
continue;
}
if (++windowCount == 2)
break;
}
// If we're down to the last window and someone tries to shut down, check to make sure we can!
if (windowCount == 1 && !canQuitApplication("lastwindow"))
return false;
if (windowCount != 1 && typeof(aPromptFunction) == "function" && !aPromptFunction())
return false;
} else if (typeof(aPromptFunction) == "function" && !aPromptFunction()) {
if (typeof(aPromptFunction) == "function" && !aPromptFunction()) {
return false;
}
#else
var windowCount = 0;
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator);
var e = wm.getEnumerator(null);
while (e.hasMoreElements()) {
var w = e.getNext();
if (w.closed) {
continue;
}
if (++windowCount == 2)
break;
}
// If we're down to the last window and someone tries to shut down, check to make sure we can!
if (windowCount == 1 && !canQuitApplication("lastwindow"))
return false;
if (windowCount != 1 && typeof(aPromptFunction) == "function" && !aPromptFunction())
return false;
#endif
if (aClose) {
window.close();

View File

@ -20,7 +20,7 @@ toolkit.jar:
content/global/aboutNetworking.js
content/global/aboutNetworking.xhtml
#ifndef ANDROID
content/global/aboutProfiles.js
* content/global/aboutProfiles.js
content/global/aboutProfiles.xhtml
#endif
content/global/aboutServiceWorkers.js
@ -32,19 +32,19 @@ toolkit.jar:
#endif
* content/global/aboutSupport.js
* content/global/aboutSupport.xhtml
content/global/aboutTelemetry.js
* content/global/aboutTelemetry.js
content/global/aboutTelemetry.xhtml
content/global/aboutTelemetry.css
content/global/directionDetector.html
content/global/plugins.html
content/global/plugins.css
content/global/browser-child.js
* content/global/browser-child.js
content/global/browser-content.js
* content/global/buildconfig.html
content/global/contentAreaUtils.js
* content/global/contentAreaUtils.js
#ifndef MOZ_FENNEC
content/global/customizeToolbar.css
content/global/customizeToolbar.js
* content/global/customizeToolbar.js
content/global/customizeToolbar.xul
#endif
content/global/datepicker.xhtml
@ -56,7 +56,7 @@ toolkit.jar:
content/global/findUtils.js
#endif
content/global/filepicker.properties
content/global/globalOverlay.js
* content/global/globalOverlay.js
content/global/mozilla.xhtml
#ifdef MOZ_PHOENIX
content/global/logopage.xhtml

View File

@ -8,7 +8,6 @@ const {utils: Cu} = Components;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/AppConstants.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "LightweightThemeImageOptimizer",
"resource://gre/modules/addons/LightweightThemeImageOptimizer.jsm");
@ -148,12 +147,13 @@ LightweightThemeConsumer.prototype = {
footer.removeAttribute("lwthemefooter");
}
#ifdef XP_MACOSX
// On OS X, we extend the lightweight theme into the titlebar, which means setting
// the chromemargin attribute. Some XUL applications already draw in the titlebar,
// so we need to save the chromemargin value before we overwrite it with the value
// that lets us draw in the titlebar. We stash this value on the root attribute so
// that XUL applications have the ability to invalidate the saved value.
if (AppConstants.platform == "macosx" && stateChanging) {
if (stateChanging) {
if (!root.hasAttribute("chromemargin-nonlwtheme")) {
root.setAttribute("chromemargin-nonlwtheme", root.getAttribute("chromemargin"));
}
@ -169,6 +169,7 @@ LightweightThemeConsumer.prototype = {
}
}
}
#endif
Services.obs.notifyObservers(this._win, "lightweight-theme-window-updated",
JSON.stringify(aData));
}

View File

@ -9,14 +9,21 @@ this.EXPORTED_SYMBOLS = ["ResetProfile"];
const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/AppConstants.jsm");
// For Basilisk and Pale Moon
// Hard-code MOZ_APP_NAME to firefox because of hard-coded type in migrator.
const MOZ_APP_NAME = (((AppConstants.MOZ_APP_NAME == "basilisk")
|| (AppConstants.MOZ_APP_NAME == "palemoon"))
? "firefox" : AppConstants.MOZ_APP_NAME);
const MOZ_BUILD_APP = AppConstants.MOZ_BUILD_APP;
// We need to tell the migrator that many different applications are Mozilla applications
#ifdef MOZ_PHOENIX
const MOZ_APP_NAME = "firefox";
const MOZ_BUILD_APP = "browser";
#elifdef MOZ_THUNDERBIRD
const MOZ_APP_NAME = "thunderbird";
const MOZ_BUILD_APP = "mail";
#elif defined(MOZ_SUITE) && !defined(BINOC_BOREALIS)
const MOZ_APP_NAME = "seamonkey";
const MOZ_BUILD_APP = "suite";
#else
#expand const MOZ_APP_NAME = "__MOZ_APP_NAME__";
#expand const MOZ_BUILD_APP = "__MOZ_BUILD_APP__".match(/([^\/]*)\/*$/)[1];
#endif
this.ResetProfile = {
/**

View File

@ -8,7 +8,6 @@ const Ci = Components.interfaces;
const Cc = Components.classes;
const Cr = Components.results;
Components.utils.import("resource://gre/modules/AppConstants.jsm");
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
this.Services = {};

View File

@ -8,7 +8,6 @@ this.EXPORTED_SYMBOLS = ["UpdateUtils"];
const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
Cu.import("resource://gre/modules/AppConstants.jsm");
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/NetUtil.jsm");
@ -34,8 +33,7 @@ this.UpdateUtils = {
*/
getUpdateChannel(aIncludePartners = true) {
let defaults = Services.prefs.getDefaultBranch(null);
let channel = defaults.getCharPref("app.update.channel",
AppConstants.MOZ_UPDATE_CHANNEL);
#expand let channel = defaults.getCharPref("app.update.channel", "__MOZ_UPDATE_CHANNEL__");
if (aIncludePartners) {
try {
@ -132,49 +130,48 @@ XPCOMUtils.defineLazyGetter(UpdateUtils, "Locale", function() {
* Provides adhoc system capability information for application update.
*/
XPCOMUtils.defineLazyGetter(this, "gSystemCapabilities", function aus_gSC() {
if (AppConstants.platform == "win") {
const PF_MMX_INSTRUCTIONS_AVAILABLE = 3; // MMX
const PF_XMMI_INSTRUCTIONS_AVAILABLE = 6; // SSE
const PF_XMMI64_INSTRUCTIONS_AVAILABLE = 10; // SSE2
const PF_SSE3_INSTRUCTIONS_AVAILABLE = 13; // SSE3
#ifdef XP_WIN
const PF_MMX_INSTRUCTIONS_AVAILABLE = 3; // MMX
const PF_XMMI_INSTRUCTIONS_AVAILABLE = 6; // SSE
const PF_XMMI64_INSTRUCTIONS_AVAILABLE = 10; // SSE2
const PF_SSE3_INSTRUCTIONS_AVAILABLE = 13; // SSE3
let lib = ctypes.open("kernel32.dll");
let IsProcessorFeaturePresent = lib.declare("IsProcessorFeaturePresent",
ctypes.winapi_abi,
ctypes.int32_t, /* success */
ctypes.uint32_t); /* DWORD */
let instructionSet = "unknown";
try {
if (IsProcessorFeaturePresent(PF_SSE3_INSTRUCTIONS_AVAILABLE)) {
instructionSet = "SSE3";
} else if (IsProcessorFeaturePresent(PF_XMMI64_INSTRUCTIONS_AVAILABLE)) {
instructionSet = "SSE2";
} else if (IsProcessorFeaturePresent(PF_XMMI_INSTRUCTIONS_AVAILABLE)) {
instructionSet = "SSE";
} else if (IsProcessorFeaturePresent(PF_MMX_INSTRUCTIONS_AVAILABLE)) {
instructionSet = "MMX";
}
} catch (e) {
instructionSet = "error";
Cu.reportError("Error getting processor instruction set. " +
"Exception: " + e);
}
lib.close();
return instructionSet;
}
if (AppConstants == "linux") {
let instructionSet = "unknown";
if (navigator.cpuHasSSE2) {
let lib = ctypes.open("kernel32.dll");
let IsProcessorFeaturePresent = lib.declare("IsProcessorFeaturePresent",
ctypes.winapi_abi,
ctypes.int32_t, /* success */
ctypes.uint32_t); /* DWORD */
let instructionSet = "unknown";
try {
if (IsProcessorFeaturePresent(PF_SSE3_INSTRUCTIONS_AVAILABLE)) {
instructionSet = "SSE3";
} else if (IsProcessorFeaturePresent(PF_XMMI64_INSTRUCTIONS_AVAILABLE)) {
instructionSet = "SSE2";
} else if (IsProcessorFeaturePresent(PF_XMMI_INSTRUCTIONS_AVAILABLE)) {
instructionSet = "SSE";
} else if (IsProcessorFeaturePresent(PF_MMX_INSTRUCTIONS_AVAILABLE)) {
instructionSet = "MMX";
}
return instructionSet;
} catch (e) {
instructionSet = "error";
Cu.reportError("Error getting processor instruction set. " +
"Exception: " + e);
}
lib.close();
return instructionSet;
#elifdef XP_LINUX
let instructionSet = "unknown";
if (navigator.cpuHasSSE2) {
instructionSet = "SSE2";
}
return instructionSet;
#else
return "NA"
#endif
});
#ifdef XP_WIN
/* Windows only getter that returns the processor architecture. */
XPCOMUtils.defineLazyGetter(this, "gWinCPUArch", function aus_gWinCPUArch() {
// Get processor architecture
@ -239,6 +236,7 @@ XPCOMUtils.defineLazyGetter(this, "gWinCPUArch", function aus_gWinCPUArch() {
return arch;
});
#endif
XPCOMUtils.defineLazyGetter(UpdateUtils, "ABI", function() {
let abi = null;
@ -249,19 +247,20 @@ XPCOMUtils.defineLazyGetter(UpdateUtils, "ABI", function() {
Cu.reportError("XPCOM ABI unknown");
}
if (AppConstants.platform == "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);
#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;
}
} else if (AppConstants.platform == "win") {
// Windows build should report the CPU architecture that it's running on.
abi += "-" + gWinCPUArch;
if (macutils.isUniversalBinary) {
abi += "-u-" + macutils.architecturesInBinary;
}
#elifdef XP_WIN
// Windows build should report the CPU architecture that it's running on.
abi += "-" + gWinCPUArch;
#endif
return abi;
});
@ -275,95 +274,96 @@ XPCOMUtils.defineLazyGetter(UpdateUtils, "OSVersion", function() {
Cu.reportError("OS Version unknown.");
}
#ifdef XP_WIN
if (osVersion) {
if (AppConstants.platform == "win") {
const BYTE = ctypes.uint8_t;
const WORD = ctypes.uint16_t;
const DWORD = ctypes.uint32_t;
const WCHAR = ctypes.char16_t;
const BOOL = ctypes.int;
const BYTE = ctypes.uint8_t;
const WORD = ctypes.uint16_t;
const DWORD = ctypes.uint32_t;
const WCHAR = ctypes.char16_t;
const BOOL = ctypes.int;
// This structure is described at:
// http://msdn.microsoft.com/en-us/library/ms724833%28v=vs.85%29.aspx
const SZCSDVERSIONLENGTH = 128;
const OSVERSIONINFOEXW = new ctypes.StructType('OSVERSIONINFOEXW',
[
{dwOSVersionInfoSize: DWORD},
{dwMajorVersion: DWORD},
{dwMinorVersion: DWORD},
{dwBuildNumber: DWORD},
{dwPlatformId: DWORD},
{szCSDVersion: ctypes.ArrayType(WCHAR, SZCSDVERSIONLENGTH)},
{wServicePackMajor: WORD},
{wServicePackMinor: WORD},
{wSuiteMask: WORD},
{wProductType: BYTE},
{wReserved: BYTE}
]);
// This structure is described at:
// http://msdn.microsoft.com/en-us/library/ms724833%28v=vs.85%29.aspx
const SZCSDVERSIONLENGTH = 128;
const OSVERSIONINFOEXW = new ctypes.StructType('OSVERSIONINFOEXW',
[
{dwOSVersionInfoSize: DWORD},
{dwMajorVersion: DWORD},
{dwMinorVersion: DWORD},
{dwBuildNumber: DWORD},
{dwPlatformId: DWORD},
{szCSDVersion: ctypes.ArrayType(WCHAR, SZCSDVERSIONLENGTH)},
{wServicePackMajor: WORD},
{wServicePackMinor: WORD},
{wSuiteMask: WORD},
{wProductType: BYTE},
{wReserved: BYTE}
]);
// This structure is described at:
// http://msdn.microsoft.com/en-us/library/ms724958%28v=vs.85%29.aspx
const SYSTEM_INFO = new ctypes.StructType('SYSTEM_INFO',
[
{wProcessorArchitecture: WORD},
{wReserved: WORD},
{dwPageSize: DWORD},
{lpMinimumApplicationAddress: ctypes.voidptr_t},
{lpMaximumApplicationAddress: ctypes.voidptr_t},
{dwActiveProcessorMask: DWORD.ptr},
{dwNumberOfProcessors: DWORD},
{dwProcessorType: DWORD},
{dwAllocationGranularity: DWORD},
{wProcessorLevel: WORD},
{wProcessorRevision: WORD}
]);
// This structure is described at:
// http://msdn.microsoft.com/en-us/library/ms724958%28v=vs.85%29.aspx
const SYSTEM_INFO = new ctypes.StructType('SYSTEM_INFO',
[
{wProcessorArchitecture: WORD},
{wReserved: WORD},
{dwPageSize: DWORD},
{lpMinimumApplicationAddress: ctypes.voidptr_t},
{lpMaximumApplicationAddress: ctypes.voidptr_t},
{dwActiveProcessorMask: DWORD.ptr},
{dwNumberOfProcessors: DWORD},
{dwProcessorType: DWORD},
{dwAllocationGranularity: DWORD},
{wProcessorLevel: WORD},
{wProcessorRevision: WORD}
]);
let kernel32 = false;
let kernel32 = false;
try {
kernel32 = ctypes.open("Kernel32");
} catch (e) {
Cu.reportError("Unable to open kernel32! " + e);
osVersion += ".unknown (unknown)";
}
if (kernel32) {
try {
kernel32 = ctypes.open("Kernel32");
} catch (e) {
Cu.reportError("Unable to open kernel32! " + e);
osVersion += ".unknown (unknown)";
}
if (kernel32) {
// Get Service pack info
try {
// Get Service pack info
try {
let GetVersionEx = kernel32.declare("GetVersionExW",
ctypes.default_abi,
BOOL,
OSVERSIONINFOEXW.ptr);
let winVer = OSVERSIONINFOEXW();
winVer.dwOSVersionInfoSize = OSVERSIONINFOEXW.size;
let GetVersionEx = kernel32.declare("GetVersionExW",
ctypes.default_abi,
BOOL,
OSVERSIONINFOEXW.ptr);
let winVer = OSVERSIONINFOEXW();
winVer.dwOSVersionInfoSize = OSVERSIONINFOEXW.size;
if (0 !== GetVersionEx(winVer.address())) {
osVersion += "." + winVer.wServicePackMajor +
"." + winVer.wServicePackMinor;
} else {
Cu.reportError("Unknown failure in GetVersionEX (returned 0)");
osVersion += ".unknown";
}
} catch (e) {
Cu.reportError("Error getting service pack information. Exception: " + e);
if (0 !== GetVersionEx(winVer.address())) {
osVersion += "." + winVer.wServicePackMajor +
"." + winVer.wServicePackMinor;
} else {
Cu.reportError("Unknown failure in GetVersionEX (returned 0)");
osVersion += ".unknown";
}
} finally {
kernel32.close();
} catch (e) {
Cu.reportError("Error getting service pack information. Exception: " + e);
osVersion += ".unknown";
}
// Add processor architecture
osVersion += " (" + gWinCPUArch + ")";
} finally {
kernel32.close();
}
}
try {
osVersion += " (" + Services.sysinfo.getProperty("secondaryLibrary") + ")";
// Add processor architecture
osVersion += " (" + gWinCPUArch + ")";
}
catch (e) {
// Not all platforms have a secondary widget library, so an error is nothing to worry about.
}
osVersion = encodeURIComponent(osVersion);
}
try {
osVersion += " (" + Services.sysinfo.getProperty("secondaryLibrary") + ")";
}
catch (e) {
// Not all platforms have a secondary widget library, so an error is nothing to worry about.
}
osVersion = encodeURIComponent(osVersion);
#endif
return osVersion;
});

View File

@ -2,9 +2,11 @@
* 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");
const HAVE_CSS_WINDOW_DRAG_SUPPORT = ["win", "macosx"].includes(AppConstants.platform);
#if defined(XP_WIN) || defined(XP_MACOSX)
const HAVE_CSS_WINDOW_DRAG_SUPPORT = true;
#else
const HAVE_CSS_WINDOW_DRAG_SUPPORT = false;
#endif
this.EXPORTED_SYMBOLS = [ "WindowDraggingElement" ];
@ -62,12 +64,13 @@ WindowDraggingElement.prototype = {
if (!this.shouldDrag(aEvent))
return;
if (/^gtk/i.test(AppConstants.MOZ_WIDGET_TOOLKIT)) {
// On GTK, there is a toolkit-level function which handles
// window dragging, which must be used.
this._window.beginWindowMove(aEvent, isPanel ? this._elem : null);
break;
}
#ifdef MOZ_WIDGET_GTK
// On GTK, there is a toolkit-level function which handles
// window dragging, which must be used.
this._window.beginWindowMove(aEvent, isPanel ? this._elem : null);
break;
#endif
if (isPanel) {
let screenRect = this._elem.getOuterScreenRect();
this._deltaX = aEvent.screenX - screenRect.left;

View File

@ -19,8 +19,6 @@ Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/Task.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "AppConstants",
"resource://gre/modules/AppConstants.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "BrowserUtils",
"resource://gre/modules/BrowserUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "ExtensionUtils",
@ -846,9 +844,9 @@ var onBeforeRequest = {
get allowedOptions() {
delete this.allowedOptions;
this.allowedOptions = ["blocking"];
if (!AppConstants.RELEASE_OR_BETA) {
this.allowedOptions.push("requestBody");
}
#ifndef RELEASE_OR_BETA
this.allowedOptions.push("requestBody");
#endif
return this.allowedOptions;
},
addListener(callback, filter = null, opt_extraInfoSpec = null) {

View File

@ -22,7 +22,6 @@ EXTRA_JS_MODULES += [
'addons/WebNavigation.jsm',
'addons/WebNavigationContent.js',
'addons/WebNavigationFrames.jsm',
'addons/WebRequest.jsm',
'addons/WebRequestCommon.jsm',
'addons/WebRequestContent.js',
'addons/WebRequestUpload.jsm',
@ -74,7 +73,6 @@ EXTRA_JS_MODULES += [
'RemotePageManager.jsm',
'RemoteSecurityUI.jsm',
'RemoteWebProgress.jsm',
'ResetProfile.jsm',
'ResponsivenessMonitor.jsm',
'secondscreen/PresentationApp.jsm',
'secondscreen/RokuApp.jsm',
@ -93,16 +91,18 @@ EXTRA_JS_MODULES += [
'Task.jsm',
'Timer.jsm',
'WebChannel.jsm',
'WindowDraggingUtils.jsm',
'ZipUtils.jsm',
]
EXTRA_JS_MODULES.third_party.jsesc += ['third_party/jsesc/jsesc.js']
EXTRA_JS_MODULES.sessionstore += ['sessionstore/Utils.jsm']
EXTRA_PP_JS_MODULES += [
'addons/WebRequest.jsm',
'NewTabUtils.jsm',
'ResetProfile.jsm',
'Troubleshoot.jsm',
'UpdateUtils.jsm',
'WindowDraggingUtils.jsm',
]
if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('windows', 'cocoa'):
@ -120,7 +120,7 @@ EXTRA_PP_JS_MODULES += [
]
if 'Android' != CONFIG['OS_TARGET']:
EXTRA_JS_MODULES += [
EXTRA_PP_JS_MODULES += [
'LightweightThemeConsumer.jsm',
]

View File

@ -18,17 +18,16 @@ let EXPORTED_SYMBOLS = ["Subprocess"];
var {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
Cu.import("resource://gre/modules/AppConstants.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/subprocess/subprocess_common.jsm");
if (AppConstants.platform == "win") {
XPCOMUtils.defineLazyModuleGetter(this, "SubprocessImpl",
"resource://gre/modules/subprocess/subprocess_win.jsm");
} else {
XPCOMUtils.defineLazyModuleGetter(this, "SubprocessImpl",
"resource://gre/modules/subprocess/subprocess_unix.jsm");
}
#ifdef XP_WIN
XPCOMUtils.defineLazyModuleGetter(this, "SubprocessImpl",
"resource://gre/modules/subprocess/subprocess_win.jsm");
#else
XPCOMUtils.defineLazyModuleGetter(this, "SubprocessImpl",
"resource://gre/modules/subprocess/subprocess_unix.jsm");
#endif
/**
* Allows for creation of and communication with OS-level sub-processes.

View File

@ -4,7 +4,7 @@
# 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/.
EXTRA_JS_MODULES += [
EXTRA_PP_JS_MODULES += [
'Subprocess.jsm',
]

View File

@ -15,7 +15,6 @@ var {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
var EXPORTED_SYMBOLS = ["SubprocessImpl"];
Cu.import("resource://gre/modules/AppConstants.jsm");
Cu.import("resource://gre/modules/ctypes.jsm");
Cu.import("resource://gre/modules/osfile.jsm");
Cu.import("resource://gre/modules/Services.jsm");
@ -35,7 +34,7 @@ class WinPromiseWorker extends PromiseWorker {
this.signalEvent = libc.CreateSemaphoreW(null, 0, 32, null);
this.call("init", [{
breakAwayFromJob: !AppConstants.isPlatformAndVersionAtLeast("win", "6.2"),
breakAwayFromJob: Services.vc.compare(Services.sysinfo.getProperty("version"), "6.2") <= 0,
comspec: env.get("COMSPEC"),
signalEvent: String(ctypes.cast(this.signalEvent, ctypes.uintptr_t).value),
}]);

View File

@ -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();
#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._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;
}
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
},
/**

View File

@ -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;
}
}

View File

@ -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)

View File

@ -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']

View File

@ -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) { }
#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);
}
// 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;
},
@ -640,21 +639,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).
#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;
}
// 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 +675,11 @@ nsUnknownContentTypeDialog.prototype = {
// getPath:
getPath: function (aFile) {
if (AppConstants.platform == "macosx") {
#ifdef XP_MACOSX
return aFile.leafName || aFile.path;
}
#else
return aFile.path;
#endif
},
// initAppAndSaveToDiskValues:
@ -980,19 +981,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 +1008,13 @@ 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,85 +1030,84 @@ 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;
// 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;
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;
}
}
else {
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 // XP_WIN
#if MOZ_WIDGET_GTK == 3
var nsIApplicationChooser = Components.interfaces.nsIApplicationChooser;
var appChooser = Components.classes["@mozilla.org/applicationchooser;1"]
.createInstance(nsIApplicationChooser);
appChooser.init(this.mDialog, this.dialogElement("strings").getString("chooseAppFilePickerTitle"));
var contentTypeDialogObj = this;
let appChooserCallback = function appChooserCallback_done(aResult) {
if (aResult) {
contentTypeDialogObj.chosenApp = aResult.QueryInterface(Components.interfaces.nsILocalHandlerApp);
}
contentTypeDialogObj.finishChooseApp();
};
appChooser.open(this.mLauncher.MIMEInfo.MIMEType, appChooserCallback);
// The finishChooseApp is called from appChooserCallback
return;
#else
var nsIFilePicker = Components.interfaces.nsIFilePicker;
var fp = Components.classes["@mozilla.org/filepicker;1"]
.createInstance(nsIFilePicker);
fp.init(this.mDialog,
this.dialogElement("strings").getString("chooseAppFilePickerTitle"),
nsIFilePicker.modeOpen);
fp.appendFilters(nsIFilePicker.filterApps);
if (fp.show() == nsIFilePicker.returnOK && fp.file) {
// Remember the file they chose to run.
var localHandlerApp =
Components.classes["@mozilla.org/uriloader/local-handler-app;1"].
createInstance(Components.interfaces.nsILocalHandlerApp);
localHandlerApp.executable = fp.file;
this.chosenApp = localHandlerApp;
var nsIApplicationChooser = Components.interfaces.nsIApplicationChooser;
var appChooser = Components.classes["@mozilla.org/applicationchooser;1"]
.createInstance(nsIApplicationChooser);
appChooser.init(this.mDialog, this.dialogElement("strings").getString("chooseAppFilePickerTitle"));
var contentTypeDialogObj = this;
let appChooserCallback = function appChooserCallback_done(aResult) {
if (aResult) {
contentTypeDialogObj.chosenApp = aResult.QueryInterface(Components.interfaces.nsILocalHandlerApp);
}
#endif // MOZ_WIDGET_GTK == 3
contentTypeDialogObj.finishChooseApp();
};
appChooser.open(this.mLauncher.MIMEInfo.MIMEType, appChooserCallback);
// The finishChooseApp is called from appChooserCallback
return;
#else // MOZ_WIDGET_GTK == 3
var nsIFilePicker = Components.interfaces.nsIFilePicker;
var fp = Components.classes["@mozilla.org/filepicker;1"]
.createInstance(nsIFilePicker);
fp.init(this.mDialog,
this.dialogElement("strings").getString("chooseAppFilePickerTitle"),
nsIFilePicker.modeOpen);
fp.appendFilters(nsIFilePicker.filterApps);
if (fp.show() == nsIFilePicker.returnOK && fp.file) {
// Remember the file they chose to run.
var localHandlerApp =
Components.classes["@mozilla.org/uriloader/local-handler-app;1"].
createInstance(Components.interfaces.nsILocalHandlerApp);
localHandlerApp.executable = fp.file;
this.chosenApp = localHandlerApp;
}
#endif // MOZ_WIDGET_GTK == 3
#endif // XP_WIN
this.finishChooseApp();
},

View File

@ -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
},
/**

View File

@ -37,9 +37,8 @@ EXTRA_PP_JS_MODULES += [
]
if CONFIG['THE_GMP']:
EXTRA_JS_MODULES += ['GMPUtils.jsm',]
EXTRA_PP_JS_MODULES += ['GMPInstallManager.jsm',]
EXTRA_PP_JS_MODULES += ['GMPInstallManager.jsm',
'GMPUtils.jsm',]
# Additional debugging info is exposed in debug builds
if CONFIG['MOZ_EM_DEBUG']:

View File

@ -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('**'):

View File

@ -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);
#ifndef XP_MACOSX
try {
let updateTestFile = getUpdateFile([FILE_UPDATE_TEST]);
LOG("getCanApplyUpdates - testing write access " + updateTestFile.path);
testWriteAccess(updateTestFile, false);
/**
* 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;
#ifdef XP_WIN
// Example windowsVersion: Windows XP == 5.1
let windowsVersion = Services.sysinfo.getProperty("version");
LOG("getCanApplyUpdates - windowsVersion = " + windowsVersion);
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");
}
}
/**
* 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;
/**
* 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);
}
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;
},
@ -2889,11 +2897,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);

View File

@ -2,6 +2,8 @@
* 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/. */
#filter substitution
"use strict";
const Cc = Components.classes;
@ -21,9 +23,7 @@ if ("@mozilla.org/xre/app-info;1" in Cc) {
}
}
Cu.import("resource://gre/modules/AppConstants.jsm");
const MOZ_COMPATIBILITY_NIGHTLY = !['aurora', 'beta', 'release', 'esr'].includes(AppConstants.MOZ_UPDATE_CHANNEL);
const MOZ_COMPATIBILITY_NIGHTLY = !['aurora', 'beta', 'release', 'esr'].includes("@MOZ_UPDATE_CHANNEL@");
const PREF_BLOCKLIST_PINGCOUNTVERSION = "extensions.blocklist.pingCountVersion";
const PREF_DEFAULT_PROVIDERS_ENABLED = "extensions.defaultProviders.enabled";
@ -3391,7 +3391,11 @@ this.AddonManager = {
STATE_ASK_TO_ACTIVATE: "askToActivate",
get __AddonManagerInternal__() {
return AppConstants.DEBUG ? AddonManagerInternal : undefined;
#ifdef DEBUG
return AddonManagerInternal;
#else
return undefined;
#endif
},
get isReady() {

View File

@ -2,6 +2,8 @@
* 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/. */
#filter substitution
"use strict";
const Cc = Components.classes;
@ -21,7 +23,6 @@ Cu.import("resource://gre/modules/Log.jsm");
Cu.import("resource://gre/modules/Task.jsm");
Cu.import("resource://gre/modules/GMPUtils.jsm");
/* globals GMP_PLUGIN_IDS, GMPPrefs, GMPUtils, OPEN_H264_ID, WIDEVINE_ID */
Cu.import("resource://gre/modules/AppConstants.jsm");
Cu.import("resource://gre/modules/UpdateUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(
@ -473,7 +474,7 @@ GMPWrapper.prototype = {
};
let id = this._plugin.id.substring(4);
let libName = AppConstants.DLL_PREFIX + id + AppConstants.DLL_SUFFIX;
let libName = "@DLL_PREFIX@" + id + "@DLL_SUFFIX@";
let infoName;
if (this._plugin.id == WIDEVINE_ID) {
infoName = "manifest.json";

View File

@ -2,6 +2,8 @@
* 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/. */
#filter substitution
"use strict";
const Cc = Components.classes;
@ -54,8 +56,6 @@ XPCOMUtils.defineLazyModuleGetter(this, "ProductAddonChecker",
"resource://gre/modules/addons/ProductAddonChecker.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "UpdateUtils",
"resource://gre/modules/UpdateUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "AppConstants",
"resource://gre/modules/AppConstants.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "LegacyExtensionsUtils",
"resource://gre/modules/LegacyExtensionsUtils.jsm");
@ -223,8 +223,9 @@ const TYPES = {
experiment: 128,
};
if (!AppConstants.RELEASE_OR_BETA)
#ifndef RELEASE_OR_BETA
TYPES.apiextension = 256;
#endif
// Some add-on types that we track internally are presented as other types
// externally
@ -6723,7 +6724,11 @@ function AddonInstallWrapper(aInstall) {
AddonInstallWrapper.prototype = {
get __AddonInstallInternal__() {
return AppConstants.DEBUG ? installFor(this) : undefined;
#ifdef DEBUG
return installFor(this);
#else
return undefined;
#endif
},
get type() {
@ -7341,7 +7346,11 @@ function AddonWrapper(aAddon) {
AddonWrapper.prototype = {
get __AddonInternal__() {
return AppConstants.DEBUG ? addonFor(this) : undefined;
#ifdef DEBUG
return addonFor(this);
#else
return undefined;
#endif
},
get seen() {
@ -9116,7 +9125,7 @@ WinRegInstallLocation.prototype = {
let appName = Services.appinfo.name;
// XXX Thunderbird doesn't specify a vendor string
if (AppConstants.MOZ_APP_NAME == "thunderbird" && appVendor == "")
if ("@MOZ_APP_NAME@" == "thunderbird" && appVendor == "")
appVendor = "Mozilla";
// XULRunner-based apps may intentionally not specify a vendor

View File

@ -12,13 +12,16 @@ EXTRA_JS_MODULES.addons += [
'AddonRepository.jsm',
'AddonRepository_SQLiteMigrator.jsm',
'APIExtensionBootstrap.js',
'GMPProvider.jsm',
'LightweightThemeImageOptimizer.jsm',
'WebExtensionBootstrap.js',
'XPIProvider.jsm',
'XPIProviderUtils.js',
]
if CONFIG['THE_GMP']:
EXTRA_PP_JS_MODULES.addons += ['GMPProvider.jsm',
]
# Don't ship unused providers on Android
if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'android':
EXTRA_JS_MODULES.addons += [
@ -28,4 +31,9 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'android':
EXTRA_PP_JS_MODULES.addons += [
'../../extensions/internal/AddonUpdateChecker.jsm',
'AddonConstants.jsm',
'XPIProvider.jsm',
]
DEFINES['DLL_PREFIX'] = CONFIG['DLL_PREFIX']
DEFINES['DLL_SUFFIX'] = CONFIG['DLL_SUFFIX']
DEFINES['MOZ_APP_NAME'] = CONFIG['MOZ_APP_NAME']

View File

@ -30,14 +30,16 @@ EXTRA_PP_COMPONENTS += [
EXTRA_JS_MODULES += [
'../extensions/ChromeManifestParser.jsm',
'../extensions/DeferredSave.jsm',
'AddonManager.jsm',
'LightweightThemeManager.jsm',
]
EXTRA_PP_JS_MODULES += [
'AddonManager.jsm',
]
if CONFIG['THE_GMP']:
EXTRA_JS_MODULES += ['../extensions/GMPUtils.jsm',
'GMPInstallManager.jsm',
]
EXTRA_JS_MODULES += ['GMPInstallManager.jsm',]
EXTRA_PP_JS_MODULES += ['../extensions/GMPUtils.jsm',]
JAR_MANIFESTS += ['jar.mn']
@ -57,4 +59,6 @@ LOCAL_INCLUDES += [
'/dom/base',
]
DEFINES['MOZ_UPDATE_CHANNEL'] = CONFIG['MOZ_UPDATE_CHANNEL']
FINAL_LIBRARY = 'xul'

View File

@ -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;
@ -123,12 +121,11 @@ function checkCurrentInput(currentInput)
if (!errorMessage) {
finishText.className = "";
if (AppConstants.platform == "macosx") {
finishText.firstChild.data = gProfileManagerBundle.getString("profileFinishTextMac");
}
else {
finishText.firstChild.data = gProfileManagerBundle.getString("profileFinishText");
}
#ifdef XP_MACOSX
finishText.firstChild.data = gProfileManagerBundle.getString("profileFinishTextMac");
#else
finishText.firstChild.data = gProfileManagerBundle.getString("profileFinishText");
#endif
canAdvance = true;
}
else {

View File

@ -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;
@ -135,8 +134,9 @@ function onProfilesKey(aEvent)
switch ( aEvent.keyCode )
{
case KeyEvent.DOM_VK_BACK_SPACE:
if (AppConstants.platform != "macosx")
break;
#ifndef XP_MACOSX
break;
#endif
case KeyEvent.DOM_VK_DELETE:
ConfirmDelete();
break;

View File

@ -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)