diff --git a/docshell/base/CanonicalBrowsingContext.cpp b/docshell/base/CanonicalBrowsingContext.cpp index c08198ba3e10..5af235c4fb72 100644 --- a/docshell/base/CanonicalBrowsingContext.cpp +++ b/docshell/base/CanonicalBrowsingContext.cpp @@ -65,6 +65,23 @@ ContentParent* CanonicalBrowsingContext::GetContentParent() const { return cpm->GetContentProcessById(ContentParentId(mProcessId)); } +void CanonicalBrowsingContext::GetCurrentRemoteType(nsAString& aRemoteType, + ErrorResult& aRv) const { + // If we're in the parent process, dump out the void string. + if (mProcessId == 0) { + aRemoteType.Assign(VoidString()); + return; + } + + ContentParent* cp = GetContentParent(); + if (!cp) { + aRv.Throw(NS_ERROR_UNEXPECTED); + return; + } + + aRemoteType.Assign(cp->GetRemoteType()); +} + void CanonicalBrowsingContext::GetWindowGlobals( nsTArray>& aWindows) { aWindows.SetCapacity(mWindowGlobals.Count()); diff --git a/docshell/base/CanonicalBrowsingContext.h b/docshell/base/CanonicalBrowsingContext.h index 1dc6ea80a2d6..74de53dd05fa 100644 --- a/docshell/base/CanonicalBrowsingContext.h +++ b/docshell/base/CanonicalBrowsingContext.h @@ -36,6 +36,8 @@ class CanonicalBrowsingContext final : public BrowsingContext { uint64_t OwnerProcessId() const { return mProcessId; } ContentParent* GetContentParent() const; + void GetCurrentRemoteType(nsAString& aRemoteType, ErrorResult& aRv) const; + void SetOwnerProcessId(uint64_t aProcessId) { mProcessId = aProcessId; } void GetWindowGlobals(nsTArray>& aWindows); diff --git a/dom/chrome-webidl/BrowsingContext.webidl b/dom/chrome-webidl/BrowsingContext.webidl index 12e0b1dc0ce2..14dac2b76322 100644 --- a/dom/chrome-webidl/BrowsingContext.webidl +++ b/dom/chrome-webidl/BrowsingContext.webidl @@ -33,6 +33,12 @@ interface CanonicalBrowsingContext : BrowsingContext { readonly attribute WindowGlobalParent? currentWindowGlobal; + // XXX(nika): This feels kinda hacky, but will do for now while we don't + // synchronously create WindowGlobalParent. It can throw if somehow the + // content process has died. + [Throws] + readonly attribute DOMString? currentRemoteType; + void notifyStartDelayedAutoplayMedia(); };