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 48441a08048fc1b8d2bdb290acef211b75a00590..7e9c76be809169ae0af4406036e28583d522581b 100644 |
--- a/third_party/WebKit/Source/web/WebPageSerializer.cpp |
+++ b/third_party/WebKit/Source/web/WebPageSerializer.cpp |
@@ -166,16 +166,34 @@ WebData WebPageSerializer::generateMHTMLHeader( |
return buffer.release(); |
} |
+WebVector<WebURL> WebPageSerializer::enumerateMHTMLResources(WebLocalFrame* webFrame) |
+{ |
+ Vector<SerializedResource> resources; |
+ PageSerializer serializer(resources, nullptr); |
+ serializer.serializeFrame(*toWebLocalFrameImpl(webFrame)->frame()); |
+ |
+ Vector<WebURL> result; |
+ for (size_t i = 0; i < resources.size(); i++) { |
+ const SerializedResource& resource = resources[i]; |
+ if (i != 0) // Report only resources, not the frame. |
+ result.append(resource.url); |
+ } |
+ |
+ return result; |
+} |
+ |
WebData WebPageSerializer::generateMHTMLParts( |
const WebString& boundary, WebLocalFrame* webFrame, bool useBinaryEncoding, |
- const WebVector<std::pair<WebFrame*, WebString>>& webFrameToContentID) |
+ const WebVector<std::pair<WebFrame*, WebString>>& webFrameToContentID, |
+ const WebVector<WebURL>& resourcesToSkip) |
{ |
// Translate arguments from public to internal blink APIs. |
LocalFrame* frame = toWebLocalFrameImpl(webFrame)->frame(); |
MHTMLArchive::EncodingPolicy encodingPolicy = useBinaryEncoding |
? MHTMLArchive::EncodingPolicy::UseBinaryEncoding |
: MHTMLArchive::EncodingPolicy::UseDefaultEncoding; |
- ContentIDMap frameToContentID = createFrameToContentIDMap(webFrameToContentID); |
+ ContentIDMap frameToContentID = |
+ createFrameToContentIDMap(webFrameToContentID); |
// Serialize. |
Vector<SerializedResource> resources; |
@@ -191,6 +209,10 @@ WebData WebPageSerializer::generateMHTMLParts( |
// comment). Frames need a Content-ID header. |
String contentID = isFirstResource ? frameToContentID.get(frame) : String(); |
+ // Resources don't yet get a Content ID and are deduped based on URI. |
+ if (contentID.isEmpty() && resourcesToSkip.contains(resource.url)) |
+ continue; |
+ |
MHTMLArchive::generateMHTMLPart( |
boundary, contentID, encodingPolicy, resource, *output); |