Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | const NS_ERROR_MODULE_NETWORK = 2152398848; |
michael@0 | 7 | const NS_NET_STATUS_READ_FROM = NS_ERROR_MODULE_NETWORK + 8; |
michael@0 | 8 | const NS_NET_STATUS_WROTE_TO = NS_ERROR_MODULE_NETWORK + 9; |
michael@0 | 9 | |
michael@0 | 10 | function getPanelBrowser() |
michael@0 | 11 | { |
michael@0 | 12 | return document.getElementById("web-panels-browser"); |
michael@0 | 13 | } |
michael@0 | 14 | |
michael@0 | 15 | var panelProgressListener = { |
michael@0 | 16 | onProgressChange : function (aWebProgress, aRequest, |
michael@0 | 17 | aCurSelfProgress, aMaxSelfProgress, |
michael@0 | 18 | aCurTotalProgress, aMaxTotalProgress) { |
michael@0 | 19 | }, |
michael@0 | 20 | |
michael@0 | 21 | onStateChange : function(aWebProgress, aRequest, aStateFlags, aStatus) |
michael@0 | 22 | { |
michael@0 | 23 | if (!aRequest) |
michael@0 | 24 | return; |
michael@0 | 25 | |
michael@0 | 26 | //ignore local/resource:/chrome: files |
michael@0 | 27 | if (aStatus == NS_NET_STATUS_READ_FROM || aStatus == NS_NET_STATUS_WROTE_TO) |
michael@0 | 28 | return; |
michael@0 | 29 | |
michael@0 | 30 | if (aStateFlags & Ci.nsIWebProgressListener.STATE_START && |
michael@0 | 31 | aStateFlags & Ci.nsIWebProgressListener.STATE_IS_NETWORK) { |
michael@0 | 32 | window.parent.document.getElementById('sidebar-throbber').setAttribute("loading", "true"); |
michael@0 | 33 | } |
michael@0 | 34 | else if (aStateFlags & Ci.nsIWebProgressListener.STATE_STOP && |
michael@0 | 35 | aStateFlags & Ci.nsIWebProgressListener.STATE_IS_NETWORK) { |
michael@0 | 36 | window.parent.document.getElementById('sidebar-throbber').removeAttribute("loading"); |
michael@0 | 37 | } |
michael@0 | 38 | } |
michael@0 | 39 | , |
michael@0 | 40 | |
michael@0 | 41 | onLocationChange : function(aWebProgress, aRequest, aLocation, aFlags) { |
michael@0 | 42 | UpdateBackForwardCommands(getPanelBrowser().webNavigation); |
michael@0 | 43 | }, |
michael@0 | 44 | |
michael@0 | 45 | onStatusChange : function(aWebProgress, aRequest, aStatus, aMessage) { |
michael@0 | 46 | }, |
michael@0 | 47 | |
michael@0 | 48 | onSecurityChange : function(aWebProgress, aRequest, aState) { |
michael@0 | 49 | }, |
michael@0 | 50 | |
michael@0 | 51 | QueryInterface : function(aIID) |
michael@0 | 52 | { |
michael@0 | 53 | if (aIID.equals(Ci.nsIWebProgressListener) || |
michael@0 | 54 | aIID.equals(Ci.nsISupportsWeakReference) || |
michael@0 | 55 | aIID.equals(Ci.nsISupports)) |
michael@0 | 56 | return this; |
michael@0 | 57 | throw Cr.NS_NOINTERFACE; |
michael@0 | 58 | } |
michael@0 | 59 | }; |
michael@0 | 60 | |
michael@0 | 61 | var gLoadFired = false; |
michael@0 | 62 | function loadWebPanel(aURI) { |
michael@0 | 63 | var panelBrowser = getPanelBrowser(); |
michael@0 | 64 | if (gLoadFired) { |
michael@0 | 65 | panelBrowser.webNavigation |
michael@0 | 66 | .loadURI(aURI, nsIWebNavigation.LOAD_FLAGS_NONE, |
michael@0 | 67 | null, null, null); |
michael@0 | 68 | } |
michael@0 | 69 | panelBrowser.setAttribute("cachedurl", aURI); |
michael@0 | 70 | } |
michael@0 | 71 | |
michael@0 | 72 | function load() |
michael@0 | 73 | { |
michael@0 | 74 | var panelBrowser = getPanelBrowser(); |
michael@0 | 75 | panelBrowser.webProgress.addProgressListener(panelProgressListener, |
michael@0 | 76 | Ci.nsIWebProgress.NOTIFY_ALL); |
michael@0 | 77 | var cachedurl = panelBrowser.getAttribute("cachedurl") |
michael@0 | 78 | if (cachedurl) { |
michael@0 | 79 | panelBrowser.webNavigation |
michael@0 | 80 | .loadURI(cachedurl, nsIWebNavigation.LOAD_FLAGS_NONE, null, |
michael@0 | 81 | null, null); |
michael@0 | 82 | } |
michael@0 | 83 | |
michael@0 | 84 | gLoadFired = true; |
michael@0 | 85 | } |
michael@0 | 86 | |
michael@0 | 87 | function unload() |
michael@0 | 88 | { |
michael@0 | 89 | getPanelBrowser().webProgress.removeProgressListener(panelProgressListener); |
michael@0 | 90 | } |
michael@0 | 91 | |
michael@0 | 92 | function PanelBrowserStop() |
michael@0 | 93 | { |
michael@0 | 94 | getPanelBrowser().webNavigation.stop(nsIWebNavigation.STOP_ALL) |
michael@0 | 95 | } |
michael@0 | 96 | |
michael@0 | 97 | function PanelBrowserReload() |
michael@0 | 98 | { |
michael@0 | 99 | getPanelBrowser().webNavigation |
michael@0 | 100 | .sessionHistory |
michael@0 | 101 | .QueryInterface(nsIWebNavigation) |
michael@0 | 102 | .reload(nsIWebNavigation.LOAD_FLAGS_NONE); |
michael@0 | 103 | } |