Bug 75599; enabling the infamous '-turbo' cmd line switch; makes nsINativeAppSupport scriptable, adds Win32 code to handle -turbo switch; and tweaks window close logic in navigator.js to 'cache' a browser window; r=cathleen, sr=alecf

This commit is contained in:
law%netscape.com 2006-09-14 05:58:23 +00:00
Родитель 72cfa5dd0a
Коммит 07d52db8d0
3 изменённых файлов: 55 добавлений и 17 удалений

Просмотреть файл

@ -348,6 +348,58 @@ function Startup()
}
}
function BrowserFlushBookmarksAndHistory() {
// Flush bookmakrs and history (used when window closes or is cached).
try {
// If bookmarks are dirty, flush 'em to disk
var bmks = Components.classes["@mozilla.org/browser/bookmarks-service;1"]
.getService(Components.interfaces.nsIRDFRemoteDataSource);
bmks.Flush();
// give history a chance at flushing to disk also
var history = Components.classes["@mozilla.org/browser/global-history;1"]
.getService(Components.interfaces.nsIRDFRemoteDataSource);
history.Flush();
} catch(ex) {
}
}
function BrowserCanClose() {
// Check for "server mode."
try {
var appShellSvc = Components.classes["@mozilla.org/appshell/appShellService;1"]
.getService(Components.interfaces.nsIAppShellService);
var nativeSupport = appShellSvc.nativeAppSupport;
if (nativeSupport && nativeSupport.isServerMode) {
// Give native app a chance to cache this window.
if (nativeSupport.cacheBrowserWindow(window)) {
// Window is "cached" so don't close it.
// But flush bookmarks and history, as if we did close it.
BrowserFlushBookmarksAndHistory();
// Reset session history.
var webNav = getWebNavigation();
if (webNav) {
try {
webNav.sessionHistory.PurgeHistory( webNav.sessionHistory.count );
} catch(ex) {
}
}
// Go to blank page.
loadURI( "about:blank" );
// This stops the close.
return false;
}
}
} catch (ex) {
}
// Ok to close window.
return true;
}
function Shutdown()
{
var browser = getBrowser();
@ -364,21 +416,7 @@ function Shutdown()
window.XULBrowserWindow.destroy();
window.XULBrowserWindow = null;
try {
// If bookmarks are dirty, flush 'em to disk
var bmks = Components.classes["@mozilla.org/browser/bookmarks-service;1"]
.getService(Components.interfaces.nsIRDFRemoteDataSource);
bmks.Flush();
} catch (ex) {
}
try {
// give history a chance at flushing to disk also
var history = Components.classes["@mozilla.org/browser/global-history;1"]
.getService(Components.interfaces.nsIRDFRemoteDataSource);
history.Flush();
} catch (ex) {
}
BrowserFlushBookmarksAndHistory();
// unregister us as a pref listener
pref.removeObserver(window.buttonPrefListener.domain,

Просмотреть файл

@ -45,7 +45,7 @@ Contributor(s): ______________________________________. -->
<window id="main-window" xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="Startup()" onunload="Shutdown()"
onload="Startup()" onunload="Shutdown()" onclose="return BrowserCanClose()"
contenttitlesetting="true"
title="&mainWindow.title;"
titlemodifier="&mainWindow.titlemodifier;"

Просмотреть файл

@ -111,7 +111,7 @@
<command id="Browser:Open" oncommand="BrowserOpenWindow();"/>
<command id="Browser:Print" oncommand="BrowserPrint();"/>
<command id="cmd_quit"/>
<command id="cmd_close" oncommand="BrowserClose()"/>
<command id="cmd_close" oncommand="if(BrowserCanClose()){BrowserClose();}"/>
<!-- Edit Menu -->
<command id="cmd_undo"/>