From 382b3408557b6cb8825f2dd6844adcbe5cdef6f8 Mon Sep 17 00:00:00 2001 From: Ed Morley Date: Mon, 9 Jun 2014 11:28:02 +0100 Subject: [PATCH] Backed out changeset 820e34a74647 (bug 890570) --- docshell/base/LoadContext.cpp | 8 - docshell/base/LoadContext.h | 21 --- docshell/base/nsDocShell.cpp | 7 - docshell/base/nsDocShell.h | 1 - docshell/base/nsILoadContext.idl | 10 +- .../BrowserElementPromptService.jsm | 9 +- dom/ipc/PBrowser.ipdl | 9 -- dom/ipc/TabChild.cpp | 13 -- dom/ipc/TabChild.h | 22 --- dom/ipc/TabParent.cpp | 145 ------------------ dom/ipc/TabParent.h | 4 - netwerk/ipc/NeckoChild.cpp | 23 +-- netwerk/ipc/NeckoChild.h | 11 +- netwerk/ipc/NeckoParent.cpp | 128 ++-------------- netwerk/ipc/NeckoParent.h | 60 ++------ netwerk/ipc/PNecko.ipdl | 29 +--- netwerk/protocol/http/HttpChannelChild.cpp | 18 +-- netwerk/protocol/http/HttpChannelParent.cpp | 34 +--- netwerk/protocol/http/HttpChannelParent.h | 9 +- .../prefetch/OfflineCacheUpdateParent.cpp | 6 - 20 files changed, 49 insertions(+), 518 deletions(-) diff --git a/docshell/base/LoadContext.cpp b/docshell/base/LoadContext.cpp index 9b46f2de0a0f..8f453f6637fd 100644 --- a/docshell/base/LoadContext.cpp +++ b/docshell/base/LoadContext.cpp @@ -40,14 +40,6 @@ LoadContext::GetTopFrameElement(nsIDOMElement** aElement) return NS_OK; } -NS_IMETHODIMP -LoadContext::GetNestedFrameId(uint64_t* aId) -{ - NS_ENSURE_ARG(aId); - *aId = mNestedFrameId; - return NS_OK; -} - NS_IMETHODIMP LoadContext::IsAppOfType(uint32_t, bool*) { diff --git a/docshell/base/LoadContext.h b/docshell/base/LoadContext.h index 83d997abd267..48a7b41fca76 100644 --- a/docshell/base/LoadContext.h +++ b/docshell/base/LoadContext.h @@ -45,24 +45,6 @@ public: dom::Element* aTopFrameElement, uint32_t aAppId, bool aInBrowser) : mTopFrameElement(do_GetWeakReference(aTopFrameElement)) - , mNestedFrameId(0) - , mAppId(aAppId) - , mIsContent(aToCopy.mIsContent) - , mUsePrivateBrowsing(aToCopy.mUsePrivateBrowsing) - , mUseRemoteTabs(aToCopy.mUseRemoteTabs) - , mIsInBrowserElement(aInBrowser) -#ifdef DEBUG - , mIsNotNull(aToCopy.mIsNotNull) -#endif - {} - - // AppId/inBrowser arguments override those in SerializedLoadContext provided - // by child process. - LoadContext(const IPC::SerializedLoadContext& aToCopy, - uint64_t aNestedFrameId, - uint32_t aAppId, bool aInBrowser) - : mTopFrameElement(nullptr) - , mNestedFrameId(aNestedFrameId) , mAppId(aAppId) , mIsContent(aToCopy.mIsContent) , mUsePrivateBrowsing(aToCopy.mUsePrivateBrowsing) @@ -80,7 +62,6 @@ public: bool aUseRemoteTabs, bool aIsInBrowserElement) : mTopFrameElement(do_GetWeakReference(aTopFrameElement)) - , mNestedFrameId(0) , mAppId(aAppId) , mIsContent(aIsContent) , mUsePrivateBrowsing(aUsePrivateBrowsing) @@ -94,7 +75,6 @@ public: // Constructor taking reserved appId for the safebrowsing cookie. LoadContext(uint32_t aAppId) : mTopFrameElement(nullptr) - , mNestedFrameId(0) , mAppId(aAppId) , mIsContent(false) , mUsePrivateBrowsing(false) @@ -107,7 +87,6 @@ public: private: nsWeakPtr mTopFrameElement; - uint64_t mNestedFrameId; uint32_t mAppId; bool mIsContent; bool mUsePrivateBrowsing; diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 790b1607771c..a9fe46fdba99 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -12260,13 +12260,6 @@ nsDocShell::GetTopFrameElement(nsIDOMElement** aElement) return top->GetFrameElement(aElement); } -NS_IMETHODIMP -nsDocShell::GetNestedFrameId(uint64_t* aId) -{ - *aId = 0; - return NS_OK; -} - NS_IMETHODIMP nsDocShell::IsAppOfType(uint32_t aAppType, bool *aIsOfType) { diff --git a/docshell/base/nsDocShell.h b/docshell/base/nsDocShell.h index 6e9b1eefb565..367677ebceac 100644 --- a/docshell/base/nsDocShell.h +++ b/docshell/base/nsDocShell.h @@ -210,7 +210,6 @@ public: NS_IMETHOD GetAssociatedWindow(nsIDOMWindow**); NS_IMETHOD GetTopWindow(nsIDOMWindow**); NS_IMETHOD GetTopFrameElement(nsIDOMElement**); - NS_IMETHOD GetNestedFrameId(uint64_t*); NS_IMETHOD IsAppOfType(uint32_t, bool*); NS_IMETHOD GetIsContent(bool*); NS_IMETHOD GetUsePrivateBrowsing(bool*); diff --git a/docshell/base/nsILoadContext.idl b/docshell/base/nsILoadContext.idl index 7a9ddde9c024..87327c5883f9 100644 --- a/docshell/base/nsILoadContext.idl +++ b/docshell/base/nsILoadContext.idl @@ -14,7 +14,7 @@ interface nsIDOMElement; * can be queried for various information about where the load is * happening. */ -[scriptable, uuid(6ec837fa-af93-4350-bbb8-0985d54c74ca)] +[scriptable, uuid(852ed1f0-8ec0-11e3-baa8-0800200c9a66)] interface nsILoadContext : nsISupports { /** @@ -43,14 +43,6 @@ interface nsILoadContext : nsISupports */ readonly attribute nsIDOMElement topFrameElement; - /** - * If this LoadContext corresponds to a nested remote iframe, we don't have - * access to the topFrameElement. Instead, we must use this id to send - * messages. A return value of 0 signifies that this load context is not for - * a nested frame. - */ - readonly attribute unsigned long long nestedFrameId; - /** * Check whether the load is happening in a particular type of application. * diff --git a/dom/browser-element/BrowserElementPromptService.jsm b/dom/browser-element/BrowserElementPromptService.jsm index 9830dd079e65..8f66c4254148 100644 --- a/dom/browser-element/BrowserElementPromptService.jsm +++ b/dom/browser-element/BrowserElementPromptService.jsm @@ -442,12 +442,9 @@ AuthPromptWrapper.prototype = { _canGetParentElement: function(channel) { try { - let context = channel.notificationCallbacks.getInterface(Ci.nsILoadContext); - let frame = context.topFrameElement; - if (!frame) { - // This function returns a boolean value - return !!context.nestedFrameId; - } + let frame = channel.notificationCallbacks.getInterface(Ci.nsILoadContext).topFrameElement; + if (!frame) + return false; if (!BrowserElementPromptService.getBrowserElementParentForFrame(frame)) return false; diff --git a/dom/ipc/PBrowser.ipdl b/dom/ipc/PBrowser.ipdl index fbf60c81e510..c643662e1db0 100644 --- a/dom/ipc/PBrowser.ipdl +++ b/dom/ipc/PBrowser.ipdl @@ -357,15 +357,6 @@ parent: UpdateZoomConstraints(uint32_t aPresShellId, ViewID aViewId, bool aIsRoot, ZoomConstraints aConstraints); - /** - * Brings up the auth prompt dialog. - * Called when this is the PBrowserParent for a nested remote iframe. - * aCallbackId corresponds to an nsIAuthPromptCallback that lives in the - * root process. It will be passed back to the root process with either the - * OnAuthAvailable or OnAuthCancelled message. - */ - AsyncAuthPrompt(nsCString uri, nsString realm, uint64_t aCallbackId); - __delete__(); ReplyKeyEvent(WidgetKeyboardEvent event); diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index 6eb00240f45c..7bdf69214877 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -617,15 +617,6 @@ private: StaticRefPtr sPreallocatedTab; -/*static*/ -std::map >& -TabChild::NestedTabChildMap() -{ - MOZ_ASSERT(NS_IsMainThread()); - static std::map > sNestedTabChildMap; - return sNestedTabChildMap; -} - /*static*/ void TabChild::PreloadSlowThings() { @@ -705,7 +696,6 @@ TabChild::TabChild(nsIContentChild* aManager, const TabContext& aContext, uint32 , mIgnoreKeyPressEvent(false) , mActiveElementManager(new ActiveElementManager()) , mHasValidInnerSize(false) - , mUniqueId(0) { if (!sActiveDurationMsSet) { Preferences::AddIntVarCache(&sActiveDurationMs, @@ -1382,9 +1372,6 @@ TabChild::ActorDestroy(ActorDestroyReason why) (mTabChildGlobal->mMessageManager.get())->Disconnect(); mTabChildGlobal->mMessageManager = nullptr; } - if (Id() != 0) { - NestedTabChildMap().erase(Id()); - } } TabChild::~TabChild() diff --git a/dom/ipc/TabChild.h b/dom/ipc/TabChild.h index e3044c188b6c..0f9218f05369 100644 --- a/dom/ipc/TabChild.h +++ b/dom/ipc/TabChild.h @@ -240,9 +240,6 @@ class TabChild : public TabChildBase, typedef mozilla::layout::ScrollingBehavior ScrollingBehavior; typedef mozilla::layers::ActiveElementManager ActiveElementManager; -public: - static std::map >& NestedTabChildMap(); - public: /** * This is expected to be called off the critical path to content @@ -259,24 +256,6 @@ public: bool IsRootContentDocument(); - const uint64_t Id() const { - return mUniqueId; - } - - static uint64_t - GetTabChildId(TabChild* aTabChild) - { - MOZ_ASSERT(NS_IsMainThread()); - if (aTabChild->Id() != 0) { - return aTabChild->Id(); - } - static uint64_t sId = 0; - sId++; - aTabChild->mUniqueId = sId; - NestedTabChildMap()[sId] = aTabChild; - return sId; - } - NS_DECL_ISUPPORTS_INHERITED NS_DECL_NSIWEBBROWSERCHROME NS_DECL_NSIWEBBROWSERCHROME2 @@ -589,7 +568,6 @@ private: bool mIgnoreKeyPressEvent; nsRefPtr mActiveElementManager; bool mHasValidInnerSize; - uint64_t mUniqueId; DISALLOW_EVIL_CONSTRUCTORS(TabChild); }; diff --git a/dom/ipc/TabParent.cpp b/dom/ipc/TabParent.cpp index 64224f012bee..679771333a9f 100644 --- a/dom/ipc/TabParent.cpp +++ b/dom/ipc/TabParent.cpp @@ -22,7 +22,6 @@ #include "mozilla/layers/CompositorParent.h" #include "mozilla/layout/RenderFrameParent.h" #include "mozilla/MouseEvents.h" -#include "mozilla/net/NeckoChild.h" #include "mozilla/Preferences.h" #include "mozilla/TextEvents.h" #include "mozilla/TouchEvents.h" @@ -62,10 +61,6 @@ #include "TabChild.h" #include "LoadContext.h" #include "nsNetCID.h" -#include "nsIAuthInformation.h" -#include "nsIAuthPromptCallback.h" -#include "nsAuthInformationHolder.h" -#include "nsICancelable.h" #include "gfxPrefs.h" #include @@ -2081,145 +2076,5 @@ TabParent::SetIsDocShellActive(bool isActive) return NS_OK; } -class FakeChannel MOZ_FINAL : public nsIChannel, - public nsIAuthPromptCallback, - public nsIInterfaceRequestor, - public nsILoadContext -{ -public: - FakeChannel(const nsCString& aUri, uint64_t aCallbackId, Element* aElement) - : mCallbackId(aCallbackId) - , mElement(aElement) - { - NS_NewURI(getter_AddRefs(mUri), aUri); - } - - NS_DECL_ISUPPORTS -#define NO_IMPL { return NS_ERROR_NOT_IMPLEMENTED; } - NS_IMETHOD GetName(nsACString&) NO_IMPL - NS_IMETHOD IsPending(bool*) NO_IMPL - NS_IMETHOD GetStatus(nsresult*) NO_IMPL - NS_IMETHOD Cancel(nsresult) NO_IMPL - NS_IMETHOD Suspend() NO_IMPL - NS_IMETHOD Resume() NO_IMPL - NS_IMETHOD GetLoadGroup(nsILoadGroup**) NO_IMPL - NS_IMETHOD SetLoadGroup(nsILoadGroup*) NO_IMPL - NS_IMETHOD SetLoadFlags(nsLoadFlags) NO_IMPL - NS_IMETHOD GetLoadFlags(nsLoadFlags*) NO_IMPL - NS_IMETHOD GetOriginalURI(nsIURI**) NO_IMPL - NS_IMETHOD SetOriginalURI(nsIURI*) NO_IMPL - NS_IMETHOD GetURI(nsIURI** aUri) - { - NS_IF_ADDREF(mUri); - *aUri = mUri; - return NS_OK; - } - NS_IMETHOD GetOwner(nsISupports**) NO_IMPL - NS_IMETHOD SetOwner(nsISupports*) NO_IMPL - NS_IMETHOD GetNotificationCallbacks(nsIInterfaceRequestor** aRequestor) - { - NS_ADDREF(*aRequestor = this); - return NS_OK; - } - NS_IMETHOD SetNotificationCallbacks(nsIInterfaceRequestor*) NO_IMPL - NS_IMETHOD GetSecurityInfo(nsISupports**) NO_IMPL - NS_IMETHOD GetContentType(nsACString&) NO_IMPL - NS_IMETHOD SetContentType(const nsACString&) NO_IMPL - NS_IMETHOD GetContentCharset(nsACString&) NO_IMPL - NS_IMETHOD SetContentCharset(const nsACString&) NO_IMPL - NS_IMETHOD GetContentLength(int64_t*) NO_IMPL - NS_IMETHOD SetContentLength(int64_t) NO_IMPL - NS_IMETHOD Open(nsIInputStream**) NO_IMPL - NS_IMETHOD AsyncOpen(nsIStreamListener*, nsISupports*) NO_IMPL - NS_IMETHOD GetContentDisposition(uint32_t*) NO_IMPL - NS_IMETHOD SetContentDisposition(uint32_t) NO_IMPL - NS_IMETHOD GetContentDispositionFilename(nsAString&) NO_IMPL - NS_IMETHOD SetContentDispositionFilename(const nsAString&) NO_IMPL - NS_IMETHOD GetContentDispositionHeader(nsACString&) NO_IMPL - NS_IMETHOD OnAuthAvailable(nsISupports *aContext, nsIAuthInformation *aAuthInfo); - NS_IMETHOD OnAuthCancelled(nsISupports *aContext, bool userCancel); - NS_IMETHOD GetInterface(const nsIID & uuid, void **result) - { - return QueryInterface(uuid, result); - } - NS_IMETHOD GetAssociatedWindow(nsIDOMWindow**) NO_IMPL - NS_IMETHOD GetTopWindow(nsIDOMWindow**) NO_IMPL - NS_IMETHOD GetTopFrameElement(nsIDOMElement** aElement) - { - nsCOMPtr elem = do_QueryInterface(mElement); - elem.forget(aElement); - return NS_OK; - } - NS_IMETHOD GetNestedFrameId(uint64_t*) NO_IMPL - NS_IMETHOD IsAppOfType(uint32_t, bool*) NO_IMPL - NS_IMETHOD GetIsContent(bool*) NO_IMPL - NS_IMETHOD GetUsePrivateBrowsing(bool*) NO_IMPL - NS_IMETHOD SetUsePrivateBrowsing(bool) NO_IMPL - NS_IMETHOD SetPrivateBrowsing(bool) NO_IMPL - NS_IMETHOD GetIsInBrowserElement(bool*) NO_IMPL - NS_IMETHOD GetAppId(uint32_t*) NO_IMPL - NS_IMETHOD GetUseRemoteTabs(bool*) NO_IMPL - NS_IMETHOD SetRemoteTabs(bool) NO_IMPL -#undef NO_IMPL - -protected: - nsCOMPtr mUri; - uint64_t mCallbackId; - nsCOMPtr mElement; -}; - -NS_IMPL_ISUPPORTS(FakeChannel, nsIChannel, nsIAuthPromptCallback, - nsIRequest, nsIInterfaceRequestor, nsILoadContext); - -bool -TabParent::RecvAsyncAuthPrompt(const nsCString& aUri, - const nsString& aRealm, - const uint64_t& aCallbackId) -{ - nsCOMPtr authPrompt; - GetAuthPrompt(nsIAuthPromptProvider::PROMPT_NORMAL, - NS_GET_IID(nsIAuthPrompt2), - getter_AddRefs(authPrompt)); - nsRefPtr channel = new FakeChannel(aUri, aCallbackId, mFrameElement); - uint32_t promptFlags = nsIAuthInformation::AUTH_HOST; - - nsRefPtr holder = - new nsAuthInformationHolder(promptFlags, aRealm, - EmptyCString()); - - uint32_t level = nsIAuthPrompt2::LEVEL_NONE; - nsCOMPtr dummy; - nsresult rv = - authPrompt->AsyncPromptAuth(channel, channel, nullptr, - level, holder, getter_AddRefs(dummy)); - - return rv == NS_OK; -} - -NS_IMETHODIMP -FakeChannel::OnAuthAvailable(nsISupports *aContext, nsIAuthInformation *aAuthInfo) -{ - nsAuthInformationHolder* holder = - static_cast(aAuthInfo); - - if (!net::gNeckoChild->SendOnAuthAvailable(mCallbackId, - holder->User(), - holder->Password(), - holder->Domain())) { - return NS_ERROR_FAILURE; - } - return NS_OK; -} - -NS_IMETHODIMP -FakeChannel::OnAuthCancelled(nsISupports *aContext, bool userCancel) -{ - if (!net::gNeckoChild->SendOnAuthCancelled(mCallbackId, userCancel)) { - return NS_ERROR_FAILURE; - } - return NS_OK; -} - - } // namespace tabs } // namespace mozilla diff --git a/dom/ipc/TabParent.h b/dom/ipc/TabParent.h index 8cad9ad59195..385657a8f7db 100644 --- a/dom/ipc/TabParent.h +++ b/dom/ipc/TabParent.h @@ -307,10 +307,6 @@ protected: nsIPrincipal* aPrincipal, InfallibleTArray* aJSONRetVal = nullptr); - virtual bool RecvAsyncAuthPrompt(const nsCString& aUri, - const nsString& aRealm, - const uint64_t& aCallbackId) MOZ_OVERRIDE; - virtual bool Recv__delete__() MOZ_OVERRIDE; virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE; diff --git a/netwerk/ipc/NeckoChild.cpp b/netwerk/ipc/NeckoChild.cpp index d509c5e1e6b7..81eacf70efd9 100644 --- a/netwerk/ipc/NeckoChild.cpp +++ b/netwerk/ipc/NeckoChild.cpp @@ -9,7 +9,6 @@ #include "nsHttp.h" #include "mozilla/net/NeckoChild.h" #include "mozilla/dom/ContentChild.h" -#include "mozilla/dom/TabChild.h" #include "mozilla/net/HttpChannelChild.h" #include "mozilla/net/CookieServiceChild.h" #include "mozilla/net/WyciwygChannelChild.h" @@ -74,7 +73,7 @@ void NeckoChild::DestroyNeckoChild() } PHttpChannelChild* -NeckoChild::AllocPHttpChannelChild(const PBrowserOrId& browser, +NeckoChild::AllocPHttpChannelChild(PBrowserChild* browser, const SerializedLoadContext& loadContext, const HttpChannelCreationArgs& aOpenArgs) { @@ -95,7 +94,7 @@ NeckoChild::DeallocPHttpChannelChild(PHttpChannelChild* channel) } PFTPChannelChild* -NeckoChild::AllocPFTPChannelChild(const PBrowserOrId& aBrowser, +NeckoChild::AllocPFTPChannelChild(PBrowserChild* aBrowser, const SerializedLoadContext& aSerialized, const FTPChannelCreationArgs& aOpenArgs) { @@ -151,7 +150,7 @@ NeckoChild::DeallocPWyciwygChannelChild(PWyciwygChannelChild* channel) } PWebSocketChild* -NeckoChild::AllocPWebSocketChild(const PBrowserOrId& browser, +NeckoChild::AllocPWebSocketChild(PBrowserChild* browser, const SerializedLoadContext& aSerialized) { NS_NOTREACHED("AllocPWebSocketChild should not be called"); @@ -301,21 +300,5 @@ NeckoChild::DeallocPChannelDiverterChild(PChannelDiverterChild* child) return true; } -bool -NeckoChild::RecvAsyncAuthPromptForNestedFrame(const uint64_t& aNestedFrameId, - const nsCString& aUri, - const nsString& aRealm, - const uint64_t& aCallbackId) -{ - auto iter = dom::TabChild::NestedTabChildMap().find(aNestedFrameId); - if (iter == dom::TabChild::NestedTabChildMap().end()) { - MOZ_CRASH(); - return false; - } - dom::TabChild* tabChild = iter->second; - tabChild->SendAsyncAuthPrompt(aUri, aRealm, aCallbackId); - return true; -} - }} // mozilla::net diff --git a/netwerk/ipc/NeckoChild.h b/netwerk/ipc/NeckoChild.h index ea649206a1cc..06918a7bfe6c 100644 --- a/netwerk/ipc/NeckoChild.h +++ b/netwerk/ipc/NeckoChild.h @@ -27,7 +27,7 @@ public: protected: virtual PHttpChannelChild* - AllocPHttpChannelChild(const PBrowserOrId&, const SerializedLoadContext&, + AllocPHttpChannelChild(PBrowserChild*, const SerializedLoadContext&, const HttpChannelCreationArgs& aOpenArgs) MOZ_OVERRIDE; virtual bool DeallocPHttpChannelChild(PHttpChannelChild*) MOZ_OVERRIDE; virtual PCookieServiceChild* AllocPCookieServiceChild() MOZ_OVERRIDE; @@ -35,13 +35,12 @@ protected: virtual PWyciwygChannelChild* AllocPWyciwygChannelChild() MOZ_OVERRIDE; virtual bool DeallocPWyciwygChannelChild(PWyciwygChannelChild*) MOZ_OVERRIDE; virtual PFTPChannelChild* - AllocPFTPChannelChild(const PBrowserOrId& aBrowser, + AllocPFTPChannelChild(PBrowserChild* aBrowser, const SerializedLoadContext& aSerialized, const FTPChannelCreationArgs& aOpenArgs) MOZ_OVERRIDE; virtual bool DeallocPFTPChannelChild(PFTPChannelChild*) MOZ_OVERRIDE; virtual PWebSocketChild* - AllocPWebSocketChild(const PBrowserOrId&, - const SerializedLoadContext&) MOZ_OVERRIDE; + AllocPWebSocketChild(PBrowserChild*, const SerializedLoadContext&) MOZ_OVERRIDE; virtual bool DeallocPWebSocketChild(PWebSocketChild*) MOZ_OVERRIDE; virtual PTCPSocketChild* AllocPTCPSocketChild() MOZ_OVERRIDE; virtual bool DeallocPTCPSocketChild(PTCPSocketChild*) MOZ_OVERRIDE; @@ -72,10 +71,6 @@ protected: AllocPChannelDiverterChild(const ChannelDiverterArgs& channel) MOZ_OVERRIDE; virtual bool DeallocPChannelDiverterChild(PChannelDiverterChild* actor) MOZ_OVERRIDE; - virtual bool RecvAsyncAuthPromptForNestedFrame(const uint64_t& aNestedFrameId, - const nsCString& aUri, - const nsString& aRealm, - const uint64_t& aCallbackId) MOZ_OVERRIDE; }; /** diff --git a/netwerk/ipc/NeckoParent.cpp b/netwerk/ipc/NeckoParent.cpp index 559e4bbedd85..ef3293b2448c 100644 --- a/netwerk/ipc/NeckoParent.cpp +++ b/netwerk/ipc/NeckoParent.cpp @@ -35,8 +35,6 @@ #include "nsEscape.h" #include "RemoteOpenFileParent.h" #include "SerializedLoadContext.h" -#include "nsAuthInformationHolder.h" -#include "nsIAuthPromptCallback.h" using mozilla::dom::ContentParent; using mozilla::dom::TabParent; @@ -153,43 +151,28 @@ NeckoParent::GetValidatedAppInfo(const SerializedLoadContext& aSerialized, } const char * -NeckoParent::CreateChannelLoadContext(const PBrowserOrId& aBrowser, +NeckoParent::CreateChannelLoadContext(PBrowserParent* aBrowser, PContentParent* aContent, const SerializedLoadContext& aSerialized, nsCOMPtr &aResult) { uint32_t appId = NECKO_UNKNOWN_APP_ID; bool inBrowser = false; + dom::Element* topFrameElement = nullptr; const char* error = GetValidatedAppInfo(aSerialized, aContent, &appId, &inBrowser); if (error) { return error; } + if (aBrowser) { + nsRefPtr tabParent = static_cast(aBrowser); + topFrameElement = tabParent->GetOwnerElement(); + } + // if !UsingNeckoIPCSecurity(), we may not have a LoadContext to set. This is // the common case for most xpcshell tests. if (aSerialized.IsNotNull()) { - switch (aBrowser.type()) { - case PBrowserOrId::TPBrowserParent: - { - nsRefPtr tabParent = - static_cast(aBrowser.get_PBrowserParent()); - dom::Element* topFrameElement = nullptr; - if (tabParent) { - topFrameElement = tabParent->GetOwnerElement(); - } - aResult = new LoadContext(aSerialized, topFrameElement, - appId, inBrowser); - break; - } - case PBrowserOrId::Tuint64_t: - { - aResult = new LoadContext(aSerialized, aBrowser.get_uint64_t(), - appId, inBrowser); - break; - } - default: - MOZ_CRASH(); - } + aResult = new LoadContext(aSerialized, topFrameElement, appId, inBrowser); } return nullptr; @@ -202,7 +185,7 @@ NeckoParent::ActorDestroy(ActorDestroyReason aWhy) } PHttpChannelParent* -NeckoParent::AllocPHttpChannelParent(const PBrowserOrId& aBrowser, +NeckoParent::AllocPHttpChannelParent(PBrowserParent* aBrowser, const SerializedLoadContext& aSerialized, const HttpChannelCreationArgs& aOpenArgs) { @@ -232,7 +215,7 @@ NeckoParent::DeallocPHttpChannelParent(PHttpChannelParent* channel) bool NeckoParent::RecvPHttpChannelConstructor( PHttpChannelParent* aActor, - const PBrowserOrId& aBrowser, + PBrowserParent* aBrowser, const SerializedLoadContext& aSerialized, const HttpChannelCreationArgs& aOpenArgs) { @@ -241,7 +224,7 @@ NeckoParent::RecvPHttpChannelConstructor( } PFTPChannelParent* -NeckoParent::AllocPFTPChannelParent(const PBrowserOrId& aBrowser, +NeckoParent::AllocPFTPChannelParent(PBrowserParent* aBrowser, const SerializedLoadContext& aSerialized, const FTPChannelCreationArgs& aOpenArgs) { @@ -271,7 +254,7 @@ NeckoParent::DeallocPFTPChannelParent(PFTPChannelParent* channel) bool NeckoParent::RecvPFTPChannelConstructor( PFTPChannelParent* aActor, - const PBrowserOrId& aBrowser, + PBrowserParent* aBrowser, const SerializedLoadContext& aSerialized, const FTPChannelCreationArgs& aOpenArgs) { @@ -309,7 +292,7 @@ NeckoParent::DeallocPWyciwygChannelParent(PWyciwygChannelParent* channel) } PWebSocketParent* -NeckoParent::AllocPWebSocketParent(const PBrowserOrId& browser, +NeckoParent::AllocPWebSocketParent(PBrowserParent* browser, const SerializedLoadContext& serialized) { nsCOMPtr loadContext; @@ -322,7 +305,7 @@ NeckoParent::AllocPWebSocketParent(const PBrowserOrId& browser, return nullptr; } - nsRefPtr tabParent = static_cast(browser.get_PBrowserParent()); + TabParent* tabParent = static_cast(browser); PBOverrideStatus overrideStatus = PBOverrideStatusFromLoadContext(serialized); WebSocketChannelParent* p = new WebSocketChannelParent(tabParent, loadContext, overrideStatus); @@ -718,87 +701,4 @@ NeckoParent::CloneProtocol(Channel* aChannel, return actor.forget(); } -namespace { -std::map >& -CallbackMap() -{ - MOZ_ASSERT(NS_IsMainThread()); - static std::map > sCallbackMap; - return sCallbackMap; -} -} // anonymous namespace - -NS_IMPL_ISUPPORTS(NeckoParent::NestedFrameAuthPrompt, nsIAuthPrompt2) - -NeckoParent::NestedFrameAuthPrompt::NestedFrameAuthPrompt(PNeckoParent* aParent, - uint64_t aNestedFrameId) - : mNeckoParent(aParent) - , mNestedFrameId(aNestedFrameId) -{} - -NS_IMETHODIMP -NeckoParent::NestedFrameAuthPrompt::AsyncPromptAuth( - nsIChannel* aChannel, nsIAuthPromptCallback* callback, - nsISupports*, uint32_t, - nsIAuthInformation* aInfo, nsICancelable**) -{ - static uint64_t callbackId = 0; - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); - nsCOMPtr uri; - nsresult rv = aChannel->GetURI(getter_AddRefs(uri)); - NS_ENSURE_SUCCESS(rv, rv); - nsAutoCString spec; - if (uri) { - rv = uri->GetSpec(spec); - NS_ENSURE_SUCCESS(rv, rv); - } - nsString realm; - rv = aInfo->GetRealm(realm); - NS_ENSURE_SUCCESS(rv, rv); - callbackId++; - if (mNeckoParent->SendAsyncAuthPromptForNestedFrame(mNestedFrameId, - spec, - realm, - callbackId)) { - CallbackMap()[callbackId] = callback; - return NS_OK; - } - return NS_ERROR_FAILURE; -} - -bool -NeckoParent::RecvOnAuthAvailable(const uint64_t& aCallbackId, - const nsString& aUser, - const nsString& aPassword, - const nsString& aDomain) -{ - nsCOMPtr callback = CallbackMap()[aCallbackId]; - if (!callback) { - return true; - } - CallbackMap().erase(aCallbackId); - - nsRefPtr holder = - new nsAuthInformationHolder(0, EmptyString(), EmptyCString()); - holder->SetUsername(aUser); - holder->SetPassword(aPassword); - holder->SetDomain(aDomain); - - callback->OnAuthAvailable(nullptr, holder); - return true; -} - -bool -NeckoParent::RecvOnAuthCancelled(const uint64_t& aCallbackId, - const bool& aUserCancel) -{ - nsCOMPtr callback = CallbackMap()[aCallbackId]; - if (!callback) { - return true; - } - CallbackMap().erase(aCallbackId); - callback->OnAuthCancelled(nullptr, aUserCancel); - return true; -} - }} // mozilla::net diff --git a/netwerk/ipc/NeckoParent.h b/netwerk/ipc/NeckoParent.h index 602b165d3153..ac6053266d67 100644 --- a/netwerk/ipc/NeckoParent.h +++ b/netwerk/ipc/NeckoParent.h @@ -29,6 +29,13 @@ public: NeckoParent(); virtual ~NeckoParent(); + MOZ_WARN_UNUSED_RESULT + static const char * + GetValidatedAppInfo(const SerializedLoadContext& aSerialized, + PBrowserParent* aBrowser, + uint32_t* aAppId, + bool* aInBrowserElement); + MOZ_WARN_UNUSED_RESULT static const char * GetValidatedAppInfo(const SerializedLoadContext& aSerialized, @@ -45,7 +52,7 @@ public: */ MOZ_WARN_UNUSED_RESULT static const char* - CreateChannelLoadContext(const PBrowserOrId& aBrowser, + CreateChannelLoadContext(PBrowserParent* aBrowser, PContentParent* aContent, const SerializedLoadContext& aSerialized, nsCOMPtr &aResult); @@ -62,48 +69,14 @@ public: return PNeckoParent::RecvPCookieServiceConstructor(aActor); } - /* - * This implementation of nsIAuthPrompt2 is used for nested remote iframes that - * want an auth prompt. This class lives in the parent process and informs the - * NeckoChild that we want an auth prompt, which forwards the request to the - * TabParent in the remote iframe that contains the nested iframe - */ - class NestedFrameAuthPrompt MOZ_FINAL : public nsIAuthPrompt2 - { - public: - NS_DECL_ISUPPORTS - - NestedFrameAuthPrompt(PNeckoParent* aParent, uint64_t aNestedFrameId); - - NS_IMETHOD PromptAuth(nsIChannel*, uint32_t, nsIAuthInformation*, bool*) - { - return NS_ERROR_NOT_IMPLEMENTED; - } - - NS_IMETHOD AsyncPromptAuth(nsIChannel* aChannel, nsIAuthPromptCallback* callback, - nsISupports*, uint32_t, - nsIAuthInformation* aInfo, nsICancelable**); - - NS_IMETHOD AsyncPromptAuth2(nsIChannel*, nsIDOMElement*, - nsIAuthPromptCallback*, nsISupports*, - uint32_t, nsIAuthInformation*, nsICancelable**) - { - return NS_ERROR_NOT_IMPLEMENTED; - } - - protected: - PNeckoParent* mNeckoParent; - uint64_t mNestedFrameId; - }; - protected: virtual PHttpChannelParent* - AllocPHttpChannelParent(const PBrowserOrId&, const SerializedLoadContext&, + AllocPHttpChannelParent(PBrowserParent*, const SerializedLoadContext&, const HttpChannelCreationArgs& aOpenArgs) MOZ_OVERRIDE; virtual bool RecvPHttpChannelConstructor( PHttpChannelParent* aActor, - const PBrowserOrId& aBrowser, + PBrowserParent* aBrowser, const SerializedLoadContext& aSerialized, const HttpChannelCreationArgs& aOpenArgs) MOZ_OVERRIDE; virtual bool DeallocPHttpChannelParent(PHttpChannelParent*) MOZ_OVERRIDE; @@ -111,18 +84,18 @@ protected: virtual PWyciwygChannelParent* AllocPWyciwygChannelParent() MOZ_OVERRIDE; virtual bool DeallocPWyciwygChannelParent(PWyciwygChannelParent*) MOZ_OVERRIDE; virtual PFTPChannelParent* - AllocPFTPChannelParent(const PBrowserOrId& aBrowser, + AllocPFTPChannelParent(PBrowserParent* aBrowser, const SerializedLoadContext& aSerialized, const FTPChannelCreationArgs& aOpenArgs) MOZ_OVERRIDE; virtual bool RecvPFTPChannelConstructor( PFTPChannelParent* aActor, - const PBrowserOrId& aBrowser, + PBrowserParent* aBrowser, const SerializedLoadContext& aSerialized, const FTPChannelCreationArgs& aOpenArgs) MOZ_OVERRIDE; virtual bool DeallocPFTPChannelParent(PFTPChannelParent*) MOZ_OVERRIDE; virtual PWebSocketParent* - AllocPWebSocketParent(const PBrowserOrId& browser, + AllocPWebSocketParent(PBrowserParent* browser, const SerializedLoadContext& aSerialized) MOZ_OVERRIDE; virtual bool DeallocPWebSocketParent(PWebSocketParent*) MOZ_OVERRIDE; virtual PTCPSocketParent* AllocPTCPSocketParent() MOZ_OVERRIDE; @@ -193,13 +166,6 @@ protected: virtual bool DeallocPChannelDiverterParent(PChannelDiverterParent* actor) MOZ_OVERRIDE; - virtual bool RecvOnAuthAvailable(const uint64_t& aCallbackId, - const nsString& aUser, - const nsString& aPassword, - const nsString& aDomain) MOZ_OVERRIDE; - virtual bool RecvOnAuthCancelled(const uint64_t& aCallbackId, - const bool& aUserCancel) MOZ_OVERRIDE; - private: nsCString mCoreAppsBasePath; nsCString mWebAppsBasePath; diff --git a/netwerk/ipc/PNecko.ipdl b/netwerk/ipc/PNecko.ipdl index 4c5e5bc0247f..3d73f245e96c 100644 --- a/netwerk/ipc/PNecko.ipdl +++ b/netwerk/ipc/PNecko.ipdl @@ -33,11 +33,6 @@ using class IPC::SerializedLoadContext from "SerializedLoadContext.h"; namespace mozilla { namespace net { -union PBrowserOrId { - nullable PBrowser; - uint64_t; -}; - //------------------------------------------------------------------- sync protocol PNecko { @@ -60,14 +55,14 @@ parent: __delete__(); PCookieService(); - PHttpChannel(PBrowserOrId browser, + PHttpChannel(nullable PBrowser browser, SerializedLoadContext loadContext, HttpChannelCreationArgs args); PWyciwygChannel(); - PFTPChannel(PBrowserOrId browser, SerializedLoadContext loadContext, + PFTPChannel(PBrowser browser, SerializedLoadContext loadContext, FTPChannelCreationArgs args); - PWebSocket(PBrowserOrId browser, SerializedLoadContext loadContext); + PWebSocket(PBrowser browser, SerializedLoadContext loadContext); PTCPServerSocket(uint16_t localPort, uint16_t backlog, nsString binaryType); PUDPSocket(nsCString host, uint16_t port, nsCString filter); @@ -83,24 +78,6 @@ parent: PRtspChannel(RtspChannelConnectArgs args); PChannelDiverter(ChannelDiverterArgs channel); - /** - * These are called from the child with the results of the auth prompt. - * callbackId is the id that was passed in PBrowser::AsyncAuthPrompt, - * corresponding to an nsIAuthPromptCallback - */ - OnAuthAvailable(uint64_t callbackId, nsString user, - nsString password, nsString domain); - OnAuthCancelled(uint64_t callbackId, bool userCancel); - -child: - /* - * Bring up the http auth prompt for a nested remote mozbrowser. - * NestedFrameId is the id corresponding to the PBrowser. It is the same id - * that was passed to the PBrowserOrId param in to the PHttpChannel constructor - */ - AsyncAuthPromptForNestedFrame(uint64_t nestedFrameId, nsCString uri, - nsString realm, uint64_t callbackId); - both: PTCPSocket(); }; diff --git a/netwerk/protocol/http/HttpChannelChild.cpp b/netwerk/protocol/http/HttpChannelChild.cpp index 234e073519fc..0eee244d0581 100644 --- a/netwerk/protocol/http/HttpChannelChild.cpp +++ b/netwerk/protocol/http/HttpChannelChild.cpp @@ -964,15 +964,8 @@ HttpChannelChild::ConnectParent(uint32_t id) AddIPDLReference(); HttpChannelConnectArgs connectArgs(id); - PBrowserOrId browser; - if (!tabChild || - static_cast(gNeckoChild->Manager()) == tabChild->Manager()) { - browser = tabChild; - } else { - browser = TabChild::GetTabChildId(tabChild); - } if (!gNeckoChild-> - SendPHttpChannelConstructor(this, browser, + SendPHttpChannelConstructor(this, tabChild, IPC::SerializedLoadContext(this), connectArgs)) { return NS_ERROR_FAILURE; @@ -1281,14 +1274,7 @@ HttpChannelChild::AsyncOpen(nsIStreamListener *listener, nsISupports *aContext) // until OnStopRequest, or we do a redirect, or we hit an IPDL error. AddIPDLReference(); - PBrowserOrId browser; - if (!tabChild || - static_cast(gNeckoChild->Manager()) == tabChild->Manager()) { - browser = tabChild; - } else { - browser = TabChild::GetTabChildId(tabChild); - } - gNeckoChild->SendPHttpChannelConstructor(this, browser, + gNeckoChild->SendPHttpChannelConstructor(this, tabChild, IPC::SerializedLoadContext(this), openArgs); diff --git a/netwerk/protocol/http/HttpChannelParent.cpp b/netwerk/protocol/http/HttpChannelParent.cpp index 9e862b5a5f31..ac39347254be 100644 --- a/netwerk/protocol/http/HttpChannelParent.cpp +++ b/netwerk/protocol/http/HttpChannelParent.cpp @@ -25,8 +25,6 @@ #include "mozilla/ipc/InputStreamUtils.h" #include "mozilla/ipc/URIUtils.h" #include "SerializedLoadContext.h" -#include "nsIAuthInformation.h" -#include "nsIAuthPromptCallback.h" using namespace mozilla::dom; using namespace mozilla::ipc; @@ -34,7 +32,7 @@ using namespace mozilla::ipc; namespace mozilla { namespace net { -HttpChannelParent::HttpChannelParent(const PBrowserOrId& iframeEmbedding, +HttpChannelParent::HttpChannelParent(PBrowserParent* iframeEmbedding, nsILoadContext* aLoadContext, PBOverrideStatus aOverrideStatus) : mIPCClosed(false) @@ -50,7 +48,6 @@ HttpChannelParent::HttpChannelParent(const PBrowserOrId& iframeEmbedding, , mDivertingFromChild(false) , mDivertedOnStartRequest(false) , mSuspendedForDiversion(false) - , mNestedFrameId(0) { // Ensure gHttpHandler is initialized: we need the atom table up and running. nsCOMPtr dummyInitializer = @@ -59,11 +56,7 @@ HttpChannelParent::HttpChannelParent(const PBrowserOrId& iframeEmbedding, MOZ_ASSERT(gHttpHandler); mHttpHandler = gHttpHandler; - if (iframeEmbedding.type() == PBrowserOrId::TPBrowserParent) { - mTabParent = static_cast(iframeEmbedding.get_PBrowserParent()); - } else { - mNestedFrameId = iframeEmbedding.get_uint64_t(); - } + mTabParent = static_cast(iframeEmbedding); } HttpChannelParent::~HttpChannelParent() @@ -116,7 +109,6 @@ NS_IMPL_ISUPPORTS(HttpChannelParent, nsIRequestObserver, nsIStreamListener, nsIParentChannel, - nsIAuthPromptProvider, nsIParentRedirectingChannel) //----------------------------------------------------------------------------- @@ -128,16 +120,10 @@ HttpChannelParent::GetInterface(const nsIID& aIID, void **result) { if (aIID.Equals(NS_GET_IID(nsIAuthPromptProvider)) || aIID.Equals(NS_GET_IID(nsISecureBrowserUI))) { - if (mTabParent) { - return mTabParent->QueryInterface(aIID, result); - } - } + if (!mTabParent) + return NS_NOINTERFACE; - // Only support nsIAuthPromptProvider in Content process - if (XRE_GetProcessType() == GeckoProcessType_Default && - aIID.Equals(NS_GET_IID(nsIAuthPromptProvider))) { - *result = nullptr; - return NS_OK; + return mTabParent->QueryInterface(aIID, result); } // Only support nsILoadContext if child channel's callbacks did too @@ -1001,14 +987,4 @@ HttpChannelParent::NotifyDiversionFailed(nsresult aErrorCode, } } -NS_IMETHODIMP -HttpChannelParent::GetAuthPrompt(uint32_t aPromptReason, const nsIID& iid, - void** aResult) -{ - nsCOMPtr prompt = - new NeckoParent::NestedFrameAuthPrompt(Manager(), mNestedFrameId); - prompt.forget(aResult); - return NS_OK; -} - }} // mozilla::net diff --git a/netwerk/protocol/http/HttpChannelParent.h b/netwerk/protocol/http/HttpChannelParent.h index 6e6bc23ca26f..a03b06e731ce 100644 --- a/netwerk/protocol/http/HttpChannelParent.h +++ b/netwerk/protocol/http/HttpChannelParent.h @@ -10,13 +10,13 @@ #include "ADivertableParentChannel.h" #include "nsHttp.h" +#include "mozilla/dom/PBrowserParent.h" #include "mozilla/net/PHttpChannelParent.h" #include "mozilla/net/NeckoCommon.h" #include "mozilla/net/NeckoParent.h" #include "nsIParentRedirectingChannel.h" #include "nsIProgressEventSink.h" #include "nsHttpChannel.h" -#include "nsIAuthPromptProvider.h" class nsICacheEntry; class nsIAssociatedContentSecurity; @@ -30,14 +30,12 @@ class TabParent; namespace net { class HttpChannelParentListener; -class PBrowserOrId; class HttpChannelParent : public PHttpChannelParent , public nsIParentRedirectingChannel , public nsIProgressEventSink , public nsIInterfaceRequestor , public ADivertableParentChannel - , public nsIAuthPromptProvider { public: NS_DECL_ISUPPORTS @@ -47,9 +45,8 @@ public: NS_DECL_NSIPARENTREDIRECTINGCHANNEL NS_DECL_NSIPROGRESSEVENTSINK NS_DECL_NSIINTERFACEREQUESTOR - NS_DECL_NSIAUTHPROMPTPROVIDER - HttpChannelParent(const PBrowserOrId& iframeEmbedding, + HttpChannelParent(mozilla::dom::PBrowserParent* iframeEmbedding, nsILoadContext* aLoadContext, PBOverrideStatus aStatus); virtual ~HttpChannelParent(); @@ -163,8 +160,6 @@ private: bool mDivertedOnStartRequest; bool mSuspendedForDiversion; - - uint64_t mNestedFrameId; }; } // namespace net diff --git a/uriloader/prefetch/OfflineCacheUpdateParent.cpp b/uriloader/prefetch/OfflineCacheUpdateParent.cpp index 04ced4468a21..8abc68daa17a 100644 --- a/uriloader/prefetch/OfflineCacheUpdateParent.cpp +++ b/uriloader/prefetch/OfflineCacheUpdateParent.cpp @@ -204,12 +204,6 @@ OfflineCacheUpdateParent::GetTopFrameElement(nsIDOMElement** aElement) return NS_ERROR_NOT_IMPLEMENTED; } -NS_IMETHODIMP -OfflineCacheUpdateParent::GetNestedFrameId(uint64_t* aId) -{ - return NS_ERROR_NOT_IMPLEMENTED; -} - NS_IMETHODIMP OfflineCacheUpdateParent::IsAppOfType(uint32_t appType, bool *_retval) {