Commit 3b912b9c authored by Jeff Boek's avatar Jeff Boek Committed by Pier Angelo Vendrame
Browse files

Bug 1818679 - Decide when to call GeckoView r=necko-reviewers,valentin

parent ceed81aa
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -909,7 +909,9 @@ auto DocumentLoadListener::Open(nsDocShellLoadState* aLoadState,
  if (documentContext && aLoadState->LoadType() != LOAD_ERROR_PAGE &&
      !(aLoadState->HasInternalLoadFlags(
          nsDocShell::INTERNAL_LOAD_FLAGS_BYPASS_LOAD_URI_DELEGATE)) &&
      !(aLoadState->LoadType() & LOAD_HISTORY)) {
      !(aLoadState->LoadType() & LOAD_HISTORY) &&
      !nsExternalHelperAppService::ExternalProtocolIsBlockedBySandbox(
          documentContext, aLoadState->HasValidUserGestureActivation())) {
    nsCOMPtr<nsIWidget> widget =
        documentContext->GetParentProcessWidgetContaining();
    RefPtr<nsWindow> window = nsWindow::From(widget);
@@ -3091,7 +3093,8 @@ DocumentLoadListener::AsyncOnChannelRedirect(
      bc ? bc->GetParentProcessWidgetContaining() : nullptr;
  RefPtr<nsWindow> window = nsWindow::From(widget);

  if (window) {
  if (window && !nsExternalHelperAppService::ExternalProtocolIsBlockedBySandbox(
                    bc, false)) {
    promise = window->OnLoadRequest(uriBeingLoaded,
                                    nsIBrowserDOMWindow::OPEN_CURRENTWINDOW,
                                    nsIWebNavigation::LOAD_FLAGS_IS_REDIRECT,
+1 −1
Original line number Diff line number Diff line
@@ -967,7 +967,7 @@ nsresult nsExternalHelperAppService::EscapeURI(nsIURI* aURI, nsIURI** aResult) {
  return ios->NewURI(escapedSpec, nullptr, nullptr, aResult);
}

bool ExternalProtocolIsBlockedBySandbox(
bool nsExternalHelperAppService::ExternalProtocolIsBlockedBySandbox(
    BrowsingContext* aBrowsingContext,
    const bool aHasValidUserGestureActivation) {
  if (!StaticPrefs::dom_block_external_protocol_navigation_from_sandbox()) {
+8 −0
Original line number Diff line number Diff line
@@ -130,6 +130,14 @@ class nsExternalHelperAppService : public nsIExternalHelperAppService,
  // Internal method. Only called directly from tests.
  static nsresult EscapeURI(nsIURI* aURI, nsIURI** aResult);

  /**
   * Check whether `aBrowsingContext` is sandboxed such that external
   * protocol navigations performed in that context would be blocked.
   */
  static bool ExternalProtocolIsBlockedBySandbox(
      mozilla::dom::BrowsingContext* aBrowsingContext,
      const bool aHasValidUserGestureActivation);

  /**
   * Logging Module. Usage: set MOZ_LOG=HelperAppService:level, where level
   * should be 2 for errors, 3 for debug messages from the cross- platform