2006-09-14 09:59:50 +04:00
|
|
|
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
2006-09-14 09:57:07 +04:00
|
|
|
*
|
2006-09-14 09:59:50 +04:00
|
|
|
* 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/
|
2006-09-14 09:57:07 +04:00
|
|
|
*
|
2006-09-14 09:59:50 +04:00
|
|
|
* 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.
|
2006-09-14 09:57:07 +04:00
|
|
|
*
|
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2006-09-14 09:59:50 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
2006-09-14 09:57:07 +04:00
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
* Blake Ross <blakeross@telocity.com>
|
|
|
|
* Peter Annema <disttsc@bart.nl>
|
2006-09-14 09:59:50 +04:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the NPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the NPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
2006-09-14 09:57:07 +04:00
|
|
|
|
2006-09-14 09:57:45 +04:00
|
|
|
const NS_ERROR_MODULE_NETWORK = 2152398848;
|
|
|
|
const NS_NET_STATUS_READ_FROM = NS_ERROR_MODULE_NETWORK + 8;
|
|
|
|
const NS_NET_STATUS_WROTE_TO = NS_ERROR_MODULE_NETWORK + 9;
|
|
|
|
|
|
|
|
|
2006-09-14 09:57:07 +04:00
|
|
|
function nsBrowserStatusHandler()
|
|
|
|
{
|
|
|
|
this.init();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsBrowserStatusHandler.prototype =
|
|
|
|
{
|
2006-09-14 10:01:14 +04:00
|
|
|
userTyped :
|
|
|
|
{
|
|
|
|
_value : false,
|
|
|
|
browser : null,
|
|
|
|
|
|
|
|
get value() {
|
|
|
|
if (this.browser != getBrowser().mCurrentBrowser)
|
|
|
|
this._value = false;
|
|
|
|
|
|
|
|
return this._value;
|
|
|
|
},
|
|
|
|
|
|
|
|
set value(aValue) {
|
|
|
|
if (this._value != aValue) {
|
|
|
|
this._value = aValue;
|
|
|
|
this.browser = aValue ? getBrowser().mCurrentBrowser : null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return aValue;
|
2006-09-14 10:01:36 +04:00
|
|
|
}
|
2006-09-14 10:01:14 +04:00
|
|
|
},
|
2006-09-14 10:01:11 +04:00
|
|
|
|
2006-09-14 09:57:07 +04:00
|
|
|
// Stored Status, Link and Loading values
|
|
|
|
status : "",
|
|
|
|
defaultStatus : "",
|
|
|
|
jsStatus : "",
|
|
|
|
jsDefaultStatus : "",
|
|
|
|
overLink : "",
|
|
|
|
|
|
|
|
statusTimeoutInEffect : false,
|
|
|
|
|
|
|
|
hideAboutBlank : true,
|
|
|
|
|
2006-09-14 10:05:01 +04:00
|
|
|
locationChanged : false,
|
|
|
|
|
2006-09-14 09:57:07 +04:00
|
|
|
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");
|
2006-09-14 10:02:51 +04:00
|
|
|
this.isImage = document.getElementById("isImage");
|
2006-09-14 10:04:44 +04:00
|
|
|
this.securityButton = document.getElementById("security-button");
|
2006-09-14 09:57:07 +04:00
|
|
|
|
2006-09-14 10:04:44 +04:00
|
|
|
// Initialize the security button's state and tooltip text
|
|
|
|
const nsIWebProgressListener = Components.interfaces.nsIWebProgressListener;
|
|
|
|
this.onSecurityChange(null, null, nsIWebProgressListener.STATE_IS_INSECURE);
|
2006-09-14 09:57:07 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
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;
|
2006-09-14 10:02:51 +04:00
|
|
|
this.isImage = null;
|
2006-09-14 10:04:44 +04:00
|
|
|
this.securityButton = null;
|
2006-09-14 10:01:14 +04:00
|
|
|
this.userTyped = null;
|
2006-09-14 09:57:07 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
setJSStatus : function(status)
|
|
|
|
{
|
|
|
|
this.jsStatus = status;
|
|
|
|
this.updateStatusField();
|
|
|
|
},
|
|
|
|
|
|
|
|
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();
|
2006-09-14 10:03:26 +04:00
|
|
|
if (link)
|
|
|
|
this.statusTextField.setAttribute('crop', 'center');
|
|
|
|
else
|
2006-09-14 10:03:27 +04:00
|
|
|
this.statusTextField.setAttribute('crop', 'end');
|
2006-09-14 09:57:07 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
updateStatusField : function()
|
|
|
|
{
|
2006-09-14 10:01:38 +04:00
|
|
|
var text = this.overLink || this.status || this.jsStatus || this.jsDefaultStatus || this.defaultStatus;
|
2006-09-14 09:57:07 +04:00
|
|
|
|
|
|
|
// check the current value so we don't trigger an attribute change
|
|
|
|
// and cause needless (slow!) UI updates
|
2006-09-14 10:04:44 +04:00
|
|
|
if (this.statusTextField.label != text)
|
2006-09-14 09:57:07 +04:00
|
|
|
this.statusTextField.label = text;
|
|
|
|
},
|
|
|
|
|
2006-09-14 10:04:48 +04:00
|
|
|
mimeTypeIsTextBased : function(contentType)
|
|
|
|
{
|
2006-09-14 10:04:49 +04:00
|
|
|
return /^text\/|\+xml$/.test(contentType) ||
|
|
|
|
contentType == "application/x-javascript" ||
|
|
|
|
contentType == "application/xml" ||
|
|
|
|
contentType == "mozilla.application/cached-xul";
|
2006-09-14 10:04:48 +04:00
|
|
|
},
|
|
|
|
|
2006-09-14 10:00:54 +04:00
|
|
|
onLinkIconAvailable : function(aHref) {
|
2006-09-14 10:00:55 +04:00
|
|
|
if (gProxyFavIcon && pref.getBoolPref("browser.chrome.site_icons"))
|
2006-09-14 10:01:34 +04:00
|
|
|
{
|
2006-09-14 10:00:54 +04:00
|
|
|
gProxyFavIcon.setAttribute("src", aHref);
|
2006-09-14 10:01:34 +04:00
|
|
|
|
|
|
|
// update any bookmarks with new icon reference
|
|
|
|
if (!gBookmarksService)
|
|
|
|
gBookmarksService = Components.classes["@mozilla.org/browser/bookmarks-service;1"]
|
|
|
|
.getService(Components.interfaces.nsIBookmarksService);
|
2006-09-14 10:03:23 +04:00
|
|
|
gBookmarksService.updateBookmarkIcon(this.urlBar.value, aHref);
|
2006-09-14 10:01:34 +04:00
|
|
|
}
|
2006-09-14 10:00:54 +04:00
|
|
|
},
|
|
|
|
|
2006-09-14 09:57:07 +04:00
|
|
|
onProgressChange : function (aWebProgress, aRequest,
|
|
|
|
aCurSelfProgress, aMaxSelfProgress,
|
|
|
|
aCurTotalProgress, aMaxTotalProgress)
|
|
|
|
{
|
|
|
|
if (aMaxTotalProgress > 0) {
|
|
|
|
// 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;
|
2006-09-14 10:00:05 +04:00
|
|
|
}
|
2006-09-14 09:57:07 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
onStateChange : function(aWebProgress, aRequest, aStateFlags, aStatus)
|
2006-09-14 09:59:41 +04:00
|
|
|
{
|
2006-09-14 09:57:07 +04:00
|
|
|
const nsIWebProgressListener = Components.interfaces.nsIWebProgressListener;
|
|
|
|
const nsIChannel = Components.interfaces.nsIChannel;
|
2006-09-14 10:02:48 +04:00
|
|
|
var ctype;
|
2006-09-14 09:57:07 +04:00
|
|
|
if (aStateFlags & nsIWebProgressListener.STATE_START) {
|
2006-09-14 10:04:53 +04:00
|
|
|
// If this is a network start or the first stray request (the first
|
|
|
|
// request outside of the document load), initialize the throbber and his
|
|
|
|
// friends.
|
|
|
|
if (aStateFlags & nsIWebProgressListener.STATE_IS_NETWORK ||
|
|
|
|
(aStateFlags & nsIWebProgressListener.STATE_IS_REQUEST &&
|
|
|
|
!aWebProgress.isLoadingDocument &&
|
|
|
|
this.totalRequests == this.finishedRequests)) {
|
2006-09-14 09:57:07 +04:00
|
|
|
|
2006-09-14 10:04:53 +04:00
|
|
|
// Call start document load listeners (only if this is a network load)
|
|
|
|
if (aStateFlags & nsIWebProgressListener.STATE_IS_NETWORK &&
|
|
|
|
aRequest && aWebProgress.DOMWindow == content)
|
2006-09-14 09:57:07 +04:00
|
|
|
this.startDocumentLoad(aRequest);
|
|
|
|
|
2006-09-14 10:00:05 +04:00
|
|
|
// Turn the throbber on.
|
2006-09-14 09:57:07 +04:00
|
|
|
this.throbberElement.setAttribute("busy", true);
|
|
|
|
|
|
|
|
// XXX: These need to be based on window activity...
|
|
|
|
this.stopButton.disabled = false;
|
2006-09-14 09:57:45 +04:00
|
|
|
this.stopMenu.removeAttribute('disabled');
|
|
|
|
this.stopContext.removeAttribute('disabled');
|
2006-09-14 10:05:01 +04:00
|
|
|
|
|
|
|
this.locationChanged = false;
|
2006-09-14 09:57:07 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (aStateFlags & nsIWebProgressListener.STATE_STOP) {
|
|
|
|
if (aStateFlags & nsIWebProgressListener.STATE_IS_NETWORK) {
|
2006-09-14 09:59:41 +04:00
|
|
|
if (aRequest) {
|
2006-09-14 10:03:24 +04:00
|
|
|
if (aWebProgress.DOMWindow == content)
|
2006-09-14 09:59:41 +04:00
|
|
|
this.endDocumentLoad(aRequest, aStatus);
|
2006-09-14 10:04:53 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// If this is a network stop or the last request stop outside of loading
|
|
|
|
// the document, stop throbbers and progress bars and such
|
|
|
|
if (aStateFlags & nsIWebProgressListener.STATE_IS_NETWORK ||
|
|
|
|
(aStateFlags & nsIWebProgressListener.STATE_IS_REQUEST &&
|
|
|
|
!aWebProgress.isLoadingDocument &&
|
|
|
|
this.totalRequests == this.finishedRequests)) {
|
2006-09-14 09:59:41 +04:00
|
|
|
|
2006-09-14 10:04:53 +04:00
|
|
|
if (aRequest) {
|
2006-09-14 09:59:41 +04:00
|
|
|
var msg = "";
|
2006-09-14 10:04:53 +04:00
|
|
|
// Get the channel if the request is a channel
|
|
|
|
var channel;
|
|
|
|
try {
|
|
|
|
channel = aRequest.QueryInterface(nsIChannel);
|
|
|
|
}
|
|
|
|
catch(e) { };
|
|
|
|
|
|
|
|
if (channel) {
|
|
|
|
var location = channel.URI.spec;
|
|
|
|
if (location != "about:blank") {
|
|
|
|
const kErrorBindingAborted = 2152398850;
|
|
|
|
const kErrorNetTimeout = 2152398862;
|
|
|
|
switch (aStatus) {
|
|
|
|
case kErrorBindingAborted:
|
|
|
|
msg = gNavigatorBundle.getString("nv_stopped");
|
|
|
|
break;
|
|
|
|
case kErrorNetTimeout:
|
|
|
|
msg = gNavigatorBundle.getString("nv_timeout");
|
|
|
|
break;
|
|
|
|
}
|
2006-09-14 10:04:52 +04:00
|
|
|
}
|
2006-09-14 09:59:41 +04:00
|
|
|
}
|
2006-09-14 10:04:53 +04:00
|
|
|
// If msg is false then we did not have an error (channel may have
|
|
|
|
// been null, in the case of a stray image load).
|
|
|
|
if (!msg) {
|
|
|
|
msg = gNavigatorBundle.getString("nv_done");
|
|
|
|
}
|
2006-09-14 09:59:41 +04:00
|
|
|
this.status = "";
|
|
|
|
this.setDefaultStatus(msg);
|
2006-09-14 10:05:01 +04:00
|
|
|
|
|
|
|
//if the location hasn't been changed, the document may be null(eg a full-page plugin),
|
|
|
|
//we may not be able to get the correct content-type.
|
|
|
|
//so we need to skip the test and keep the menu status.
|
|
|
|
//otherwise(this.locationChanged = true), test normally.
|
|
|
|
if (channel && this.locationChanged) {
|
2006-09-14 10:04:53 +04:00
|
|
|
try {
|
|
|
|
ctype = channel.contentType;
|
|
|
|
if (this.mimeTypeIsTextBased(ctype))
|
|
|
|
this.isImage.removeAttribute('disabled');
|
|
|
|
else
|
|
|
|
this.isImage.setAttribute('disabled', 'true');
|
|
|
|
}
|
|
|
|
catch (e) {}
|
2006-09-14 10:02:51 +04:00
|
|
|
}
|
2006-09-14 09:57:07 +04:00
|
|
|
}
|
|
|
|
|
2006-09-14 10:00:05 +04:00
|
|
|
// Turn the progress meter and throbber off.
|
2006-09-14 09:57:07 +04:00
|
|
|
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;
|
2006-09-14 09:57:45 +04:00
|
|
|
this.stopMenu.setAttribute('disabled', 'true');
|
|
|
|
this.stopContext.setAttribute('disabled', 'true');
|
2006-09-14 09:57:07 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
onLocationChange : function(aWebProgress, aRequest, aLocation)
|
|
|
|
{
|
2006-09-14 10:01:38 +04:00
|
|
|
this.setOverLink("", null);
|
|
|
|
|
2006-09-14 10:05:12 +04:00
|
|
|
var location = "";
|
|
|
|
|
|
|
|
if (aLocation) {
|
|
|
|
try {
|
|
|
|
if (!gURIFixup)
|
|
|
|
gURIFixup = Components.classes["@mozilla.org/docshell/urifixup;1"]
|
|
|
|
.getService(Components.interfaces.nsIURIFixup);
|
|
|
|
// If the url has "wyciwyg://" as the protocol, strip it off.
|
|
|
|
// Nobody wants to see it on the urlbar for dynamically generated
|
|
|
|
// pages.
|
|
|
|
location = gURIFixup.createExposableURI(aLocation).spec;
|
|
|
|
}
|
|
|
|
catch(ex) {
|
|
|
|
location = aLocation.spec;
|
|
|
|
}
|
|
|
|
}
|
2006-09-14 09:57:07 +04:00
|
|
|
|
|
|
|
if (this.hideAboutBlank) {
|
|
|
|
this.hideAboutBlank = false;
|
|
|
|
if (location == "about:blank")
|
|
|
|
location = "";
|
|
|
|
}
|
|
|
|
|
2006-09-14 10:04:48 +04:00
|
|
|
// Disable menu entries for images, enable otherwise
|
2006-09-14 10:04:50 +04:00
|
|
|
if (content.document && this.mimeTypeIsTextBased(content.document.contentType))
|
2006-09-14 10:04:48 +04:00
|
|
|
this.isImage.removeAttribute('disabled');
|
|
|
|
else
|
|
|
|
this.isImage.setAttribute('disabled', 'true');
|
|
|
|
|
2006-09-14 09:57:07 +04:00
|
|
|
// We should probably not do this if the value has changed since the user
|
|
|
|
// searched
|
2006-09-14 09:57:42 +04:00
|
|
|
// Update urlbar only if a new page was loaded on the primary content area
|
|
|
|
// Do not update urlbar if there was a subframe navigation
|
2006-09-14 10:01:14 +04:00
|
|
|
|
2006-09-14 10:03:24 +04:00
|
|
|
if (aWebProgress.DOMWindow == content) {
|
2006-09-14 10:01:39 +04:00
|
|
|
if (!this.userTyped.value) {
|
2006-09-14 10:01:14 +04:00
|
|
|
this.urlBar.value = location;
|
2006-09-14 10:01:39 +04:00
|
|
|
// the above causes userTyped.value to become true, reset it
|
|
|
|
this.userTyped.value = false;
|
|
|
|
}
|
2006-09-14 10:01:14 +04:00
|
|
|
|
2006-09-14 10:00:54 +04:00
|
|
|
SetPageProxyState("valid", aLocation);
|
2006-09-14 09:57:42 +04:00
|
|
|
}
|
2006-09-14 09:57:07 +04:00
|
|
|
UpdateBackForwardButtons();
|
2006-09-14 10:05:01 +04:00
|
|
|
|
|
|
|
this.locationChanged = true;
|
2006-09-14 09:57:07 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
onStatusChange : function(aWebProgress, aRequest, aStatus, aMessage)
|
|
|
|
{
|
2006-09-14 10:01:15 +04:00
|
|
|
this.status = aMessage;
|
2006-09-14 10:04:54 +04:00
|
|
|
this.updateStatusField();
|
2006-09-14 09:57:07 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
onSecurityChange : function(aWebProgress, aRequest, aState)
|
|
|
|
{
|
2006-09-14 10:04:44 +04:00
|
|
|
const wpl = Components.interfaces.nsIWebProgressListener;
|
|
|
|
|
|
|
|
switch (aState) {
|
|
|
|
case wpl.STATE_IS_SECURE | wpl.STATE_SECURE_HIGH:
|
|
|
|
this.securityButton.setAttribute("level", "high");
|
|
|
|
break;
|
|
|
|
case wpl.STATE_IS_SECURE | wpl.STATE_SECURE_LOW:
|
|
|
|
this.securityButton.setAttribute("level", "low");
|
|
|
|
break;
|
|
|
|
case wpl.STATE_IS_BROKEN:
|
|
|
|
this.securityButton.setAttribute("level", "broken");
|
|
|
|
break;
|
|
|
|
case wpl.STATE_IS_INSECURE:
|
|
|
|
default:
|
|
|
|
this.securityButton.removeAttribute("level");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
var securityUI = getBrowser().securityUI;
|
|
|
|
if (securityUI)
|
|
|
|
this.securityButton.setAttribute("tooltiptext", securityUI.tooltipText);
|
|
|
|
else
|
|
|
|
this.securityButton.removeAttribute("tooltiptext");
|
2006-09-14 09:57:07 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
startDocumentLoad : function(aRequest)
|
|
|
|
{
|
2006-09-14 10:01:11 +04:00
|
|
|
// Reset so we can see if the user typed after the document load
|
|
|
|
// starting and the location changing.
|
2006-09-14 10:01:14 +04:00
|
|
|
this.userTyped.value = false;
|
2006-09-14 10:01:11 +04:00
|
|
|
|
2006-09-14 09:57:07 +04:00
|
|
|
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 {
|
2006-09-14 10:00:04 +04:00
|
|
|
observerService.notifyObservers(_content, "StartDocumentLoad", urlStr);
|
2006-09-14 09:57:07 +04:00
|
|
|
} 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
|
2006-09-14 09:57:44 +04:00
|
|
|
else {
|
|
|
|
// per QA request
|
|
|
|
var e = new Components.Exception("", aStatus);
|
|
|
|
var name = e.name;
|
|
|
|
dump("Error loading URL "+urlStr+" : "+
|
|
|
|
Number(aStatus).toString(16));
|
|
|
|
if (name)
|
|
|
|
dump(" ("+name+")");
|
|
|
|
dump('\n');
|
|
|
|
}
|
2006-09-14 09:57:07 +04:00
|
|
|
|
|
|
|
var observerService = Components.classes["@mozilla.org/observer-service;1"]
|
|
|
|
.getService(Components.interfaces.nsIObserverService);
|
|
|
|
|
2006-09-14 09:57:09 +04:00
|
|
|
var notification = Components.isSuccessCode(aStatus) ? "EndDocumentLoad" : "FailDocumentLoad";
|
2006-09-14 09:57:07 +04:00
|
|
|
try {
|
2006-09-14 10:00:04 +04:00
|
|
|
observerService.notifyObservers(_content, notification, urlStr);
|
2006-09-14 09:57:07 +04:00
|
|
|
} catch (e) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|