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

Side by Side 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: 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 // For security reasons we only load MHTML pages from local URLs. 76 // For security reasons we only load MHTML pages from local URLs.
77 if (!SchemeRegistry::shouldTreatURLSchemeAsLocal(url.protocol())) 77 if (!SchemeRegistry::shouldTreatURLSchemeAsLocal(url.protocol()))
78 return nullptr; 78 return nullptr;
79 79
80 MHTMLParser parser(data); 80 MHTMLParser parser(data);
81 WillBeHeapVector<RefPtrWillBeMember<ArchiveResource>> resources = parser.par seArchive(); 81 WillBeHeapVector<RefPtrWillBeMember<ArchiveResource>> resources = parser.par seArchive();
82 if (resources.isEmpty()) 82 if (resources.isEmpty())
83 return nullptr; // Invalid MHTML file. 83 return nullptr; // Invalid MHTML file.
84 84
85 RefPtrWillBeRawPtr<MHTMLArchive> archive = adoptRefWillBeNoop(new MHTMLArchi ve); 85 RefPtrWillBeRawPtr<MHTMLArchive> archive = adoptRefWillBeNoop(new MHTMLArchi ve);
86 // Special case for single resource archives, in that case we will make an i mage
87 // the main resource.
88 if (resources.size() == 1) {
89 if (MIMETypeRegistry::isSupportedNonImageMIMEType(mimeType)
Dmitry Titov 2016/02/18 01:31:15 I am not sure why you are checking for both non-im
90 || MIMETypeRegistry::isSupportedImageResourceMIMEType(mimeType)) {
91 archive->setMainResource(resources[0].get());
92 } else {
93 archive->addSubresource(resources[0].get());
Dmitry Titov 2016/02/18 01:30:05 Is there a need to add non-recognized mime type as
94 }
95 return archive.release();
96 }
97
86 // The first document suitable resource is the main resource of the top fram e. 98 // The first document suitable resource is the main resource of the top fram e.
87 for (size_t i = 0; i < resources.size(); ++i) { 99 for (size_t i = 0; i < resources.size(); ++i) {
88 const AtomicString& mimeType = resources[i]->mimeType(); 100 const AtomicString& mimeType = resources[i]->mimeType();
89 if (archive->mainResource() || !MIMETypeRegistry::isSupportedNonImageMIM EType(mimeType) || MIMETypeRegistry::isSupportedJavaScriptMIMEType(mimeType) || mimeType == "text/css") 101 if (archive->mainResource() || !MIMETypeRegistry::isSupportedNonImageMIM EType(mimeType) || MIMETypeRegistry::isSupportedJavaScriptMIMEType(mimeType) || mimeType == "text/css")
90 archive->addSubresource(resources[i].get()); 102 archive->addSubresource(resources[i].get());
91 else 103 else
92 archive->setMainResource(resources[i].get()); 104 archive->setMainResource(resources[i].get());
93 } 105 }
94 return archive.release(); 106 return archive.release();
95 } 107 }
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 253
242 DEFINE_TRACE(MHTMLArchive) 254 DEFINE_TRACE(MHTMLArchive)
243 { 255 {
244 visitor->trace(m_mainResource); 256 visitor->trace(m_mainResource);
245 #if ENABLE(OILPAN) 257 #if ENABLE(OILPAN)
246 visitor->trace(m_subresources); 258 visitor->trace(m_subresources);
247 #endif 259 #endif
248 } 260 }
249 261
250 } // namespace blink 262 } // namespace blink
OLDNEW
« 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