mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 20:05:49 +00:00
bug 328159 - the one that should work, or I'm buying the build team drinks
This commit is contained in:
parent
1dc4b9a31e
commit
605be74d73
@ -60,6 +60,7 @@ DIRS = \
|
||||
migration \
|
||||
preferences \
|
||||
search \
|
||||
sessionstore \
|
||||
shell \
|
||||
sidebar \
|
||||
$(NULL)
|
||||
|
@ -101,6 +101,25 @@ BrowserGlue.prototype = {
|
||||
ww.openWindow(null, "chrome://browser/content/safeMode.xul",
|
||||
"_blank", "chrome,centerscreen,modal,resizable=no", null);
|
||||
}
|
||||
else {
|
||||
// initialize the session-restore service
|
||||
var ssEnabled = true;
|
||||
var prefBranch = Components.classes["@mozilla.org/preferences-service;1"].
|
||||
getService(Components.interfaces.nsIPrefBranch);
|
||||
try {
|
||||
ssEnabled = prefBranch.getBoolPref("browser.sessionstore.enabled");
|
||||
} catch (ex) {}
|
||||
|
||||
if (ssEnabled) {
|
||||
try {
|
||||
var ss = Components.classes["@mozilla.org/browser/sessionstore;1"].
|
||||
getService(Components.interfaces.nsISessionStore);
|
||||
ss.init();
|
||||
} catch(ex) {
|
||||
dump("nsSessionStore could not be initialized: " + ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// profile shutdown handler (contains profile cleanup routines)
|
||||
|
@ -110,6 +110,9 @@ const DEFAULT_RESUME_SESSION = false;
|
||||
// resume the current session at startup just this once
|
||||
const DEFAULT_RESUME_SESSION_ONCE = false;
|
||||
|
||||
// resume the current session at startup if it had previously crashed
|
||||
const DEFAULT_RESUME_FROM_CRASH = false;
|
||||
|
||||
// global notifications observed
|
||||
const OBSERVING = [
|
||||
"domwindowopened", "domwindowclosed",
|
||||
@ -149,7 +152,6 @@ function debug(aMsg) {
|
||||
|
||||
/* :::::::: The Service ::::::::::::::: */
|
||||
|
||||
//var SessionStoreService = {
|
||||
function SessionStoreService() {
|
||||
}
|
||||
|
||||
@ -234,14 +236,14 @@ SessionStoreService.prototype = {
|
||||
}, this);
|
||||
delete this._initialState.Window[0].hidden;
|
||||
}
|
||||
catch (ex) { debug(ex); } // invalid .INI file - nothing can be restored
|
||||
catch (ex) { "The session file is invalid: " + debug(ex); } // invalid .INI file - nothing can be restored
|
||||
}
|
||||
|
||||
// if last session crashed, backup the session
|
||||
// and try to restore the disk cache
|
||||
if (this._lastSessionCrashed) {
|
||||
try {
|
||||
this._writeFile(this._getSessionFile(true), aState, true);
|
||||
this._writeFile(this._getSessionFile(true), iniString);
|
||||
}
|
||||
catch (ex) { } // nothing else we can do here
|
||||
try {
|
||||
@ -1670,7 +1672,7 @@ SessionStoreService.prototype = {
|
||||
"state=" + (this._loadState == STATE_RUNNING ? STATE_RUNNING_STR : STATE_STOPPED_STR),
|
||||
this._getCurrentState(),
|
||||
""
|
||||
].join("\n").replace(/\n\[/g, "\n$&"), aUpdateAll);
|
||||
].join("\n").replace(/\n\[/g, "\n$&"));
|
||||
this._lastSaveTime = Date.now();
|
||||
},
|
||||
|
||||
@ -1769,6 +1771,10 @@ SessionStoreService.prototype = {
|
||||
* @returns bool
|
||||
*/
|
||||
_doRecoverSession: function sss_doRecoverSession() {
|
||||
// do not prompt or resume, post-crash
|
||||
if (!this._getPref("sessionstore.resume_from_crash", DEFAULT_RESUME_FROM_CRASH))
|
||||
return false;
|
||||
|
||||
// if the prompt fails, recover anyway
|
||||
var recover = true;
|
||||
// allow extensions to hook in a more elaborate restore prompt
|
||||
@ -1991,27 +1997,12 @@ SessionStoreService.prototype = {
|
||||
* nsIFile
|
||||
* @param aData
|
||||
* String data
|
||||
* @param aThisThread
|
||||
* bool Write in current thread
|
||||
*/
|
||||
_writeFile: function sss_writeFile(aFile, aData, aThisThread) {
|
||||
_writeFile: function sss_writeFile(aFile, aData) {
|
||||
// save the file in the current thread
|
||||
// (making sure we don't get killed at shutdown)
|
||||
if (aThisThread) {
|
||||
(new FileWriter(aFile, aData)).run();
|
||||
return;
|
||||
}
|
||||
|
||||
// save file in new thread
|
||||
var nsIThread = Ci.nsIThread;
|
||||
var thread = Cc["@mozilla.org/thread;1"].createInstance(Ci.nsIThread);
|
||||
thread.init(
|
||||
new FileWriter(aFile, aData),
|
||||
128 * 1024,
|
||||
nsIThread.PRIORITY_NORMAL,
|
||||
nsIThread.SCOPE_GLOBAL,
|
||||
nsIThread.STATE_UNJOINABLE
|
||||
);
|
||||
(new FileWriter(aFile, aData)).run();
|
||||
return;
|
||||
},
|
||||
|
||||
/* ........ QueryInterface .............. */
|
||||
@ -2268,7 +2259,6 @@ const SessionStoreFactory = {
|
||||
return null;
|
||||
}
|
||||
|
||||
//return SessionStoreService.QueryInterface(aIID);
|
||||
return (new SessionStoreService()).QueryInterface(aIID);
|
||||
},
|
||||
|
||||
|
@ -23,6 +23,7 @@
|
||||
locale/browser/engineManager.dtd (%chrome/browser/engineManager.dtd)
|
||||
locale/browser/setDesktopBackground.dtd (%chrome/browser/setDesktopBackground.dtd)
|
||||
locale/browser/shellservice.properties (%chrome/browser/shellservice.properties)
|
||||
locale/browser/sessionstore.properties (%chrome/browser/sessionstore.properties)
|
||||
#ifdef MOZ_PLACES
|
||||
locale/browser/places/places.dtd (%chrome/browser/places/places.dtd)
|
||||
locale/browser/places/bookmarkProperties.dtd (%chrome/browser/places/bookmarkProperties.dtd)
|
||||
|
Loading…
Reference in New Issue
Block a user