michael@0: /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: const NS_ERROR_MODULE_NETWORK = 2152398848; michael@0: const NS_NET_STATUS_READ_FROM = NS_ERROR_MODULE_NETWORK + 8; michael@0: const NS_NET_STATUS_WROTE_TO = NS_ERROR_MODULE_NETWORK + 9; michael@0: michael@0: function getPanelBrowser() michael@0: { michael@0: return document.getElementById("web-panels-browser"); michael@0: } michael@0: michael@0: var panelProgressListener = { michael@0: onProgressChange : function (aWebProgress, aRequest, michael@0: aCurSelfProgress, aMaxSelfProgress, michael@0: aCurTotalProgress, aMaxTotalProgress) { michael@0: }, michael@0: michael@0: onStateChange : function(aWebProgress, aRequest, aStateFlags, aStatus) michael@0: { michael@0: if (!aRequest) michael@0: return; michael@0: michael@0: //ignore local/resource:/chrome: files michael@0: if (aStatus == NS_NET_STATUS_READ_FROM || aStatus == NS_NET_STATUS_WROTE_TO) michael@0: return; michael@0: michael@0: if (aStateFlags & Ci.nsIWebProgressListener.STATE_START && michael@0: aStateFlags & Ci.nsIWebProgressListener.STATE_IS_NETWORK) { michael@0: window.parent.document.getElementById('sidebar-throbber').setAttribute("loading", "true"); michael@0: } michael@0: else if (aStateFlags & Ci.nsIWebProgressListener.STATE_STOP && michael@0: aStateFlags & Ci.nsIWebProgressListener.STATE_IS_NETWORK) { michael@0: window.parent.document.getElementById('sidebar-throbber').removeAttribute("loading"); michael@0: } michael@0: } michael@0: , michael@0: michael@0: onLocationChange : function(aWebProgress, aRequest, aLocation, aFlags) { michael@0: UpdateBackForwardCommands(getPanelBrowser().webNavigation); michael@0: }, michael@0: michael@0: onStatusChange : function(aWebProgress, aRequest, aStatus, aMessage) { michael@0: }, michael@0: michael@0: onSecurityChange : function(aWebProgress, aRequest, aState) { michael@0: }, michael@0: michael@0: QueryInterface : function(aIID) michael@0: { michael@0: if (aIID.equals(Ci.nsIWebProgressListener) || michael@0: aIID.equals(Ci.nsISupportsWeakReference) || michael@0: aIID.equals(Ci.nsISupports)) michael@0: return this; michael@0: throw Cr.NS_NOINTERFACE; michael@0: } michael@0: }; michael@0: michael@0: var gLoadFired = false; michael@0: function loadWebPanel(aURI) { michael@0: var panelBrowser = getPanelBrowser(); michael@0: if (gLoadFired) { michael@0: panelBrowser.webNavigation michael@0: .loadURI(aURI, nsIWebNavigation.LOAD_FLAGS_NONE, michael@0: null, null, null); michael@0: } michael@0: panelBrowser.setAttribute("cachedurl", aURI); michael@0: } michael@0: michael@0: function load() michael@0: { michael@0: var panelBrowser = getPanelBrowser(); michael@0: panelBrowser.webProgress.addProgressListener(panelProgressListener, michael@0: Ci.nsIWebProgress.NOTIFY_ALL); michael@0: var cachedurl = panelBrowser.getAttribute("cachedurl") michael@0: if (cachedurl) { michael@0: panelBrowser.webNavigation michael@0: .loadURI(cachedurl, nsIWebNavigation.LOAD_FLAGS_NONE, null, michael@0: null, null); michael@0: } michael@0: michael@0: gLoadFired = true; michael@0: } michael@0: michael@0: function unload() michael@0: { michael@0: getPanelBrowser().webProgress.removeProgressListener(panelProgressListener); michael@0: } michael@0: michael@0: function PanelBrowserStop() michael@0: { michael@0: getPanelBrowser().webNavigation.stop(nsIWebNavigation.STOP_ALL) michael@0: } michael@0: michael@0: function PanelBrowserReload() michael@0: { michael@0: getPanelBrowser().webNavigation michael@0: .sessionHistory michael@0: .QueryInterface(nsIWebNavigation) michael@0: .reload(nsIWebNavigation.LOAD_FLAGS_NONE); michael@0: }