Mozilla/mozilla/suite/browser/viewsource.js
disttsc%bart.nl 824c4f4a32 Let's try this again. No changes since the last time, it looks like I was bitten by something else that was checked in and I just happened to trigger the bug. It all seems to work fine now, so:
More appCore killing. bug=46200, r=ben, a=alecf.


git-svn-id: svn://10.0.0.236/trunk@210657 18797224-902f-48f8-a5cc-f745e15eee43
2006-09-14 05:55:53 +00:00

69 lines
1.4 KiB
JavaScript

var appCore = null;
function onLoadViewSource()
{
viewSource(window.arguments[0]);
}
function viewSource(url)
{
if (!url)
return false; // throw Components.results.NS_ERROR_FAILURE;
try {
appCore = Components.classes["@mozilla.org/appshell/component/browser/instance;1"]
.createInstance(Components.interfaces.nsIBrowserInstance);
// Initialize browser instance..
appCore.setWebShellWindow(window);
} catch(ex) {
// Give up.
window.close();
return false;
}
var docShellElement = document.getElementById("content");
docShellElement.docShell.viewMode = Components.interfaces.nsIDocShell.viewSource;
try {
if ("arguments" in window && window.arguments.length >= 2) {
if (window.arguments[1].indexOf('charset=') != -1) {
var arrayArgComponents = window.arguments[1].split('=');
if (arrayArgComponents) {
docShellElement.markupDocumentViewer.defaultCharacterSet = arrayArgComponents[1];
}
}
}
} catch(ex) {
}
var loadFlags = Components.interfaces.nsIWebNavigation.LOAD_FLAGS_NONE;
docShellElement.webNavigation.loadURI(url, loadFlags);
return true;
}
function BrowserClose()
{
window.close();
}
function getMarkupDocumentViewer()
{
return document.getElementById("content").markupDocumentViewer;
}
function BrowserFind()
{
if (appCore)
appCore.find();
}
function BrowserFindAgain()
{
if (appCore)
appCore.findNext();
}