diff --git a/netwerk/base/src/PrivateBrowsingChannel.h b/netwerk/base/src/PrivateBrowsingChannel.h index 451915c4cc1a..367ebe4d997b 100644 --- a/netwerk/base/src/PrivateBrowsingChannel.h +++ b/netwerk/base/src/PrivateBrowsingChannel.h @@ -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 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 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: diff --git a/netwerk/protocol/ftp/FTPChannelChild.cpp b/netwerk/protocol/ftp/FTPChannelChild.cpp index f6a3759475de..58af33162536 100644 --- a/netwerk/protocol/ftp/FTPChannelChild.cpp +++ b/netwerk/protocol/ftp/FTPChannelChild.cpp @@ -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; } diff --git a/netwerk/protocol/ftp/nsFTPChannel.cpp b/netwerk/protocol/ftp/nsFTPChannel.cpp index 0866805f17fe..4a3ca176382f 100644 --- a/netwerk/protocol/ftp/nsFTPChannel.cpp +++ b/netwerk/protocol/ftp/nsFTPChannel.cpp @@ -222,7 +222,7 @@ nsFtpChannel::GetFTPEventSink(nsCOMPtr &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; } diff --git a/netwerk/protocol/http/HttpBaseChannel.cpp b/netwerk/protocol/http/HttpBaseChannel.cpp index cf73b391bc0b..02d28bee4954 100644 --- a/netwerk/protocol/http/HttpBaseChannel.cpp +++ b/netwerk/protocol/http/HttpBaseChannel.cpp @@ -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; } diff --git a/netwerk/protocol/wyciwyg/WyciwygChannelChild.cpp b/netwerk/protocol/wyciwyg/WyciwygChannelChild.cpp index 0a8da5ed31d0..98cc0eea4853 100644 --- a/netwerk/protocol/wyciwyg/WyciwygChannelChild.cpp +++ b/netwerk/protocol/wyciwyg/WyciwygChannelChild.cpp @@ -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; } diff --git a/netwerk/protocol/wyciwyg/nsWyciwygChannel.cpp b/netwerk/protocol/wyciwyg/nsWyciwygChannel.cpp index f687eaea7480..f40aa36c4d61 100644 --- a/netwerk/protocol/wyciwyg/nsWyciwygChannel.cpp +++ b/netwerk/protocol/wyciwyg/nsWyciwygChannel.cpp @@ -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; }