Bug 397869 - Sanify console.host usage
r=ajvincent@gmail.com (Alex Vincent) Venkman Only. NPOTDB. git-svn-id: svn://10.0.0.236/trunk@243604 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -631,15 +631,61 @@ function init()
|
||||
|
||||
function initApplicationCompatibility()
|
||||
{
|
||||
// This routine does nothing more than tweak the UI based on the host
|
||||
// This function does nothing more than tweak the UI based on the host
|
||||
// application.
|
||||
|
||||
var windowMenu = document.getElementById("windowMenu");
|
||||
|
||||
// Set up simple host and platform information.
|
||||
console.host = "Mozilla";
|
||||
if (!windowMenu.firstChild)
|
||||
console.host = "Firefox";
|
||||
console.host = "Unknown";
|
||||
console.haveBrowser = false;
|
||||
|
||||
var app = getService("@mozilla.org/xre/app-info;1", "nsIXULAppInfo");
|
||||
// nsIXULAppInfo wasn't implemented before 1.8...
|
||||
if (app)
|
||||
{
|
||||
// Use the XULAppInfo.ID to find out what host we run on.
|
||||
switch (app.ID)
|
||||
{
|
||||
case "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}":
|
||||
console.host = "Firefox";
|
||||
console.haveBrowser = true;
|
||||
break;
|
||||
case "{3550f703-e582-4d05-9a08-453d09bdfdc6}": // Thunderbird
|
||||
console.host = "Thunderbird";
|
||||
break;
|
||||
case "{a463f10c-3994-11da-9945-000d60ca027b}": // Flock
|
||||
console.host = "Flock";
|
||||
console.haveBrowser = true;
|
||||
break;
|
||||
case "{718e30fb-e89b-41dd-9da7-e25a45638b28}": // Sunbird
|
||||
console.host = "Sunbird";
|
||||
break;
|
||||
case "{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}": // SeaMonkey
|
||||
console.host = "Mozilla";
|
||||
console.haveBrowser = true;
|
||||
break;
|
||||
default:
|
||||
console.unknownAppUID = app.ID;
|
||||
console.host = "ToolkitApp"; // Unknown host, platform install
|
||||
}
|
||||
}
|
||||
else if ("getBrowserURL" in window)
|
||||
{
|
||||
var url = getBrowserURL();
|
||||
if (url == "chrome://navigator/content/navigator.xul")
|
||||
{
|
||||
console.host = "Mozilla";
|
||||
console.haveBrowser = true;
|
||||
}
|
||||
else if (url == "chrome://browser/content/browser.xul")
|
||||
{
|
||||
console.host = "Firefox";
|
||||
console.haveBrowser = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
console.unknownAppUID = url;
|
||||
}
|
||||
}
|
||||
|
||||
console.platform = "Unknown";
|
||||
if (navigator.platform.search(/mac/i) > -1)
|
||||
@@ -648,6 +694,8 @@ function initApplicationCompatibility()
|
||||
console.platform = "Windows";
|
||||
if (navigator.platform.search(/linux/i) > -1)
|
||||
console.platform = "Linux";
|
||||
if (navigator.platform.search(/os\/2/i) > -1)
|
||||
console.platform = "OS/2";
|
||||
|
||||
console.hostPlatform = console.host + console.platform;
|
||||
|
||||
@@ -657,15 +705,11 @@ function initApplicationCompatibility()
|
||||
//var toolsMenu = document.getElementById("mainmenu:tools");
|
||||
var comBar = document.getElementById("component-bar");
|
||||
|
||||
if (console.host == "Firefox") {
|
||||
if (console.host != "Mozilla") {
|
||||
tasksMenu.parentNode.removeChild(tasksMenu);
|
||||
winMenu.parentNode.removeChild(winMenu);
|
||||
comBar.collapsed = true;
|
||||
}
|
||||
|
||||
//if ((console.host != "Firefox") || (console.platform == "Linux")) {
|
||||
// toolsMenu.parentNode.removeChild(toolsMenu);
|
||||
//}
|
||||
}
|
||||
|
||||
function initPost()
|
||||
|
||||
@@ -215,6 +215,37 @@ function dumpObjectTree (o, recurse, compress, level)
|
||||
|
||||
}
|
||||
|
||||
function getService(contractID, iface)
|
||||
{
|
||||
var rv;
|
||||
var cls = Components.classes[contractID];
|
||||
|
||||
if (!cls)
|
||||
return null;
|
||||
|
||||
switch (typeof iface)
|
||||
{
|
||||
case "undefined":
|
||||
rv = cls.getService();
|
||||
break;
|
||||
|
||||
case "string":
|
||||
rv = cls.getService(Components.interfaces[iface]);
|
||||
break;
|
||||
|
||||
case "object":
|
||||
rv = cls.getService(iface);
|
||||
break;
|
||||
|
||||
default:
|
||||
rv = null;
|
||||
break;
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
||||
}
|
||||
|
||||
function safeHTML(str)
|
||||
{
|
||||
function replaceChars(ch)
|
||||
|
||||
Reference in New Issue
Block a user