зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1616716 - Implement nsIRemoteWindowContext on ParentChannelListener. r=mayhemer
Differential Revision: https://phabricator.services.mozilla.com/D63427 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
939a89ed58
Коммит
ea53fed3b6
|
@ -25,6 +25,8 @@
|
|||
#include "Element.h"
|
||||
#include "nsILoginManagerAuthPrompter.h"
|
||||
#include "mozilla/dom/CanonicalBrowsingContext.h"
|
||||
#include "mozilla/dom/LoadURIOptionsBinding.h"
|
||||
#include "nsIWebNavigation.h"
|
||||
|
||||
using mozilla::Unused;
|
||||
using mozilla::dom::ServiceWorkerInterceptController;
|
||||
|
@ -49,6 +51,8 @@ ParentChannelListener::ParentChannelListener(nsIStreamListener* aListener,
|
|||
}
|
||||
if (mBrowserParent) {
|
||||
mBrowsingContext = mBrowserParent->GetBrowsingContext();
|
||||
nsCOMPtr<nsILoadContext> loadContext = mBrowserParent->GetLoadContext();
|
||||
mUsePrivateBrowsing = loadContext && loadContext->UsePrivateBrowsing();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -69,6 +73,7 @@ NS_INTERFACE_MAP_BEGIN(ParentChannelListener)
|
|||
NS_INTERFACE_MAP_ENTRY(nsIMultiPartChannelListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsINetworkInterceptController)
|
||||
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIAuthPromptProvider, mBrowsingContext)
|
||||
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIRemoteWindowContext, mBrowsingContext)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIInterfaceRequestor)
|
||||
NS_INTERFACE_MAP_ENTRY_CONCRETE(ParentChannelListener)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
@ -154,7 +159,8 @@ ParentChannelListener::OnAfterLastPart(nsresult aStatus) {
|
|||
|
||||
NS_IMETHODIMP
|
||||
ParentChannelListener::GetInterface(const nsIID& aIID, void** result) {
|
||||
if (aIID.Equals(NS_GET_IID(nsINetworkInterceptController))) {
|
||||
if (aIID.Equals(NS_GET_IID(nsINetworkInterceptController)) ||
|
||||
aIID.Equals(NS_GET_IID(nsIRemoteWindowContext))) {
|
||||
return QueryInterface(aIID, result);
|
||||
}
|
||||
|
||||
|
@ -189,13 +195,6 @@ ParentChannelListener::GetInterface(const nsIID& aIID, void** result) {
|
|||
return GetAuthPrompt(nsIAuthPromptProvider::PROMPT_NORMAL, aIID, result);
|
||||
}
|
||||
|
||||
if (aIID.Equals(NS_GET_IID(nsIRemoteWindowContext)) && mBrowserParent) {
|
||||
nsCOMPtr<nsIRemoteWindowContext> ctx(
|
||||
new dom::RemoteWindowContext(mBrowserParent));
|
||||
ctx.forget(result);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIInterfaceRequestor> ir;
|
||||
if (mNextListener && NS_SUCCEEDED(CallQueryInterface(mNextListener.get(),
|
||||
getter_AddRefs(ir)))) {
|
||||
|
@ -417,5 +416,31 @@ ParentChannelListener::GetAuthPrompt(uint32_t aPromptReason, const nsIID& iid,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// ParentChannelListener::nsIRemoteWindowContext
|
||||
//
|
||||
|
||||
NS_IMETHODIMP
|
||||
ParentChannelListener::OpenURI(nsIURI* aURI) {
|
||||
nsCString spec;
|
||||
aURI->GetSpec(spec);
|
||||
|
||||
dom::LoadURIOptions loadURIOptions;
|
||||
loadURIOptions.mTriggeringPrincipal = nsContentUtils::GetSystemPrincipal();
|
||||
loadURIOptions.mLoadFlags =
|
||||
nsIWebNavigation::LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP |
|
||||
nsIWebNavigation::LOAD_FLAGS_DISALLOW_INHERIT_PRINCIPAL;
|
||||
|
||||
ErrorResult rv;
|
||||
mBrowsingContext->LoadURI(NS_ConvertUTF8toUTF16(spec), loadURIOptions, rv);
|
||||
return rv.StealNSResult();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ParentChannelListener::GetUsePrivateBrowsing(bool* aUsePrivateBrowsing) {
|
||||
*aUsePrivateBrowsing = mUsePrivateBrowsing;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // namespace net
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "nsINetworkInterceptController.h"
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsIMultiPartChannel.h"
|
||||
#include "nsIRemoteWindowContext.h"
|
||||
#include "mozilla/dom/BrowserParent.h"
|
||||
#include "mozilla/dom/CanonicalBrowsingContext.h"
|
||||
|
||||
|
@ -34,7 +35,8 @@ class ParentChannelListener final : public nsIInterfaceRequestor,
|
|||
public nsIStreamListener,
|
||||
public nsIMultiPartChannelListener,
|
||||
public nsINetworkInterceptController,
|
||||
private nsIAuthPromptProvider {
|
||||
private nsIAuthPromptProvider,
|
||||
private nsIRemoteWindowContext {
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIINTERFACEREQUESTOR
|
||||
|
@ -43,6 +45,7 @@ class ParentChannelListener final : public nsIInterfaceRequestor,
|
|||
NS_DECL_NSIMULTIPARTCHANNELLISTENER
|
||||
NS_DECL_NSINETWORKINTERCEPTCONTROLLER
|
||||
NS_DECL_NSIAUTHPROMPTPROVIDER
|
||||
NS_DECL_NSIREMOTEWINDOWCONTEXT
|
||||
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(PARENT_CHANNEL_LISTENER)
|
||||
|
||||
|
@ -99,6 +102,9 @@ class ParentChannelListener final : public nsIInterfaceRequestor,
|
|||
// True if we received OnStartRequest for a nsIMultiPartChannel, and are
|
||||
// expected AllPartsStopped to be called when complete.
|
||||
bool mIsMultiPart = false;
|
||||
|
||||
// True if the nsILoadContext for this channel has private browsing enabled.
|
||||
bool mUsePrivateBrowsing = false;
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(ParentChannelListener, PARENT_CHANNEL_LISTENER)
|
||||
|
|
Загрузка…
Ссылка в новой задаче