| 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 #include "media/blink/webencryptedmediaclient_impl.h" | 143 #include "media/blink/webencryptedmediaclient_impl.h" |
| 144 #include "media/blink/webmediaplayer_impl.h" | 144 #include "media/blink/webmediaplayer_impl.h" |
| 145 #include "media/renderers/gpu_video_accelerator_factories.h" | 145 #include "media/renderers/gpu_video_accelerator_factories.h" |
| 146 #include "mojo/common/url_type_converters.h" | 146 #include "mojo/common/url_type_converters.h" |
| 147 #include "mojo/edk/js/core.h" | 147 #include "mojo/edk/js/core.h" |
| 148 #include "mojo/edk/js/support.h" | 148 #include "mojo/edk/js/support.h" |
| 149 #include "net/base/data_url.h" | 149 #include "net/base/data_url.h" |
| 150 #include "net/base/net_errors.h" | 150 #include "net/base/net_errors.h" |
| 151 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 151 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
| 152 #include "net/http/http_util.h" | 152 #include "net/http/http_util.h" |
| 153 #include "storage/common/data_element.h" |
| 153 #include "third_party/WebKit/public/platform/URLConversion.h" | 154 #include "third_party/WebKit/public/platform/URLConversion.h" |
| 154 #include "third_party/WebKit/public/platform/WebCachePolicy.h" | 155 #include "third_party/WebKit/public/platform/WebCachePolicy.h" |
| 155 #include "third_party/WebKit/public/platform/WebData.h" | 156 #include "third_party/WebKit/public/platform/WebData.h" |
| 156 #include "third_party/WebKit/public/platform/WebMediaPlayer.h" | 157 #include "third_party/WebKit/public/platform/WebMediaPlayer.h" |
| 157 #include "third_party/WebKit/public/platform/WebMediaPlayerSource.h" | 158 #include "third_party/WebKit/public/platform/WebMediaPlayerSource.h" |
| 158 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" | 159 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" |
| 159 #include "third_party/WebKit/public/platform/WebStorageQuotaCallbacks.h" | 160 #include "third_party/WebKit/public/platform/WebStorageQuotaCallbacks.h" |
| 160 #include "third_party/WebKit/public/platform/WebString.h" | 161 #include "third_party/WebKit/public/platform/WebString.h" |
| 161 #include "third_party/WebKit/public/platform/WebURL.h" | 162 #include "third_party/WebKit/public/platform/WebURL.h" |
| 162 #include "third_party/WebKit/public/platform/WebURLError.h" | 163 #include "third_party/WebKit/public/platform/WebURLError.h" |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 // passed back to the browser in the DidCommitProvisionalLoad and the | 531 // passed back to the browser in the DidCommitProvisionalLoad and the |
| 531 // DocumentLoadComplete IPCs. | 532 // DocumentLoadComplete IPCs. |
| 532 base::TimeDelta ui_timestamp = common_params.ui_timestamp - base::TimeTicks(); | 533 base::TimeDelta ui_timestamp = common_params.ui_timestamp - base::TimeTicks(); |
| 533 request.setUiStartTime(ui_timestamp.InSecondsF()); | 534 request.setUiStartTime(ui_timestamp.InSecondsF()); |
| 534 request.setInputPerfMetricReportPolicy( | 535 request.setInputPerfMetricReportPolicy( |
| 535 static_cast<WebURLRequest::InputToLoadPerfMetricReportPolicy>( | 536 static_cast<WebURLRequest::InputToLoadPerfMetricReportPolicy>( |
| 536 common_params.report_type)); | 537 common_params.report_type)); |
| 537 return request; | 538 return request; |
| 538 } | 539 } |
| 539 | 540 |
| 541 // Converts the HTTP body data stored in ResourceRequestBody format to a |
| 542 // WebHTTPBody, which is then added to the WebURLRequest. |
| 543 // PlzNavigate: used to add the POST data sent by the renderer at commit time |
| 544 // to the WebURLRequest used to commit the navigation. This ensures that the |
| 545 // POST data will be in the PageState sent to the browser on commit. |
| 546 void AddHTTPBodyToRequest(WebURLRequest* request, |
| 547 scoped_refptr<ResourceRequestBody> body) { |
| 548 WebHTTPBody http_body; |
| 549 http_body.initialize(); |
| 550 http_body.setIdentifier(body->identifier()); |
| 551 for (const ResourceRequestBody::Element& element : *(body->elements())) { |
| 552 long long length = -1; |
| 553 switch (element.type()) { |
| 554 case storage::DataElement::TYPE_BYTES: |
| 555 http_body.appendData(WebData(element.bytes(), element.length())); |
| 556 break; |
| 557 case storage::DataElement::TYPE_FILE: |
| 558 if (element.length() != std::numeric_limits<uint64_t>::max()) |
| 559 length = element.length(); |
| 560 http_body.appendFileRange( |
| 561 element.path().AsUTF16Unsafe(), element.offset(), length, |
| 562 element.expected_modification_time().ToDoubleT()); |
| 563 break; |
| 564 case storage::DataElement::TYPE_FILE_FILESYSTEM: |
| 565 http_body.appendFileSystemURLRange( |
| 566 element.filesystem_url(), element.offset(), element.length(), |
| 567 element.expected_modification_time().ToDoubleT()); |
| 568 break; |
| 569 case storage::DataElement::TYPE_BLOB: |
| 570 http_body.appendBlob(WebString::fromUTF8(element.blob_uuid())); |
| 571 break; |
| 572 default: |
| 573 // TYPE_BYTES_DESCRIPTION and TYPE_DISK_CACHE_ENTRY should not be |
| 574 // encountered. |
| 575 NOTREACHED(); |
| 576 break; |
| 577 } |
| 578 } |
| 579 request->setHTTPBody(http_body); |
| 580 } |
| 581 |
| 540 // Sanitizes the navigation_start timestamp for browser-initiated navigations, | 582 // Sanitizes the navigation_start timestamp for browser-initiated navigations, |
| 541 // where the browser possibly has a better notion of start time than the | 583 // where the browser possibly has a better notion of start time than the |
| 542 // renderer. In the case of cross-process navigations, this carries over the | 584 // renderer. In the case of cross-process navigations, this carries over the |
| 543 // time of finishing the onbeforeunload handler of the previous page. | 585 // time of finishing the onbeforeunload handler of the previous page. |
| 544 // TimeTicks is sometimes not monotonic across processes, and because | 586 // TimeTicks is sometimes not monotonic across processes, and because |
| 545 // |browser_navigation_start| is likely before this process existed, | 587 // |browser_navigation_start| is likely before this process existed, |
| 546 // InterProcessTimeTicksConverter won't help. The timestamp is sanitized by | 588 // InterProcessTimeTicksConverter won't help. The timestamp is sanitized by |
| 547 // clamping it to renderer_navigation_start, initialized earlier in the call | 589 // clamping it to renderer_navigation_start, initialized earlier in the call |
| 548 // stack. | 590 // stack. |
| 549 base::TimeTicks SanitizeNavigationTiming( | 591 base::TimeTicks SanitizeNavigationTiming( |
| (...skipping 944 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1494 } | 1536 } |
| 1495 | 1537 |
| 1496 RenderThreadImpl* render_thread_impl = RenderThreadImpl::current(); | 1538 RenderThreadImpl* render_thread_impl = RenderThreadImpl::current(); |
| 1497 // Can be NULL in tests. | 1539 // Can be NULL in tests. |
| 1498 if (render_thread_impl) | 1540 if (render_thread_impl) |
| 1499 render_thread_impl->GetRendererScheduler()->OnNavigationStarted(); | 1541 render_thread_impl->GetRendererScheduler()->OnNavigationStarted(); |
| 1500 DCHECK(!IsBrowserSideNavigationEnabled()); | 1542 DCHECK(!IsBrowserSideNavigationEnabled()); |
| 1501 TRACE_EVENT2("navigation", "RenderFrameImpl::OnNavigate", "id", routing_id_, | 1543 TRACE_EVENT2("navigation", "RenderFrameImpl::OnNavigate", "id", routing_id_, |
| 1502 "url", common_params.url.possibly_invalid_spec()); | 1544 "url", common_params.url.possibly_invalid_spec()); |
| 1503 NavigateInternal(common_params, start_params, request_params, | 1545 NavigateInternal(common_params, start_params, request_params, |
| 1504 std::unique_ptr<StreamOverrideParameters>()); | 1546 std::unique_ptr<StreamOverrideParameters>(), nullptr); |
| 1505 } | 1547 } |
| 1506 | 1548 |
| 1507 void RenderFrameImpl::BindServiceRegistry( | 1549 void RenderFrameImpl::BindServiceRegistry( |
| 1508 shell::mojom::InterfaceProviderRequest services, | 1550 shell::mojom::InterfaceProviderRequest services, |
| 1509 shell::mojom::InterfaceProviderPtr exposed_services) { | 1551 shell::mojom::InterfaceProviderPtr exposed_services) { |
| 1510 service_registry_.Bind(std::move(services)); | 1552 service_registry_.Bind(std::move(services)); |
| 1511 service_registry_.BindRemoteServiceProvider(std::move(exposed_services)); | 1553 service_registry_.BindRemoteServiceProvider(std::move(exposed_services)); |
| 1512 } | 1554 } |
| 1513 | 1555 |
| 1514 ManifestManager* RenderFrameImpl::manifest_manager() { | 1556 ManifestManager* RenderFrameImpl::manifest_manager() { |
| (...skipping 3116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4631 void RenderFrameImpl::FocusedNodeChangedForAccessibility(const WebNode& node) { | 4673 void RenderFrameImpl::FocusedNodeChangedForAccessibility(const WebNode& node) { |
| 4632 if (renderer_accessibility()) | 4674 if (renderer_accessibility()) |
| 4633 renderer_accessibility()->AccessibilityFocusedNodeChanged(node); | 4675 renderer_accessibility()->AccessibilityFocusedNodeChanged(node); |
| 4634 } | 4676 } |
| 4635 | 4677 |
| 4636 // PlzNavigate | 4678 // PlzNavigate |
| 4637 void RenderFrameImpl::OnCommitNavigation( | 4679 void RenderFrameImpl::OnCommitNavigation( |
| 4638 const ResourceResponseHead& response, | 4680 const ResourceResponseHead& response, |
| 4639 const GURL& stream_url, | 4681 const GURL& stream_url, |
| 4640 const CommonNavigationParams& common_params, | 4682 const CommonNavigationParams& common_params, |
| 4641 const RequestNavigationParams& request_params) { | 4683 const RequestNavigationParams& request_params, |
| 4684 scoped_refptr<ResourceRequestBody> post_data) { |
| 4642 CHECK(IsBrowserSideNavigationEnabled()); | 4685 CHECK(IsBrowserSideNavigationEnabled()); |
| 4643 // This will override the url requested by the WebURLLoader, as well as | 4686 // This will override the url requested by the WebURLLoader, as well as |
| 4644 // provide it with the response to the request. | 4687 // provide it with the response to the request. |
| 4645 std::unique_ptr<StreamOverrideParameters> stream_override( | 4688 std::unique_ptr<StreamOverrideParameters> stream_override( |
| 4646 new StreamOverrideParameters()); | 4689 new StreamOverrideParameters()); |
| 4647 stream_override->stream_url = stream_url; | 4690 stream_override->stream_url = stream_url; |
| 4648 stream_override->response = response; | 4691 stream_override->response = response; |
| 4649 | 4692 |
| 4650 NavigateInternal(common_params, StartNavigationParams(), request_params, | 4693 NavigateInternal(common_params, StartNavigationParams(), request_params, |
| 4651 std::move(stream_override)); | 4694 std::move(stream_override), post_data); |
| 4652 } | 4695 } |
| 4653 | 4696 |
| 4654 // PlzNavigate | 4697 // PlzNavigate |
| 4655 void RenderFrameImpl::OnFailedNavigation( | 4698 void RenderFrameImpl::OnFailedNavigation( |
| 4656 const CommonNavigationParams& common_params, | 4699 const CommonNavigationParams& common_params, |
| 4657 const RequestNavigationParams& request_params, | 4700 const RequestNavigationParams& request_params, |
| 4658 bool has_stale_copy_in_cache, | 4701 bool has_stale_copy_in_cache, |
| 4659 int error_code) { | 4702 int error_code) { |
| 4660 DCHECK(IsBrowserSideNavigationEnabled()); | 4703 DCHECK(IsBrowserSideNavigationEnabled()); |
| 4661 bool is_reload = IsReload(common_params.navigation_type); | 4704 bool is_reload = IsReload(common_params.navigation_type); |
| (...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5237 params.frame_unique_name = frame_->uniqueName().utf8(); | 5280 params.frame_unique_name = frame_->uniqueName().utf8(); |
| 5238 } | 5281 } |
| 5239 | 5282 |
| 5240 Send(new FrameHostMsg_OpenURL(routing_id_, params)); | 5283 Send(new FrameHostMsg_OpenURL(routing_id_, params)); |
| 5241 } | 5284 } |
| 5242 | 5285 |
| 5243 void RenderFrameImpl::NavigateInternal( | 5286 void RenderFrameImpl::NavigateInternal( |
| 5244 const CommonNavigationParams& common_params, | 5287 const CommonNavigationParams& common_params, |
| 5245 const StartNavigationParams& start_params, | 5288 const StartNavigationParams& start_params, |
| 5246 const RequestNavigationParams& request_params, | 5289 const RequestNavigationParams& request_params, |
| 5247 std::unique_ptr<StreamOverrideParameters> stream_params) { | 5290 std::unique_ptr<StreamOverrideParameters> stream_params, |
| 5291 scoped_refptr<ResourceRequestBody> post_data) { |
| 5248 bool browser_side_navigation = IsBrowserSideNavigationEnabled(); | 5292 bool browser_side_navigation = IsBrowserSideNavigationEnabled(); |
| 5249 | 5293 |
| 5250 // Lower bound for browser initiated navigation start time. | 5294 // Lower bound for browser initiated navigation start time. |
| 5251 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now(); | 5295 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now(); |
| 5252 bool is_reload = IsReload(common_params.navigation_type); | 5296 bool is_reload = IsReload(common_params.navigation_type); |
| 5253 bool is_history_navigation = request_params.page_state.IsValid(); | 5297 bool is_history_navigation = request_params.page_state.IsValid(); |
| 5254 WebCachePolicy cache_policy = WebCachePolicy::UseProtocolCachePolicy; | 5298 WebCachePolicy cache_policy = WebCachePolicy::UseProtocolCachePolicy; |
| 5255 RenderFrameImpl::PrepareRenderViewForNavigation( | 5299 RenderFrameImpl::PrepareRenderViewForNavigation( |
| 5256 common_params.url, request_params); | 5300 common_params.url, request_params); |
| 5257 | 5301 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5298 ? blink::WebFrameLoadType::ReplaceCurrentItem | 5342 ? blink::WebFrameLoadType::ReplaceCurrentItem |
| 5299 : blink::WebFrameLoadType::Standard; | 5343 : blink::WebFrameLoadType::Standard; |
| 5300 blink::WebHistoryLoadType history_load_type = | 5344 blink::WebHistoryLoadType history_load_type = |
| 5301 blink::WebHistoryDifferentDocumentLoad; | 5345 blink::WebHistoryDifferentDocumentLoad; |
| 5302 bool should_load_request = false; | 5346 bool should_load_request = false; |
| 5303 WebHistoryItem item_for_history_navigation; | 5347 WebHistoryItem item_for_history_navigation; |
| 5304 WebURLRequest request = | 5348 WebURLRequest request = |
| 5305 CreateURLRequestForNavigation(common_params, std::move(stream_params), | 5349 CreateURLRequestForNavigation(common_params, std::move(stream_params), |
| 5306 frame_->isViewSourceModeEnabled()); | 5350 frame_->isViewSourceModeEnabled()); |
| 5307 | 5351 |
| 5352 if (IsBrowserSideNavigationEnabled() && post_data) |
| 5353 AddHTTPBodyToRequest(&request, post_data); |
| 5354 |
| 5308 // Used to determine whether this frame is actually loading a request as part | 5355 // Used to determine whether this frame is actually loading a request as part |
| 5309 // of a history navigation. | 5356 // of a history navigation. |
| 5310 bool has_history_navigation_in_frame = false; | 5357 bool has_history_navigation_in_frame = false; |
| 5311 | 5358 |
| 5312 #if defined(OS_ANDROID) | 5359 #if defined(OS_ANDROID) |
| 5313 request.setHasUserGesture(start_params.has_user_gesture); | 5360 request.setHasUserGesture(start_params.has_user_gesture); |
| 5314 #endif | 5361 #endif |
| 5315 | 5362 |
| 5316 // PlzNavigate: Make sure that Blink's loader will not try to use browser side | 5363 // PlzNavigate: Make sure that Blink's loader will not try to use browser side |
| 5317 // navigation for this request (since it already went to the browser). | 5364 // navigation for this request (since it already went to the browser). |
| (...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6048 int match_count, | 6095 int match_count, |
| 6049 int ordinal, | 6096 int ordinal, |
| 6050 const WebRect& selection_rect, | 6097 const WebRect& selection_rect, |
| 6051 bool final_status_update) { | 6098 bool final_status_update) { |
| 6052 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count, | 6099 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count, |
| 6053 selection_rect, ordinal, | 6100 selection_rect, ordinal, |
| 6054 final_status_update)); | 6101 final_status_update)); |
| 6055 } | 6102 } |
| 6056 | 6103 |
| 6057 } // namespace content | 6104 } // namespace content |
| OLD | NEW |