Move browser's nsIWebProgressListener implementation into js. More work for bug 46200, r=ben, r=adamlock, sr=alecf.
git-svn-id: svn://10.0.0.236/trunk@92303 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
60a697e6c7
commit
5b3736f0b7
@ -22,8 +22,6 @@
|
||||
|
||||
const nsIWebNavigation = Components.interfaces.nsIWebNavigation;
|
||||
|
||||
var appCore = null;
|
||||
var locationFld = null;
|
||||
var commandHandler = null;
|
||||
var gURLBar = null;
|
||||
|
||||
@ -53,77 +51,73 @@ nsCommandHandler.prototype =
|
||||
|
||||
//
|
||||
|
||||
function nsXULBrowserWindow()
|
||||
function nsBrowserStatusHandler()
|
||||
{
|
||||
this.init();
|
||||
}
|
||||
|
||||
nsXULBrowserWindow.prototype =
|
||||
nsBrowserStatusHandler.prototype =
|
||||
{
|
||||
QueryInterface : function(iid)
|
||||
{
|
||||
if(iid.equals(Components.interfaces.nsIXULBrowserWindow))
|
||||
QueryInterface : function(aIID)
|
||||
{
|
||||
if (aIID.equals(Components.interfaces.nsIWebProgressListener) ||
|
||||
aIID.equals(Components.interfaces.nsISupportsWeakReference))
|
||||
return this;
|
||||
throw Components.results.NS_NOINTERFACE;
|
||||
},
|
||||
setJSStatus : function(status)
|
||||
{
|
||||
},
|
||||
setJSDefaultStatus : function(status)
|
||||
{
|
||||
},
|
||||
setDefaultStatus : function(status)
|
||||
{
|
||||
},
|
||||
setOverLink : function(link)
|
||||
{
|
||||
},
|
||||
onProgress : function (channel, current, max)
|
||||
{
|
||||
},
|
||||
onStateChange : function (progress, request, state, status)
|
||||
{
|
||||
},
|
||||
onStatus : function(url, message)
|
||||
{
|
||||
},
|
||||
onLocationChange : function(location)
|
||||
{
|
||||
if(!locationFld)
|
||||
locationFld = document.getElementById("urlbar");
|
||||
},
|
||||
|
||||
// We should probably not do this if the value has changed since the user
|
||||
// searched
|
||||
locationFld.setAttribute("value", location);
|
||||
}
|
||||
init : function()
|
||||
{
|
||||
this.urlBar = document.getElementById("urlbar");
|
||||
},
|
||||
|
||||
destroy : function()
|
||||
{
|
||||
this.urlBar = null;
|
||||
},
|
||||
|
||||
onStateChange : function(aWebProgress, aRequest, aStateFlags, aStatus)
|
||||
{
|
||||
},
|
||||
|
||||
onProgressChange : function(aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress)
|
||||
{
|
||||
},
|
||||
|
||||
onLocationChange : function(aWebProgress, aRequest, aLocation)
|
||||
{
|
||||
this.urlBar.value = aLocation.spec;
|
||||
},
|
||||
|
||||
onStatusChange : function(aWebProgress, aRequest, aStatus, aMessage)
|
||||
{
|
||||
},
|
||||
|
||||
onSecurityChange : function(aWebProgress, aRequest, aState)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var gBrowserStatusHandler;
|
||||
function MiniNavStartup()
|
||||
{
|
||||
dump("*** MiniNavStartup\n");
|
||||
window.XULBrowserWindow = new nsXULBrowserWindow();
|
||||
|
||||
var succeeded = false;
|
||||
var webNavigation = getWebNavigation();
|
||||
try {
|
||||
// Create the browser instance component.
|
||||
appCore = Components.classes["@mozilla.org/appshell/component/browser/instance;1"]
|
||||
.createInstance(Components.interfaces.nsIBrowserInstance);
|
||||
|
||||
gBrowserStatusHandler = new nsBrowserStatusHandler();
|
||||
var webNavigation = getWebNavigation();
|
||||
webNavigation.sessionHistory = Components.classes["@mozilla.org/browser/shistory;1"]
|
||||
.createInstance(Components.interfaces.nsISHistory);
|
||||
succeeded = true;
|
||||
} catch (e) {
|
||||
}
|
||||
|
||||
if (!succeeded) {
|
||||
// Give up.
|
||||
dump("Error creating browser instance\n");
|
||||
var interfaceRequestor = getBrowser().docShell.QueryInterface(Components.interfaces.nsIInterfaceRequestor);
|
||||
var webProgress = interfaceRequestor.getInterface(Components.interfaces.nsIWebProgress);
|
||||
webProgress.addProgressListener(gBrowserStatusHandler);
|
||||
} catch (e) {
|
||||
alert("Error opening a mini-nav window");
|
||||
dump(e+"\n");
|
||||
window.close();
|
||||
return;
|
||||
}
|
||||
// Initialize browser instance..
|
||||
appCore.setWebShellWindow(window);
|
||||
_content.appCore = appCore;
|
||||
|
||||
// create the embedding command handler
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
@ -142,9 +136,8 @@ function MiniNavStartup()
|
||||
function MiniNavShutdown()
|
||||
{
|
||||
dump("*** MiniNavShutdown\n");
|
||||
// Close the app core.
|
||||
if ( appCore )
|
||||
appCore.close();
|
||||
if (gBrowserStatusHandler)
|
||||
gBrowserStatusHandler.destroy();
|
||||
}
|
||||
|
||||
function getBrowser()
|
||||
|
||||
@ -55,7 +55,7 @@ Contributor(s): ______________________________________. -->
|
||||
|
||||
<!-- The following DEBUG MENU ITEMS can be removed -->
|
||||
<menuseparator/>
|
||||
<menu value="Debug">
|
||||
<menu label="Debug">
|
||||
<menupopup>
|
||||
<menuitem id="command-handler" label="CommandHandler::Exec" oncommand="CHExecTest()"/>
|
||||
<menuitem id="command-handler" label="CommandHandler::Query" oncommand="CHQueryTest()"/>
|
||||
@ -93,7 +93,7 @@ Contributor(s): ______________________________________. -->
|
||||
<!-- type attribute is used by frame construction to locate iframes
|
||||
intended to hold (html) content -->
|
||||
<browser context="context" type="content-primary" id="content"
|
||||
src="about:blank" flex="1"/>
|
||||
src="about:blank" flex="1"/>
|
||||
</box>
|
||||
</box>
|
||||
</box>
|
||||
|
||||
@ -253,33 +253,16 @@ nsMsgStatusFeedback.prototype =
|
||||
setJSDefaultStatus : function(status)
|
||||
{
|
||||
},
|
||||
setDefaultStatus : function(status)
|
||||
{
|
||||
},
|
||||
setOverLink : function(link)
|
||||
{
|
||||
this.showStatusString(link);
|
||||
},
|
||||
onProgress : function (channel, current, max)
|
||||
{
|
||||
},
|
||||
onStateChange : function (progress, request, state, status)
|
||||
{
|
||||
},
|
||||
onStatus : function(channel, url, message)
|
||||
{
|
||||
},
|
||||
onLocationChange : function(location)
|
||||
{
|
||||
},
|
||||
QueryInterface : function(iid)
|
||||
{
|
||||
if(iid.equals(Components.interfaces.nsIMsgStatusFeedback))
|
||||
return this;
|
||||
if(iid.equals(Components.interfaces.nsIXULBrowserWindow))
|
||||
return this;
|
||||
throw Components.results.NS_NOINTERFACE;
|
||||
return null;
|
||||
{
|
||||
if (iid.equals(Components.interfaces.nsIMsgStatusFeedback) ||
|
||||
iid.equals(Components.interfaces.nsIXULBrowserWindow))
|
||||
return this;
|
||||
throw Components.results.NS_NOINTERFACE;
|
||||
},
|
||||
|
||||
// nsIMsgStatusFeedback implementation.
|
||||
|
||||
@ -47,32 +47,5 @@ interface nsIXULBrowserWindow : nsISupports
|
||||
Tells the object implementing this function what link we are currently over.
|
||||
*/
|
||||
void setOverLink(in wstring link);
|
||||
|
||||
/*
|
||||
Tells the browser window what to use for the default status text.
|
||||
*/
|
||||
void setDefaultStatus(in wstring status);
|
||||
|
||||
/*
|
||||
Tells the browser window that there is a state change with the window.
|
||||
These state flags are specified in nsIWebProgress.
|
||||
*/
|
||||
void onStateChange(in nsIRequest aRequest, in unsigned long aProgressStateFlags);
|
||||
|
||||
/*
|
||||
Tells the browser window that the location of the window has changed.
|
||||
*/
|
||||
void onLocationChange(in wstring location);
|
||||
|
||||
/*
|
||||
Tells the browser window that the progress for the current load has changed.
|
||||
*/
|
||||
void onProgress (in nsIRequest aRequest, in long aCurrentProgress, in long aMaxProgress);
|
||||
|
||||
/*
|
||||
Tells the browser window that a new status message is available.
|
||||
*/
|
||||
void onStatus(in nsIRequest aRequest, in nsresult aStatus, in wstring aMsg);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -11,6 +11,7 @@ comm.jar:
|
||||
content/navigator/navExtraOverlay.xul (resources/content/navExtraOverlay.xul)
|
||||
content/navigator/navigator.js (resources/content/navigator.js)
|
||||
content/navigator/navigatorDD.js (resources/content/navigatorDD.js)
|
||||
content/navigator/nsBrowserStatusHandler.js (resources/content/nsBrowserStatusHandler.js)
|
||||
content/navigator/tooltip.js (resources/content/tooltip.js)
|
||||
content/navigator/metadata.xul (resources/content/metadata.xul)
|
||||
content/navigator/metadata.js (resources/content/metadata.js)
|
||||
|
||||
@ -47,32 +47,5 @@ interface nsIXULBrowserWindow : nsISupports
|
||||
Tells the object implementing this function what link we are currently over.
|
||||
*/
|
||||
void setOverLink(in wstring link);
|
||||
|
||||
/*
|
||||
Tells the browser window what to use for the default status text.
|
||||
*/
|
||||
void setDefaultStatus(in wstring status);
|
||||
|
||||
/*
|
||||
Tells the browser window that there is a state change with the window.
|
||||
These state flags are specified in nsIWebProgress.
|
||||
*/
|
||||
void onStateChange(in nsIRequest aRequest, in unsigned long aProgressStateFlags);
|
||||
|
||||
/*
|
||||
Tells the browser window that the location of the window has changed.
|
||||
*/
|
||||
void onLocationChange(in wstring location);
|
||||
|
||||
/*
|
||||
Tells the browser window that the progress for the current load has changed.
|
||||
*/
|
||||
void onProgress (in nsIRequest aRequest, in long aCurrentProgress, in long aMaxProgress);
|
||||
|
||||
/*
|
||||
Tells the browser window that a new status message is available.
|
||||
*/
|
||||
void onStatus(in nsIRequest aRequest, in nsresult aStatus, in wstring aMsg);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -35,14 +35,8 @@ var pref = Components.classes["@mozilla.org/preferences;1"]
|
||||
|
||||
var appCore = null;
|
||||
|
||||
//cached elements/fields
|
||||
//cached elements
|
||||
var gBrowser = null;
|
||||
var statusTextFld = null;
|
||||
var statusMeter = null;
|
||||
var throbberElement = null;
|
||||
var stopButton = null;
|
||||
var stopMenu = null;
|
||||
var stopContext = null;
|
||||
|
||||
// focused frame URL
|
||||
var gFocusedURL = null;
|
||||
@ -130,217 +124,6 @@ function UpdateInternetSearchResults(event)
|
||||
}
|
||||
}
|
||||
|
||||
function nsXULBrowserWindow()
|
||||
{
|
||||
this.defaultStatus = gNavigatorBundle.getString("defaultStatus");
|
||||
}
|
||||
|
||||
nsXULBrowserWindow.prototype =
|
||||
{
|
||||
useRealProgressFlag : false,
|
||||
totalRequests : 0,
|
||||
finishedRequests : 0,
|
||||
|
||||
// Stored Status, Link and Loading values
|
||||
status : "",
|
||||
defaultStatus : "",
|
||||
jsStatus : "",
|
||||
jsDefaultStatus : "",
|
||||
overLink : "",
|
||||
startTime : 0,
|
||||
|
||||
statusTimeoutInEffect : false,
|
||||
|
||||
hideAboutBlank : true,
|
||||
|
||||
QueryInterface : function(iid)
|
||||
{
|
||||
if (iid.equals(Components.interfaces.nsIXULBrowserWindow))
|
||||
return this;
|
||||
throw Components.results.NS_NOINTERFACE;
|
||||
},
|
||||
|
||||
setJSStatus : function(status)
|
||||
{
|
||||
this.jsStatus = status;
|
||||
this.updateStatusField();
|
||||
// set empty so defaults show up next change
|
||||
this.jsStatus = "";
|
||||
},
|
||||
|
||||
setJSDefaultStatus : function(status)
|
||||
{
|
||||
this.jsDefaultStatus = status;
|
||||
this.updateStatusField();
|
||||
},
|
||||
|
||||
setDefaultStatus : function(status)
|
||||
{
|
||||
this.defaultStatus = status;
|
||||
this.updateStatusField();
|
||||
},
|
||||
|
||||
setOverLink : function(link, b)
|
||||
{
|
||||
this.overLink = link;
|
||||
this.updateStatusField();
|
||||
// set empty so defaults show up next change
|
||||
this.overLink = "";
|
||||
},
|
||||
|
||||
updateStatusField : function()
|
||||
{
|
||||
var text = this.overLink || this.status || this.jsStatus || this.jsDefaultStatus || this.defaultStatus;
|
||||
|
||||
if (!statusTextFld)
|
||||
statusTextFld = document.getElementById("statusbar-display");
|
||||
|
||||
// check the current value so we don't trigger an attribute change
|
||||
// and cause needless (slow!) UI updates
|
||||
if (statusTextFld.label != text) {
|
||||
statusTextFld.label = text;
|
||||
}
|
||||
},
|
||||
|
||||
onProgress : function (request, current, max)
|
||||
{
|
||||
if (!this.useRealProgressFlag && request)
|
||||
return;
|
||||
|
||||
if (!statusMeter)
|
||||
statusMeter = document.getElementById("statusbar-icon");
|
||||
|
||||
if (max > 0) {
|
||||
statusMeter.mode = "normal";
|
||||
|
||||
// This is highly optimized. Don't touch this code unless
|
||||
// you are intimately familiar with the cost of setting
|
||||
// attrs on XUL elements. -- hyatt
|
||||
var percentage = (current * 100) / max ;
|
||||
statusMeter.value = percentage;
|
||||
} else {
|
||||
statusMeter.mode = "undetermined";
|
||||
}
|
||||
},
|
||||
|
||||
onStateChange : function(request, state)
|
||||
{
|
||||
const nsIWebProgressListener = Components.interfaces.nsIWebProgressListener;
|
||||
|
||||
if (!throbberElement)
|
||||
throbberElement = document.getElementById("navigator-throbber");
|
||||
if (!statusMeter)
|
||||
statusMeter = document.getElementById("statusbar-icon");
|
||||
if (!stopButton)
|
||||
stopButton = document.getElementById("stop-button");
|
||||
if (!stopMenu)
|
||||
stopMenu = document.getElementById("menuitem-stop");
|
||||
if (!stopContext)
|
||||
stopContext = document.getElementById("context-stop");
|
||||
|
||||
if (state & nsIWebProgressListener.STATE_START) {
|
||||
if (state & nsIWebProgressListener.STATE_IS_NETWORK) {
|
||||
// Remember when loading commenced.
|
||||
this.startTime = (new Date()).getTime();
|
||||
|
||||
// Turn progress meter on.
|
||||
statusMeter.mode = "undetermined";
|
||||
throbberElement.setAttribute("busy", true);
|
||||
|
||||
// XXX: These need to be based on window activity...
|
||||
stopButton.setAttribute("disabled", false);
|
||||
stopMenu.setAttribute("disabled", false);
|
||||
stopContext.setAttribute("disabled", false);
|
||||
|
||||
// Initialize the progress stuff...
|
||||
this.useRealProgressFlag = false;
|
||||
this.totalRequests = 0;
|
||||
this.finishedRequests = 0;
|
||||
}
|
||||
|
||||
if (state & nsIWebProgressListener.STATE_IS_REQUEST) {
|
||||
this.totalRequests += 1;
|
||||
}
|
||||
}
|
||||
else if (state & nsIWebProgressListener.STATE_STOP) {
|
||||
if (state & nsIWebProgressListener.STATE_IS_REQUEST) {
|
||||
this.finishedRequests += 1;
|
||||
if (!this.useRealProgressFlag)
|
||||
this.onProgress(null, this.finishedRequests, this.totalRequests);
|
||||
}
|
||||
if (state & nsIWebProgressListener.STATE_IS_NETWORK) {
|
||||
var channel = request.QueryInterface(Components.interfaces.nsIChannel);
|
||||
var location = channel.URI.spec;
|
||||
var msg = "";
|
||||
if (location != "about:blank") {
|
||||
// Record page loading time.
|
||||
var elapsed = ((new Date()).getTime() - this.startTime) / 1000;
|
||||
msg = gNavigatorBundle.getString("nv_done");
|
||||
msg = msg.replace(/%elapsed%/, elapsed);
|
||||
}
|
||||
this.status = "";
|
||||
this.setDefaultStatus(msg);
|
||||
|
||||
// Turn progress meter off.
|
||||
statusMeter.mode = "normal";
|
||||
statusMeter.value = 0; // be sure to clear the progress bar
|
||||
throbberElement.removeAttribute("busy");
|
||||
|
||||
// XXX: These need to be based on window activity...
|
||||
stopButton.setAttribute("disabled", true);
|
||||
stopMenu.setAttribute("disabled", true);
|
||||
stopContext.setAttribute("disabled", true);
|
||||
}
|
||||
}
|
||||
else if (state & nsIWebProgressListener.STATE_TRANSFERRING) {
|
||||
if (state & nsIWebProgressListener.STATE_IS_DOCUMENT) {
|
||||
var channel = request.QueryInterface(Components.interfaces.nsIChannel);
|
||||
var ctype=channel.contentType;
|
||||
|
||||
if (ctype != "text/html")
|
||||
this.useRealProgressFlag = true;
|
||||
|
||||
statusMeter.mode = "normal";
|
||||
}
|
||||
|
||||
if (state & nsIWebProgressListener.STATE_IS_REQUEST) {
|
||||
if (!this.useRealProgressFlag)
|
||||
this.onProgress(null, this.finishedRequests, this.totalRequests);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
onLocationChange : function(location)
|
||||
{
|
||||
if (this.hideAboutBlank) {
|
||||
this.hideAboutBlank = false;
|
||||
if (location == "about:blank")
|
||||
location = "";
|
||||
}
|
||||
|
||||
// We should probably not do this if the value has changed since the user
|
||||
// searched
|
||||
gURLBar.value = location;
|
||||
|
||||
UpdateBackForwardButtons();
|
||||
},
|
||||
|
||||
onStatus : function(request, status, msg)
|
||||
{
|
||||
if (!this.statusTimeoutInEffect) {
|
||||
this.statusTimeoutInEffect = true;
|
||||
this.status = msg;
|
||||
this.updateStatusField();
|
||||
setTimeout(updateStatus, 400);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function updateStatus()
|
||||
{
|
||||
window.XULBrowserWindow.statusTimeoutInEffect = false;
|
||||
}
|
||||
|
||||
function getBrowser()
|
||||
{
|
||||
if (!gBrowser)
|
||||
@ -463,7 +246,7 @@ function Startup()
|
||||
}
|
||||
|
||||
// initialize observers and listeners
|
||||
window.XULBrowserWindow = new nsXULBrowserWindow();
|
||||
window.XULBrowserWindow = new nsBrowserStatusHandler();
|
||||
window.buttonPrefListener = new nsButtonPrefListener();
|
||||
|
||||
// XXXjag hack for directory.xul/js
|
||||
@ -499,7 +282,7 @@ function Startup()
|
||||
// hook up UI through progress listener
|
||||
var interfaceRequestor = getBrowser().docShell.QueryInterface(Components.interfaces.nsIInterfaceRequestor);
|
||||
var webProgress = interfaceRequestor.getInterface(Components.interfaces.nsIWebProgress);
|
||||
webProgress.addProgressListener(appCore);
|
||||
webProgress.addProgressListener(window.XULBrowserWindow);
|
||||
|
||||
// XXXjag see bug 68662
|
||||
getBrowser().boxObject.setPropertyAsSupports("listenerkungfu", appCore);
|
||||
@ -558,10 +341,13 @@ function Shutdown()
|
||||
try {
|
||||
var interfaceRequestor = browser.docShell.QueryInterface(Components.interfaces.nsIInterfaceRequestor);
|
||||
var webProgress = interfaceRequestor.getInterface(Components.interfaces.nsIWebProgress);
|
||||
webProgress.removeProgressListener(appCore);
|
||||
webProgress.removeProgressListener(window.XULBrowserWindow);
|
||||
} catch (ex) {
|
||||
}
|
||||
|
||||
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"]
|
||||
|
||||
@ -64,6 +64,7 @@ Contributor(s): ______________________________________. -->
|
||||
<script type="application/x-javascript" src="chrome://communicator/content/contentAreaDD.js"/>
|
||||
<script type="application/x-javascript" src="chrome://communicator/content/bookmarks/bookmarksOverlay.js"/>
|
||||
<script type="application/x-javascript" src="chrome://navigator/content/navigator.js"/>
|
||||
<script type="application/x-javascript" src="chrome://navigator/content/nsBrowserStatusHandler.js"/>
|
||||
<script type="application/x-javascript" src="tooltip.js"/>
|
||||
<script type="application/x-javascript" src="navigatorDD.js"/>
|
||||
<!-- UI services -->
|
||||
@ -145,12 +146,12 @@ Contributor(s): ______________________________________. -->
|
||||
<hbox id="nav-bar-inner" flex="1">
|
||||
<hbox id="urlbar-group" class="box-toolbar-group chromeclass-location" flex="1">
|
||||
<hbox autostretch="never" valign="middle" flex="1" id="urlbar-container">
|
||||
<image id="page-proxy-button" ondraggesture="nsDragAndDrop.startDrag(event, proxyIconDNDObserver);"/>
|
||||
<textbox autocomplete="true" timeout="300" class="plain"
|
||||
searchSessionType="urlbar" id="urlbar" tooltip="aTooltip" tooltiptext="&locationBar.tooltip;"
|
||||
<image id="page-proxy-button" ondraggesture="nsDragAndDrop.startDrag(event, proxyIconDNDObserver);"/>
|
||||
<textbox autocomplete="true" timeout="300" class="plain"
|
||||
searchSessionType="urlbar" id="urlbar" tooltip="aTooltip" tooltiptext="&locationBar.tooltip;"
|
||||
onclick="if (event.button == 0) URLBarLeftClickHandler(event);"
|
||||
onblur="URLBarBlurHandler(event);"
|
||||
onkeypress="if( event.keyCode == 13 ) { addToUrlbarHistory(); BrowserLoadURL(); }" flex="1"/>
|
||||
onkeypress="if (event.keyCode == 13) { addToUrlbarHistory(); BrowserLoadURL(); }" flex="1"/>
|
||||
</hbox>
|
||||
<menubutton class="menubutton-icon" id="ubhist">
|
||||
<menupopup id="ubhist-popup" popupalign="topright" popupanchor="bottomright"
|
||||
|
||||
296
mozilla/xpfe/browser/resources/content/nsBrowserStatusHandler.js
Normal file
296
mozilla/xpfe/browser/resources/content/nsBrowserStatusHandler.js
Normal file
@ -0,0 +1,296 @@
|
||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Blake Ross <blakeross@telocity.com>
|
||||
* Peter Annema <disttsc@bart.nl>
|
||||
*/
|
||||
|
||||
function nsBrowserStatusHandler()
|
||||
{
|
||||
this.init();
|
||||
}
|
||||
|
||||
nsBrowserStatusHandler.prototype =
|
||||
{
|
||||
useRealProgressFlag : false,
|
||||
totalRequests : 0,
|
||||
finishedRequests : 0,
|
||||
|
||||
// Stored Status, Link and Loading values
|
||||
status : "",
|
||||
defaultStatus : "",
|
||||
jsStatus : "",
|
||||
jsDefaultStatus : "",
|
||||
overLink : "",
|
||||
startTime : 0,
|
||||
|
||||
statusTimeoutInEffect : false,
|
||||
|
||||
hideAboutBlank : true,
|
||||
|
||||
QueryInterface : function(aIID)
|
||||
{
|
||||
if (aIID.equals(Components.interfaces.nsIWebProgressListener) ||
|
||||
aIID.equals(Components.interfaces.nsISupportsWeakReference) ||
|
||||
aIID.equals(Components.interfaces.nsIXULBrowserWindow) ||
|
||||
aIID.equals(Components.interfaces.nsISupports))
|
||||
return this;
|
||||
throw Components.results.NS_NOINTERFACE;
|
||||
},
|
||||
|
||||
init : function()
|
||||
{
|
||||
// XXXjag is this still needed? It's currently just ""
|
||||
this.defaultStatus = gNavigatorBundle.getString("defaultStatus");
|
||||
|
||||
this.urlBar = document.getElementById("urlbar");
|
||||
this.throbberElement = document.getElementById("navigator-throbber");
|
||||
this.statusMeter = document.getElementById("statusbar-icon");
|
||||
this.stopButton = document.getElementById("stop-button");
|
||||
this.stopMenu = document.getElementById("menuitem-stop");
|
||||
this.stopContext = document.getElementById("context-stop");
|
||||
this.statusTextField = document.getElementById("statusbar-display");
|
||||
|
||||
},
|
||||
|
||||
destroy : function()
|
||||
{
|
||||
// XXXjag to avoid leaks :-/, see bug 60729
|
||||
this.urlBar = null;
|
||||
this.throbberElement = null;
|
||||
this.statusMeter = null;
|
||||
this.stopButton = null;
|
||||
this.stopMenu = null;
|
||||
this.stopContext = null;
|
||||
this.statusTextField = null;
|
||||
},
|
||||
|
||||
setJSStatus : function(status)
|
||||
{
|
||||
this.jsStatus = status;
|
||||
this.updateStatusField();
|
||||
// set empty so defaults show up next change
|
||||
this.jsStatus = "";
|
||||
},
|
||||
|
||||
setJSDefaultStatus : function(status)
|
||||
{
|
||||
this.jsDefaultStatus = status;
|
||||
this.updateStatusField();
|
||||
},
|
||||
|
||||
setDefaultStatus : function(status)
|
||||
{
|
||||
this.defaultStatus = status;
|
||||
this.updateStatusField();
|
||||
},
|
||||
|
||||
setOverLink : function(link, b)
|
||||
{
|
||||
this.overLink = link;
|
||||
this.updateStatusField();
|
||||
// set empty so defaults show up next change
|
||||
this.overLink = "";
|
||||
},
|
||||
|
||||
updateStatusField : function()
|
||||
{
|
||||
var text = this.overLink || this.status || this.jsStatus || this.jsDefaultStatus || this.defaultStatus;
|
||||
|
||||
// check the current value so we don't trigger an attribute change
|
||||
// and cause needless (slow!) UI updates
|
||||
if (this.statusTextField.label != text) {
|
||||
this.statusTextField.label = text;
|
||||
}
|
||||
},
|
||||
|
||||
onProgressChange : function (aWebProgress, aRequest,
|
||||
aCurSelfProgress, aMaxSelfProgress,
|
||||
aCurTotalProgress, aMaxTotalProgress)
|
||||
{
|
||||
if (!this.useRealProgressFlag && aRequest)
|
||||
return;
|
||||
|
||||
if (aMaxTotalProgress > 0) {
|
||||
this.statusMeter.mode = "normal";
|
||||
|
||||
// This is highly optimized. Don't touch this code unless
|
||||
// you are intimately familiar with the cost of setting
|
||||
// attrs on XUL elements. -- hyatt
|
||||
var percentage = (aCurTotalProgress * 100) / aMaxTotalProgress;
|
||||
this.statusMeter.value = percentage;
|
||||
} else {
|
||||
this.statusMeter.mode = "undetermined";
|
||||
}
|
||||
},
|
||||
|
||||
onStateChange : function(aWebProgress, aRequest, aStateFlags, aStatus)
|
||||
{
|
||||
if (!aRequest)
|
||||
return;
|
||||
|
||||
const nsIWebProgressListener = Components.interfaces.nsIWebProgressListener;
|
||||
const nsIChannel = Components.interfaces.nsIChannel;
|
||||
var domWindow;
|
||||
if (aStateFlags & nsIWebProgressListener.STATE_START) {
|
||||
if (aStateFlags & nsIWebProgressListener.STATE_IS_NETWORK) {
|
||||
// Remember when loading commenced.
|
||||
this.startTime = (new Date()).getTime();
|
||||
|
||||
domWindow = aWebProgress.DOMWindow;
|
||||
if (domWindow == _content)
|
||||
this.startDocumentLoad(aRequest);
|
||||
|
||||
// Turn progress meter on.
|
||||
this.statusMeter.mode = "undetermined";
|
||||
this.throbberElement.setAttribute("busy", true);
|
||||
|
||||
// XXX: These need to be based on window activity...
|
||||
this.stopButton.disabled = false;
|
||||
this.stopMenu.disabled = false;
|
||||
this.stopContext.disabled = false;
|
||||
|
||||
// Initialize the progress stuff...
|
||||
this.useRealProgressFlag = false;
|
||||
this.totalRequests = 0;
|
||||
this.finishedRequests = 0;
|
||||
}
|
||||
|
||||
if (aStateFlags & nsIWebProgressListener.STATE_IS_REQUEST) {
|
||||
this.totalRequests += 1;
|
||||
}
|
||||
}
|
||||
else if (aStateFlags & nsIWebProgressListener.STATE_STOP) {
|
||||
if (aStateFlags & nsIWebProgressListener.STATE_IS_REQUEST) {
|
||||
this.finishedRequests += 1;
|
||||
if (!this.useRealProgressFlag)
|
||||
this.onProgressChange(null, null, 0, 0, this.finishedRequests, this.totalRequests);
|
||||
}
|
||||
if (aStateFlags & nsIWebProgressListener.STATE_IS_NETWORK) {
|
||||
domWindow = aWebProgress.DOMWindow;
|
||||
if (domWindow == domWindow.top)
|
||||
this.endDocumentLoad(aRequest, aStatus);
|
||||
|
||||
var location = aRequest.QueryInterface(nsIChannel).URI.spec;
|
||||
var msg = "";
|
||||
if (location != "about:blank") {
|
||||
// Record page loading time.
|
||||
var elapsed = ((new Date()).getTime() - this.startTime) / 1000;
|
||||
msg = gNavigatorBundle.getString("nv_done");
|
||||
msg = msg.replace(/%elapsed%/, elapsed);
|
||||
}
|
||||
this.status = "";
|
||||
this.setDefaultStatus(msg);
|
||||
|
||||
// Turn progress meter off.
|
||||
this.statusMeter.mode = "normal";
|
||||
this.statusMeter.value = 0; // be sure to clear the progress bar
|
||||
this.throbberElement.removeAttribute("busy");
|
||||
|
||||
// XXX: These need to be based on window activity...
|
||||
// XXXjag: <command id="cmd_stop"/> ?
|
||||
this.stopButton.disabled = true;
|
||||
this.stopMenu.disabled = true;
|
||||
this.stopContext.disabled = true;
|
||||
|
||||
}
|
||||
}
|
||||
else if (aStateFlags & nsIWebProgressListener.STATE_TRANSFERRING) {
|
||||
if (aStateFlags & nsIWebProgressListener.STATE_IS_DOCUMENT) {
|
||||
var ctype = aRequest.QueryInterface(nsIChannel).contentType;
|
||||
|
||||
if (ctype != "text/html")
|
||||
this.useRealProgressFlag = true;
|
||||
|
||||
this.statusMeter.mode = "normal";
|
||||
}
|
||||
|
||||
if (aStateFlags & nsIWebProgressListener.STATE_IS_REQUEST) {
|
||||
if (!this.useRealProgressFlag)
|
||||
this.onProgressChange(null, null, 0, 0, this.finishedRequests, this.totalRequests);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
onLocationChange : function(aWebProgress, aRequest, aLocation)
|
||||
{
|
||||
var location = aLocation.spec;
|
||||
|
||||
if (this.hideAboutBlank) {
|
||||
this.hideAboutBlank = false;
|
||||
if (location == "about:blank")
|
||||
location = "";
|
||||
}
|
||||
|
||||
// We should probably not do this if the value has changed since the user
|
||||
// searched
|
||||
this.urlBar.value = location;
|
||||
|
||||
UpdateBackForwardButtons();
|
||||
},
|
||||
|
||||
onStatusChange : function(aWebProgress, aRequest, aStatus, aMessage)
|
||||
{
|
||||
if (!this.statusTimeoutInEffect) {
|
||||
this.statusTimeoutInEffect = true;
|
||||
this.status = aMessage;
|
||||
this.updateStatusField();
|
||||
setTimeout(function(aClosure) { aClosure.statusTimeoutInEffect = false; }, 400, this);
|
||||
}
|
||||
},
|
||||
|
||||
onSecurityChange : function(aWebProgress, aRequest, aState)
|
||||
{
|
||||
throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
|
||||
},
|
||||
|
||||
startDocumentLoad : function(aRequest)
|
||||
{
|
||||
const nsIChannel = Components.interfaces.nsIChannel;
|
||||
var urlStr = aRequest.QueryInterface(nsIChannel).URI.spec;
|
||||
var observerService = Components.classes["@mozilla.org/observer-service;1"]
|
||||
.getService(Components.interfaces.nsIObserverService);
|
||||
try {
|
||||
observerService.Notify(_content, "StartDocumentLoad", urlStr);
|
||||
} catch (e) {
|
||||
}
|
||||
},
|
||||
|
||||
endDocumentLoad : function(aRequest, aStatus)
|
||||
{
|
||||
const nsIChannel = Components.interfaces.nsIChannel;
|
||||
var urlStr = aRequest.QueryInterface(nsIChannel).originalURI.spec;
|
||||
|
||||
if (Components.isSuccessCode(aStatus))
|
||||
dump("Document "+urlStr+" loaded successfully\n"); // per QA request
|
||||
else
|
||||
dump("Error loading URL "+urlStr+" : "+aStatus+"\n"); // per QA request
|
||||
|
||||
var observerService = Components.classes["@mozilla.org/observer-service;1"]
|
||||
.getService(Components.interfaces.nsIObserverService);
|
||||
|
||||
var notification = Components.isSuccessCode(aStatus) ? "FailDocumentLoad" : "EndDocumentLoad";
|
||||
try {
|
||||
observerService.Notify(_content, notification, urlStr);
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -34,8 +34,6 @@
|
||||
#include "nsIDocShellTreeItem.h"
|
||||
#include "nsISHistory.h"
|
||||
#include "nsIWebNavigation.h"
|
||||
#include "nsIWebProgress.h"
|
||||
#include "nsIXULBrowserWindow.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsIHTTPChannel.h"
|
||||
|
||||
@ -588,7 +586,6 @@ NS_IMPL_RELEASE(nsBrowserInstance)
|
||||
NS_INTERFACE_MAP_BEGIN(nsBrowserInstance)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIBrowserInstance)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIURIContentListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIWebProgressListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIURIContentListener)
|
||||
NS_INTERFACE_MAP_END
|
||||
@ -866,173 +863,6 @@ nsBrowserInstance::FindNext()
|
||||
return rv;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
// Helper functions for notifying observers when documents start and finish
|
||||
// loading.
|
||||
//*****************************************************************************
|
||||
|
||||
nsresult nsBrowserInstance::StartDocumentLoad(nsIDOMWindow *aDOMWindow,
|
||||
nsIRequest *request)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsXPIDLCString uriCString;
|
||||
nsAutoString urlStr;
|
||||
|
||||
nsCOMPtr<nsIChannel> aChannel = do_QueryInterface(request);
|
||||
if (!aChannel) return NS_ERROR_FAILURE;
|
||||
|
||||
// Get the URI strign and convert it to unicode...
|
||||
rv = aChannel->GetURI(getter_AddRefs(uri));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = uri->GetSpec(getter_Copies(uriCString));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
urlStr.AssignWithConversion(uriCString);
|
||||
|
||||
#ifdef DEBUG_warren
|
||||
if (gTimerLog == nsnull)
|
||||
gTimerLog = PR_NewLogModule("Timer");
|
||||
mLoadStartTime = PR_IntervalNow();
|
||||
PR_LOG(gTimerLog, PR_LOG_DEBUG,
|
||||
(">>>>> Starting timer for %s\n", (const char *)uriCString));
|
||||
printf(">>>>> Starting timer for %s\n", (const char *)uriCString);
|
||||
#endif
|
||||
|
||||
//
|
||||
// If this document notification is for a frame then ignore it...
|
||||
//
|
||||
nsCOMPtr<nsIDOMWindowInternal> contentWindow;
|
||||
nsCOMPtr<nsIDOMWindow> thisDOMWindow;
|
||||
|
||||
rv = GetContentWindow(getter_AddRefs(contentWindow));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
thisDOMWindow = do_QueryInterface(contentWindow);
|
||||
if (aDOMWindow != thisDOMWindow.get()) {
|
||||
// Since the notification is from a different DOM window, just ignore it.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Notify observers that a document load has started in the
|
||||
// content window.
|
||||
NS_WITH_SERVICE(nsIObserverService, observer, NS_OBSERVERSERVICE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = observer->Notify(contentWindow, NS_LITERAL_STRING("StartDocumentLoad").get(), urlStr.GetUnicode());
|
||||
|
||||
// XXX Ignore rv for now. They are using nsIEnumerator instead of
|
||||
// nsISimpleEnumerator.
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsBrowserInstance::EndDocumentLoad(nsIDOMWindow *aDOMWindow,
|
||||
nsIRequest *request,
|
||||
nsresult aStatus)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIChannel> aChannel = do_QueryInterface(request);
|
||||
if (!aChannel) return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
rv = aChannel->GetOriginalURI(getter_AddRefs(uri));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsXPIDLCString urlCString;
|
||||
rv = uri->GetSpec(getter_Copies(urlCString));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
#ifdef DEBUG_warren
|
||||
if (gTimerLog == nsnull)
|
||||
gTimerLog = PR_NewLogModule("Timer");
|
||||
PRIntervalTime end = PR_IntervalNow();
|
||||
PRIntervalTime diff = end - mLoadStartTime;
|
||||
PR_LOG(gTimerLog, PR_LOG_DEBUG,
|
||||
(">>>>> Stopping timer for %s. Elapsed: %.3f\n",
|
||||
(const char *)urlCString, PR_IntervalToMilliseconds(diff) / 1000.0));
|
||||
printf(">>>>> Stopping timer for %s. Elapsed: %.3f\n",
|
||||
(const char *)urlCString, PR_IntervalToMilliseconds(diff) / 1000.0);
|
||||
#endif
|
||||
|
||||
//
|
||||
// If this document notification is for a frame then ignore it...
|
||||
//
|
||||
if (aDOMWindow) {
|
||||
nsCOMPtr<nsIDOMWindow> topDOMWindow;
|
||||
|
||||
aDOMWindow->GetTop(getter_AddRefs(topDOMWindow));
|
||||
|
||||
if (aDOMWindow != topDOMWindow.get()) {
|
||||
// Since the notification is from a child DOM window, just ignore it.
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMWindowInternal> contentWindow;
|
||||
rv = GetContentWindow(getter_AddRefs(contentWindow));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
//
|
||||
// XXX: The DocLoader should never be busy at this point!!
|
||||
//
|
||||
#ifdef DEBUG
|
||||
nsCOMPtr<nsIScriptGlobalObject> globalObj(do_QueryInterface(contentWindow));
|
||||
|
||||
if (globalObj) {
|
||||
nsCOMPtr<nsIDocShell> docShell;
|
||||
globalObj->GetDocShell(getter_AddRefs(docShell));
|
||||
nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(docShell));
|
||||
|
||||
if (webShell) {
|
||||
nsCOMPtr<nsIDocumentLoader> docLoader;
|
||||
webShell->GetDocumentLoader(*getter_AddRefs(docLoader));
|
||||
|
||||
if (docLoader) {
|
||||
PRBool isBusy = PR_FALSE;
|
||||
docLoader->IsBusy(&isBusy);
|
||||
|
||||
if (isBusy) {
|
||||
NS_ASSERTION(0, "The DocLoader is still busy... There is a bug in End Document notifications\n");
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* If this is a frame, don't do any of the Global History
|
||||
* & observer thingy
|
||||
*/
|
||||
NS_WITH_SERVICE(nsIObserverService, observer, NS_OBSERVERSERVICE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Notify observers that a document load has started in the
|
||||
// content window.
|
||||
rv = observer->Notify(contentWindow,
|
||||
NS_SUCCEEDED(aStatus) ? NS_LITERAL_STRING("EndDocumentLoad").get()
|
||||
: NS_LITERAL_STRING("FailDocumentLoad").get(),
|
||||
NS_ConvertASCIItoUCS2(urlCString).get());
|
||||
|
||||
// XXX Ignore rv for now. They are using nsIEnumerator instead of
|
||||
// nsISimpleEnumerator.
|
||||
|
||||
//#ifdef DEBUG
|
||||
if (NS_SUCCEEDED(aStatus)) {
|
||||
fprintf(stdout, "Document %s loaded successfully\n", urlCString.get());
|
||||
fflush(stdout);
|
||||
} else {
|
||||
fprintf(stdout, "Error loading URL %s: %0x \n", urlCString.get(), aStatus);
|
||||
fflush(stdout);
|
||||
}
|
||||
//#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
// nsBrowserInstance: nsIURIContentListener
|
||||
//*****************************************************************************
|
||||
@ -1161,99 +991,6 @@ nsBrowserInstance::SetLoadCookie(nsISupports * aLoadCookie)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
// nsBrowserInstance::nsIWebProgressListener
|
||||
//*****************************************************************************
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBrowserInstance::OnProgressChange(nsIWebProgress* aWebProgress,
|
||||
nsIRequest* aRequest,
|
||||
PRInt32 aCurSelfProgress,
|
||||
PRInt32 aMaxSelfProgress,
|
||||
PRInt32 aCurTotalProgress,
|
||||
PRInt32 aMaxTotalProgress)
|
||||
{
|
||||
EnsureXULBrowserWindow();
|
||||
if(mXULBrowserWindow) {
|
||||
mXULBrowserWindow->OnProgress(aRequest, aCurTotalProgress, aMaxTotalProgress);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBrowserInstance::OnStateChange(nsIWebProgress* aWebProgress,
|
||||
nsIRequest* aRequest,
|
||||
PRInt32 aStateFlags,
|
||||
nsresult aStatus)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
EnsureXULBrowserWindow();
|
||||
|
||||
// Ignore this notification if it did not originate from a channel...
|
||||
if (!aRequest) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (aStateFlags & nsIWebProgressListener::STATE_IS_NETWORK) {
|
||||
nsCOMPtr<nsIDOMWindow> domWindow;
|
||||
|
||||
rv = aWebProgress->GetDOMWindow(getter_AddRefs(domWindow));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
if (aStateFlags & nsIWebProgressListener::STATE_START) {
|
||||
rv = StartDocumentLoad(domWindow, aRequest);
|
||||
}
|
||||
else if (aStateFlags & nsIWebProgressListener::STATE_STOP) {
|
||||
rv = EndDocumentLoad(domWindow, aRequest, aStatus);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(mXULBrowserWindow) {
|
||||
mXULBrowserWindow->OnStateChange(aRequest, aStateFlags);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsBrowserInstance::OnLocationChange(nsIWebProgress* aWebProgress,
|
||||
nsIRequest* aRequest,
|
||||
nsIURI* aLocation)
|
||||
{
|
||||
EnsureXULBrowserWindow();
|
||||
if(!mXULBrowserWindow)
|
||||
return NS_OK;
|
||||
|
||||
nsXPIDLCString spec;
|
||||
aLocation->GetSpec(getter_Copies(spec));
|
||||
nsAutoString specW; specW.AssignWithConversion(spec);
|
||||
mXULBrowserWindow->OnLocationChange(specW.GetUnicode());
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBrowserInstance::OnStatusChange(nsIWebProgress* aWebProgress,
|
||||
nsIRequest* aRequest,
|
||||
nsresult aStatus,
|
||||
const PRUnichar* aMessage)
|
||||
{
|
||||
EnsureXULBrowserWindow();
|
||||
if(mXULBrowserWindow) {
|
||||
mXULBrowserWindow->OnStatus(aRequest, aStatus, aMessage);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBrowserInstance::OnSecurityChange(nsIWebProgress *aWebProgress,
|
||||
nsIRequest *aRequest,
|
||||
PRInt32 state)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
//*****************************************************************************
|
||||
// nsBrowserInstance: Helpers
|
||||
//*****************************************************************************
|
||||
@ -1274,25 +1011,6 @@ nsBrowserInstance::InitializeSearch(nsIDOMWindowInternal* windowToSearch, nsIFin
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBrowserInstance::EnsureXULBrowserWindow()
|
||||
{
|
||||
if(mXULBrowserWindow)
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsPIDOMWindow> piDOMWindow(do_QueryInterface(mDOMWindow));
|
||||
NS_ENSURE_TRUE(piDOMWindow, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsISupports> xpConnectObj;
|
||||
piDOMWindow->GetObjectProperty(NS_LITERAL_STRING("XULBrowserWindow").get(), getter_AddRefs(xpConnectObj));
|
||||
mXULBrowserWindow = do_QueryInterface(xpConnectObj);
|
||||
|
||||
if(mXULBrowserWindow)
|
||||
return NS_OK;
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// browserCntHandler is a content handler component that registers
|
||||
// the browse as the preferred content handler for various content
|
||||
|
||||
@ -40,8 +40,6 @@
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsICmdLineHandler.h"
|
||||
#include "nsIXULBrowserWindow.h"
|
||||
#include "nsIWebProgressListener.h"
|
||||
#include "nsIWebShell.h"
|
||||
#include "nsIUrlbarHistory.h"
|
||||
|
||||
@ -60,7 +58,6 @@ class nsIFindComponent;
|
||||
|
||||
class nsBrowserInstance : public nsIBrowserInstance,
|
||||
public nsIURIContentListener,
|
||||
public nsIWebProgressListener,
|
||||
public nsSupportsWeakReference
|
||||
{
|
||||
public:
|
||||
@ -77,9 +74,6 @@ class nsBrowserInstance : public nsIBrowserInstance,
|
||||
// URI Content listener
|
||||
NS_DECL_NSIURICONTENTLISTENER
|
||||
|
||||
// WebProgress listener
|
||||
NS_DECL_NSIWEBPROGRESSLISTENER
|
||||
|
||||
protected:
|
||||
|
||||
nsresult GetContentAreaDocShell(nsIDocShell** outDocShell);
|
||||
@ -91,21 +85,9 @@ class nsBrowserInstance : public nsIBrowserInstance,
|
||||
|
||||
nsresult InitializeSearch(nsIDOMWindowInternal* windowToSearch, nsIFindComponent *finder );
|
||||
|
||||
NS_IMETHOD EnsureXULBrowserWindow();
|
||||
|
||||
// helper methods for dealing with document loading...
|
||||
nsresult StartDocumentLoad(nsIDOMWindow *aDOMWindow,
|
||||
nsIRequest *request);
|
||||
|
||||
nsresult EndDocumentLoad(nsIDOMWindow *aDOMWindow,
|
||||
nsIRequest *request,
|
||||
nsresult aResult);
|
||||
|
||||
PRBool mIsClosed;
|
||||
static PRBool sCmdLineURLUsed;
|
||||
|
||||
nsCOMPtr<nsIXULBrowserWindow> mXULBrowserWindow;
|
||||
|
||||
nsWeakPtr mContentAreaDocShellWeak;
|
||||
|
||||
nsIWebShellWindow *mWebShellWin; // weak reference
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user