From 2735b24083b167c34e653d85b5d527233ac13788 Mon Sep 17 00:00:00 2001 From: Mike Conley Date: Wed, 13 May 2015 16:44:39 -0400 Subject: [PATCH] Bug 863515 - Expose hasContentOpener on nsITabParent. r=smaug. hasContentOpener is set to true if a tab happened to be opened due to content requesting it - for example, a target="_blank" link, or a window.open. --HG-- extra : rebase_source : f29e509d630b25bf7af91254adb7256c1537c800 --- dom/interfaces/base/nsITabParent.idl | 4 +++- dom/ipc/TabParent.cpp | 19 +++++++++++++++++++ dom/ipc/TabParent.h | 3 +++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/dom/interfaces/base/nsITabParent.idl b/dom/interfaces/base/nsITabParent.idl index 01c4fa1842bb..e7b2e6c0bf81 100644 --- a/dom/interfaces/base/nsITabParent.idl +++ b/dom/interfaces/base/nsITabParent.idl @@ -5,7 +5,7 @@ #include "domstubs.idl" -[scriptable, uuid(b19038ba-0d75-40d2-be35-742e26d33bf9)] +[scriptable, uuid(4d4576eb-ecfe-47b9-93b8-4121518621ad)] interface nsITabParent : nsISupports { void injectTouchEvent(in AString aType, @@ -26,4 +26,6 @@ interface nsITabParent : nsISupports void setIsDocShellActive(in bool aIsActive); readonly attribute uint64_t tabId; + + readonly attribute boolean hasContentOpener; }; diff --git a/dom/ipc/TabParent.cpp b/dom/ipc/TabParent.cpp index f66d7981b57e..16d7bd358a18 100644 --- a/dom/ipc/TabParent.cpp +++ b/dom/ipc/TabParent.cpp @@ -284,6 +284,7 @@ TabParent::TabParent(nsIContentParent* aManager, , mNeedLayerTreeReadyNotification(false) , mCursor(nsCursor(-1)) , mTabSetsCursor(false) + , mHasContentOpener(false) { MOZ_ASSERT(aManager); } @@ -609,6 +610,11 @@ TabParent::RecvCreateWindow(PBrowserParent* aNewTab, NS_ENSURE_SUCCESS(rv, false); TabParent* newTab = TabParent::GetFrom(aNewTab); + MOZ_ASSERT(newTab); + + // Content has requested that we open this new content window, so + // we must have an opener. + newTab->SetHasContentOpener(true); nsCOMPtr frame(do_QueryInterface(mFrameElement)); @@ -2906,6 +2912,19 @@ TabParent::GetTabId(uint64_t* aId) return NS_OK; } +NS_IMETHODIMP +TabParent::GetHasContentOpener(bool* aResult) +{ + *aResult = mHasContentOpener; + return NS_OK; +} + +void +TabParent::SetHasContentOpener(bool aHasContentOpener) +{ + mHasContentOpener = aHasContentOpener; +} + class LayerTreeUpdateRunnable final : public nsRunnable { diff --git a/dom/ipc/TabParent.h b/dom/ipc/TabParent.h index 0150a96c4a2b..ba612c96a209 100644 --- a/dom/ipc/TabParent.h +++ b/dom/ipc/TabParent.h @@ -458,6 +458,8 @@ protected: bool InitBrowserConfiguration(const nsCString& aURI, BrowserConfiguration& aConfiguration); + void SetHasContentOpener(bool aHasContentOpener); + // IME static TabParent *mIMETabParent; nsString mIMECacheText; @@ -605,6 +607,7 @@ private: nsRefPtr mPresShellWithRefreshListener; + bool mHasContentOpener; private: // This is used when APZ needs to find the TabParent associated with a layer // to dispatch events.