From 1e51c8e2be1aabe013c4595352e2e1edc16ae0de Mon Sep 17 00:00:00 2001 From: Patrick Scott Date: Fri, 21 May 2010 14:26:44 -0400 Subject: Do not try to show pdf's in the browser. We were skipping the canShowMIMEType check if content_disposition was non-empty. That was causing us to treat an inline content disposition as if we could show it in the browser. Instead, fallback to checking the mime type so we download files that we can't natively show. Bug: 2698159 Change-Id: I846dfea565bc4eeade9d679a0101a81858ef29cb --- .../WebCoreSupport/FrameLoaderClientAndroid.cpp | 44 ++++++++++++---------- 1 file changed, 25 insertions(+), 19 deletions(-) (limited to 'WebKit/android') diff --git a/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp b/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp index 79c64fd..4d5992e 100644 --- a/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp +++ b/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp @@ -463,8 +463,11 @@ void FrameLoaderClientAndroid::dispatchDecidePolicyForMIMEType(FramePolicyFuncti ASSERT(func); if (!func) return; + + PolicyChecker* policy = m_frame->loader()->policyChecker(); + if (request.isNull()) { - (m_frame->loader()->policyChecker()->*func)(PolicyIgnore); + (policy->*func)(PolicyIgnore); return; } // Default to Use (display internally). @@ -472,30 +475,33 @@ void FrameLoaderClientAndroid::dispatchDecidePolicyForMIMEType(FramePolicyFuncti // 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()) { + if (!content_disposition.isEmpty() && + TreatAsAttachment(content_disposition)) { // 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; - } + // 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; + (policy->*func)(action); + return; + } + + // 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; + (policy->*func)(action); + return; } // 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); + (policy->*func)(action); } void FrameLoaderClientAndroid::dispatchDecidePolicyForNewWindowAction(FramePolicyFunction func, -- cgit v1.1