Index: content/renderer/render_frame_impl.cc |
diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc |
index d7399ed1d49219bd8f3222665f7e187cef1f06fb..51b804c73541e51ec8cbccfbb4267168e2ce147a 100644 |
--- a/content/renderer/render_frame_impl.cc |
+++ b/content/renderer/render_frame_impl.cc |
@@ -125,6 +125,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" |
@@ -4660,17 +4661,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); |
- const WebString mhtml_boundary = WebString::fromUTF8(std_mhtml_boundary); |
- DCHECK(!mhtml_boundary.isEmpty()); |
+ 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) |
@@ -4679,23 +4675,38 @@ 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 (IsMainFrame()) { |
+ if (success && IsMainFrame()) { |
dcheng
2015/12/11 07:36:05
Revert this.
dcheng
2015/12/11 07:36:05
Please revert this =)
Łukasz Anforowicz
2015/12/14 19:39:02
Ooops. Done (here and for the DCHECK below).
|
data = |
WebPageSerializer::generateMHTMLHeader(mhtml_boundary, GetWebFrame()); |
if (file.WriteAtCurrentPos(data.data(), data.size()) < 0) { |
success = false; |
} |
} |
+ DCHECK(!mhtml_boundary.isEmpty()); |
// 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()); |
dcheng
2015/12/11 07:36:05
I think I would prefer to see a new WebPageSeriali
Łukasz Anforowicz
2015/12/14 19:39:02
Let me think a little bit more about this.
Some r
Łukasz Anforowicz
2015/12/18 17:38:48
Some more ideas:
- Stupid idea: Pass a "callback"
|
+ 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) { |
@@ -4704,7 +4715,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; |
@@ -4713,7 +4724,8 @@ 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)); |
+ Send(new FrameHostMsg_SerializeAsMHTMLResponse( |
+ routing_id_, params.job_id, success, uris_of_generated_mhtml_parts)); |
} |
void RenderFrameImpl::OpenURL(const GURL& url, |