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; } |
| 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 = WebFrameSerializer::frameShouldBeSerializedAsMHTML( |
| 4963 GetWebFrame(), &delegate); |
| 4964 |
4956 // Generate MHTML header if needed. | 4965 // Generate MHTML header if needed. |
4957 if (IsMainFrame()) { | 4966 if (success && IsMainFrame()) { |
4958 blink::WebFrameSerializerCacheControlPolicy policy = | 4967 WebData data = WebFrameSerializer::generateMHTMLHeader( |
4959 static_cast<blink::WebFrameSerializerCacheControlPolicy>( | 4968 mhtml_boundary, GetWebFrame(), &delegate); |
4960 params.mhtml_cache_control_policy); | |
4961 success = WebFrameSerializer::generateMHTMLHeader(mhtml_boundary, policy, | |
4962 GetWebFrame(), &data); | |
4963 if (success && file.WriteAtCurrentPos(data.data(), data.size()) < 0) { | 4969 if (success && file.WriteAtCurrentPos(data.data(), data.size()) < 0) { |
4964 success = false; | 4970 success = false; |
4965 } | 4971 } |
4966 } | 4972 } |
4967 | 4973 |
4968 // Generate MHTML parts. | 4974 // Generate MHTML parts. |
4969 if (success) { | 4975 if (success) { |
4970 data = WebFrameSerializer::generateMHTMLParts( | 4976 data = WebFrameSerializer::generateMHTMLParts(mhtml_boundary, GetWebFrame(), |
4971 mhtml_boundary, GetWebFrame(), params.mhtml_binary_encoding, &delegate); | 4977 &delegate); |
4972 // TODO(jcivelli): write the chunks in deferred tasks to give a chance to | 4978 // TODO(jcivelli): write the chunks in deferred tasks to give a chance to |
4973 // the message loop to process other events. | 4979 // the message loop to process other events. |
4974 if (file.WriteAtCurrentPos(data.data(), data.size()) < 0) { | 4980 if (file.WriteAtCurrentPos(data.data(), data.size()) < 0) { |
4975 success = false; | 4981 success = false; |
4976 } | 4982 } |
4977 } | 4983 } |
4978 | 4984 |
4979 // Generate MHTML footer if needed. | 4985 // Generate MHTML footer if needed. |
4980 if (success && params.is_last_frame) { | 4986 if (success && params.is_last_frame) { |
4981 data = WebFrameSerializer::generateMHTMLFooter(mhtml_boundary); | 4987 data = WebFrameSerializer::generateMHTMLFooter(mhtml_boundary); |
(...skipping 1161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6143 // event target. Potentially a Pepper plugin will receive the event. | 6149 // 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 | 6150 // 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 | 6151 // 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 | 6152 // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
6147 // |pepper_last_mouse_event_target_|. | 6153 // |pepper_last_mouse_event_target_|. |
6148 pepper_last_mouse_event_target_ = nullptr; | 6154 pepper_last_mouse_event_target_ = nullptr; |
6149 #endif | 6155 #endif |
6150 } | 6156 } |
6151 | 6157 |
6152 } // namespace content | 6158 } // namespace content |
OLD | NEW |