Bug 206092 New window from Composer/MailNews only opens blank page p=ian@arlen.demon.co.uk r=me sr=jag

This commit is contained in:
neil%parkwaycc.co.uk 2003-06-02 14:31:52 +00:00
parent f874fa8926
commit 26d205a46f
3 changed files with 42 additions and 29 deletions

View File

@ -553,9 +553,38 @@ function Startup()
if (!isPageCycling) {
var uriToLoad = "";
// Check for window.arguments[0]. If present, use that for uriToLoad.
if ("arguments" in window && window.arguments.length >= 1 && window.arguments[0]) {
var uriArray = window.arguments[0].toString().split('\n'); // stringify and split
// Check window.arguments[0]. If not null then use it for uriArray
// otherwise the new window is being called when another browser
// window already exists so use the New Window pref for uriArray
if ("arguments" in window && window.arguments.length >= 1) {
var uriArray;
if (window.arguments[0]) {
uriArray = window.arguments[0].toString().split('\n'); // stringify and split
} else {
try {
switch (pref.getIntPref("browser.windows.loadOnNewWindow"))
{
case -1:
var handler = Components.classes['@mozilla.org/commandlinehandler/general-startup;1?type=browser']
.getService(Components.interfaces.nsICmdLineHandler);
uriArray = handler.defaultArgs.split('\n');
break;
default:
uriArray = ["about:blank"];
break;
case 1:
uriArray = getHomePage();
break;
case 2:
history = Components.classes["@mozilla.org/browser/global-history;1"]
.getService(Components.interfaces.nsIBrowserHistory);
uriArray = [history.lastPageVisited];
break;
}
} catch(e) {
uriArray = ["about:blank"];
}
}
uriToLoad = uriArray.splice(0, 1)[0];
if (uriArray.length > 0)

View File

@ -112,35 +112,12 @@ function OpenBrowserWindow()
handler = handler.QueryInterface(Components.interfaces.nsICmdLineHandler);
var url = handler.chromeUrlForTask;
var wintype = document.documentElement.getAttribute('windowtype');
var startpage;
var windowMediator = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator);
var browserWin = windowMediator.getMostRecentWindow("navigator:browser");
// if a browser window already exists then check pref for how new window should be opened
if (browserWin)
{
try {
switch ( pref.getIntPref("browser.windows.loadOnNewWindow") )
{
case -1:
startpage = handler.defaultArgs;
break;
default:
startpage = "about:blank";
break;
case 1:
startpage = getHomePage().join("\n");
break;
case 2:
startpage = getWebNavigation().currentURI.spec;
break;
}
} catch(e) {
startpage = "about:blank";
}
} else {
startpage = handler.defaultArgs;
}
// if a browser window already exists then set startpage to null so
// navigator.js can check pref for how new window should be opened
var startpage = browserWin ? null : handler.defaultArgs;
// if and only if the current window is a browser window and it has a document with a character
// set, then extract the current charset menu setting from the current document and use it to

View File

@ -106,6 +106,8 @@ nsIPrefBranch* nsGlobalHistory::gPrefBranch = nsnull;
#define PREF_BRANCH_BASE "browser."
#define PREF_BROWSER_HISTORY_EXPIRE_DAYS "history_expire_days"
#define PREF_BROWSER_STARTUP_PAGE "startup.page"
#define PREF_BROWSER_TABS_LOADONNEWTAB "tabs.loadOnNewTab"
#define PREF_BROWSER_WINDOWS_LOADONNEWWINDOW "windows.loadOnNewWindow"
#define PREF_AUTOCOMPLETE_ONLY_TYPED "urlbar.matchOnlyTyped"
#define PREF_AUTOCOMPLETE_ENABLED "urlbar.autocomplete.enabled"
@ -613,6 +615,11 @@ nsGlobalHistory::AddPage(const char *aURL)
if (gPrefBranch) {
PRInt32 choice = 0;
gPrefBranch->GetIntPref(PREF_BROWSER_STARTUP_PAGE, &choice);
if (choice != 2) {
gPrefBranch->GetIntPref(PREF_BROWSER_WINDOWS_LOADONNEWWINDOW, &choice);
if (choice != 2)
gPrefBranch->GetIntPref(PREF_BROWSER_TABS_LOADONNEWTAB, &choice);
}
if (choice == 2) {
rv = SaveLastPageVisited(aURL);
NS_ENSURE_SUCCESS(rv, rv);