Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(144)

Unified Diff: third_party/WebKit/Source/platform/mhtml/MHTMLArchive.cpp

Issue 2460843002: Revert of Allow image documents in MHT if there is only one resource. (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/platform/win/mhtml/invalid-bad-boundary2-expected.png ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« no previous file with comments | « third_party/WebKit/LayoutTests/platform/win/mhtml/invalid-bad-boundary2-expected.png ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698