| Index: third_party/WebKit/Source/platform/mhtml/MHTMLArchive.cpp
|
| diff --git a/third_party/WebKit/Source/platform/mhtml/MHTMLArchive.cpp b/third_party/WebKit/Source/platform/mhtml/MHTMLArchive.cpp
|
| index 6a852fe6faf774d5f03b5e928127c9697bdf0309..cca842e5ccd52da9bb7b2e4f0fee3ac363c6f0c4 100644
|
| --- a/third_party/WebKit/Source/platform/mhtml/MHTMLArchive.cpp
|
| +++ b/third_party/WebKit/Source/platform/mhtml/MHTMLArchive.cpp
|
| @@ -78,34 +78,16 @@
|
| return nullptr; // Invalid MHTML file.
|
|
|
| MHTMLArchive* archive = new MHTMLArchive;
|
| -
|
| - size_t resourcesCount = resources.size();
|
| // The first document suitable resource is the main resource of the top frame.
|
| - for (size_t i = 0; i < resourcesCount; ++i) {
|
| - if (archive->mainResource()) {
|
| + for (size_t i = 0; i < resources.size(); ++i) {
|
| + const AtomicString& mimeType = resources[i]->mimeType();
|
| + if (archive->mainResource() ||
|
| + !MIMETypeRegistry::isSupportedNonImageMIMEType(mimeType) ||
|
| + MIMETypeRegistry::isSupportedJavaScriptMIMEType(mimeType) ||
|
| + mimeType == "text/css")
|
| archive->addSubresource(resources[i].get());
|
| - continue;
|
| - }
|
| -
|
| - const AtomicString& mimeType = resources[i]->mimeType();
|
| - bool isMimeTypeSuitableForMainResource =
|
| - MIMETypeRegistry::isSupportedNonImageMIMEType(mimeType);
|
| - // Want to allow image-only MHTML archives, but retain behavior for other
|
| - // documents that have already been created expecting the first HTML page to
|
| - // be considered the main resource.
|
| - if (resourcesCount == 1 &&
|
| - MIMETypeRegistry::isSupportedImageResourceMIMEType(mimeType)) {
|
| - isMimeTypeSuitableForMainResource = true;
|
| - }
|
| - // explicitly disallow JS and CSS as the main resource.
|
| - if (MIMETypeRegistry::isSupportedJavaScriptMIMEType(mimeType) ||
|
| - MIMETypeRegistry::isSupportedStyleSheetMIMEType(mimeType))
|
| - isMimeTypeSuitableForMainResource = false;
|
| -
|
| - if (isMimeTypeSuitableForMainResource)
|
| + else
|
| archive->setMainResource(resources[i].get());
|
| - else
|
| - archive->addSubresource(resources[i].get());
|
| }
|
| return archive;
|
| }
|
|
|