зеркало из https://github.com/mozilla/pjs.git
Bug 342471 [sessionstore] urlbar of first tab focused after restoring a session if homepage is about:blank (for zeniko, r=dietrich)
This commit is contained in:
Родитель
7859732cad
Коммит
6d08b3b211
|
@ -1101,24 +1101,14 @@ function delayedStartup()
|
|||
// to create its singleton, whose constructor initializes the service.
|
||||
Cc["@mozilla.org/microsummary/service;1"].getService(Ci.nsIMicrosummaryService);
|
||||
|
||||
// initialize the session-restore service
|
||||
var ssEnabled = true;
|
||||
var prefBranch = Cc["@mozilla.org/preferences-service;1"].
|
||||
getService(Ci.nsIPrefBranch);
|
||||
try {
|
||||
ssEnabled = prefBranch.getBoolPref("browser.sessionstore.enabled");
|
||||
} catch (ex) {}
|
||||
|
||||
if (ssEnabled) {
|
||||
var wType = window.document.documentElement.getAttribute("windowtype");
|
||||
if (wType == "navigator:browser") {
|
||||
try {
|
||||
var ss = Cc["@mozilla.org/browser/sessionstore;1"].
|
||||
getService(Ci.nsISessionStore);
|
||||
ss.init(window);
|
||||
} catch(ex) {
|
||||
dump("nsSessionStore could not be initialized: " + ex + "\n");
|
||||
}
|
||||
// initialize the session-restore service (in case it's not already running)
|
||||
if (document.documentElement.getAttribute("windowtype") == "navigator:browser") {
|
||||
try {
|
||||
var ss = Cc["@mozilla.org/browser/sessionstore;1"].
|
||||
getService(Ci.nsISessionStore);
|
||||
ss.init(window);
|
||||
} catch(ex) {
|
||||
dump("nsSessionStore could not be initialized: " + ex + "\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -121,9 +121,6 @@ SessionStartup.prototype = {
|
|||
if (!this._getPref("sessionstore.enabled", DEFAULT_ENABLED))
|
||||
return;
|
||||
|
||||
var observerService = Cc["@mozilla.org/observer-service;1"].
|
||||
getService(Ci.nsIObserverService);
|
||||
|
||||
// get file references
|
||||
var dirService = Cc["@mozilla.org/file/directory_service;1"].
|
||||
getService(Ci.nsIProperties);
|
||||
|
@ -166,6 +163,13 @@ SessionStartup.prototype = {
|
|||
if (this._getPref("sessionstore.resume_session_once", DEFAULT_RESUME_SESSION_ONCE)) {
|
||||
this._prefBranch.setBoolPref("sessionstore.resume_session_once", false);
|
||||
}
|
||||
|
||||
if (this.doRestore()) {
|
||||
// wait for the first browser window to open
|
||||
var observerService = Cc["@mozilla.org/observer-service;1"].
|
||||
getService(Ci.nsIObserverService);
|
||||
observerService.addObserver(this, "domwindowopened", true);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -186,9 +190,37 @@ SessionStartup.prototype = {
|
|||
observerService.removeObserver(this, "final-ui-startup");
|
||||
this.init();
|
||||
break;
|
||||
case "domwindowopened":
|
||||
var window = aSubject;
|
||||
var self = this;
|
||||
window.addEventListener("load", function() {
|
||||
self._onWindowOpened(window);
|
||||
window.removeEventListener("load", arguments.callee, false);
|
||||
}, false);
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes the default arguments from the first browser window
|
||||
* (and removes the "domwindowopened" observer afterwards)
|
||||
*/
|
||||
_onWindowOpened: function sss_onWindowOpened(aWindow) {
|
||||
var wType = aWindow.document.documentElement.getAttribute("windowtype");
|
||||
if (wType != "navigator:browser")
|
||||
return;
|
||||
|
||||
var defaultArgs = Cc["@mozilla.org/browser/clh;1"].
|
||||
getService(Ci.nsIBrowserHandler).defaultArgs;
|
||||
if (aWindow.arguments && aWindow.arguments[0] &&
|
||||
aWindow.arguments[0] == defaultArgs)
|
||||
aWindow.arguments[0] = null;
|
||||
|
||||
var observerService = Cc["@mozilla.org/observer-service;1"].
|
||||
getService(Ci.nsIObserverService);
|
||||
observerService.removeObserver(this, "domwindowopened");
|
||||
},
|
||||
|
||||
/* ........ Public API ................*/
|
||||
|
||||
/**
|
||||
|
|
|
@ -172,10 +172,7 @@ SessionStoreService.prototype = {
|
|||
* Initialize the component
|
||||
*/
|
||||
init: function sss_init(aWindow) {
|
||||
if (!aWindow || aWindow == null)
|
||||
return;
|
||||
|
||||
if (this._loadState == STATE_RUNNING)
|
||||
if (!aWindow || this._loadState == STATE_RUNNING)
|
||||
return;
|
||||
|
||||
this._prefBranch = Cc["@mozilla.org/preferences-service;1"].
|
||||
|
@ -246,10 +243,7 @@ SessionStoreService.prototype = {
|
|||
}
|
||||
|
||||
// As this is called at delayedStartup, restoration must be initiated here
|
||||
var windowLoad = function(self) {
|
||||
self.onLoad(this);
|
||||
}
|
||||
aWindow.setTimeout(windowLoad, 0, this);
|
||||
this.onLoad(aWindow);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -274,9 +268,6 @@ SessionStoreService.prototype = {
|
|||
* Handle notifications
|
||||
*/
|
||||
observe: function sss_observe(aSubject, aTopic, aData) {
|
||||
var observerService = Cc["@mozilla.org/observer-service;1"].
|
||||
getService(Ci.nsIObserverService);
|
||||
|
||||
// for event listeners
|
||||
var _this = this;
|
||||
|
||||
|
@ -1822,38 +1813,13 @@ SessionStoreService.prototype = {
|
|||
* @returns bool
|
||||
*/
|
||||
_isCmdLineEmpty: function sss_isCmdLineEmpty(aWindow) {
|
||||
if (!aWindow.arguments) {
|
||||
return true;
|
||||
}
|
||||
|
||||
var homepage = null;
|
||||
switch (this._getPref("startup.page", 1)) {
|
||||
case 0:
|
||||
case 3:
|
||||
homepage = "about:blank";
|
||||
break;
|
||||
case 1:
|
||||
try {
|
||||
homepage = this._prefBranch.getComplexValue("startup.homepage", Ci.nsIPrefLocalizedString).data;
|
||||
}
|
||||
catch (ex) {
|
||||
homepage = this._getPref("startup.homepage", "");
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
homepage = Cc["@mozilla.org/browser/global-history;2"].
|
||||
getService(Ci.nsIBrowserHistory).lastPageVisited;
|
||||
break;
|
||||
}
|
||||
|
||||
for (var i = 0; i < aWindow.arguments.length; i++) {
|
||||
var url = aWindow.arguments[i].split("\n")[0];
|
||||
if (!url || url == homepage) {
|
||||
aWindow.arguments.splice(i--, 1);
|
||||
}
|
||||
}
|
||||
|
||||
return (aWindow.arguments.length == 0);
|
||||
var defaultArgs = Cc["@mozilla.org/browser/clh;1"].
|
||||
getService(Ci.nsIBrowserHandler).defaultArgs;
|
||||
if (aWindow.arguments && aWindow.arguments[0] &&
|
||||
aWindow.arguments[0] == defaultArgs)
|
||||
aWindow.arguments[0] = null;
|
||||
|
||||
return !aWindow.arguments || !aWindow.arguments[0];
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
Загрузка…
Ссылка в новой задаче