Chromium Code Reviews| 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 62 #include "content/common/ssl_status_serialization.h" | 62 #include "content/common/ssl_status_serialization.h" |
| 63 #include "content/common/swapped_out_messages.h" | 63 #include "content/common/swapped_out_messages.h" |
| 64 #include "content/common/view_messages.h" | 64 #include "content/common/view_messages.h" |
| 65 #include "content/public/common/bindings_policy.h" | 65 #include "content/public/common/bindings_policy.h" |
| 66 #include "content/public/common/browser_side_navigation_policy.h" | 66 #include "content/public/common/browser_side_navigation_policy.h" |
| 67 #include "content/public/common/content_constants.h" | 67 #include "content/public/common/content_constants.h" |
| 68 #include "content/public/common/content_features.h" | 68 #include "content/public/common/content_features.h" |
| 69 #include "content/public/common/content_switches.h" | 69 #include "content/public/common/content_switches.h" |
| 70 #include "content/public/common/context_menu_params.h" | 70 #include "content/public/common/context_menu_params.h" |
| 71 #include "content/public/common/isolated_world_ids.h" | 71 #include "content/public/common/isolated_world_ids.h" |
| 72 #include "content/public/common/mhtml_generation.h" | |
| 72 #include "content/public/common/page_state.h" | 73 #include "content/public/common/page_state.h" |
| 73 #include "content/public/common/resource_response.h" | 74 #include "content/public/common/resource_response.h" |
| 74 #include "content/public/common/url_constants.h" | 75 #include "content/public/common/url_constants.h" |
| 75 #include "content/public/common/url_utils.h" | 76 #include "content/public/common/url_utils.h" |
| 76 #include "content/public/renderer/browser_plugin_delegate.h" | 77 #include "content/public/renderer/browser_plugin_delegate.h" |
| 77 #include "content/public/renderer/content_renderer_client.h" | 78 #include "content/public/renderer/content_renderer_client.h" |
| 78 #include "content/public/renderer/context_menu_client.h" | 79 #include "content/public/renderer/context_menu_client.h" |
| 79 #include "content/public/renderer/document_state.h" | 80 #include "content/public/renderer/document_state.h" |
| 80 #include "content/public/renderer/navigation_state.h" | 81 #include "content/public/renderer/navigation_state.h" |
| 81 #include "content/public/renderer/render_frame_observer.h" | 82 #include "content/public/renderer/render_frame_observer.h" |
| (...skipping 4810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4892 | 4893 |
| 4893 void RenderFrameImpl::OnSerializeAsMHTML( | 4894 void RenderFrameImpl::OnSerializeAsMHTML( |
| 4894 const FrameMsg_SerializeAsMHTML_Params& params) { | 4895 const FrameMsg_SerializeAsMHTML_Params& params) { |
| 4895 // Unpack IPC payload. | 4896 // Unpack IPC payload. |
| 4896 base::File file = IPC::PlatformFileForTransitToFile(params.destination_file); | 4897 base::File file = IPC::PlatformFileForTransitToFile(params.destination_file); |
| 4897 const WebString mhtml_boundary = | 4898 const WebString mhtml_boundary = |
| 4898 WebString::fromUTF8(params.mhtml_boundary_marker); | 4899 WebString::fromUTF8(params.mhtml_boundary_marker); |
| 4899 DCHECK(!mhtml_boundary.isEmpty()); | 4900 DCHECK(!mhtml_boundary.isEmpty()); |
| 4900 | 4901 |
| 4901 WebData data; | 4902 WebData data; |
| 4902 bool success = true; | 4903 MHTMLSerializationResult result = MHTMLSerializationResult::OK; |
| 4903 std::set<std::string> digests_of_uris_of_serialized_resources; | 4904 std::set<std::string> digests_of_uris_of_serialized_resources; |
| 4904 MHTMLPartsGenerationDelegate delegate( | 4905 MHTMLPartsGenerationDelegate delegate( |
| 4905 params, &digests_of_uris_of_serialized_resources); | 4906 params, &digests_of_uris_of_serialized_resources); |
| 4906 | 4907 |
| 4907 // Generate MHTML header if needed. | 4908 // Generate MHTML header if needed. |
| 4908 if (IsMainFrame()) { | 4909 if (IsMainFrame()) { |
| 4909 data = | 4910 bool success = WebFrameSerializer::generateMHTMLHeader( |
|
Łukasz Anforowicz
2016/05/12 18:56:49
Hmmm... conveying MHTMLSerializationResult::NO_STO
dewittj
2016/05/12 22:58:01
Since I don't expose more granular errors any more
Łukasz Anforowicz
2016/05/12 23:56:27
Yes - looks good. Thanks.
| |
| 4910 WebFrameSerializer::generateMHTMLHeader(mhtml_boundary, GetWebFrame()); | 4911 mhtml_boundary, |
| 4911 if (file.WriteAtCurrentPos(data.data(), data.size()) < 0) { | 4912 mhtml::toCacheControlPolicy(params.mhtml_cache_control_policy), |
| 4912 success = false; | 4913 GetWebFrame(), &data); |
| 4914 if (!success) { | |
| 4915 result = MHTMLSerializationResult::NO_STORE_MAIN_FRAME; | |
| 4916 } else if (file.WriteAtCurrentPos(data.data(), data.size()) < 0) { | |
| 4917 result = MHTMLSerializationResult::FILE_WRITE_FAILED_IN_HEADER; | |
| 4913 } | 4918 } |
| 4914 } | 4919 } |
| 4915 | 4920 |
| 4916 // Generate MHTML parts. | 4921 // Generate MHTML parts. |
| 4917 if (success) { | 4922 if (result == MHTMLSerializationResult::OK) { |
| 4918 data = WebFrameSerializer::generateMHTMLParts( | 4923 data = WebFrameSerializer::generateMHTMLParts( |
| 4919 mhtml_boundary, GetWebFrame(), params.mhtml_binary_encoding, &delegate); | 4924 mhtml_boundary, GetWebFrame(), params.mhtml_binary_encoding, &delegate); |
| 4920 // TODO(jcivelli): write the chunks in deferred tasks to give a chance to | 4925 // TODO(jcivelli): write the chunks in deferred tasks to give a chance to |
| 4921 // the message loop to process other events. | 4926 // the message loop to process other events. |
| 4922 if (file.WriteAtCurrentPos(data.data(), data.size()) < 0) { | 4927 if (file.WriteAtCurrentPos(data.data(), data.size()) < 0) |
| 4923 success = false; | 4928 result = MHTMLSerializationResult::FILE_WRITE_FAILED_IN_PARTS_GEN; |
| 4924 } | |
| 4925 } | 4929 } |
| 4926 | 4930 |
| 4927 // Generate MHTML footer if needed. | 4931 // Generate MHTML footer if needed. |
| 4928 if (success && params.is_last_frame) { | 4932 if (result == MHTMLSerializationResult::OK && params.is_last_frame) { |
| 4929 data = WebFrameSerializer::generateMHTMLFooter(mhtml_boundary); | 4933 data = WebFrameSerializer::generateMHTMLFooter(mhtml_boundary); |
| 4930 if (file.WriteAtCurrentPos(data.data(), data.size()) < 0) { | 4934 if (file.WriteAtCurrentPos(data.data(), data.size()) < 0) |
| 4931 success = false; | 4935 result = MHTMLSerializationResult::FILE_WRITE_FAILED_IN_FOOTER; |
| 4932 } | |
| 4933 } | 4936 } |
| 4934 | 4937 |
| 4935 // Cleanup and notify the browser process about completion. | 4938 // Cleanup and notify the browser process about completion. |
| 4936 file.Close(); // Need to flush file contents before sending IPC response. | 4939 file.Close(); // Need to flush file contents before sending IPC response. |
| 4937 Send(new FrameHostMsg_SerializeAsMHTMLResponse( | 4940 Send(new FrameHostMsg_SerializeAsMHTMLResponse( |
| 4938 routing_id_, params.job_id, success, | 4941 routing_id_, params.job_id, result, |
| 4939 digests_of_uris_of_serialized_resources)); | 4942 digests_of_uris_of_serialized_resources)); |
| 4940 } | 4943 } |
| 4941 | 4944 |
| 4942 void RenderFrameImpl::OnFind(int request_id, | 4945 void RenderFrameImpl::OnFind(int request_id, |
| 4943 const base::string16& search_text, | 4946 const base::string16& search_text, |
| 4944 const WebFindOptions& options) { | 4947 const WebFindOptions& options) { |
| 4945 // This should only be received on the main frame, since find-in-page is | 4948 // This should only be received on the main frame, since find-in-page is |
| 4946 // currently orchestrated by the main frame. | 4949 // currently orchestrated by the main frame. |
| 4947 if (!is_main_frame_) { | 4950 if (!is_main_frame_) { |
| 4948 NOTREACHED(); | 4951 NOTREACHED(); |
| (...skipping 1078 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6027 int match_count, | 6030 int match_count, |
| 6028 int ordinal, | 6031 int ordinal, |
| 6029 const WebRect& selection_rect, | 6032 const WebRect& selection_rect, |
| 6030 bool final_status_update) { | 6033 bool final_status_update) { |
| 6031 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count, | 6034 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count, |
| 6032 selection_rect, ordinal, | 6035 selection_rect, ordinal, |
| 6033 final_status_update)); | 6036 final_status_update)); |
| 6034 } | 6037 } |
| 6035 | 6038 |
| 6036 } // namespace content | 6039 } // namespace content |
| OLD | NEW |