tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

WebIdentityChild.cpp (1693B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
      3 /* This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #include "mozilla/dom/WebIdentityChild.h"
      8 
      9 #include "mozilla/dom/WebIdentityHandler.h"
     10 #include "mozilla/dom/WindowContext.h"
     11 #include "nsGlobalWindowOuter.h"
     12 
     13 namespace mozilla::dom {
     14 
     15 void WebIdentityChild::ActorDestroy(ActorDestroyReason why) {
     16  if (mHandler) {
     17    mHandler->ActorDestroyed();
     18    mHandler = nullptr;
     19  }
     20 }
     21 
     22 void WebIdentityChild::SetHandler(WebIdentityHandler* aHandler) {
     23  mHandler = aHandler;
     24 }
     25 
     26 mozilla::ipc::IPCResult WebIdentityChild::RecvOpenContinuationWindow(
     27    nsIURI* aContinueURI, const OpenContinuationWindowResolver& aResolver) {
     28  MOZ_ASSERT(mHandler);
     29  nsPIDOMWindowInner* window = mHandler->GetWindow();
     30  MOZ_ASSERT(window);
     31  MOZ_ASSERT(window->GetWindowContext());
     32 
     33  // Open a popup on via the window opening this to the provided URL, resolving
     34  // with the new BC ID if we can get one. Otherwise resolve with the error
     35  nsGlobalWindowOuter* outer = nsGlobalWindowOuter::GetOuterWindowWithId(
     36      window->GetWindowContext()->OuterWindowId());
     37  RefPtr<BrowsingContext> newBC;
     38  nsresult rv = outer->OpenJS(aContinueURI->GetSpecOrDefault(), u"_blank"_ns,
     39                              u"popup"_ns, getter_AddRefs(newBC));
     40  if (NS_FAILED(rv)) {
     41    aResolver(rv);
     42  } else if (!newBC) {
     43    aResolver(NS_ERROR_UNEXPECTED);
     44  } else {
     45    aResolver(newBC->Id());
     46  }
     47  return IPC_OK();
     48 }
     49 
     50 }  // namespace mozilla::dom