bool DocumentLoader::shouldContinueForResponse() const { if (m_substituteData.isValid()) return true; int statusCode = m_response.httpStatusCode(); if (statusCode == 204 || statusCode == 205) { // The server does not want us to replace the page contents. return false; } if (contentDispositionType(m_response.httpHeaderField("Content-Disposition")) == ContentDispositionAttachment) { // The server wants us to download instead of replacing the page contents. // Downloading is handled by the embedder, but we still get the initial // response so that we can ignore it and clean up properly. return false; } if (!canShowMIMEType(m_response.mimeType(), m_frame->page())) return false; // Prevent remote web archives from loading because they can claim to be from any domain and thus avoid cross-domain security checks. if (equalIgnoringCase("multipart/related", m_response.mimeType()) && !SchemeRegistry::shouldTreatURLSchemeAsLocal(m_request.url().protocol())) return false; return true; }
void FrameLoaderClient::dispatchDecidePolicyForMIMEType(FramePolicyFunction policyFunction, const String& mimeType, const ResourceRequest& resourceRequest) { ASSERT(policyFunction); if (!policyFunction) return; if (resourceRequest.isNull()) { (core(m_frame)->loader()->policyChecker()->*policyFunction)(PolicyIgnore); return; } WebKitWebView* page = getViewFromFrame(m_frame); WebKitNetworkRequest* request = webkit_network_request_new_with_core_request(resourceRequest); WebKitWebPolicyDecision* policyDecision = webkit_web_policy_decision_new(m_frame, policyFunction); if (m_policyDecision) g_object_unref(m_policyDecision); m_policyDecision = policyDecision; gboolean isHandled = false; g_signal_emit_by_name(page, "mime-type-policy-decision-requested", m_frame, request, mimeType.utf8().data(), policyDecision, &isHandled); g_object_unref(request); if (isHandled) return; if (canShowMIMEType(mimeType)) webkit_web_policy_decision_use (policyDecision); else webkit_web_policy_decision_ignore (policyDecision); }
void FrameLoaderClientEfl::dispatchDecidePolicyForMIMEType(FramePolicyFunction function, const String& MIMEType, const ResourceRequest&) { // we need to call directly here (currently callPolicyFunction does that!) ASSERT(function); if (canShowMIMEType(MIMEType)) callPolicyFunction(function, PolicyUse); else callPolicyFunction(function, PolicyDownload); }
void FrameLoaderClientQt::dispatchDecidePolicyForMIMEType(FramePolicyFunction function, const WebCore::String& MIMEType, const WebCore::ResourceRequest&) { // we need to call directly here Q_ASSERT(!m_policyFunction); m_policyFunction = function; if (canShowMIMEType(MIMEType)) slotCallPolicyFunction(PolicyUse); else slotCallPolicyFunction(PolicyDownload); }
void FrameLoaderClientQt::dispatchDecidePolicyForMIMEType(FramePolicyFunction function, const WebCore::String& MIMEType, const WebCore::ResourceRequest&) { // we need to call directly here const ResourceResponse& response = m_frame->loader()->activeDocumentLoader()->response(); if (WebCore::contentDispositionType(response.httpHeaderField("Content-Disposition")) == WebCore::ContentDispositionAttachment) callPolicyFunction(function, PolicyDownload); else if (canShowMIMEType(MIMEType)) callPolicyFunction(function, PolicyUse); else callPolicyFunction(function, PolicyDownload); }
void FrameLoaderClientEfl::dispatchDecidePolicyForResponse(FramePolicyFunction function, const ResourceResponse& response, const ResourceRequest& resourceRequest) { // we need to call directly here (currently callPolicyFunction does that!) ASSERT(function); if (resourceRequest.isNull()) { callPolicyFunction(function, PolicyIgnore); return; } if (canShowMIMEType(response.mimeType())) callPolicyFunction(function, PolicyUse); else callPolicyFunction(function, PolicyDownload); }
void FrameLoaderClientAndroid::dispatchDecidePolicyForMIMEType(FramePolicyFunction func, const String& MIMEType, const ResourceRequest& request) { ASSERT(m_frame); ASSERT(func); if (!func) return; if (request.isNull()) { (m_frame->loader()->policyChecker()->*func)(PolicyIgnore); return; } // Default to Use (display internally). PolicyAction action = PolicyUse; // Check if we should Download instead. const ResourceResponse& response = m_frame->loader()->activeDocumentLoader()->response(); const String& content_disposition = response.httpHeaderField("Content-Disposition"); if (!content_disposition.isEmpty()) { // Server wants to override our normal policy. if (TreatAsAttachment(content_disposition)) { // Check to see if we are a sub frame (main frame has no owner element) if (m_frame->ownerElement() != 0) action = PolicyIgnore; else action = PolicyDownload; } } else { // Ask if it can be handled internally. if (!canShowMIMEType(MIMEType)) { // Check to see if we are a sub frame (main frame has no owner element) if (m_frame->ownerElement() != 0) action = PolicyIgnore; else action = PolicyDownload; } //SAMSUNG CHANGE + //when svg is not supported ,make svg downloadable when it is Main frame #if !ENABLE(SVG) if ((MIMEType == "image/svg+xml") && (m_frame->ownerElement() == 0)) { action = PolicyDownload; } #endif //SAMSUNG CHANGE - } // A status code of 204 indicates no content change. Ignore the result. WebCore::DocumentLoader* docLoader = m_frame->loader()->activeDocumentLoader(); if (docLoader->response().httpStatusCode() == 204) action = PolicyIgnore; (m_frame->loader()->policyChecker()->*func)(action); }
void FrameLoaderClientBlackBerry::dispatchDecidePolicyForResponse(FramePolicyFunction function, const ResourceResponse& response, const ResourceRequest& request) { // FIXME: What should we do for HTTP status code 204 and 205 and "application/zip"? PolicyAction policy = PolicyIgnore; if (contentDispositionType(response.httpHeaderField("Content-Disposition")) == ContentDispositionAttachment || request.forceDownload()) policy = PolicyDownload; else if (canShowMIMEType(response.mimeType())) policy = PolicyUse; else if ((ResourceRequest::TargetIsMainFrame == request.targetType()) && m_webPagePrivate->m_client->downloadAllowed(request.url().string().utf8().data())) policy = PolicyDownload; (m_frame->loader()->policyChecker()->*function)(policy); }
void FrameLoaderClient::dispatchDecidePolicyForResponse(FramePolicyFunction policyFunction, const ResourceResponse& response, const ResourceRequest& resourceRequest) { ASSERT(policyFunction); if (!policyFunction) return; if (resourceRequest.isNull()) { (core(m_frame)->loader()->policyChecker()->*policyFunction)(PolicyIgnore); return; } WebKitWebView* page = getViewFromFrame(m_frame); GRefPtr<WebKitNetworkRequest> request(adoptGRef(kitNew(resourceRequest))); WebKitWebPolicyDecision* policyDecision = webkit_web_policy_decision_new(m_frame, policyFunction); if (m_policyDecision) g_object_unref(m_policyDecision); m_policyDecision = policyDecision; String mimeType = response.mimeType(); gboolean isHandled = false; g_signal_emit_by_name(page, "mime-type-policy-decision-requested", m_frame, request.get(), mimeType.utf8().data(), policyDecision, &isHandled); if (isHandled) return; GRefPtr<WebKitNetworkResponse> networkResponse(adoptGRef(webkit_web_frame_get_network_response(m_frame))); if (networkResponse) { ResourceResponse response = core(networkResponse.get()); if (response.isAttachment()) { webkit_web_policy_decision_download(policyDecision); return; } } if (canShowMIMEType(mimeType)) webkit_web_policy_decision_use(policyDecision); else webkit_web_policy_decision_ignore(policyDecision); }
void FrameLoaderClientEfl::dispatchDecidePolicyForResponse(const ResourceResponse& response, const ResourceRequest& resourceRequest, FramePolicyFunction function) { // we need to call directly here (currently callPolicyFunction does that!) ASSERT(function); if (resourceRequest.isNull()) { callPolicyFunction(function, PolicyIgnore); return; } // Ignore responses with an HTTP status code of 204 (No Content) if (response.httpStatusCode() == HTTPNoContent) { callPolicyFunction(function, PolicyIgnore); return; } if (canShowMIMEType(response.mimeType())) callPolicyFunction(function, PolicyUse); else callPolicyFunction(function, PolicyDownload); }
bool DocumentLoader::shouldContinueForResponse() const { if (m_substituteData.isValid()) return true; int statusCode = m_response.httpStatusCode(); if (statusCode == 204 || statusCode == 205) { // The server does not want us to replace the page contents. return false; } if (getContentDispositionType(m_response.httpHeaderField( HTTPNames::Content_Disposition)) == ContentDispositionAttachment) { // The server wants us to download instead of replacing the page contents. // Downloading is handled by the embedder, but we still get the initial // response so that we can ignore it and clean up properly. return false; } if (!canShowMIMEType(m_response.mimeType(), m_frame)) return false; return true; }