Index: third_party/WebKit/Source/web/WebPageSerializer.cpp |
diff --git a/third_party/WebKit/Source/web/WebPageSerializer.cpp b/third_party/WebKit/Source/web/WebPageSerializer.cpp |
index 193da0a60ca134135d630398d24c567b403cd21d..336926b057a528da0b119caf7364686516f201fb 100644 |
--- a/third_party/WebKit/Source/web/WebPageSerializer.cpp |
+++ b/third_party/WebKit/Source/web/WebPageSerializer.cpp |
@@ -87,10 +87,38 @@ bool MHTMLPageSerializerDelegate::shouldIgnoreAttribute(const Attribute& attribu |
static PassRefPtr<SharedBuffer> serializePageToMHTML(Page* page, MHTMLArchive::EncodingPolicy encodingPolicy) |
dcheng
2015/11/12 23:47:32
Is this covered by any tests right now?
Łukasz Anforowicz
2015/11/13 00:22:10
If "this" = "serializePageToMHTML function", then
|
{ |
Vector<SerializedResource> resources; |
+ HashSet<KURL> alreadySerializedUrls; |
PageSerializer serializer(&resources, adoptPtr(new MHTMLPageSerializerDelegate)); |
- serializer.serialize(page); |
+ |
+ RefPtr<SharedBuffer> output = SharedBuffer::create(); |
+ String boundary = MHTMLArchive::generateMHTMLBoundary(); |
+ |
Document* document = page->deprecatedLocalMainFrame()->document(); |
- return MHTMLArchive::generateMHTMLData(resources, encodingPolicy, document->title(), document->suggestedMIMEType()); |
+ MHTMLArchive::generateMHTMLHeader( |
+ boundary, document->title(), document->suggestedMIMEType(), *output); |
+ |
+ Frame* frame = page->deprecatedLocalMainFrame(); |
+ for (; frame; frame = frame->tree().traverseNext()) { |
+ // TODO(lukasza): This causes incomplete MHTML for OOPIFs. |
+ // (crbug.com/538766) |
+ if (!frame->isLocalFrame()) |
+ continue; |
+ |
+ resources.clear(); |
+ serializer.serializeFrame(toLocalFrame(frame)); |
+ |
+ for (const auto& resource : resources) { |
+ if (alreadySerializedUrls.contains(resource.url)) |
+ continue; |
+ alreadySerializedUrls.add(resource.url); |
+ |
+ MHTMLArchive::generateMHTMLPart( |
+ boundary, encodingPolicy, resource, *output); |
+ } |
+ } |
+ |
+ MHTMLArchive::generateMHTMLFooter(boundary, *output); |
+ return output.release(); |
} |
WebCString WebPageSerializer::serializeToMHTML(WebView* view) |