Bug 788275 - Part 1: Only check whether the PB state bit overridden condition holds for the cases where we actually have a load context around; r=jduell

This commit is contained in:
Ehsan Akhgari 2012-09-26 10:36:38 -04:00
Родитель 96053589c9
Коммит 14ce0f9814
6 изменённых файлов: 32 добавлений и 14 удалений

Просмотреть файл

@ -11,6 +11,8 @@
#include "nsCOMPtr.h"
#include "nsILoadGroup.h"
#include "nsILoadContext.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsIInterfaceRequestor.h"
namespace mozilla {
namespace net {
@ -56,19 +58,35 @@ public:
return NS_OK;
}
bool CanSetCallbacks() const
bool CanSetCallbacks(nsIInterfaceRequestor* aCallbacks) const
{
// Make sure that the private bit override flag is not set.
// This is a fatal error in debug builds, and a runtime error in release
// builds.
if (!aCallbacks) {
return true;
}
nsCOMPtr<nsILoadContext> loadContext = do_GetInterface(aCallbacks);
if (!loadContext) {
return true;
}
MOZ_ASSERT(!mPrivateBrowsingOverriden);
return !mPrivateBrowsingOverriden;
}
bool CanSetLoadGroup() const
bool CanSetLoadGroup(nsILoadGroup* aLoadGroup) const
{
// We can set a load group whenever we can set a callback
return CanSetCallbacks();
// Make sure that the private bit override flag is not set.
// This is a fatal error in debug builds, and a runtime error in release
// builds.
if (!aLoadGroup) {
return true;
}
nsCOMPtr<nsIInterfaceRequestor> callbacks;
aLoadGroup->GetNotificationCallbacks(getter_AddRefs(callbacks));
// From this point on, we just hand off the work to CanSetCallbacks,
// because the logic is exactly the same.
return CanSetCallbacks(callbacks);
}
protected:

Просмотреть файл

@ -550,7 +550,7 @@ FTPChannelChild::CompleteRedirectSetup(nsIStreamListener *listener,
NS_IMETHODIMP
FTPChannelChild::SetNotificationCallbacks(nsIInterfaceRequestor* aCallbacks)
{
if (!CanSetCallbacks()) {
if (!CanSetCallbacks(aCallbacks)) {
return NS_ERROR_FAILURE;
}
@ -560,7 +560,7 @@ FTPChannelChild::SetNotificationCallbacks(nsIInterfaceRequestor* aCallbacks)
NS_IMETHODIMP
FTPChannelChild::SetLoadGroup(nsILoadGroup * aLoadGroup)
{
if (!CanSetLoadGroup()) {
if (!CanSetLoadGroup(aLoadGroup)) {
return NS_ERROR_FAILURE;
}

Просмотреть файл

@ -222,7 +222,7 @@ nsFtpChannel::GetFTPEventSink(nsCOMPtr<nsIFTPEventSink> &aResult)
NS_IMETHODIMP
nsFtpChannel::SetNotificationCallbacks(nsIInterfaceRequestor* aCallbacks)
{
if (!CanSetCallbacks()) {
if (!CanSetCallbacks(aCallbacks)) {
return NS_ERROR_FAILURE;
}
@ -232,7 +232,7 @@ nsFtpChannel::SetNotificationCallbacks(nsIInterfaceRequestor* aCallbacks)
NS_IMETHODIMP
nsFtpChannel::SetLoadGroup(nsILoadGroup * aLoadGroup)
{
if (!CanSetLoadGroup()) {
if (!CanSetLoadGroup(aLoadGroup)) {
return NS_ERROR_FAILURE;
}

Просмотреть файл

@ -189,7 +189,7 @@ HttpBaseChannel::GetLoadGroup(nsILoadGroup **aLoadGroup)
NS_IMETHODIMP
HttpBaseChannel::SetLoadGroup(nsILoadGroup *aLoadGroup)
{
if (!CanSetLoadGroup()) {
if (!CanSetLoadGroup(aLoadGroup)) {
return NS_ERROR_FAILURE;
}
@ -273,7 +273,7 @@ HttpBaseChannel::GetNotificationCallbacks(nsIInterfaceRequestor **aCallbacks)
NS_IMETHODIMP
HttpBaseChannel::SetNotificationCallbacks(nsIInterfaceRequestor *aCallbacks)
{
if (!CanSetCallbacks()) {
if (!CanSetCallbacks(aCallbacks)) {
return NS_ERROR_FAILURE;
}

Просмотреть файл

@ -385,7 +385,7 @@ WyciwygChannelChild::GetLoadGroup(nsILoadGroup * *aLoadGroup)
NS_IMETHODIMP
WyciwygChannelChild::SetLoadGroup(nsILoadGroup * aLoadGroup)
{
if (!CanSetLoadGroup()) {
if (!CanSetLoadGroup(aLoadGroup)) {
return NS_ERROR_FAILURE;
}
@ -471,7 +471,7 @@ WyciwygChannelChild::GetNotificationCallbacks(nsIInterfaceRequestor * *aCallback
NS_IMETHODIMP
WyciwygChannelChild::SetNotificationCallbacks(nsIInterfaceRequestor * aCallbacks)
{
if (!CanSetCallbacks()) {
if (!CanSetCallbacks(aCallbacks)) {
return NS_ERROR_FAILURE;
}

Просмотреть файл

@ -188,7 +188,7 @@ nsWyciwygChannel::GetLoadGroup(nsILoadGroup* *aLoadGroup)
NS_IMETHODIMP
nsWyciwygChannel::SetLoadGroup(nsILoadGroup* aLoadGroup)
{
if (!CanSetLoadGroup()) {
if (!CanSetLoadGroup(aLoadGroup)) {
return NS_ERROR_FAILURE;
}
@ -271,7 +271,7 @@ nsWyciwygChannel::GetNotificationCallbacks(nsIInterfaceRequestor* *aCallbacks)
NS_IMETHODIMP
nsWyciwygChannel::SetNotificationCallbacks(nsIInterfaceRequestor* aNotificationCallbacks)
{
if (!CanSetCallbacks()) {
if (!CanSetCallbacks(aNotificationCallbacks)) {
return NS_ERROR_FAILURE;
}