Bug 617851 (followup) - Don't ignore command-line arguments when restoring sessions [r=mfinkle]

This commit is contained in:
Matt Brubeck 2010-12-15 23:00:33 -08:00
parent c3c8c59378
commit 630eb1f249
2 changed files with 18 additions and 27 deletions

View File

@ -359,19 +359,21 @@ var Browser = {
// Make sure we're online before attempting to load
Util.forceOnline();
// If this is an intial window launch the commandline handler passes us the default
// page as an argument
let defaultURL = this.getHomePage();
let homeURL = this.getHomePage();
let commandURL;
if (window.arguments && window.arguments[0])
defaultURL = window.arguments[0];
commandURL = window.arguments[0];
// Should we restore the previous session (crash or some other event)
let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
if (ss.shouldRestore())
if (ss.shouldRestore()) {
ss.restoreLastSession();
else
this.addTab(defaultURL, true);
if (commandURL)
this.addTab(commandURL, true);
} else {
this.addTab(commandURL || homeURL, true);
}
// JavaScript Error Console
if (Services.prefs.getBoolPref("browser.console.showInPanel")){
let button = document.getElementById("tool-console");
@ -2219,11 +2221,11 @@ var ContentCrashObserver = {
let buttons = Ci.nsIPrompt.BUTTON_POS_1_DEFAULT +
(Ci.nsIPrompt.BUTTON_TITLE_IS_STRING * Ci.nsIPrompt.BUTTON_POS_0) +
(Ci.nsIPrompt.BUTTON_TITLE_IS_STRING * Ci.nsIPrompt.BUTTON_POS_1);
// Only show the submit checkbox if we have a crash report we can submit
if (!dumpID)
submitText = null;
let submit = { value: true };
let reload = Services.prompt.confirmEx(window, title, message, buttons, closeText, reloadText, null, submitText, submit);
if (reload) {
@ -2237,12 +2239,12 @@ var ContentCrashObserver = {
// have zero open tabs
if (Browser.tabs.length == 1)
Browser.addTab(Browser.getHomePage(), false, null, { getAttention: false });
// Close this tab, it could be the reason we crashed. The undo-close-tab
// system will pick it up.
Browser.closeTab(Browser.selectedTab);
}
// Submit the report, if we have one and the user wants to submit it
if (submit.value && dumpID)
self.CrashSubmit.submit(dumpID, Elements.stack, null, null);

View File

@ -48,7 +48,7 @@ function openWindow(aParent, aURL, aTarget, aFeatures, aArgs) {
argString = Cc["@mozilla.org/supports-string;1"].createInstance(Ci.nsISupportsString);
argString.data = aArgs;
}
return Services.ww.openWindow(aParent, aURL, aTarget, aFeatures, argString);
}
@ -105,16 +105,6 @@ function needHomepageOverride() {
return "none";
}
function getHomePage() {
let url = "about:home";
try {
url = Services.prefs.getComplexValue("browser.startup.homepage", Ci.nsIPrefLocalizedString).data;
} catch (e) { }
return url;
}
function BrowserCLH() { }
BrowserCLH.prototype = {
@ -182,13 +172,12 @@ BrowserCLH.prototype = {
try {
win = Services.wm.getMostRecentWindow("navigator:browser");
if (!win) {
// Default to the saved homepage
let defaultURL = getHomePage();
let defaultURL;
// Override the default if we have a new profile
if (needHomepageOverride() == "new profile")
defaultURL = "about:firstrun";
// Override the default if we have a URL passed on command line
if (uris.length > 0) {
defaultURL = uris[0].spec;