| Index: content/renderer/render_frame_impl.cc
|
| diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc
|
| index beeed94535d7f1265d40a753b43c2066b76af33a..6ea1f8e15350d848cebc7a2d38802f982edb3d0d 100644
|
| --- a/content/renderer/render_frame_impl.cc
|
| +++ b/content/renderer/render_frame_impl.cc
|
| @@ -124,6 +124,7 @@
|
| #include "content/renderer/web_frame_utils.h"
|
| #include "content/renderer/web_ui_extension.h"
|
| #include "content/renderer/websharedworker_proxy.h"
|
| +#include "crypto/sha2.h"
|
| #include "gin/modules/module_registry.h"
|
| #include "media/audio/audio_output_device.h"
|
| #include "media/base/audio_renderer_mixer_input.h"
|
| @@ -168,6 +169,7 @@
|
| #include "third_party/WebKit/public/web/WebView.h"
|
| #include "third_party/mojo/src/mojo/edk/js/core.h"
|
| #include "third_party/mojo/src/mojo/edk/js/support.h"
|
| +#include "url/gurl.h"
|
| #include "url/url_util.h"
|
|
|
| #if defined(ENABLE_PLUGINS)
|
| @@ -4708,16 +4710,12 @@ void RenderFrameImpl::OnGetSerializedHtmlWithLocalLinks(
|
| }
|
|
|
| void RenderFrameImpl::OnSerializeAsMHTML(
|
| - int job_id,
|
| - IPC::PlatformFileForTransit file_for_transit,
|
| - const std::string& std_mhtml_boundary,
|
| - const std::map<int, std::string>& frame_routing_id_to_content_id,
|
| - bool is_last_frame) {
|
| + const FrameMsg_SerializeAsMHTML_Params& params) {
|
| // Unpack IPC payload.
|
| - base::File file = IPC::PlatformFileForTransitToFile(file_for_transit);
|
| - WebString mhtml_boundary = WebString::fromUTF8(std_mhtml_boundary);
|
| + base::File file = IPC::PlatformFileForTransitToFile(params.destination_file);
|
| + WebString mhtml_boundary = WebString::fromUTF8(params.mhtml_boundary_marker);
|
| std::vector<std::pair<WebFrame*, WebString>> web_frame_to_content_id;
|
| - for (const auto& it : frame_routing_id_to_content_id) {
|
| + for (const auto& it : params.frame_routing_id_to_content_id) {
|
| const std::string& content_id = it.second;
|
| WebFrame* web_frame = GetWebFrameFromRoutingIdForFrameOrProxy(it.first);
|
| if (!web_frame)
|
| @@ -4726,9 +4724,11 @@ void RenderFrameImpl::OnSerializeAsMHTML(
|
| web_frame_to_content_id.push_back(
|
| std::make_pair(web_frame, WebString::fromUTF8(content_id)));
|
| }
|
| + const std::string& salt = params.salt;
|
|
|
| WebData data;
|
| bool success = true;
|
| + std::set<GURL> uris_of_generated_mhtml_parts;
|
|
|
| // Generate MHTML header if needed.
|
| if (success && IsMainFrame()) {
|
| @@ -4745,8 +4745,20 @@ void RenderFrameImpl::OnSerializeAsMHTML(
|
|
|
| // Generate MHTML parts.
|
| if (success) {
|
| - data = WebPageSerializer::generateMHTMLParts(
|
| - mhtml_boundary, GetWebFrame(), false, web_frame_to_content_id);
|
| + std::vector<WebURL> uris_to_skip;
|
| + WebVector<WebURL> all_urls =
|
| + WebPageSerializer::enumerateMHTMLResources(GetWebFrame());
|
| + for (const WebURL url : all_urls) {
|
| + std::string digest = crypto::SHA256HashString(salt + GURL(url).spec());
|
| + if (0 != params.digests_of_uris_to_skip.count(digest))
|
| + uris_to_skip.push_back(url);
|
| + else
|
| + uris_of_generated_mhtml_parts.insert(url);
|
| + }
|
| +
|
| + data = WebPageSerializer::generateMHTMLParts(mhtml_boundary, GetWebFrame(),
|
| + false, web_frame_to_content_id,
|
| + uris_to_skip);
|
| // TODO(jcivelli): write the chunks in deferred tasks to give a chance to
|
| // the message loop to process other events.
|
| if (file.WriteAtCurrentPos(data.data(), data.size()) < 0) {
|
| @@ -4755,7 +4767,7 @@ void RenderFrameImpl::OnSerializeAsMHTML(
|
| }
|
|
|
| // Generate MHTML footer if needed.
|
| - if (success && is_last_frame) {
|
| + if (success && params.is_last_frame) {
|
| data = WebPageSerializer::generateMHTMLFooter(mhtml_boundary);
|
| if (file.WriteAtCurrentPos(data.data(), data.size()) < 0) {
|
| success = false;
|
| @@ -4764,8 +4776,9 @@ void RenderFrameImpl::OnSerializeAsMHTML(
|
|
|
| // Cleanup and notify the browser process about completion.
|
| file.Close(); // Need to flush file contents before sending IPC response.
|
| - Send(new FrameHostMsg_SerializeAsMHTMLResponse(routing_id_, job_id, success,
|
| - mhtml_boundary.utf8()));
|
| + Send(new FrameHostMsg_SerializeAsMHTMLResponse(
|
| + routing_id_, params.job_id, success, mhtml_boundary.utf8(),
|
| + uris_of_generated_mhtml_parts));
|
| }
|
|
|
| void RenderFrameImpl::OpenURL(const GURL& url,
|
|
|