Untitled diff

Created Diff never expires
44 removals
143 lines
14 additions
114 lines
/* This Source Code Form is subject to the terms of the Mozilla Public
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
* You can obtain one at http://mozilla.org/MPL/2.0/. */
const wpl = Components.interfaces.nsIWebProgressListener;
const wpl = Components.interfaces.nsIWebProgressListener;
var reporterListener = {
var reporterListener = {
_isBusy: false,
_isBusy: false,
get statusMeter() {
delete this.statusMeter;
return this.statusMeter = document.getElementById("statusbar-icon");
},
get securityButton() {
get securityButton() {
delete this.securityButton;
delete this.securityButton;
return this.securityButton = document.getElementById("security-button");
return this.securityButton = document.getElementById("security-button");
},
},
get securityLabel() {
delete this.securityLabel;
return this.securityLabel = document.getElementById("security-status");
},
get securityDisplay() {
delete this.securityDisplay;
return this.securityDisplay = document.getElementById("security-display");
},
QueryInterface: function(aIID) {
QueryInterface: function(aIID) {
if (aIID.equals(Components.interfaces.nsIWebProgressListener) ||
if (aIID.equals(Components.interfaces.nsIWebProgressListener) ||
aIID.equals(Components.interfaces.nsISupportsWeakReference) ||
aIID.equals(Components.interfaces.nsISupportsWeakReference) ||
aIID.equals(Components.interfaces.nsISupports))
aIID.equals(Components.interfaces.nsISupports))
return this;
return this;
throw Components.results.NS_NOINTERFACE;
throw Components.results.NS_NOINTERFACE;
},
},
onStateChange: function(/*in nsIWebProgress*/ aWebProgress,
onStateChange: function(/*in nsIWebProgress*/ aWebProgress,
/*in nsIRequest*/ aRequest,
/*in nsIRequest*/ aRequest,
/*in unsigned long*/ aStateFlags,
/*in unsigned long*/ aStateFlags,
/*in nsresult*/ aStatus) {
/*in nsresult*/ aStatus) {
if (aStateFlags & wpl.STATE_START &&
aStateFlags & wpl.STATE_IS_NETWORK) {
this.statusMeter.value = 0;
this.statusMeter.parentNode.collapsed = false;
this.securityLabel.collapsed = true;
}
else if (aStateFlags & wpl.STATE_STOP &&
aStateFlags & wpl.STATE_IS_NETWORK) {
this.statusMeter.parentNode.collapsed = true;
this.securityLabel.collapsed = false;
}
},
},
onProgressChange: function(/*in nsIWebProgress*/ aWebProgress,
onProgressChange: function(/*in nsIWebProgress*/ aWebProgress,
/*in nsIRequest*/ aRequest,
/*in nsIRequest*/ aRequest,
/*in long*/ aCurSelfProgress,
/*in long*/ aCurSelfProgress,
/*in long */aMaxSelfProgress,
/*in long */aMaxSelfProgress,
/*in long */aCurTotalProgress,
/*in long */aCurTotalProgress,
/*in long */aMaxTotalProgress) {
/*in long */aMaxTotalProgress) {
if (aMaxTotalProgress > 0) {
let percentage = (aCurTotalProgress * 100) / aMaxTotalProgress;
this.statusMeter.value = percentage;
}
},
},
onLocationChange: function(/*in nsIWebProgress*/ aWebProgress,
onLocationChange: function(/*in nsIWebProgress*/ aWebProgress,
/*in nsIRequest*/ aRequest,
/*in nsIRequest*/ aRequest,
/*in nsIURI*/ aLocation) {
/*in nsIURI*/ aLocation) {
this.securityDisplay.setAttribute('label', aLocation.host);
document.getElementById("headerMessage").textContent = aLocation.spec;
},
},
onStatusChange: function(/*in nsIWebProgress*/ aWebProgress,
onStatusChange: function(/*in nsIWebProgress*/ aWebProgress,
/*in nsIRequest*/ aRequest,
/*in nsIRequest*/ aRequest,
/*in nsresult*/ aStatus,
/*in nsresult*/ aStatus,
/*in wstring*/ aMessage) {
/*in wstring*/ aMessage) {
},
},
onSecurityChange: function(/*in nsIWebProgress*/ aWebProgress,
onSecurityChange: function(/*in nsIWebProgress*/ aWebProgress,
/*in nsIRequest*/ aRequest,
/*in nsIRequest*/ aRequest,
/*in unsigned long*/ aState) {
/*in unsigned long*/ aState) {
const wpl_security_bits = wpl.STATE_IS_SECURE |
const wpl_security_bits = wpl.STATE_IS_SECURE |
wpl.STATE_IS_BROKEN |
wpl.STATE_IS_BROKEN |
wpl.STATE_IS_INSECURE |
wpl.STATE_IS_INSECURE |
wpl.STATE_SECURE_HIGH |
wpl.STATE_SECURE_HIGH |
wpl.STATE_SECURE_MED |
wpl.STATE_SECURE_MED |
wpl.STATE_SECURE_LOW;
wpl.STATE_SECURE_LOW;
let browser = document.getElementById("requestFrame");
var browser = document.getElementById("requestFrame");
let level;
var level;
switch (aState & wpl_security_bits) {
switch (aState & wpl_security_bits) {
case wpl.STATE_IS_SECURE | wpl.STATE_SECURE_HIGH:
case wpl.STATE_IS_SECURE | wpl.STATE_SECURE_HIGH:
level = "high";
level = "high";
break;
break;
case wpl.STATE_IS_SECURE | wpl.STATE_SECURE_MED:
case wpl.STATE_IS_SECURE | wpl.STATE_SECURE_MED:
case wpl.STATE_IS_SECURE | wpl.STATE_SECURE_LOW:
case wpl.STATE_IS_SECURE | wpl.STATE_SECURE_LOW:
level = "low";
level = "low";
break;
break;
case wpl.STATE_IS_BROKEN:
case wpl.STATE_IS_BROKEN:
level = "broken";
level = "broken";
break;
break;
}
}
if (level) {
if (level) {
this.securityButton.setAttribute("level", level);
this.securityButton.setAttribute("level", level);
this.securityButton.hidden = false;
this.securityButton.hidden = false;
this.securityLabel.setAttribute("label", browser.securityUI.tooltipText);
} else {
} else {
this.securityButton.hidden = true;
this.securityButton.hidden = true;
this.securityButton.removeAttribute("level");
this.securityButton.removeAttribute("level");
}
}
this.securityButton.setAttribute("tooltiptext",
this.securityButton.setAttribute("tooltiptext",
browser.securityUI.tooltipText);
browser.securityUI.tooltipText);
}
}
}
}
function cancelRequest()
function cancelRequest()
{
{
reportUserClosed();
reportUserClosed();
window.close();
window.close();
}
}
function reportUserClosed()
function reportUserClosed()
{
{
let request = window.arguments[0];
let request = window.arguments[0].wrappedJSObject;
request.QueryInterface(Components.interfaces.prplIRequestBrowser);
request.cancelled();
request.cancelled();
}
}
function loadRequestedUrl()
function loadRequestedUrl()
{
{
let request = window.arguments[0];
let request = window.arguments[0].wrappedJSObject;
request.QueryInterface(Components.interfaces.prplIRequestBrowser);
document.getElementById("headerMessage").textContent = request.promptText;
document.getElementById("headerMessage").textContent = request.promptText;
let account = request.account;
let account = request.account;
document.getElementById("headerLabel").value =
if (request.iconURI != "")
account.protocol.name + " - " + account.name;
document.getElementById("headerImage").src = request.iconURI;
document.getElementById("headerImage").src =
account.protocol.iconBaseURI + "icon48.png";
let browser = document.getElementById("requestFrame");
var browser = document.getElementById("requestFrame");
browser.addProgressListener(reporterListener,
browser.addProgressListener(reporterListener,
Components.interfaces.nsIWebProgress.NOTIFY_ALL);
Components.interfaces.nsIWebProgress.NOTIFY_ALL);
let url = request.url;
var url = request.url;
if (url != "")
if (url != "") {
browser.setAttribute("src", url);
browser.setAttribute("src", url);
document.getElementById("headerMessage").textContent = url;
}
request.loaded(window, browser.webProgress);
request.loaded(window, browser.webProgress);
}
}