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

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

Issue 1705903003: Special case support for MHTML archives consisting of a single image. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a special case for MHTML archives of one resource Created 4 years, 10 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 | « no previous file | 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 4c8811dcaf0429650b643978e56a654098f0f6cd..d749a587a0e713378fc3f23dba29f89d8ca07c9c 100644
--- a/third_party/WebKit/Source/platform/mhtml/MHTMLArchive.cpp
+++ b/third_party/WebKit/Source/platform/mhtml/MHTMLArchive.cpp
@@ -83,6 +83,19 @@ PassRefPtrWillBeRawPtr<MHTMLArchive> MHTMLArchive::create(const KURL& url, Share
return nullptr; // Invalid MHTML file.
RefPtrWillBeRawPtr<MHTMLArchive> archive = adoptRefWillBeNoop(new MHTMLArchive);
+ // Special case for single resource archives, in that case we will make an image
+ // the main resource.
+ if (resources.size() == 1) {
+ const AtomicString& mimeType = resources[0]->mimeType();
+ if (MIMETypeRegistry::isSupportedNonImageMIMEType(mimeType)
+ || MIMETypeRegistry::isSupportedImageResourceMIMEType(mimeType)) {
+ archive->setMainResource(resources[0].get());
+ } else {
+ archive->addSubresource(resources[0].get());
+ }
+ return archive.release();
+ }
+
// The first document suitable resource is the main resource of the top frame.
for (size_t i = 0; i < resources.size(); ++i) {
const AtomicString& mimeType = resources[i]->mimeType();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698