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

Side by Side Diff: content/renderer/render_frame_impl.cc

Issue 2683493002: Get signals working in the EXTRA_DATA section of MHTML (Closed)
Patch Set: Created 3 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/render_frame_impl.h" 5 #include "content/renderer/render_frame_impl.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 5472 matching lines...) Expand 10 before | Expand all | Expand 10 after
5483 5483
5484 void RenderFrameImpl::OnSerializeAsMHTML( 5484 void RenderFrameImpl::OnSerializeAsMHTML(
5485 const FrameMsg_SerializeAsMHTML_Params& params) { 5485 const FrameMsg_SerializeAsMHTML_Params& params) {
5486 TRACE_EVENT0("page-serialization", "RenderFrameImpl::OnSerializeAsMHTML"); 5486 TRACE_EVENT0("page-serialization", "RenderFrameImpl::OnSerializeAsMHTML");
5487 base::TimeTicks start_time = base::TimeTicks::Now(); 5487 base::TimeTicks start_time = base::TimeTicks::Now();
5488 // Unpack IPC payload. 5488 // Unpack IPC payload.
5489 base::File file = IPC::PlatformFileForTransitToFile(params.destination_file); 5489 base::File file = IPC::PlatformFileForTransitToFile(params.destination_file);
5490 const WebString mhtml_boundary = 5490 const WebString mhtml_boundary =
5491 WebString::fromUTF8(params.mhtml_boundary_marker); 5491 WebString::fromUTF8(params.mhtml_boundary_marker);
5492 DCHECK(!mhtml_boundary.isEmpty()); 5492 DCHECK(!mhtml_boundary.isEmpty());
5493 const std::vector<std::string> extra_data(params.extra_data);
5493 5494
5494 // Holds WebThreadSafeData instances for some or all of header, contents and 5495 // Holds WebThreadSafeData instances for some or all of header, contents and
5495 // footer. 5496 // footer.
5496 std::vector<WebThreadSafeData> mhtml_contents; 5497 std::vector<WebThreadSafeData> mhtml_contents;
5497 std::set<std::string> serialized_resources_uri_digests; 5498 std::set<std::string> serialized_resources_uri_digests;
5498 MHTMLPartsGenerationDelegate delegate(params, 5499 MHTMLPartsGenerationDelegate delegate(params,
5499 &serialized_resources_uri_digests); 5500 &serialized_resources_uri_digests);
5500 5501
5501 MhtmlSaveStatus save_status = MhtmlSaveStatus::SUCCESS; 5502 MhtmlSaveStatus save_status = MhtmlSaveStatus::SUCCESS;
5502 bool has_some_data = false; 5503 bool has_some_data = false;
(...skipping 18 matching lines...) Expand all
5521 if (save_status == MhtmlSaveStatus::SUCCESS) { 5522 if (save_status == MhtmlSaveStatus::SUCCESS) {
5522 TRACE_EVENT0("page-serialization", 5523 TRACE_EVENT0("page-serialization",
5523 "RenderFrameImpl::OnSerializeAsMHTML parts serialization"); 5524 "RenderFrameImpl::OnSerializeAsMHTML parts serialization");
5524 // The returned data can be empty if the frame should be skipped, but this 5525 // The returned data can be empty if the frame should be skipped, but this
5525 // is OK. 5526 // is OK.
5526 mhtml_contents.emplace_back(WebFrameSerializer::generateMHTMLParts( 5527 mhtml_contents.emplace_back(WebFrameSerializer::generateMHTMLParts(
5527 mhtml_boundary, GetWebFrame(), &delegate)); 5528 mhtml_boundary, GetWebFrame(), &delegate));
5528 has_some_data |= !mhtml_contents.back().isEmpty(); 5529 has_some_data |= !mhtml_contents.back().isEmpty();
5529 } 5530 }
5530 5531
5532 // Generate signal data (invisible) if needed, with mime-type SIGNAL_DATA
5533 if (IsMainFrame() && extra_data.size() > 0) {
5534 std::string data_string("\n");
5535 data_string.append(mhtml_boundary.utf8());
5536 // TODO(petewil): insert a mime type here instead of just a string
5537 data_string.append("\nEXTRA_DATA\n");
5538
5539 for (const std::string& data : extra_data) {
5540 data_string.append(data);
5541 data_string.append("\n");
5542 }
5543
5544 data_string.append(mhtml_boundary.utf8());
5545 data_string.append("\n");
5546 WebThreadSafeData mhtml_extra_data(data_string.c_str(), data_string.size());
5547 mhtml_contents.emplace_back(mhtml_extra_data);
5548 }
5549
5531 // Generate MHTML footer if needed. 5550 // Generate MHTML footer if needed.
5532 if (save_status == MhtmlSaveStatus::SUCCESS && params.is_last_frame) { 5551 if (save_status == MhtmlSaveStatus::SUCCESS && params.is_last_frame) {
5533 TRACE_EVENT0("page-serialization", 5552 TRACE_EVENT0("page-serialization",
5534 "RenderFrameImpl::OnSerializeAsMHTML footer"); 5553 "RenderFrameImpl::OnSerializeAsMHTML footer");
5535 mhtml_contents.emplace_back( 5554 mhtml_contents.emplace_back(
5536 WebFrameSerializer::generateMHTMLFooter(mhtml_boundary)); 5555 WebFrameSerializer::generateMHTMLFooter(mhtml_boundary));
5537 has_some_data |= !mhtml_contents.back().isEmpty(); 5556 has_some_data |= !mhtml_contents.back().isEmpty();
5538 } 5557 }
5539 5558
5540 // Note: we assume RenderFrameImpl::OnWriteMHTMLToDiskComplete and the rest of 5559 // Note: we assume RenderFrameImpl::OnWriteMHTMLToDiskComplete and the rest of
(...skipping 1273 matching lines...) Expand 10 before | Expand all | Expand 10 after
6814 // event target. Potentially a Pepper plugin will receive the event. 6833 // event target. Potentially a Pepper plugin will receive the event.
6815 // In order to tell whether a plugin gets the last mouse event and which it 6834 // In order to tell whether a plugin gets the last mouse event and which it
6816 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets 6835 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets
6817 // the event, it will notify us via DidReceiveMouseEvent() and set itself as 6836 // the event, it will notify us via DidReceiveMouseEvent() and set itself as
6818 // |pepper_last_mouse_event_target_|. 6837 // |pepper_last_mouse_event_target_|.
6819 pepper_last_mouse_event_target_ = nullptr; 6838 pepper_last_mouse_event_target_ = nullptr;
6820 #endif 6839 #endif
6821 } 6840 }
6822 6841
6823 } // namespace content 6842 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698