Fixing bug 277564. Make sure to update the lock icon state correctly when dealing with wyciwyg: URLs. r=bugmail@sicking.cc, dveditz@cruzio.com, darin@meer.net, sr=brendan@mozilla.org, a=asa@mozilla.org

This commit is contained in:
jst%mozilla.jstenback.com 2005-01-12 00:00:53 +00:00
parent c9254ad5f7
commit 21799339e6
4 changed files with 132 additions and 84 deletions

View File

@ -1305,6 +1305,14 @@ nsDocShell::SetParentURIContentListener(nsIURIContentListener * aParent)
/* [noscript] void setCurrentURI (in nsIURI uri); */
NS_IMETHODIMP
nsDocShell::SetCurrentURI(nsIURI *aURI)
{
SetCurrentURI(aURI, nsnull);
return NS_OK;
}
void
nsDocShell::SetCurrentURI(nsIURI *aURI, nsIRequest *aRequest)
{
mCurrentURI = aURI; //This assignment addrefs
PRBool isRoot = PR_FALSE; // Is this the root docshell
@ -1333,12 +1341,10 @@ nsDocShell::SetCurrentURI(nsIURI *aURI)
* a subframe is being loaded for the first time, while
* visiting a frameset page
*/
return NS_OK;
return;
}
FireOnLocationChange(this, nsnull, aURI);
return NS_OK;
FireOnLocationChange(this, aRequest, aURI);
}
NS_IMETHODIMP
@ -4369,7 +4375,7 @@ nsDocShell::OnStateChange(nsIWebProgress * aProgress, nsIRequest * aRequest,
// This is a document.write(). Get the made-up url
// from the channel and store it in session history.
rv = AddToSessionHistory(uri, wcwgChannel, getter_AddRefs(mLSHE));
SetCurrentURI(uri);
SetCurrentURI(uri, aRequest);
// Save history state of the previous page
rv = PersistLayoutHistoryState();
if (mOSHE)
@ -4608,7 +4614,7 @@ nsDocShell::CreateAboutBlankContentViewer()
Embed(viewer, "", 0);
viewer->SetDOMDocument(domdoc);
SetCurrentURI(blankDoc->GetDocumentURI());
SetCurrentURI(blankDoc->GetDocumentURI(), nsnull);
rv = NS_OK;
}
}
@ -6217,7 +6223,7 @@ nsDocShell::OnNewURI(nsIURI * aURI, nsIChannel * aChannel,
if (shInternal)
shInternal->UpdateIndex();
}
SetCurrentURI(aURI);
SetCurrentURI(aURI, aChannel);
// if there's a refresh header in the channel, this method
// will set it up for us.
SetupRefreshURI(aChannel);

View File

@ -342,6 +342,8 @@ protected:
nsresult CheckLoadingPermissions();
void SetCurrentURI(nsIURI *aURI, nsIRequest *aRequest);
protected:
// Override the parent setter from nsDocLoader
virtual nsresult SetDocLoaderParent(nsDocLoader * aLoader);

View File

@ -381,6 +381,79 @@ void nsSecureBrowserUIImpl::ResetStateTracking()
sizeof(RequestHashEntry), 16);
}
nsresult
nsSecureBrowserUIImpl::EvaluateAndUpdateSecurityState(nsIRequest *aRequest)
{
nsCOMPtr<nsIChannel> channel(do_QueryInterface(aRequest));
if (!channel) {
mNewToplevelSecurityState = nsIWebProgressListener::STATE_IS_INSECURE;
} else {
mNewToplevelSecurityState = GetSecurityStateFromChannel(channel);
PR_LOG(gSecureDocLog, PR_LOG_DEBUG,
("SecureUI:%p: OnStateChange: remember mNewToplevelSecurityState => %x\n", this,
mNewToplevelSecurityState));
// Get SSL Status information if possible
nsCOMPtr<nsISupports> info;
channel->GetSecurityInfo(getter_AddRefs(info));
nsCOMPtr<nsISSLStatusProvider> sp = do_QueryInterface(info);
if (sp) {
// Ignore result
sp->GetSSLStatus(getter_AddRefs(mSSLStatus));
}
if (info) {
nsCOMPtr<nsITransportSecurityInfo> secInfo(do_QueryInterface(info));
if (secInfo) {
secInfo->GetShortSecurityDescription(getter_Copies(mInfoTooltip));
}
}
}
// assume mNewToplevelSecurityState was set in this scope!
// see code that is directly above
mNewToplevelSecurityStateKnown = PR_TRUE;
return UpdateSecurityState(aRequest);
}
void
nsSecureBrowserUIImpl::UpdateSubrequestMembers(nsIRequest *aRequest)
{
// For wyciwyg channels in subdocuments we only update our
// subrequest state members.
PRUint32 reqState = nsIWebProgressListener::STATE_IS_INSECURE;
nsCOMPtr<nsIChannel> channel(do_QueryInterface(aRequest));
if (channel) {
reqState = GetSecurityStateFromChannel(channel);
}
if (reqState & STATE_IS_SECURE) {
if (reqState & STATE_SECURE_LOW || reqState & STATE_SECURE_MED) {
PR_LOG(gSecureDocLog, PR_LOG_DEBUG,
("SecureUI:%p: OnStateChange: subreq LOW\n", this));
++mSubRequestsLowSecurity;
} else {
PR_LOG(gSecureDocLog, PR_LOG_DEBUG,
("SecureUI:%p: OnStateChange: subreq HIGH\n", this));
++mSubRequestsHighSecurity;
}
} else if (reqState & STATE_IS_BROKEN) {
PR_LOG(gSecureDocLog, PR_LOG_DEBUG,
("SecureUI:%p: OnStateChange: subreq BROKEN\n", this));
++mSubRequestsBrokenSecurity;
} else {
PR_LOG(gSecureDocLog, PR_LOG_DEBUG,
("SecureUI:%p: OnStateChange: subreq INSECURE\n", this));
++mSubRequestsNoSecurity;
}
}
NS_IMETHODIMP
nsSecureBrowserUIImpl::OnStateChange(nsIWebProgress* aWebProgress,
nsIRequest* aRequest,
@ -794,50 +867,11 @@ nsSecureBrowserUIImpl::OnStateChange(nsIWebProgress* aWebProgress,
--mDocumentRequestsInProgress;
{
PRBool MustEvaluate = PR_TRUE;
if (requestHasTransferedData) {
// Data has been transferred for the single toplevel
// request. Evaluate the security state.
if (!requestHasTransferedData)
{
// No data has been transfered for the single toplevel request.
MustEvaluate = PR_FALSE;
}
if (MustEvaluate)
{
if (channel) {
mNewToplevelSecurityState = GetSecurityStateFromChannel(channel);
PR_LOG(gSecureDocLog, PR_LOG_DEBUG,
("SecureUI:%p: OnStateChange: remember mNewToplevelSecurityState => %x\n", this,
mNewToplevelSecurityState));
// Get SSL Status information if possible
nsCOMPtr<nsISupports> info;
channel->GetSecurityInfo(getter_AddRefs(info));
nsCOMPtr<nsISSLStatusProvider> sp = do_QueryInterface(info);
if (sp) {
// Ignore result
sp->GetSSLStatus(getter_AddRefs(mSSLStatus));
}
if (info) {
nsCOMPtr<nsITransportSecurityInfo> secInfo(do_QueryInterface(info));
if (secInfo) {
secInfo->GetShortSecurityDescription(getter_Copies(mInfoTooltip));
}
}
}
else {
mNewToplevelSecurityState = nsIWebProgressListener::STATE_IS_INSECURE;
}
// assume mNewToplevelSecurityState was set in this scope!
// see code that is directly above
mNewToplevelSecurityStateKnown = PR_TRUE;
return UpdateSecurityState(aRequest);
}
return EvaluateAndUpdateSecurityState(aRequest);
}
return NS_OK;
@ -856,39 +890,7 @@ nsSecureBrowserUIImpl::OnStateChange(nsIWebProgress* aWebProgress,
if (requestHasTransferedData)
{
PRUint32 reqState = nsIWebProgressListener::STATE_IS_INSECURE;
if (channel) {
reqState = GetSecurityStateFromChannel(channel);
}
if (reqState & STATE_IS_SECURE)
{
if (reqState & STATE_SECURE_LOW || reqState & STATE_SECURE_MED)
{
PR_LOG(gSecureDocLog, PR_LOG_DEBUG,
("SecureUI:%p: OnStateChange: subreq LOW\n", this));
++mSubRequestsLowSecurity;
}
else
{
PR_LOG(gSecureDocLog, PR_LOG_DEBUG,
("SecureUI:%p: OnStateChange: subreq HIGH\n", this));
++mSubRequestsHighSecurity;
}
}
else if (reqState & STATE_IS_BROKEN)
{
PR_LOG(gSecureDocLog, PR_LOG_DEBUG,
("SecureUI:%p: OnStateChange: subreq BROKEN\n", this));
++ mSubRequestsBrokenSecurity;
}
else
{
PR_LOG(gSecureDocLog, PR_LOG_DEBUG,
("SecureUI:%p: OnStateChange: subreq INSECURE\n", this));
++mSubRequestsNoSecurity;
}
UpdateSubrequestMembers(aRequest);
// Care for the following scenario:
// A new top level document load might have already started,
@ -1117,11 +1119,16 @@ nsSecureBrowserUIImpl::OnLocationChange(nsIWebProgress* aWebProgress,
nsIRequest* aRequest,
nsIURI* aLocation)
{
PRBool isWyciwyg = PR_FALSE;
if (aLocation)
{
nsresult rv = aLocation->SchemeIs("wyciwyg", &isWyciwyg);
NS_ENSURE_SUCCESS(rv, rv);
PRBool vs;
nsresult rv = aLocation->SchemeIs("view-source", &vs);
rv = aLocation->SchemeIs("view-source", &vs);
NS_ENSURE_SUCCESS(rv, rv);
if (vs) {
@ -1134,6 +1141,36 @@ nsSecureBrowserUIImpl::OnLocationChange(nsIWebProgress* aWebProgress,
mCurrentURI = aLocation;
if (isWyciwyg) {
nsCOMPtr<nsIDOMWindow> windowForProgress;
aWebProgress->GetDOMWindow(getter_AddRefs(windowForProgress));
if (windowForProgress.get() == mWindow.get()) {
// For toplevel wyciwyg channels, upate the security state right
// away.
return EvaluateAndUpdateSecurityState(aRequest);
}
// For wyciwyg channels in subdocuments we only update our
// subrequest state members.
UpdateSubrequestMembers(aRequest);
// Care for the following scenario:
// A new top level document load might have already started, but
// the security state of the new top level document might not yet
// been known.
//
// At this point, we are learning about the security state of a
// sub-document. We must not update the security state based on
// the sub content, if the new top level state is not yet known.
//
// We skip updating the security state in this case.
if (mNewToplevelSecurityStateKnown)
return UpdateSecurityState(aRequest);
}
return NS_OK;
}

View File

@ -121,6 +121,9 @@ protected:
PRInt32 mSubRequestsNoSecurity;
nsresult UpdateSecurityState(nsIRequest* aRequest);
nsresult EvaluateAndUpdateSecurityState(nsIRequest *aRequest);
void UpdateSubrequestMembers(nsIRequest *aRequest);
void ObtainEventSink(nsIChannel *channel);
nsCOMPtr<nsISupports> mSSLStatus;