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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 #include "content/common/ssl_status_serialization.h" | 63 #include "content/common/ssl_status_serialization.h" |
64 #include "content/common/swapped_out_messages.h" | 64 #include "content/common/swapped_out_messages.h" |
65 #include "content/common/view_messages.h" | 65 #include "content/common/view_messages.h" |
66 #include "content/public/common/bindings_policy.h" | 66 #include "content/public/common/bindings_policy.h" |
67 #include "content/public/common/browser_side_navigation_policy.h" | 67 #include "content/public/common/browser_side_navigation_policy.h" |
68 #include "content/public/common/content_constants.h" | 68 #include "content/public/common/content_constants.h" |
69 #include "content/public/common/content_features.h" | 69 #include "content/public/common/content_features.h" |
70 #include "content/public/common/content_switches.h" | 70 #include "content/public/common/content_switches.h" |
71 #include "content/public/common/context_menu_params.h" | 71 #include "content/public/common/context_menu_params.h" |
72 #include "content/public/common/isolated_world_ids.h" | 72 #include "content/public/common/isolated_world_ids.h" |
73 #include "content/public/common/mhtml_generation_params.h" | |
74 #include "content/public/common/page_state.h" | 73 #include "content/public/common/page_state.h" |
75 #include "content/public/common/resource_response.h" | 74 #include "content/public/common/resource_response.h" |
76 #include "content/public/common/url_constants.h" | 75 #include "content/public/common/url_constants.h" |
77 #include "content/public/common/url_utils.h" | 76 #include "content/public/common/url_utils.h" |
78 #include "content/public/renderer/browser_plugin_delegate.h" | 77 #include "content/public/renderer/browser_plugin_delegate.h" |
79 #include "content/public/renderer/content_renderer_client.h" | 78 #include "content/public/renderer/content_renderer_client.h" |
80 #include "content/public/renderer/context_menu_client.h" | 79 #include "content/public/renderer/context_menu_client.h" |
81 #include "content/public/renderer/document_state.h" | 80 #include "content/public/renderer/document_state.h" |
82 #include "content/public/renderer/navigation_state.h" | 81 #include "content/public/renderer/navigation_state.h" |
83 #include "content/public/renderer/render_frame_observer.h" | 82 #include "content/public/renderer/render_frame_observer.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 #include "third_party/WebKit/public/platform/WebString.h" | 160 #include "third_party/WebKit/public/platform/WebString.h" |
162 #include "third_party/WebKit/public/platform/WebURL.h" | 161 #include "third_party/WebKit/public/platform/WebURL.h" |
163 #include "third_party/WebKit/public/platform/WebURLError.h" | 162 #include "third_party/WebKit/public/platform/WebURLError.h" |
164 #include "third_party/WebKit/public/platform/WebURLResponse.h" | 163 #include "third_party/WebKit/public/platform/WebURLResponse.h" |
165 #include "third_party/WebKit/public/platform/WebVector.h" | 164 #include "third_party/WebKit/public/platform/WebVector.h" |
166 #include "third_party/WebKit/public/web/WebColorSuggestion.h" | 165 #include "third_party/WebKit/public/web/WebColorSuggestion.h" |
167 #include "third_party/WebKit/public/web/WebConsoleMessage.h" | 166 #include "third_party/WebKit/public/web/WebConsoleMessage.h" |
168 #include "third_party/WebKit/public/web/WebDocument.h" | 167 #include "third_party/WebKit/public/web/WebDocument.h" |
169 #include "third_party/WebKit/public/web/WebFindOptions.h" | 168 #include "third_party/WebKit/public/web/WebFindOptions.h" |
170 #include "third_party/WebKit/public/web/WebFrameSerializer.h" | 169 #include "third_party/WebKit/public/web/WebFrameSerializer.h" |
| 170 #include "third_party/WebKit/public/web/WebFrameSerializerCacheControlPolicy.h" |
171 #include "third_party/WebKit/public/web/WebFrameWidget.h" | 171 #include "third_party/WebKit/public/web/WebFrameWidget.h" |
172 #include "third_party/WebKit/public/web/WebKit.h" | 172 #include "third_party/WebKit/public/web/WebKit.h" |
173 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 173 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
174 #include "third_party/WebKit/public/web/WebMediaStreamRegistry.h" | 174 #include "third_party/WebKit/public/web/WebMediaStreamRegistry.h" |
175 #include "third_party/WebKit/public/web/WebNavigationPolicy.h" | 175 #include "third_party/WebKit/public/web/WebNavigationPolicy.h" |
176 #include "third_party/WebKit/public/web/WebPlugin.h" | 176 #include "third_party/WebKit/public/web/WebPlugin.h" |
177 #include "third_party/WebKit/public/web/WebPluginContainer.h" | 177 #include "third_party/WebKit/public/web/WebPluginContainer.h" |
178 #include "third_party/WebKit/public/web/WebPluginDocument.h" | 178 #include "third_party/WebKit/public/web/WebPluginDocument.h" |
179 #include "third_party/WebKit/public/web/WebPluginParams.h" | 179 #include "third_party/WebKit/public/web/WebPluginParams.h" |
180 #include "third_party/WebKit/public/web/WebRange.h" | 180 #include "third_party/WebKit/public/web/WebRange.h" |
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
731 int routing_id = GetRoutingIdForFrameOrProxy(frame); | 731 int routing_id = GetRoutingIdForFrameOrProxy(frame); |
732 | 732 |
733 auto it = params_.frame_routing_id_to_content_id.find(routing_id); | 733 auto it = params_.frame_routing_id_to_content_id.find(routing_id); |
734 if (it == params_.frame_routing_id_to_content_id.end()) | 734 if (it == params_.frame_routing_id_to_content_id.end()) |
735 return WebString(); | 735 return WebString(); |
736 | 736 |
737 const std::string& content_id = it->second; | 737 const std::string& content_id = it->second; |
738 return WebString::fromUTF8(content_id); | 738 return WebString::fromUTF8(content_id); |
739 } | 739 } |
740 | 740 |
| 741 blink::WebFrameSerializerCacheControlPolicy cacheControlPolicy() override { |
| 742 return params_.mhtml_cache_control_policy; |
| 743 } |
| 744 |
| 745 bool useBinaryEncoding() override { return params_.mhtml_binary_encoding; } |
| 746 |
741 private: | 747 private: |
742 const FrameMsg_SerializeAsMHTML_Params& params_; | 748 const FrameMsg_SerializeAsMHTML_Params& params_; |
743 std::set<std::string>* digests_of_uris_of_serialized_resources_; | 749 std::set<std::string>* digests_of_uris_of_serialized_resources_; |
744 | 750 |
745 DISALLOW_COPY_AND_ASSIGN(MHTMLPartsGenerationDelegate); | 751 DISALLOW_COPY_AND_ASSIGN(MHTMLPartsGenerationDelegate); |
746 }; | 752 }; |
747 | 753 |
748 // Returns true if a subresource certificate error (described by |url| | 754 // Returns true if a subresource certificate error (described by |url| |
749 // and |security_info|) is "interesting" to the browser process. The | 755 // and |security_info|) is "interesting" to the browser process. The |
750 // browser process is interested in certificate errors that differ from | 756 // browser process is interested in certificate errors that differ from |
(...skipping 4205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4956 | 4962 |
4957 void RenderFrameImpl::OnSerializeAsMHTML( | 4963 void RenderFrameImpl::OnSerializeAsMHTML( |
4958 const FrameMsg_SerializeAsMHTML_Params& params) { | 4964 const FrameMsg_SerializeAsMHTML_Params& params) { |
4959 // Unpack IPC payload. | 4965 // Unpack IPC payload. |
4960 base::File file = IPC::PlatformFileForTransitToFile(params.destination_file); | 4966 base::File file = IPC::PlatformFileForTransitToFile(params.destination_file); |
4961 const WebString mhtml_boundary = | 4967 const WebString mhtml_boundary = |
4962 WebString::fromUTF8(params.mhtml_boundary_marker); | 4968 WebString::fromUTF8(params.mhtml_boundary_marker); |
4963 DCHECK(!mhtml_boundary.isEmpty()); | 4969 DCHECK(!mhtml_boundary.isEmpty()); |
4964 | 4970 |
4965 WebData data; | 4971 WebData data; |
4966 bool success = true; | |
4967 std::set<std::string> digests_of_uris_of_serialized_resources; | 4972 std::set<std::string> digests_of_uris_of_serialized_resources; |
4968 MHTMLPartsGenerationDelegate delegate( | 4973 MHTMLPartsGenerationDelegate delegate( |
4969 params, &digests_of_uris_of_serialized_resources); | 4974 params, &digests_of_uris_of_serialized_resources); |
4970 | 4975 |
| 4976 bool success = true; |
| 4977 |
4971 // Generate MHTML header if needed. | 4978 // Generate MHTML header if needed. |
4972 if (IsMainFrame()) { | 4979 if (IsMainFrame()) { |
4973 blink::WebFrameSerializerCacheControlPolicy policy = | 4980 // |data| can be empty if the main frame should be skipped. If the main |
4974 static_cast<blink::WebFrameSerializerCacheControlPolicy>( | 4981 // frame is |
4975 params.mhtml_cache_control_policy); | 4982 // skipped, then the whole archive is bad, so bail to the error condition. |
4976 success = WebFrameSerializer::generateMHTMLHeader(mhtml_boundary, policy, | 4983 WebData data = WebFrameSerializer::generateMHTMLHeader( |
4977 GetWebFrame(), &data); | 4984 mhtml_boundary, GetWebFrame(), &delegate); |
4978 if (success && file.WriteAtCurrentPos(data.data(), data.size()) < 0) { | 4985 if (data.isEmpty() || |
| 4986 file.WriteAtCurrentPos(data.data(), data.size()) < 0) { |
4979 success = false; | 4987 success = false; |
4980 } | 4988 } |
4981 } | 4989 } |
4982 | 4990 |
4983 // Generate MHTML parts. | 4991 // Generate MHTML parts. Note that if this is not the main frame, then even |
| 4992 // skipping the whole parts generation step is not an error - it simply |
| 4993 // results in an omitted resource in the final file. |
4984 if (success) { | 4994 if (success) { |
4985 data = WebFrameSerializer::generateMHTMLParts( | 4995 // |data| can be empty if the frame should be skipped, but this is OK. |
4986 mhtml_boundary, GetWebFrame(), params.mhtml_binary_encoding, &delegate); | 4996 data = WebFrameSerializer::generateMHTMLParts(mhtml_boundary, GetWebFrame(), |
| 4997 &delegate); |
4987 // TODO(jcivelli): write the chunks in deferred tasks to give a chance to | 4998 // TODO(jcivelli): write the chunks in deferred tasks to give a chance to |
4988 // the message loop to process other events. | 4999 // the message loop to process other events. |
4989 if (file.WriteAtCurrentPos(data.data(), data.size()) < 0) { | 5000 if (!data.isEmpty() && |
| 5001 file.WriteAtCurrentPos(data.data(), data.size()) < 0) { |
4990 success = false; | 5002 success = false; |
4991 } | 5003 } |
4992 } | 5004 } |
4993 | 5005 |
4994 // Generate MHTML footer if needed. | 5006 // Generate MHTML footer if needed. |
4995 if (success && params.is_last_frame) { | 5007 if (success && params.is_last_frame) { |
4996 data = WebFrameSerializer::generateMHTMLFooter(mhtml_boundary); | 5008 data = WebFrameSerializer::generateMHTMLFooter(mhtml_boundary); |
4997 if (file.WriteAtCurrentPos(data.data(), data.size()) < 0) { | 5009 if (file.WriteAtCurrentPos(data.data(), data.size()) < 0) { |
4998 success = false; | 5010 success = false; |
4999 } | 5011 } |
(...skipping 1154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6154 // event target. Potentially a Pepper plugin will receive the event. | 6166 // event target. Potentially a Pepper plugin will receive the event. |
6155 // In order to tell whether a plugin gets the last mouse event and which it | 6167 // In order to tell whether a plugin gets the last mouse event and which it |
6156 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets | 6168 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets |
6157 // the event, it will notify us via DidReceiveMouseEvent() and set itself as | 6169 // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
6158 // |pepper_last_mouse_event_target_|. | 6170 // |pepper_last_mouse_event_target_|. |
6159 pepper_last_mouse_event_target_ = nullptr; | 6171 pepper_last_mouse_event_target_ = nullptr; |
6160 #endif | 6172 #endif |
6161 } | 6173 } |
6162 | 6174 |
6163 } // namespace content | 6175 } // namespace content |
OLD | NEW |