Bug 711515 - Opening links from external apps doesn't work if session restore is active [r=mbrubeck]

This commit is contained in:
Mark Finkle 2012-01-04 01:21:49 -05:00
parent 625b29ce54
commit 27f33128b7
2 changed files with 30 additions and 7 deletions

View File

@ -225,9 +225,9 @@ var BrowserApp = {
// Init FormHistory
Cc["@mozilla.org/satchel/form-history;1"].getService(Ci.nsIFormHistory2);
let uri = "about:home";
let url = "about:home";
if ("arguments" in window && window.arguments[0])
uri = window.arguments[0];
url = window.arguments[0];
// XXX maybe we don't do this if the launch was kicked off from external
Services.io.offline = false;
@ -239,10 +239,33 @@ var BrowserApp = {
// restore the previous session
let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
if (ss.shouldRestore())
ss.restoreLastSession(true);
else
this.addTab(uri);
if (ss.shouldRestore()) {
// A restored tab should not be active if we are loading a URL
let restoreToFront = false;
// Open any commandline URLs, except the homepage
if (url && url != "about:home") {
this.addTab(url);
} else {
// Let the session make a restored tab active
restoreToFront = true;
// Be ready to handle any restore failures by making sure we have a valid tab opened
let restoreCleanup = {
observe: function(aSubject, aTopic, aData) {
Services.obs.removeObserver(restoreCleanup, "sessionstore-windows-restored");
if (aData == "fail")
BrowserApp.addTab("about:home");
}
};
Services.obs.addObserver(restoreCleanup, "sessionstore-windows-restored", false);
}
// Start the restore
ss.restoreLastSession(restoreToFront);
} else {
this.addTab(url);
}
// notify java that gecko has loaded
sendMessageToJava({

View File

@ -965,7 +965,7 @@ SessionStore.prototype = {
for (let i=0; i<tabs.length; i++) {
let tabData = tabs[i];
let isSelected = i + 1 == selected;
let isSelected = (i + 1 <= selected) && aBringToFront;
let entry = tabData.entries[tabData.index - 1];
// Add a tab, but don't load the URL until we need to