OLD | NEW |
---|---|
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 Loading... | |
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; } | |
dcheng
2016/05/20 20:25:02
Is this just incidental cleanup to make the policy
dewittj
2016/05/20 21:22:22
Incidental. Do you prefer I revert it? It cleane
| |
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 Loading... | |
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 success = true; | |
4963 | |
4956 // Generate MHTML header if needed. | 4964 // Generate MHTML header if needed. |
4957 if (IsMainFrame()) { | 4965 if (IsMainFrame()) { |
4958 blink::WebFrameSerializerCacheControlPolicy policy = | 4966 // |data| can be empty if the main frame should be skipped. If the main |
4959 static_cast<blink::WebFrameSerializerCacheControlPolicy>( | 4967 // frame is |
4960 params.mhtml_cache_control_policy); | 4968 // skipped, then the whole archive is bad, so bail to the error condition. |
4961 success = WebFrameSerializer::generateMHTMLHeader(mhtml_boundary, policy, | 4969 WebData data = WebFrameSerializer::generateMHTMLHeader( |
4962 GetWebFrame(), &data); | 4970 mhtml_boundary, GetWebFrame(), &delegate); |
4963 if (success && file.WriteAtCurrentPos(data.data(), data.size()) < 0) { | 4971 if (data.size() == 0 || |
dcheng
2016/05/20 20:25:02
data.isEmpty()
dcheng
2016/05/20 20:25:02
isEmpty()
dewittj
2016/05/20 21:22:22
Done.
| |
4972 file.WriteAtCurrentPos(data.data(), data.size()) < 0) { | |
4964 success = false; | 4973 success = false; |
4965 } | 4974 } |
4966 } | 4975 } |
4967 | 4976 |
4968 // Generate MHTML parts. | 4977 // Generate MHTML parts. Note that if this is not the main frame, then even |
4978 // skipping the whole parts generation step is not an error - it simply | |
4979 // results in an omitted resource in the final file. | |
4969 if (success) { | 4980 if (success) { |
4970 data = WebFrameSerializer::generateMHTMLParts( | 4981 // |data| can be empty if the frame should be skipped, but this is OK. |
4971 mhtml_boundary, GetWebFrame(), params.mhtml_binary_encoding, &delegate); | 4982 data = WebFrameSerializer::generateMHTMLParts(mhtml_boundary, GetWebFrame(), |
4983 &delegate); | |
4972 // TODO(jcivelli): write the chunks in deferred tasks to give a chance to | 4984 // TODO(jcivelli): write the chunks in deferred tasks to give a chance to |
4973 // the message loop to process other events. | 4985 // the message loop to process other events. |
4974 if (file.WriteAtCurrentPos(data.data(), data.size()) < 0) { | 4986 if (data.size() > 0 && |
dcheng
2016/05/20 20:25:02
!data.isEmpty()
dcheng
2016/05/20 20:25:02
!isEmpty()
dewittj
2016/05/20 21:22:22
Done.
| |
4987 file.WriteAtCurrentPos(data.data(), data.size()) < 0) { | |
4975 success = false; | 4988 success = false; |
4976 } | 4989 } |
4977 } | 4990 } |
4978 | 4991 |
4979 // Generate MHTML footer if needed. | 4992 // Generate MHTML footer if needed. |
4980 if (success && params.is_last_frame) { | 4993 if (success && params.is_last_frame) { |
4981 data = WebFrameSerializer::generateMHTMLFooter(mhtml_boundary); | 4994 data = WebFrameSerializer::generateMHTMLFooter(mhtml_boundary); |
4982 if (file.WriteAtCurrentPos(data.data(), data.size()) < 0) { | 4995 if (file.WriteAtCurrentPos(data.data(), data.size()) < 0) { |
4983 success = false; | 4996 success = false; |
4984 } | 4997 } |
(...skipping 1158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6143 // event target. Potentially a Pepper plugin will receive the event. | 6156 // 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 | 6157 // 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 | 6158 // 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 | 6159 // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
6147 // |pepper_last_mouse_event_target_|. | 6160 // |pepper_last_mouse_event_target_|. |
6148 pepper_last_mouse_event_target_ = nullptr; | 6161 pepper_last_mouse_event_target_ = nullptr; |
6149 #endif | 6162 #endif |
6150 } | 6163 } |
6151 | 6164 |
6152 } // namespace content | 6165 } // namespace content |
OLD | NEW |