| 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 #include "third_party/WebKit/public/platform/WebData.h" | 147 #include "third_party/WebKit/public/platform/WebData.h" |
| 148 #include "third_party/WebKit/public/platform/WebStorageQuotaCallbacks.h" | 148 #include "third_party/WebKit/public/platform/WebStorageQuotaCallbacks.h" |
| 149 #include "third_party/WebKit/public/platform/WebString.h" | 149 #include "third_party/WebKit/public/platform/WebString.h" |
| 150 #include "third_party/WebKit/public/platform/WebURL.h" | 150 #include "third_party/WebKit/public/platform/WebURL.h" |
| 151 #include "third_party/WebKit/public/platform/WebURLError.h" | 151 #include "third_party/WebKit/public/platform/WebURLError.h" |
| 152 #include "third_party/WebKit/public/platform/WebURLResponse.h" | 152 #include "third_party/WebKit/public/platform/WebURLResponse.h" |
| 153 #include "third_party/WebKit/public/platform/WebVector.h" | 153 #include "third_party/WebKit/public/platform/WebVector.h" |
| 154 #include "third_party/WebKit/public/platform/modules/webusb/WebUSBClient.h" | 154 #include "third_party/WebKit/public/platform/modules/webusb/WebUSBClient.h" |
| 155 #include "third_party/WebKit/public/web/WebColorSuggestion.h" | 155 #include "third_party/WebKit/public/web/WebColorSuggestion.h" |
| 156 #include "third_party/WebKit/public/web/WebDocument.h" | 156 #include "third_party/WebKit/public/web/WebDocument.h" |
| 157 #include "third_party/WebKit/public/web/WebFrameSerializer.h" |
| 157 #include "third_party/WebKit/public/web/WebFrameWidget.h" | 158 #include "third_party/WebKit/public/web/WebFrameWidget.h" |
| 158 #include "third_party/WebKit/public/web/WebKit.h" | 159 #include "third_party/WebKit/public/web/WebKit.h" |
| 159 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 160 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 160 #include "third_party/WebKit/public/web/WebMediaStreamRegistry.h" | 161 #include "third_party/WebKit/public/web/WebMediaStreamRegistry.h" |
| 161 #include "third_party/WebKit/public/web/WebNavigationPolicy.h" | 162 #include "third_party/WebKit/public/web/WebNavigationPolicy.h" |
| 162 #include "third_party/WebKit/public/web/WebPageSerializer.h" | |
| 163 #include "third_party/WebKit/public/web/WebPlugin.h" | 163 #include "third_party/WebKit/public/web/WebPlugin.h" |
| 164 #include "third_party/WebKit/public/web/WebPluginParams.h" | 164 #include "third_party/WebKit/public/web/WebPluginParams.h" |
| 165 #include "third_party/WebKit/public/web/WebRange.h" | 165 #include "third_party/WebKit/public/web/WebRange.h" |
| 166 #include "third_party/WebKit/public/web/WebScopedUserGesture.h" | 166 #include "third_party/WebKit/public/web/WebScopedUserGesture.h" |
| 167 #include "third_party/WebKit/public/web/WebScriptSource.h" | 167 #include "third_party/WebKit/public/web/WebScriptSource.h" |
| 168 #include "third_party/WebKit/public/web/WebSearchableFormData.h" | 168 #include "third_party/WebKit/public/web/WebSearchableFormData.h" |
| 169 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" | 169 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" |
| 170 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" | 170 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" |
| 171 #include "third_party/WebKit/public/web/WebSerializedScriptValue.h" | 171 #include "third_party/WebKit/public/web/WebSerializedScriptValue.h" |
| 172 #include "third_party/WebKit/public/web/WebSettings.h" | 172 #include "third_party/WebKit/public/web/WebSettings.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 using blink::WebCString; | 233 using blink::WebCString; |
| 234 using blink::WebData; | 234 using blink::WebData; |
| 235 using blink::WebDataSource; | 235 using blink::WebDataSource; |
| 236 using blink::WebDocument; | 236 using blink::WebDocument; |
| 237 using blink::WebDOMEvent; | 237 using blink::WebDOMEvent; |
| 238 using blink::WebDOMMessageEvent; | 238 using blink::WebDOMMessageEvent; |
| 239 using blink::WebElement; | 239 using blink::WebElement; |
| 240 using blink::WebExternalPopupMenu; | 240 using blink::WebExternalPopupMenu; |
| 241 using blink::WebExternalPopupMenuClient; | 241 using blink::WebExternalPopupMenuClient; |
| 242 using blink::WebFrame; | 242 using blink::WebFrame; |
| 243 using blink::WebFrameSerializer; |
| 244 using blink::WebFrameSerializerClient; |
| 243 using blink::WebHistoryItem; | 245 using blink::WebHistoryItem; |
| 244 using blink::WebHTTPBody; | 246 using blink::WebHTTPBody; |
| 245 using blink::WebLocalFrame; | 247 using blink::WebLocalFrame; |
| 246 using blink::WebMediaPlayer; | 248 using blink::WebMediaPlayer; |
| 247 using blink::WebMediaPlayerClient; | 249 using blink::WebMediaPlayerClient; |
| 248 using blink::WebMediaPlayerEncryptedMediaClient; | 250 using blink::WebMediaPlayerEncryptedMediaClient; |
| 249 using blink::WebMediaSession; | 251 using blink::WebMediaSession; |
| 250 using blink::WebNavigationPolicy; | 252 using blink::WebNavigationPolicy; |
| 251 using blink::WebNavigationType; | 253 using blink::WebNavigationType; |
| 252 using blink::WebNode; | 254 using blink::WebNode; |
| 253 using blink::WebPageSerializer; | |
| 254 using blink::WebPageSerializerClient; | |
| 255 using blink::WebPluginParams; | 255 using blink::WebPluginParams; |
| 256 using blink::WebPopupMenuInfo; | 256 using blink::WebPopupMenuInfo; |
| 257 using blink::WebRange; | 257 using blink::WebRange; |
| 258 using blink::WebReferrerPolicy; | 258 using blink::WebReferrerPolicy; |
| 259 using blink::WebScriptSource; | 259 using blink::WebScriptSource; |
| 260 using blink::WebSearchableFormData; | 260 using blink::WebSearchableFormData; |
| 261 using blink::WebSecurityOrigin; | 261 using blink::WebSecurityOrigin; |
| 262 using blink::WebSecurityPolicy; | 262 using blink::WebSecurityPolicy; |
| 263 using blink::WebSerializedScriptValue; | 263 using blink::WebSerializedScriptValue; |
| 264 using blink::WebServiceWorkerProvider; | 264 using blink::WebServiceWorkerProvider; |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 576 | 576 |
| 577 void OnGotContentHandlerID(uint32_t content_handler_id) {} | 577 void OnGotContentHandlerID(uint32_t content_handler_id) {} |
| 578 | 578 |
| 579 WebString ConvertRelativePathToHtmlAttribute(const base::FilePath& path) { | 579 WebString ConvertRelativePathToHtmlAttribute(const base::FilePath& path) { |
| 580 DCHECK(!path.IsAbsolute()); | 580 DCHECK(!path.IsAbsolute()); |
| 581 return WebString::fromUTF8( | 581 return WebString::fromUTF8( |
| 582 std::string("./") + | 582 std::string("./") + |
| 583 path.NormalizePathSeparatorsTo(FILE_PATH_LITERAL('/')).AsUTF8Unsafe()); | 583 path.NormalizePathSeparatorsTo(FILE_PATH_LITERAL('/')).AsUTF8Unsafe()); |
| 584 } | 584 } |
| 585 | 585 |
| 586 // Implementation of WebPageSerializer::MHTMLPartsGenerationDelegate that | 586 // Implementation of WebFrameSerializer::MHTMLPartsGenerationDelegate that |
| 587 // 1. Bases shouldSkipResource and getContentID responses on contents of | 587 // 1. Bases shouldSkipResource and getContentID responses on contents of |
| 588 // FrameMsg_SerializeAsMHTML_Params. | 588 // FrameMsg_SerializeAsMHTML_Params. |
| 589 // 2. Stores digests of urls of serialized resources (i.e. urls reported via | 589 // 2. Stores digests of urls of serialized resources (i.e. urls reported via |
| 590 // shouldSkipResource) into |digests_of_uris_of_serialized_resources| passed | 590 // shouldSkipResource) into |digests_of_uris_of_serialized_resources| passed |
| 591 // to the constructor. | 591 // to the constructor. |
| 592 class MHTMLPartsGenerationDelegate | 592 class MHTMLPartsGenerationDelegate |
| 593 : public WebPageSerializer::MHTMLPartsGenerationDelegate { | 593 : public WebFrameSerializer::MHTMLPartsGenerationDelegate { |
| 594 public: | 594 public: |
| 595 MHTMLPartsGenerationDelegate( | 595 MHTMLPartsGenerationDelegate( |
| 596 const FrameMsg_SerializeAsMHTML_Params& params, | 596 const FrameMsg_SerializeAsMHTML_Params& params, |
| 597 std::set<std::string>* digests_of_uris_of_serialized_resources) | 597 std::set<std::string>* digests_of_uris_of_serialized_resources) |
| 598 : params_(params), | 598 : params_(params), |
| 599 digests_of_uris_of_serialized_resources_( | 599 digests_of_uris_of_serialized_resources_( |
| 600 digests_of_uris_of_serialized_resources) { | 600 digests_of_uris_of_serialized_resources) { |
| 601 DCHECK(digests_of_uris_of_serialized_resources_); | 601 DCHECK(digests_of_uris_of_serialized_resources_); |
| 602 } | 602 } |
| 603 | 603 |
| (...skipping 3604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4208 blink::WebVRClient* RenderFrameImpl::webVRClient() { | 4208 blink::WebVRClient* RenderFrameImpl::webVRClient() { |
| 4209 if (!vr_dispatcher_) | 4209 if (!vr_dispatcher_) |
| 4210 vr_dispatcher_.reset(new VRDispatcher(GetServiceRegistry())); | 4210 vr_dispatcher_.reset(new VRDispatcher(GetServiceRegistry())); |
| 4211 | 4211 |
| 4212 return vr_dispatcher_.get(); | 4212 return vr_dispatcher_.get(); |
| 4213 } | 4213 } |
| 4214 #endif | 4214 #endif |
| 4215 | 4215 |
| 4216 void RenderFrameImpl::didSerializeDataForFrame( | 4216 void RenderFrameImpl::didSerializeDataForFrame( |
| 4217 const WebCString& data, | 4217 const WebCString& data, |
| 4218 WebPageSerializerClient::PageSerializationStatus status) { | 4218 WebFrameSerializerClient::FrameSerializationStatus status) { |
| 4219 bool end_of_data = status == WebPageSerializerClient::CurrentFrameIsFinished; | 4219 bool end_of_data = status == WebFrameSerializerClient::CurrentFrameIsFinished; |
| 4220 Send(new FrameHostMsg_SerializedHtmlWithLocalLinksResponse( | 4220 Send(new FrameHostMsg_SerializedHtmlWithLocalLinksResponse( |
| 4221 routing_id_, data, end_of_data)); | 4221 routing_id_, data, end_of_data)); |
| 4222 } | 4222 } |
| 4223 | 4223 |
| 4224 void RenderFrameImpl::AddObserver(RenderFrameObserver* observer) { | 4224 void RenderFrameImpl::AddObserver(RenderFrameObserver* observer) { |
| 4225 observers_.AddObserver(observer); | 4225 observers_.AddObserver(observer); |
| 4226 } | 4226 } |
| 4227 | 4227 |
| 4228 void RenderFrameImpl::RemoveObserver(RenderFrameObserver* observer) { | 4228 void RenderFrameImpl::RemoveObserver(RenderFrameObserver* observer) { |
| 4229 observer->RenderFrameGone(); | 4229 observer->RenderFrameGone(); |
| (...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4805 // Convert input to the canonical way of passing a map into a Blink API. | 4805 // Convert input to the canonical way of passing a map into a Blink API. |
| 4806 std::vector<std::pair<WebURL, WebString>> weburl_to_local_path; | 4806 std::vector<std::pair<WebURL, WebString>> weburl_to_local_path; |
| 4807 for (const auto& it : url_to_local_path) { | 4807 for (const auto& it : url_to_local_path) { |
| 4808 const GURL& url = it.first; | 4808 const GURL& url = it.first; |
| 4809 const base::FilePath& local_path = it.second; | 4809 const base::FilePath& local_path = it.second; |
| 4810 weburl_to_local_path.push_back(std::make_pair( | 4810 weburl_to_local_path.push_back(std::make_pair( |
| 4811 WebURL(url), ConvertRelativePathToHtmlAttribute(local_path))); | 4811 WebURL(url), ConvertRelativePathToHtmlAttribute(local_path))); |
| 4812 } | 4812 } |
| 4813 | 4813 |
| 4814 // Serialize the frame (without recursing into subframes). | 4814 // Serialize the frame (without recursing into subframes). |
| 4815 WebPageSerializer::serialize(GetWebFrame(), | 4815 WebFrameSerializer::serialize(GetWebFrame(), |
| 4816 this, // WebPageSerializerClient. | 4816 this, // WebFrameSerializerClient. |
| 4817 weburl_to_local_path); | 4817 weburl_to_local_path); |
| 4818 } | 4818 } |
| 4819 | 4819 |
| 4820 void RenderFrameImpl::OnSerializeAsMHTML( | 4820 void RenderFrameImpl::OnSerializeAsMHTML( |
| 4821 const FrameMsg_SerializeAsMHTML_Params& params) { | 4821 const FrameMsg_SerializeAsMHTML_Params& params) { |
| 4822 // Unpack IPC payload. | 4822 // Unpack IPC payload. |
| 4823 base::File file = IPC::PlatformFileForTransitToFile(params.destination_file); | 4823 base::File file = IPC::PlatformFileForTransitToFile(params.destination_file); |
| 4824 const WebString mhtml_boundary = | 4824 const WebString mhtml_boundary = |
| 4825 WebString::fromUTF8(params.mhtml_boundary_marker); | 4825 WebString::fromUTF8(params.mhtml_boundary_marker); |
| 4826 DCHECK(!mhtml_boundary.isEmpty()); | 4826 DCHECK(!mhtml_boundary.isEmpty()); |
| 4827 | 4827 |
| 4828 WebData data; | 4828 WebData data; |
| 4829 bool success = true; | 4829 bool success = true; |
| 4830 std::set<std::string> digests_of_uris_of_serialized_resources; | 4830 std::set<std::string> digests_of_uris_of_serialized_resources; |
| 4831 MHTMLPartsGenerationDelegate delegate( | 4831 MHTMLPartsGenerationDelegate delegate( |
| 4832 params, &digests_of_uris_of_serialized_resources); | 4832 params, &digests_of_uris_of_serialized_resources); |
| 4833 | 4833 |
| 4834 // Generate MHTML header if needed. | 4834 // Generate MHTML header if needed. |
| 4835 if (IsMainFrame()) { | 4835 if (IsMainFrame()) { |
| 4836 data = | 4836 data = |
| 4837 WebPageSerializer::generateMHTMLHeader(mhtml_boundary, GetWebFrame()); | 4837 WebFrameSerializer::generateMHTMLHeader(mhtml_boundary, GetWebFrame()); |
| 4838 if (file.WriteAtCurrentPos(data.data(), data.size()) < 0) { | 4838 if (file.WriteAtCurrentPos(data.data(), data.size()) < 0) { |
| 4839 success = false; | 4839 success = false; |
| 4840 } | 4840 } |
| 4841 } | 4841 } |
| 4842 | 4842 |
| 4843 // Generate MHTML parts. | 4843 // Generate MHTML parts. |
| 4844 if (success) { | 4844 if (success) { |
| 4845 data = WebPageSerializer::generateMHTMLParts(mhtml_boundary, GetWebFrame(), | 4845 data = WebFrameSerializer::generateMHTMLParts(mhtml_boundary, GetWebFrame(), |
| 4846 false, &delegate); | 4846 false, &delegate); |
| 4847 // TODO(jcivelli): write the chunks in deferred tasks to give a chance to | 4847 // TODO(jcivelli): write the chunks in deferred tasks to give a chance to |
| 4848 // the message loop to process other events. | 4848 // the message loop to process other events. |
| 4849 if (file.WriteAtCurrentPos(data.data(), data.size()) < 0) { | 4849 if (file.WriteAtCurrentPos(data.data(), data.size()) < 0) { |
| 4850 success = false; | 4850 success = false; |
| 4851 } | 4851 } |
| 4852 } | 4852 } |
| 4853 | 4853 |
| 4854 // Generate MHTML footer if needed. | 4854 // Generate MHTML footer if needed. |
| 4855 if (success && params.is_last_frame) { | 4855 if (success && params.is_last_frame) { |
| 4856 data = WebPageSerializer::generateMHTMLFooter(mhtml_boundary); | 4856 data = WebFrameSerializer::generateMHTMLFooter(mhtml_boundary); |
| 4857 if (file.WriteAtCurrentPos(data.data(), data.size()) < 0) { | 4857 if (file.WriteAtCurrentPos(data.data(), data.size()) < 0) { |
| 4858 success = false; | 4858 success = false; |
| 4859 } | 4859 } |
| 4860 } | 4860 } |
| 4861 | 4861 |
| 4862 // Cleanup and notify the browser process about completion. | 4862 // Cleanup and notify the browser process about completion. |
| 4863 file.Close(); // Need to flush file contents before sending IPC response. | 4863 file.Close(); // Need to flush file contents before sending IPC response. |
| 4864 Send(new FrameHostMsg_SerializeAsMHTMLResponse( | 4864 Send(new FrameHostMsg_SerializeAsMHTMLResponse( |
| 4865 routing_id_, params.job_id, success, | 4865 routing_id_, params.job_id, success, |
| 4866 digests_of_uris_of_serialized_resources)); | 4866 digests_of_uris_of_serialized_resources)); |
| (...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5684 media::ConvertToSwitchOutputDeviceCB(web_callbacks); | 5684 media::ConvertToSwitchOutputDeviceCB(web_callbacks); |
| 5685 scoped_refptr<media::AudioOutputDevice> device = | 5685 scoped_refptr<media::AudioOutputDevice> device = |
| 5686 AudioDeviceFactory::NewOutputDevice(routing_id_, 0, sink_id.utf8(), | 5686 AudioDeviceFactory::NewOutputDevice(routing_id_, 0, sink_id.utf8(), |
| 5687 security_origin); | 5687 security_origin); |
| 5688 media::OutputDeviceStatus status = device->GetDeviceStatus(); | 5688 media::OutputDeviceStatus status = device->GetDeviceStatus(); |
| 5689 device->Stop(); | 5689 device->Stop(); |
| 5690 callback.Run(status); | 5690 callback.Run(status); |
| 5691 } | 5691 } |
| 5692 | 5692 |
| 5693 } // namespace content | 5693 } // namespace content |
| OLD | NEW |