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

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

Issue 1977303003: Adds a feature to MHTML serialization that omits subframes and subresources marked no-store. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@no-store
Patch Set: Adds a test that compares actual visible content. Created 4 years, 7 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 689 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 int routing_id = GetRoutingIdForFrameOrProxy(frame); 700 int routing_id = GetRoutingIdForFrameOrProxy(frame);
701 701
702 auto it = params_.frame_routing_id_to_content_id.find(routing_id); 702 auto it = params_.frame_routing_id_to_content_id.find(routing_id);
703 if (it == params_.frame_routing_id_to_content_id.end()) 703 if (it == params_.frame_routing_id_to_content_id.end())
704 return WebString(); 704 return WebString();
705 705
706 const std::string& content_id = it->second; 706 const std::string& content_id = it->second;
707 return WebString::fromUTF8(content_id); 707 return WebString::fromUTF8(content_id);
708 } 708 }
709 709
710 blink::WebFrameSerializerCacheControlPolicy cacheControlPolicy() override {
711 return static_cast<blink::WebFrameSerializerCacheControlPolicy>(
712 params_.mhtml_cache_control_policy);
713 }
714
715 bool useBinaryEncoding() override { return params_.mhtml_binary_encoding; }
716
710 private: 717 private:
711 const FrameMsg_SerializeAsMHTML_Params& params_; 718 const FrameMsg_SerializeAsMHTML_Params& params_;
712 std::set<std::string>* digests_of_uris_of_serialized_resources_; 719 std::set<std::string>* digests_of_uris_of_serialized_resources_;
713 720
714 DISALLOW_COPY_AND_ASSIGN(MHTMLPartsGenerationDelegate); 721 DISALLOW_COPY_AND_ASSIGN(MHTMLPartsGenerationDelegate);
715 }; 722 };
716 723
717 // Returns true if a subresource certificate error (described by |url| 724 // Returns true if a subresource certificate error (described by |url|
718 // and |security_info|) is "interesting" to the browser process. The 725 // and |security_info|) is "interesting" to the browser process. The
719 // browser process is interested in certificate errors that differ from 726 // browser process is interested in certificate errors that differ from
(...skipping 4221 matching lines...) Expand 10 before | Expand all | Expand 10 after
4941 4948
4942 void RenderFrameImpl::OnSerializeAsMHTML( 4949 void RenderFrameImpl::OnSerializeAsMHTML(
4943 const FrameMsg_SerializeAsMHTML_Params& params) { 4950 const FrameMsg_SerializeAsMHTML_Params& params) {
4944 // Unpack IPC payload. 4951 // Unpack IPC payload.
4945 base::File file = IPC::PlatformFileForTransitToFile(params.destination_file); 4952 base::File file = IPC::PlatformFileForTransitToFile(params.destination_file);
4946 const WebString mhtml_boundary = 4953 const WebString mhtml_boundary =
4947 WebString::fromUTF8(params.mhtml_boundary_marker); 4954 WebString::fromUTF8(params.mhtml_boundary_marker);
4948 DCHECK(!mhtml_boundary.isEmpty()); 4955 DCHECK(!mhtml_boundary.isEmpty());
4949 4956
4950 WebData data; 4957 WebData data;
4951 bool success = true;
4952 std::set<std::string> digests_of_uris_of_serialized_resources; 4958 std::set<std::string> digests_of_uris_of_serialized_resources;
4953 MHTMLPartsGenerationDelegate delegate( 4959 MHTMLPartsGenerationDelegate delegate(
4954 params, &digests_of_uris_of_serialized_resources); 4960 params, &digests_of_uris_of_serialized_resources);
4955 4961
4962 bool should_serialize_frame =
4963 WebFrameSerializer::frameShouldBeSerializedAsMHTML(GetWebFrame(),
4964 &delegate);
Łukasz Anforowicz 2016/05/19 17:00:13 Do we still need this (this = |should_serialize_fr
dewittj 2016/05/19 18:18:36 Done.
4965 bool success = true;
4966
4956 // Generate MHTML header if needed. 4967 // Generate MHTML header if needed.
4957 if (IsMainFrame()) { 4968 if (IsMainFrame()) {
4958 blink::WebFrameSerializerCacheControlPolicy policy = 4969 if (should_serialize_frame) {
4959 static_cast<blink::WebFrameSerializerCacheControlPolicy>( 4970 WebData data = WebFrameSerializer::generateMHTMLHeader(
4960 params.mhtml_cache_control_policy); 4971 mhtml_boundary, GetWebFrame(), &delegate);
4961 success = WebFrameSerializer::generateMHTMLHeader(mhtml_boundary, policy, 4972 if (file.WriteAtCurrentPos(data.data(), data.size()) < 0) {
Łukasz Anforowicz 2016/05/19 17:00:13 Just double-checking: do we need to check here is
dewittj 2016/05/19 18:18:35 Done.
4962 GetWebFrame(), &data); 4973 success = false;
4963 if (success && file.WriteAtCurrentPos(data.data(), data.size()) < 0) { 4974 }
4975 } else {
4976 // If we can't serialize the main frame, the whole archive is bad.
4964 success = false; 4977 success = false;
4965 } 4978 }
4966 } 4979 }
4967 4980
4968 // Generate MHTML parts. 4981 // Generate MHTML parts. Note that if this is not the main frame, then even
4969 if (success) { 4982 // skipping the whole parts generation step is not an error - it simply
4970 data = WebFrameSerializer::generateMHTMLParts( 4983 // results in an omitted resource in the final file.
4971 mhtml_boundary, GetWebFrame(), params.mhtml_binary_encoding, &delegate); 4984 if (success && should_serialize_frame) {
4985 data = WebFrameSerializer::generateMHTMLParts(mhtml_boundary, GetWebFrame(),
4986 &delegate);
Łukasz Anforowicz 2016/05/19 17:00:13 Same question as above - do we need to check if ge
dewittj 2016/05/19 18:18:36 Done.
4972 // TODO(jcivelli): write the chunks in deferred tasks to give a chance to 4987 // TODO(jcivelli): write the chunks in deferred tasks to give a chance to
4973 // the message loop to process other events. 4988 // the message loop to process other events.
4974 if (file.WriteAtCurrentPos(data.data(), data.size()) < 0) { 4989 if (file.WriteAtCurrentPos(data.data(), data.size()) < 0) {
4975 success = false; 4990 success = false;
4976 } 4991 }
4977 } 4992 }
4978 4993
4979 // Generate MHTML footer if needed. 4994 // Generate MHTML footer if needed.
4980 if (success && params.is_last_frame) { 4995 if (success && params.is_last_frame) {
4981 data = WebFrameSerializer::generateMHTMLFooter(mhtml_boundary); 4996 data = WebFrameSerializer::generateMHTMLFooter(mhtml_boundary);
(...skipping 1161 matching lines...) Expand 10 before | Expand all | Expand 10 after
6143 // event target. Potentially a Pepper plugin will receive the event. 6158 // event target. Potentially a Pepper plugin will receive the event.
6144 // In order to tell whether a plugin gets the last mouse event and which it 6159 // In order to tell whether a plugin gets the last mouse event and which it
6145 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets 6160 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets
6146 // the event, it will notify us via DidReceiveMouseEvent() and set itself as 6161 // the event, it will notify us via DidReceiveMouseEvent() and set itself as
6147 // |pepper_last_mouse_event_target_|. 6162 // |pepper_last_mouse_event_target_|.
6148 pepper_last_mouse_event_target_ = nullptr; 6163 pepper_last_mouse_event_target_ = nullptr;
6149 #endif 6164 #endif
6150 } 6165 }
6151 6166
6152 } // namespace content 6167 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698