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 <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 #include "content/renderer/renderer_webcolorchooser_impl.h" | 117 #include "content/renderer/renderer_webcolorchooser_impl.h" |
118 #include "content/renderer/savable_resources.h" | 118 #include "content/renderer/savable_resources.h" |
119 #include "content/renderer/screen_orientation/screen_orientation_dispatcher.h" | 119 #include "content/renderer/screen_orientation/screen_orientation_dispatcher.h" |
120 #include "content/renderer/shared_worker_repository.h" | 120 #include "content/renderer/shared_worker_repository.h" |
121 #include "content/renderer/skia_benchmarking_extension.h" | 121 #include "content/renderer/skia_benchmarking_extension.h" |
122 #include "content/renderer/stats_collection_controller.h" | 122 #include "content/renderer/stats_collection_controller.h" |
123 #include "content/renderer/wake_lock/wake_lock_dispatcher.h" | 123 #include "content/renderer/wake_lock/wake_lock_dispatcher.h" |
124 #include "content/renderer/web_frame_utils.h" | 124 #include "content/renderer/web_frame_utils.h" |
125 #include "content/renderer/web_ui_extension.h" | 125 #include "content/renderer/web_ui_extension.h" |
126 #include "content/renderer/websharedworker_proxy.h" | 126 #include "content/renderer/websharedworker_proxy.h" |
| 127 #include "crypto/sha2.h" |
127 #include "gin/modules/module_registry.h" | 128 #include "gin/modules/module_registry.h" |
128 #include "media/audio/audio_output_device.h" | 129 #include "media/audio/audio_output_device.h" |
129 #include "media/base/audio_renderer_mixer_input.h" | 130 #include "media/base/audio_renderer_mixer_input.h" |
130 #include "media/base/media_log.h" | 131 #include "media/base/media_log.h" |
131 #include "media/base/media_switches.h" | 132 #include "media/base/media_switches.h" |
132 #include "media/blink/webencryptedmediaclient_impl.h" | 133 #include "media/blink/webencryptedmediaclient_impl.h" |
133 #include "media/blink/webmediaplayer_impl.h" | 134 #include "media/blink/webmediaplayer_impl.h" |
134 #include "media/renderers/gpu_video_accelerator_factories.h" | 135 #include "media/renderers/gpu_video_accelerator_factories.h" |
135 #include "mojo/common/url_type_converters.h" | 136 #include "mojo/common/url_type_converters.h" |
136 #include "net/base/data_url.h" | 137 #include "net/base/data_url.h" |
(...skipping 24 matching lines...) Expand all Loading... |
161 #include "third_party/WebKit/public/web/WebSearchableFormData.h" | 162 #include "third_party/WebKit/public/web/WebSearchableFormData.h" |
162 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" | 163 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" |
163 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" | 164 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" |
164 #include "third_party/WebKit/public/web/WebSerializedScriptValue.h" | 165 #include "third_party/WebKit/public/web/WebSerializedScriptValue.h" |
165 #include "third_party/WebKit/public/web/WebSettings.h" | 166 #include "third_party/WebKit/public/web/WebSettings.h" |
166 #include "third_party/WebKit/public/web/WebSurroundingText.h" | 167 #include "third_party/WebKit/public/web/WebSurroundingText.h" |
167 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" | 168 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" |
168 #include "third_party/WebKit/public/web/WebView.h" | 169 #include "third_party/WebKit/public/web/WebView.h" |
169 #include "third_party/mojo/src/mojo/edk/js/core.h" | 170 #include "third_party/mojo/src/mojo/edk/js/core.h" |
170 #include "third_party/mojo/src/mojo/edk/js/support.h" | 171 #include "third_party/mojo/src/mojo/edk/js/support.h" |
| 172 #include "url/gurl.h" |
171 #include "url/url_util.h" | 173 #include "url/url_util.h" |
172 | 174 |
173 #if defined(ENABLE_PLUGINS) | 175 #if defined(ENABLE_PLUGINS) |
174 #include "content/renderer/npapi/webplugin_impl.h" | 176 #include "content/renderer/npapi/webplugin_impl.h" |
175 #include "content/renderer/pepper/pepper_browser_connection.h" | 177 #include "content/renderer/pepper/pepper_browser_connection.h" |
176 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" | 178 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" |
177 #include "content/renderer/pepper/pepper_webplugin_impl.h" | 179 #include "content/renderer/pepper/pepper_webplugin_impl.h" |
178 #include "content/renderer/pepper/plugin_module.h" | 180 #include "content/renderer/pepper/plugin_module.h" |
179 #endif | 181 #endif |
180 | 182 |
(...skipping 4520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4701 webstring_paths[i] = equivalent_local_paths[i].AsUTF16Unsafe(); | 4703 webstring_paths[i] = equivalent_local_paths[i].AsUTF16Unsafe(); |
4702 | 4704 |
4703 // Serialize the frame (without recursing into subframes). | 4705 // Serialize the frame (without recursing into subframes). |
4704 WebPageSerializer::serialize(GetWebFrame(), | 4706 WebPageSerializer::serialize(GetWebFrame(), |
4705 this, // WebPageSerializerClient. | 4707 this, // WebPageSerializerClient. |
4706 weburl_links, webstring_paths, | 4708 weburl_links, webstring_paths, |
4707 local_directory_path.AsUTF16Unsafe()); | 4709 local_directory_path.AsUTF16Unsafe()); |
4708 } | 4710 } |
4709 | 4711 |
4710 void RenderFrameImpl::OnSerializeAsMHTML( | 4712 void RenderFrameImpl::OnSerializeAsMHTML( |
4711 int job_id, | 4713 const FrameMsg_SerializeAsMHTML_Params& params) { |
4712 IPC::PlatformFileForTransit file_for_transit, | |
4713 const std::string& std_mhtml_boundary, | |
4714 const std::map<int, std::string>& frame_routing_id_to_content_id, | |
4715 bool is_last_frame) { | |
4716 // Unpack IPC payload. | 4714 // Unpack IPC payload. |
4717 base::File file = IPC::PlatformFileForTransitToFile(file_for_transit); | 4715 base::File file = IPC::PlatformFileForTransitToFile(params.destination_file); |
4718 WebString mhtml_boundary = WebString::fromUTF8(std_mhtml_boundary); | 4716 WebString mhtml_boundary = WebString::fromUTF8(params.mhtml_boundary_marker); |
4719 std::vector<std::pair<WebFrame*, WebString>> web_frame_to_content_id; | 4717 std::vector<std::pair<WebFrame*, WebString>> web_frame_to_content_id; |
4720 for (const auto& it : frame_routing_id_to_content_id) { | 4718 for (const auto& it : params.frame_routing_id_to_content_id) { |
4721 const std::string& content_id = it.second; | 4719 const std::string& content_id = it.second; |
4722 WebFrame* web_frame = GetWebFrameFromRoutingIdForFrameOrProxy(it.first); | 4720 WebFrame* web_frame = GetWebFrameFromRoutingIdForFrameOrProxy(it.first); |
4723 if (!web_frame) | 4721 if (!web_frame) |
4724 continue; | 4722 continue; |
4725 | 4723 |
4726 web_frame_to_content_id.push_back( | 4724 web_frame_to_content_id.push_back( |
4727 std::make_pair(web_frame, WebString::fromUTF8(content_id))); | 4725 std::make_pair(web_frame, WebString::fromUTF8(content_id))); |
4728 } | 4726 } |
| 4727 const std::string& salt = params.salt; |
4729 | 4728 |
4730 WebData data; | 4729 WebData data; |
4731 bool success = true; | 4730 bool success = true; |
| 4731 std::set<GURL> uris_of_generated_mhtml_parts; |
4732 | 4732 |
4733 // Generate MHTML header if needed. | 4733 // Generate MHTML header if needed. |
4734 if (success && IsMainFrame()) { | 4734 if (success && IsMainFrame()) { |
4735 DCHECK(mhtml_boundary.isEmpty()); | 4735 DCHECK(mhtml_boundary.isEmpty()); |
4736 mhtml_boundary = WebPageSerializer::generateMHTMLBoundary(); | 4736 mhtml_boundary = WebPageSerializer::generateMHTMLBoundary(); |
4737 | 4737 |
4738 data = | 4738 data = |
4739 WebPageSerializer::generateMHTMLHeader(mhtml_boundary, GetWebFrame()); | 4739 WebPageSerializer::generateMHTMLHeader(mhtml_boundary, GetWebFrame()); |
4740 if (file.WriteAtCurrentPos(data.data(), data.size()) < 0) { | 4740 if (file.WriteAtCurrentPos(data.data(), data.size()) < 0) { |
4741 success = false; | 4741 success = false; |
4742 } | 4742 } |
4743 } | 4743 } |
4744 DCHECK(!mhtml_boundary.isEmpty()); | 4744 DCHECK(!mhtml_boundary.isEmpty()); |
4745 | 4745 |
4746 // Generate MHTML parts. | 4746 // Generate MHTML parts. |
4747 if (success) { | 4747 if (success) { |
4748 data = WebPageSerializer::generateMHTMLParts( | 4748 std::vector<WebURL> uris_to_skip; |
4749 mhtml_boundary, GetWebFrame(), false, web_frame_to_content_id); | 4749 WebVector<WebURL> all_urls = |
| 4750 WebPageSerializer::enumerateMHTMLResources(GetWebFrame()); |
| 4751 for (const WebURL url : all_urls) { |
| 4752 std::string digest = crypto::SHA256HashString(salt + GURL(url).spec()); |
| 4753 if (0 != params.digests_of_uris_to_skip.count(digest)) |
| 4754 uris_to_skip.push_back(url); |
| 4755 else |
| 4756 uris_of_generated_mhtml_parts.insert(url); |
| 4757 } |
| 4758 |
| 4759 data = WebPageSerializer::generateMHTMLParts(mhtml_boundary, GetWebFrame(), |
| 4760 false, web_frame_to_content_id, |
| 4761 uris_to_skip); |
4750 // TODO(jcivelli): write the chunks in deferred tasks to give a chance to | 4762 // TODO(jcivelli): write the chunks in deferred tasks to give a chance to |
4751 // the message loop to process other events. | 4763 // the message loop to process other events. |
4752 if (file.WriteAtCurrentPos(data.data(), data.size()) < 0) { | 4764 if (file.WriteAtCurrentPos(data.data(), data.size()) < 0) { |
4753 success = false; | 4765 success = false; |
4754 } | 4766 } |
4755 } | 4767 } |
4756 | 4768 |
4757 // Generate MHTML footer if needed. | 4769 // Generate MHTML footer if needed. |
4758 if (success && is_last_frame) { | 4770 if (success && params.is_last_frame) { |
4759 data = WebPageSerializer::generateMHTMLFooter(mhtml_boundary); | 4771 data = WebPageSerializer::generateMHTMLFooter(mhtml_boundary); |
4760 if (file.WriteAtCurrentPos(data.data(), data.size()) < 0) { | 4772 if (file.WriteAtCurrentPos(data.data(), data.size()) < 0) { |
4761 success = false; | 4773 success = false; |
4762 } | 4774 } |
4763 } | 4775 } |
4764 | 4776 |
4765 // Cleanup and notify the browser process about completion. | 4777 // Cleanup and notify the browser process about completion. |
4766 file.Close(); // Need to flush file contents before sending IPC response. | 4778 file.Close(); // Need to flush file contents before sending IPC response. |
4767 Send(new FrameHostMsg_SerializeAsMHTMLResponse(routing_id_, job_id, success, | 4779 Send(new FrameHostMsg_SerializeAsMHTMLResponse( |
4768 mhtml_boundary.utf8())); | 4780 routing_id_, params.job_id, success, mhtml_boundary.utf8(), |
| 4781 uris_of_generated_mhtml_parts)); |
4769 } | 4782 } |
4770 | 4783 |
4771 void RenderFrameImpl::OpenURL(const GURL& url, | 4784 void RenderFrameImpl::OpenURL(const GURL& url, |
4772 const Referrer& referrer, | 4785 const Referrer& referrer, |
4773 WebNavigationPolicy policy, | 4786 WebNavigationPolicy policy, |
4774 bool should_replace_current_entry, | 4787 bool should_replace_current_entry, |
4775 bool is_history_navigation_in_new_child) { | 4788 bool is_history_navigation_in_new_child) { |
4776 FrameHostMsg_OpenURL_Params params; | 4789 FrameHostMsg_OpenURL_Params params; |
4777 params.url = url; | 4790 params.url = url; |
4778 params.referrer = referrer; | 4791 params.referrer = referrer; |
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5558 media::ConvertToSwitchOutputDeviceCB(web_callbacks); | 5571 media::ConvertToSwitchOutputDeviceCB(web_callbacks); |
5559 scoped_refptr<media::AudioOutputDevice> device = | 5572 scoped_refptr<media::AudioOutputDevice> device = |
5560 AudioDeviceFactory::NewOutputDevice(routing_id_, 0, sink_id.utf8(), | 5573 AudioDeviceFactory::NewOutputDevice(routing_id_, 0, sink_id.utf8(), |
5561 security_origin); | 5574 security_origin); |
5562 media::OutputDeviceStatus status = device->GetDeviceStatus(); | 5575 media::OutputDeviceStatus status = device->GetDeviceStatus(); |
5563 device->Stop(); | 5576 device->Stop(); |
5564 callback.Run(status); | 5577 callback.Run(status); |
5565 } | 5578 } |
5566 | 5579 |
5567 } // namespace content | 5580 } // namespace content |
OLD | NEW |