void PolicyChecker::checkNewWindowPolicy(const NavigationAction& action, NewWindowPolicyDecisionFunction function, const ResourceRequest& request, PassRefPtr<FormState> formState, const String& frameName, void* argument) { if (m_frame->document() && m_frame->document()->isSandboxed(SandboxPopups)) return continueAfterNavigationPolicy(PolicyIgnore); if (!DOMWindow::allowPopUp(m_frame)) return continueAfterNavigationPolicy(PolicyIgnore); m_callback.set(request, formState, frameName, action, function, argument); m_frame->loader().client().dispatchDecidePolicyForNewWindowAction(&PolicyChecker::continueAfterNewWindowPolicy, action, request, formState, frameName); }
void PolicyChecker::checkNewWindowPolicy(const NavigationAction& action, const ResourceRequest& request, PassRefPtr<FormState> formState, const String& frameName, NewWindowPolicyDecisionFunction function) { if (m_frame.document() && m_frame.document()->isSandboxed(SandboxPopups)) return continueAfterNavigationPolicy(PolicyIgnore); if (!DOMWindow::allowPopUp(&m_frame)) return continueAfterNavigationPolicy(PolicyIgnore); m_callback.set(request, formState, frameName, action, WTF::move(function)); m_frame.loader().client().dispatchDecidePolicyForNewWindowAction(action, request, formState, frameName, [this](PolicyAction action) { continueAfterNewWindowPolicy(action); }); }
void PolicyChecker::checkNavigationPolicy(const ResourceRequest& request, bool didReceiveRedirectResponse, DocumentLoader* loader, PassRefPtr<FormState> formState, NavigationPolicyDecisionFunction function) { NavigationAction action = loader->triggeringAction(); if (action.isEmpty()) { action = NavigationAction(request, NavigationType::Other, loader->shouldOpenExternalURLsPolicyToPropagate()); loader->setTriggeringAction(action); } // Don't ask more than once for the same request or if we are loading an empty URL. // This avoids confusion on the part of the client. if (equalIgnoringHeaderFields(request, loader->lastCheckedRequest()) || (!request.isNull() && request.url().isEmpty())) { function(request, 0, true); loader->setLastCheckedRequest(request); return; } // We are always willing to show alternate content for unreachable URLs; // treat it like a reload so it maintains the right state for b/f list. if (loader->substituteData().isValid() && !loader->substituteData().failingURL().isEmpty()) { if (isBackForwardLoadType(m_loadType)) m_loadType = FrameLoadType::Reload; function(request, 0, true); return; } if (!isAllowedByContentSecurityPolicy(request.url(), m_frame.ownerElement(), didReceiveRedirectResponse)) { function(request, 0, false); return; } loader->setLastCheckedRequest(request); m_callback.set(request, formState.get(), WTFMove(function)); #if USE(QUICK_LOOK) // Always allow QuickLook-generated URLs based on the protocol scheme. if (!request.isNull() && request.url().protocolIs(QLPreviewProtocol())) { continueAfterNavigationPolicy(PolicyUse); return; } #endif #if ENABLE(CONTENT_FILTERING) if (m_contentFilterUnblockHandler.canHandleRequest(request)) { RefPtr<Frame> frame { &m_frame }; m_contentFilterUnblockHandler.requestUnblockAsync([frame](bool unblocked) { if (unblocked) frame->loader().reload(); }); continueAfterNavigationPolicy(PolicyIgnore); return; } m_contentFilterUnblockHandler = { }; #endif m_delegateIsDecidingNavigationPolicy = true; m_suggestedFilename = action.downloadAttribute(); m_frame.loader().client().dispatchDecidePolicyForNavigationAction(action, request, formState, [this](PolicyAction action) { continueAfterNavigationPolicy(action); }); m_delegateIsDecidingNavigationPolicy = false; }