Bug 101723: security icon only works for the first tab

Bug 117203: Insecure POST warning only comes up for first tab
Bug 120043: Page Info shows information about a page in the first tab
r=sgehani, r=kaie/ddrinan (for security stuff), sr=sspitzer (for mail/news stuff), sr=hyatt, a=asa. Work based on patch by Smaug <smaug@jippii.fi>.
This commit is contained in:
jaggernaut%netscape.com 2002-03-20 09:57:35 +00:00
parent 83ea08088a
commit 8f26b59dcb
17 changed files with 130 additions and 143 deletions

View File

@ -1119,7 +1119,7 @@ NS_IMETHODIMP nsWebBrowser::Create()
if (NS_SUCCEEDED(rv))
{
mSecurityUI = do_CreateInstance(NS_SECURE_BROWSER_UI_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv))mSecurityUI->Init(domWindow, nsnull);
if (NS_SUCCEEDED(rv))mSecurityUI->Init(domWindow);
}
mDocShellTreeOwner->AddToWatcher(); // evil twin of Remove in SetDocShell(0)

View File

@ -31,7 +31,6 @@ Rights Reserved.
<?xul-overlay href="chrome://communicator/content/sidebar/sidebarOverlay.xul"?>
<?xul-overlay href="chrome://communicator/content/tasksOverlay.xul"?>
<?xul-overlay href="chrome://communicator/content/communicatorOverlay.xul"?>
<?xul-overlay href="chrome://communicator/content/securityOverlay.xul"?>
<!DOCTYPE window [
<!ENTITY % brandDTD SYSTEM "chrome://global/locale/brand.dtd" >
@ -182,8 +181,10 @@ Rights Reserved.
<hbox id="msgHeaderView"/>
<!-- message view -->
<browser id="messagepane" context="messagePaneContext" style="height: 0px" flex="1" name="messagepane"
disableHistory="true" type="content-primary" src="about:blank" onclick="contentAreaClick(event);"/>
<browser id="messagepane" context="messagePaneContext"
style="height: 0px" flex="1" name="messagepane"
disablehistory="true" type="content-primary" src="about:blank"
disablesecurity="true" onclick="contentAreaClick(event);"/>
</vbox>
</vbox>

View File

@ -1509,7 +1509,6 @@ Rights Reserved.
</hbox>
<hbox insertafter="totalMessageCount">
<statusbarpanel checkfunc="MailCheckBeforeOfflineChange()" id="offline-status" class="statusbarpanel-iconic"/>
<!-- <statusbarpanel id="security-button" class="statusbarpanel-iconic"/> -->
</hbox>
</statusbar>

View File

@ -31,7 +31,6 @@ Rights Reserved.
<?xul-overlay href="chrome://communicator/content/sidebar/sidebarOverlay.xul"?>
<?xul-overlay href="chrome://communicator/content/tasksOverlay.xul"?>
<?xul-overlay href="chrome://communicator/content/communicatorOverlay.xul"?>
<?xul-overlay href="chrome://communicator/content/securityOverlay.xul"?>
<!DOCTYPE window [
<!ENTITY % brandDTD SYSTEM "chrome://global/locale/brand.dtd" >
@ -172,8 +171,10 @@ Rights Reserved.
<vbox id="messagepanebox" flex="3" persist="collapsed height" onclick="contentAreaClick(event);">
<hbox id="msgHeaderView"/>
<browser id="messagepane" context="messagePaneContext" style="height: 0px" flex="1" name="messagepane"
disableHistory="true" type="content-primary" src="about:blank"/>
<browser id="messagepane" context="messagePaneContext"
style="height: 0px" flex="1" name="messagepane"
disablehistory="true" type="content-primary" src="about:blank"
disablesecurity="true"/>
</vbox>
</vbox>

View File

@ -31,7 +31,6 @@
<?xul-overlay href="chrome://global/content/charsetOverlay.xul"?>
<?xul-overlay href="chrome://communicator/content/tasksOverlay.xul"?>
<?xul-overlay href="chrome://communicator/content/communicatorOverlay.xul"?>
<?xul-overlay href="chrome://communicator/content/securityOverlay.xul"?>
<?xul-overlay href="chrome://messenger/content/messengercompose/addressingWidgetOverlay.xul"?>
<?xul-overlay href="chrome://global/content/globalOverlay.xul"?>

View File

@ -30,8 +30,10 @@ interface nsIDOMElement;
[scriptable, uuid(081e31e0-a144-11d3-8c7c-00609792278c)]
interface nsISecureBrowserUI : nsISupports
{
void init(in nsIDOMWindow window, in nsIDOMElement button);
void displayPageInfoUI();
void init(in nsIDOMWindow window);
readonly attribute long state;
readonly attribute AString tooltipText;
};
%{C++

View File

@ -1,13 +1,11 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://communicator/skin/securityOverlay.css" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://communicator/locale/securityOverlay.dtd">
<overlay id="NavSecurityOverlay"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/x-javascript" src="chrome://communicator/content/securityUI.js" />
<statusbarpanel id="security-button" onclick="displayPageInfo()" tooltiptext="&lockIcon.label;"/>
<statusbarpanel id="security-button" onclick="displayPageInfo()"/>
</overlay>

View File

@ -20,38 +20,8 @@
* Contributor(s):
*/
window.addEventListener("load", SetSecurityButton, false);
window.addEventListener("unload", DestroySecurity, false);
var securityUI;
function SetSecurityButton()
{
const ui = Components.classes["@mozilla.org/secure_browser_ui;1"];
if (ui) {
var securityUI = ui.createInstance(Components.interfaces.nsISecureBrowserUI);
if ("gBrowser" in window) { // XXXjag see bug 68662
gBrowser.boxObject.setPropertyAsSupports("xulwindow", window);
gBrowser.boxObject.setPropertyAsSupports("secureBrowserUI", securityUI);
}
var button = document.getElementById("security-button");
if (button && _content)
securityUI.init(_content, button);
}
}
function displayPageInfo()
{
window.openDialog("chrome://navigator/content/pageInfo.xul", "_blank",
"dialog=no", null, "securityTab");
}
function DestroySecurity()
{
if ("gBrowser" in window) { // XXXjag see bug 68662
gBrowser.boxObject.removeProperty("xulwindow");
gBrowser.boxObject.removeProperty("secureBrowserUI");
}
window.openDialog("chrome://navigator/content/pageInfo.xul", "_blank",
"dialog=no", null, "securityTab");
}

View File

@ -9,4 +9,3 @@ en-US.jar:
locale/en-US/necko/necko.properties (locale/en-US/necko.properties)
locale/en-US/necko/redirect_loop.dtd (locale/en-US/redirect_loop.dtd)
locale/en-US/communicator/security.properties (locale/en-US/security.properties)
locale/en-US/communicator/securityOverlay.dtd (locale/en-US/securityOverlay.dtd)

View File

@ -1,2 +0,0 @@
<!ENTITY lockIcon.label "Show security information for this window">

View File

@ -68,9 +68,6 @@
#define SECURITY_STRING_BUNDLE_URL "chrome://communicator/locale/security.properties"
static NS_DEFINE_CID(kCStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID);
static const char *kNSSDialogsContractId = NS_NSSDIALOGS_CONTRACTID;
#define IS_SECURE(state) ((state & 0xFFFF) == STATE_IS_SECURE)
#if defined(PR_LOGGING)
@ -121,20 +118,21 @@ NS_IMPL_ISUPPORTS6(nsSecureBrowserUIImpl,
NS_IMETHODIMP
nsSecureBrowserUIImpl::Init(nsIDOMWindow *window,
nsIDOMElement *button)
nsSecureBrowserUIImpl::Init(nsIDOMWindow *window)
{
nsresult rv = NS_OK;
mSecurityButton = button; /* may be null */
mWindow = window;
nsCOMPtr<nsIStringBundleService> service(do_GetService(kCStringBundleServiceCID, &rv));
nsCOMPtr<nsIStringBundleService> service(do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv));
if (NS_FAILED(rv)) return rv;
rv = service->CreateBundle(SECURITY_STRING_BUNDLE_URL,
getter_AddRefs(mStringBundle));
if (NS_FAILED(rv)) return rv;
GetBundleString(NS_LITERAL_STRING("SecurityButtonTooltipText").get(),
mTooltipText);
// hook up to the form post notifications:
nsCOMPtr<nsIObserverService> svc(do_GetService("@mozilla.org/observer-service;1", &rv));
if (NS_SUCCEEDED(rv)) {
@ -160,22 +158,17 @@ nsSecureBrowserUIImpl::Init(nsIDOMWindow *window,
}
NS_IMETHODIMP
nsSecureBrowserUIImpl::DisplayPageInfoUI()
nsSecureBrowserUIImpl::GetState(PRInt32* aState)
{
#if 0
nsresult res = NS_OK;
nsCOMPtr<nsISecurityManagerComponent> psm(do_GetService(PSM_COMPONENT_CONTRACTID,
&res));
if (NS_FAILED(res))
return res;
nsXPIDLCString host;
if (mCurrentURI)
mCurrentURI->GetHost(getter_Copies(host));
// return psm->DisplayPSMAdvisor(mLastPSMStatus, host);
#endif
return NS_ERROR_NOT_IMPLEMENTED;
*aState = mSecurityState;
return NS_OK;
}
NS_IMETHODIMP
nsSecureBrowserUIImpl::GetTooltipText(nsAString& aText)
{
aText = mTooltipText;
return NS_OK;
}
NS_IMETHODIMP
@ -389,29 +382,21 @@ nsSecureBrowserUIImpl::OnStateChange(nsIWebProgress* aWebProgress,
sp->GetSSLStatus(getter_AddRefs(mSSLStatus));
}
if (eventSink)
eventSink->OnSecurityChange(aRequest, mSecurityState);
if (!mSecurityButton)
return res;
/* TNH - need event for changing the tooltip */
// Do we really need to look at res here? What happens if there's an error?
// We should still set the certificate authority display.
nsXPIDLString tooltip;
// update the tooltip text so it can be read
// when we do the security change notification
if (info) {
nsXPIDLString tooltip;
nsCOMPtr<nsITransportSecurityInfo> secInfo(do_QueryInterface(info));
if (secInfo &&
NS_SUCCEEDED(secInfo->GetShortSecurityDescription(getter_Copies(tooltip))) &&
tooltip) {
res = mSecurityButton->SetAttribute(NS_LITERAL_STRING("tooltiptext"),
nsString(tooltip));
mTooltipText = tooltip;
}
}
if (eventSink)
eventSink->OnSecurityChange(aRequest, mSecurityState);
}
return res;
@ -454,20 +439,6 @@ nsSecureBrowserUIImpl::OnSecurityChange(nsIWebProgress *aWebProgress,
aURI->GetSpec(temp);
printf("OnSecurityChange: (%x) %s\n", state, temp.get());
#endif
/* Deprecated support for mSecurityButton */
if (mSecurityButton) {
NS_NAMED_LITERAL_STRING(level, "level");
if (state == (STATE_IS_SECURE|STATE_SECURE_HIGH)) {
res = mSecurityButton->SetAttribute(level, NS_LITERAL_STRING("high"));
} else if (state == (STATE_IS_SECURE|STATE_SECURE_LOW)) {
res = mSecurityButton->SetAttribute(level, NS_LITERAL_STRING("low"));
} else if (state == STATE_IS_BROKEN) {
res = mSecurityButton->SetAttribute(level, NS_LITERAL_STRING("broken"));
} else {
res = mSecurityButton->RemoveAttribute(level);
}
}
return res;
}
@ -639,7 +610,11 @@ nsSecureBrowserUIImpl::SetBrokenLockIcon(nsISecurityEventSink *eventSink,
nsIRequest* aRequest,
PRBool removeValue)
{
nsresult rv = NS_OK;
// update the tooltip text so it can be read
// when we do the security change notification
GetBundleString(NS_LITERAL_STRING("SecurityButtonTooltipText").get(),
mTooltipText);
if (removeValue) {
if (eventSink)
(void) eventSink->OnSecurityChange(aRequest, STATE_IS_INSECURE);
@ -648,15 +623,7 @@ nsSecureBrowserUIImpl::SetBrokenLockIcon(nsISecurityEventSink *eventSink,
(void) eventSink->OnSecurityChange(aRequest, (STATE_IS_BROKEN));
}
nsAutoString tooltiptext;
GetBundleString(NS_LITERAL_STRING("SecurityButtonTooltipText").get(),
tooltiptext);
/* TNH - need tooltip notification here */
if (mSecurityButton)
rv = mSecurityButton->SetAttribute(NS_LITERAL_STRING("tooltiptext"),
tooltiptext);
return rv;
return NS_OK;
}
//
@ -712,7 +679,7 @@ nsresult nsSecureBrowserUIImpl::
GetNSSDialogs(nsISecurityWarningDialogs **result)
{
nsresult rv;
nsCOMPtr<nsISecurityWarningDialogs> my_result(do_GetService(kNSSDialogsContractId, &rv));
nsCOMPtr<nsISecurityWarningDialogs> my_result(do_GetService(NS_NSSDIALOGS_CONTRACTID, &rv));
if (NS_FAILED(rv))
return rv;

View File

@ -79,7 +79,6 @@ public:
protected:
nsCOMPtr<nsIDOMWindow> mWindow;
nsCOMPtr<nsIDOMElement> mSecurityButton;
nsCOMPtr<nsIStringBundle> mStringBundle;
nsCOMPtr<nsIURI> mCurrentURI;
@ -88,6 +87,8 @@ protected:
PRBool mFirstRequest;
PRBool mRedirecting;
nsString mTooltipText;
nsCOMPtr<nsISupports> mSSLStatus;
void GetBundleString(const PRUnichar* name, nsString &outString);

View File

@ -49,6 +49,8 @@
var w;
if ("arguments" in window && window.arguments.length > 1 && window.arguments[0])
w = window.arguments[0];
else if ("gBrowser" in window.opener)
w = window.opener.gBrowser.contentWindow;
else
w = window.opener.frames[0];
@ -97,9 +99,8 @@
// Find the secureBrowserUI object (if present)
_getSecurityUI : function() {
if ("gBrowser" in window.opener)
return window.opener.gBrowser.boxObject.getPropertyAsSupports("secureBrowserUI");
else
return null;
return window.opener.gBrowser.securityUI;
return null;
},
// Interface for mapping a certificate issuer organization to

View File

@ -110,7 +110,11 @@ nsBrowserStatusHandler.prototype =
this.stopContext = document.getElementById("context-stop");
this.statusTextField = document.getElementById("statusbar-display");
this.isImage = document.getElementById("isImage");
this.securityButton = document.getElementById("security-button");
// Initialize the security button's state and tooltip text
const nsIWebProgressListener = Components.interfaces.nsIWebProgressListener;
this.onSecurityChange(null, null, nsIWebProgressListener.STATE_IS_INSECURE);
},
destroy : function()
@ -124,6 +128,7 @@ nsBrowserStatusHandler.prototype =
this.stopContext = null;
this.statusTextField = null;
this.isImage = null;
this.securityButton = null;
this.userTyped = null;
},
@ -161,9 +166,8 @@ nsBrowserStatusHandler.prototype =
// check the current value so we don't trigger an attribute change
// and cause needless (slow!) UI updates
if (this.statusTextField.label != text) {
if (this.statusTextField.label != text)
this.statusTextField.label = text;
}
},
onLinkIconAvailable : function(aHref) {
@ -340,6 +344,29 @@ nsBrowserStatusHandler.prototype =
onSecurityChange : function(aWebProgress, aRequest, aState)
{
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");
},
startDocumentLoad : function(aRequest)

View File

@ -94,7 +94,10 @@ function onLoadPageInfo()
}
else
{
theWindow = window.opener.frames[0];
if ("gBrowser" in window.opener)
theWindow = window.opener.gBrowser.contentWindow;
else
theWindow = window.opener.frames[0];
theDocument = theWindow.document;
docTitle = theBundle.getString("pageInfo.title");
}

View File

@ -249,37 +249,51 @@
<field name="mDragDropHandler">
null
</field>
<field name="securityUI">
null
</field>
<constructor>
<![CDATA[
try {
if (!this.hasAttribute("disableHistory")) {
// wire up session history
// XXXdwh On a dynamic skin switch, we should be checking our box object to obtain
// the session history.
this.webNavigation.sessionHistory = Components.classes["@mozilla.org/browser/shistory;1"].createInstance(Components.interfaces.nsISHistory);
try {
if (!this.hasAttribute("disablehistory")) {
// wire up session history
this.webNavigation.sessionHistory = Components.classes["@mozilla.org/browser/shistory;1"].createInstance(Components.interfaces.nsISHistory);
// wire up global history. the same applies here.
var globalHistory = Components.classes["@mozilla.org/browser/global-history;1"].getService(Components.interfaces.nsIGlobalHistory);
// wire up global history
var globalHistory = Components.classes["@mozilla.org/browser/global-history;1"].getService(Components.interfaces.nsIGlobalHistory);
this.docShell.QueryInterface(Components.interfaces.nsIDocShellHistory).globalHistory = globalHistory;
this.docShell.QueryInterface(Components.interfaces.nsIDocShellHistory).globalHistory = globalHistory;
}
}
catch (e) {
}
try {
this.mDragDropHandler = Components.classes["@mozilla.org:/content/content-area-dragdrop;1"].createInstance(Components.interfaces.nsIDragDropHandler);
this.mDragDropHandler.hookupTo(this, null, null, null);
}
catch (e) {
}
try {
const SECUREBROWSERUI_CONTRACTID = "@mozilla.org/secure_browser_ui;1";
if (!this.hasAttribute("disablesecurity") &&
SECUREBROWSERUI_CONTRACTID in Components.classes) {
this.securityUI = Components.classes[SECUREBROWSERUI_CONTRACTID].createInstance(Components.interfaces.nsISecureBrowserUI);
this.securityUI.init(this.contentWindow);
}
}
catch (e) {
}
}
catch (x) { }
try {
this.mDragDropHandler = Components.classes["@mozilla.org:/content/content-area-dragdrop;1"]
.createInstance(Components.interfaces.nsIDragDropHandler);
if ( this.mDragDropHandler )
mDragDropHandler.hookupTo(this,null,null,null);
}
catch (x) { }
]]>
</constructor>
<destructor>
<![CDATA[
if ( this.mDragDropHandler )
mDragDropHandler.detach();
if (this.mDragDropHandler)
this.mDragDropHandler.detach();
this.securityUI = null;
]]>
</destructor>
</implementation>

View File

@ -160,8 +160,8 @@
mIcon: "",
onProgressChange : function (aWebProgress, aRequest,
aCurSelfProgress, aMaxSelfProgress,
aCurTotalProgress, aMaxTotalProgress) {
aCurSelfProgress, aMaxSelfProgress,
aCurTotalProgress, aMaxTotalProgress) {
if (!this.mBlank && this.mTabBrowser.mCurrentTab == this.mTab) {
for (var i = 0; i < this.mTabBrowser.mProgressListeners.length; i++) {
var p = this.mTabBrowser.mProgressListeners[i];
@ -253,7 +253,7 @@
},
onSecurityChange : function(aWebProgress, aRequest, aState) {
if (!this.mBlank && this.mTabBrowser.mCurrentTab == this.mTab) {
if (this.mTabBrowser.mCurrentTab == this.mTab) {
for (var i = 0; i < this.mTabBrowser.mProgressListeners.length; i++) {
var p = this.mTabBrowser.mProgressListeners[i];
if (p)
@ -375,11 +375,14 @@
loc = ({ spec: "" });
var webProgress = this.mCurrentBrowser.webProgress;
var securityUI = this.mCurrentBrowser.securityUI;
var i, p;
for (i = 0; i < this.mProgressListeners.length; i++) {
p = this.mProgressListeners[i];
if (p) {
p.onLocationChange(webProgress, null, loc);
if (securityUI)
p.onSecurityChange(webProgress, null, securityUI.state);
var listener = this.mTabListeners[this.mPanelContainer.selectedIndex];
if (listener.mIcon)
p.onLinkIconAvailable(listener.mIcon);
@ -1069,6 +1072,10 @@
onget="return this.mCurrentBrowser.contentDocument;"
readonly="true"/>
<property name="securityUI"
onget="return this.mCurrentBrowser.securityUI;"
readonly="true"/>
<constructor>
<![CDATA[
this.mCurrentBrowser = this.mPanelContainer.firstChild;