|
Lines 963-972
WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp_sec1
|
| 963 |
return newPage->mainFrame()->d->frame; |
963 |
return newPage->mainFrame()->d->frame; |
| 964 |
} |
964 |
} |
| 965 |
|
965 |
|
|
|
966 |
static bool shouldTreatAsAttachment(const ResourceResponse& response) |
| 967 |
{ |
| 968 |
const String& contentDisposition = |
| 969 |
response.httpHeaderField("Content-Disposition"); |
| 970 |
if (contentDisposition.isEmpty()) |
| 971 |
return false; |
| 972 |
|
| 973 |
// Some broken sites just send |
| 974 |
// Content-Disposition: ; filename="file" |
| 975 |
// screen those out here. |
| 976 |
if (contentDisposition.startsWith(";")) |
| 977 |
return false; |
| 978 |
|
| 979 |
if (contentDisposition.startsWith("inline", false)) |
| 980 |
return false; |
| 981 |
|
| 982 |
// Some broken sites just send |
| 983 |
// Content-Disposition: filename="file" |
| 984 |
// without a disposition token... screen those out. |
| 985 |
if (contentDisposition.startsWith("filename", false)) |
| 986 |
return false; |
| 987 |
|
| 988 |
// Also in use is Content-Disposition: name="file" |
| 989 |
if (contentDisposition.startsWith("name", false)) |
| 990 |
return false; |
| 991 |
|
| 992 |
// We have a content-disposition of "attachment" or unknown. |
| 993 |
// RFC 2183, section 2.8 says that an unknown disposition |
| 994 |
// value should be treated as "attachment" |
| 995 |
return true; |
| 996 |
} |
| 997 |
|
| 966 |
void FrameLoaderClientQt::dispatchDecidePolicyForMIMEType(FramePolicyFunction function, const WebCore::String& MIMEType, const WebCore::ResourceRequest&) |
998 |
void FrameLoaderClientQt::dispatchDecidePolicyForMIMEType(FramePolicyFunction function, const WebCore::String& MIMEType, const WebCore::ResourceRequest&) |
| 967 |
{ |
999 |
{ |
| 968 |
// we need to call directly here |
1000 |
// we need to call directly here |
| 969 |
if (canShowMIMEType(MIMEType)) |
1001 |
if (shouldTreatAsAttachment(m_frame->loader()->activeDocumentLoader()->response())) |
|
|
1002 |
callPolicyFunction(function, PolicyDownload); |
| 1003 |
else if (canShowMIMEType(MIMEType)) |
| 970 |
callPolicyFunction(function, PolicyUse); |
1004 |
callPolicyFunction(function, PolicyUse); |
| 971 |
else |
1005 |
else |
| 972 |
callPolicyFunction(function, PolicyDownload); |
1006 |
callPolicyFunction(function, PolicyDownload); |