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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 #include "media/blink/webencryptedmediaclient_impl.h" | 142 #include "media/blink/webencryptedmediaclient_impl.h" |
143 #include "media/blink/webmediaplayer_impl.h" | 143 #include "media/blink/webmediaplayer_impl.h" |
144 #include "media/renderers/gpu_video_accelerator_factories.h" | 144 #include "media/renderers/gpu_video_accelerator_factories.h" |
145 #include "mojo/common/url_type_converters.h" | 145 #include "mojo/common/url_type_converters.h" |
146 #include "mojo/edk/js/core.h" | 146 #include "mojo/edk/js/core.h" |
147 #include "mojo/edk/js/support.h" | 147 #include "mojo/edk/js/support.h" |
148 #include "net/base/data_url.h" | 148 #include "net/base/data_url.h" |
149 #include "net/base/net_errors.h" | 149 #include "net/base/net_errors.h" |
150 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 150 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
151 #include "net/http/http_util.h" | 151 #include "net/http/http_util.h" |
| 152 #include "storage/common/data_element.h" |
152 #include "third_party/WebKit/public/platform/URLConversion.h" | 153 #include "third_party/WebKit/public/platform/URLConversion.h" |
153 #include "third_party/WebKit/public/platform/WebCachePolicy.h" | 154 #include "third_party/WebKit/public/platform/WebCachePolicy.h" |
154 #include "third_party/WebKit/public/platform/WebData.h" | 155 #include "third_party/WebKit/public/platform/WebData.h" |
155 #include "third_party/WebKit/public/platform/WebMediaPlayer.h" | 156 #include "third_party/WebKit/public/platform/WebMediaPlayer.h" |
156 #include "third_party/WebKit/public/platform/WebMediaPlayerSource.h" | 157 #include "third_party/WebKit/public/platform/WebMediaPlayerSource.h" |
157 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" | 158 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" |
158 #include "third_party/WebKit/public/platform/WebStorageQuotaCallbacks.h" | 159 #include "third_party/WebKit/public/platform/WebStorageQuotaCallbacks.h" |
159 #include "third_party/WebKit/public/platform/WebString.h" | 160 #include "third_party/WebKit/public/platform/WebString.h" |
160 #include "third_party/WebKit/public/platform/WebURL.h" | 161 #include "third_party/WebKit/public/platform/WebURL.h" |
161 #include "third_party/WebKit/public/platform/WebURLError.h" | 162 #include "third_party/WebKit/public/platform/WebURLError.h" |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 // passed back to the browser in the DidCommitProvisionalLoad and the | 534 // passed back to the browser in the DidCommitProvisionalLoad and the |
534 // DocumentLoadComplete IPCs. | 535 // DocumentLoadComplete IPCs. |
535 base::TimeDelta ui_timestamp = common_params.ui_timestamp - base::TimeTicks(); | 536 base::TimeDelta ui_timestamp = common_params.ui_timestamp - base::TimeTicks(); |
536 request.setUiStartTime(ui_timestamp.InSecondsF()); | 537 request.setUiStartTime(ui_timestamp.InSecondsF()); |
537 request.setInputPerfMetricReportPolicy( | 538 request.setInputPerfMetricReportPolicy( |
538 static_cast<WebURLRequest::InputToLoadPerfMetricReportPolicy>( | 539 static_cast<WebURLRequest::InputToLoadPerfMetricReportPolicy>( |
539 common_params.report_type)); | 540 common_params.report_type)); |
540 return request; | 541 return request; |
541 } | 542 } |
542 | 543 |
| 544 void AddHTTPBodyToRequest(WebURLRequest* request, |
| 545 scoped_refptr<ResourceRequestBody> body) { |
| 546 WebHTTPBody http_body; |
| 547 http_body.initialize(); |
| 548 http_body.setIdentifier(body->identifier()); |
| 549 for (auto element : *(body->elements())) { |
| 550 switch (element.type()) { |
| 551 case storage::DataElement::TYPE_BYTES: |
| 552 http_body.appendData(WebData( |
| 553 reinterpret_cast<const char*>(element.bytes()), element.length())); |
| 554 break; |
| 555 case storage::DataElement::TYPE_FILE: |
| 556 http_body.appendFileRange( |
| 557 element.path().AsUTF16Unsafe(), element.offset(), element.length(), |
| 558 element.expected_modification_time().ToDoubleT()); |
| 559 break; |
| 560 case storage::DataElement::TYPE_FILE_FILESYSTEM: |
| 561 http_body.appendFileSystemURLRange( |
| 562 element.filesystem_url(), element.offset(), element.length(), |
| 563 element.expected_modification_time().ToDoubleT()); |
| 564 break; |
| 565 case storage::DataElement::TYPE_BLOB: |
| 566 http_body.appendBlob(WebString::fromUTF8(element.blob_uuid())); |
| 567 break; |
| 568 default: |
| 569 NOTREACHED(); |
| 570 break; |
| 571 } |
| 572 } |
| 573 request->setHTTPBody(http_body); |
| 574 } |
| 575 |
543 // Sanitizes the navigation_start timestamp for browser-initiated navigations, | 576 // Sanitizes the navigation_start timestamp for browser-initiated navigations, |
544 // where the browser possibly has a better notion of start time than the | 577 // where the browser possibly has a better notion of start time than the |
545 // renderer. In the case of cross-process navigations, this carries over the | 578 // renderer. In the case of cross-process navigations, this carries over the |
546 // time of finishing the onbeforeunload handler of the previous page. | 579 // time of finishing the onbeforeunload handler of the previous page. |
547 // TimeTicks is sometimes not monotonic across processes, and because | 580 // TimeTicks is sometimes not monotonic across processes, and because |
548 // |browser_navigation_start| is likely before this process existed, | 581 // |browser_navigation_start| is likely before this process existed, |
549 // InterProcessTimeTicksConverter won't help. The timestamp is sanitized by | 582 // InterProcessTimeTicksConverter won't help. The timestamp is sanitized by |
550 // clamping it to renderer_navigation_start, initialized earlier in the call | 583 // clamping it to renderer_navigation_start, initialized earlier in the call |
551 // stack. | 584 // stack. |
552 base::TimeTicks SanitizeNavigationTiming( | 585 base::TimeTicks SanitizeNavigationTiming( |
(...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1479 } | 1512 } |
1480 | 1513 |
1481 RenderThreadImpl* render_thread_impl = RenderThreadImpl::current(); | 1514 RenderThreadImpl* render_thread_impl = RenderThreadImpl::current(); |
1482 // Can be NULL in tests. | 1515 // Can be NULL in tests. |
1483 if (render_thread_impl) | 1516 if (render_thread_impl) |
1484 render_thread_impl->GetRendererScheduler()->OnNavigationStarted(); | 1517 render_thread_impl->GetRendererScheduler()->OnNavigationStarted(); |
1485 DCHECK(!IsBrowserSideNavigationEnabled()); | 1518 DCHECK(!IsBrowserSideNavigationEnabled()); |
1486 TRACE_EVENT2("navigation", "RenderFrameImpl::OnNavigate", "id", routing_id_, | 1519 TRACE_EVENT2("navigation", "RenderFrameImpl::OnNavigate", "id", routing_id_, |
1487 "url", common_params.url.possibly_invalid_spec()); | 1520 "url", common_params.url.possibly_invalid_spec()); |
1488 NavigateInternal(common_params, start_params, request_params, | 1521 NavigateInternal(common_params, start_params, request_params, |
1489 std::unique_ptr<StreamOverrideParameters>()); | 1522 std::unique_ptr<StreamOverrideParameters>(), nullptr); |
1490 } | 1523 } |
1491 | 1524 |
1492 void RenderFrameImpl::BindServiceRegistry( | 1525 void RenderFrameImpl::BindServiceRegistry( |
1493 shell::mojom::InterfaceProviderRequest services, | 1526 shell::mojom::InterfaceProviderRequest services, |
1494 shell::mojom::InterfaceProviderPtr exposed_services) { | 1527 shell::mojom::InterfaceProviderPtr exposed_services) { |
1495 service_registry_.Bind(std::move(services)); | 1528 service_registry_.Bind(std::move(services)); |
1496 service_registry_.BindRemoteServiceProvider(std::move(exposed_services)); | 1529 service_registry_.BindRemoteServiceProvider(std::move(exposed_services)); |
1497 } | 1530 } |
1498 | 1531 |
1499 ManifestManager* RenderFrameImpl::manifest_manager() { | 1532 ManifestManager* RenderFrameImpl::manifest_manager() { |
(...skipping 3116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4616 void RenderFrameImpl::FocusedNodeChangedForAccessibility(const WebNode& node) { | 4649 void RenderFrameImpl::FocusedNodeChangedForAccessibility(const WebNode& node) { |
4617 if (renderer_accessibility()) | 4650 if (renderer_accessibility()) |
4618 renderer_accessibility()->AccessibilityFocusedNodeChanged(node); | 4651 renderer_accessibility()->AccessibilityFocusedNodeChanged(node); |
4619 } | 4652 } |
4620 | 4653 |
4621 // PlzNavigate | 4654 // PlzNavigate |
4622 void RenderFrameImpl::OnCommitNavigation( | 4655 void RenderFrameImpl::OnCommitNavigation( |
4623 const ResourceResponseHead& response, | 4656 const ResourceResponseHead& response, |
4624 const GURL& stream_url, | 4657 const GURL& stream_url, |
4625 const CommonNavigationParams& common_params, | 4658 const CommonNavigationParams& common_params, |
4626 const RequestNavigationParams& request_params) { | 4659 const RequestNavigationParams& request_params, |
| 4660 scoped_refptr<ResourceRequestBody> post_data) { |
4627 CHECK(IsBrowserSideNavigationEnabled()); | 4661 CHECK(IsBrowserSideNavigationEnabled()); |
4628 // This will override the url requested by the WebURLLoader, as well as | 4662 // This will override the url requested by the WebURLLoader, as well as |
4629 // provide it with the response to the request. | 4663 // provide it with the response to the request. |
4630 std::unique_ptr<StreamOverrideParameters> stream_override( | 4664 std::unique_ptr<StreamOverrideParameters> stream_override( |
4631 new StreamOverrideParameters()); | 4665 new StreamOverrideParameters()); |
4632 stream_override->stream_url = stream_url; | 4666 stream_override->stream_url = stream_url; |
4633 stream_override->response = response; | 4667 stream_override->response = response; |
4634 | 4668 |
4635 NavigateInternal(common_params, StartNavigationParams(), request_params, | 4669 NavigateInternal(common_params, StartNavigationParams(), request_params, |
4636 std::move(stream_override)); | 4670 std::move(stream_override), post_data); |
4637 } | 4671 } |
4638 | 4672 |
4639 // PlzNavigate | 4673 // PlzNavigate |
4640 void RenderFrameImpl::OnFailedNavigation( | 4674 void RenderFrameImpl::OnFailedNavigation( |
4641 const CommonNavigationParams& common_params, | 4675 const CommonNavigationParams& common_params, |
4642 const RequestNavigationParams& request_params, | 4676 const RequestNavigationParams& request_params, |
4643 bool has_stale_copy_in_cache, | 4677 bool has_stale_copy_in_cache, |
4644 int error_code) { | 4678 int error_code) { |
4645 DCHECK(IsBrowserSideNavigationEnabled()); | 4679 DCHECK(IsBrowserSideNavigationEnabled()); |
4646 bool is_reload = IsReload(common_params.navigation_type); | 4680 bool is_reload = IsReload(common_params.navigation_type); |
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5222 params.frame_unique_name = frame_->uniqueName().utf8(); | 5256 params.frame_unique_name = frame_->uniqueName().utf8(); |
5223 } | 5257 } |
5224 | 5258 |
5225 Send(new FrameHostMsg_OpenURL(routing_id_, params)); | 5259 Send(new FrameHostMsg_OpenURL(routing_id_, params)); |
5226 } | 5260 } |
5227 | 5261 |
5228 void RenderFrameImpl::NavigateInternal( | 5262 void RenderFrameImpl::NavigateInternal( |
5229 const CommonNavigationParams& common_params, | 5263 const CommonNavigationParams& common_params, |
5230 const StartNavigationParams& start_params, | 5264 const StartNavigationParams& start_params, |
5231 const RequestNavigationParams& request_params, | 5265 const RequestNavigationParams& request_params, |
5232 std::unique_ptr<StreamOverrideParameters> stream_params) { | 5266 std::unique_ptr<StreamOverrideParameters> stream_params, |
| 5267 scoped_refptr<ResourceRequestBody> post_data) { |
5233 bool browser_side_navigation = IsBrowserSideNavigationEnabled(); | 5268 bool browser_side_navigation = IsBrowserSideNavigationEnabled(); |
5234 | 5269 |
5235 // Lower bound for browser initiated navigation start time. | 5270 // Lower bound for browser initiated navigation start time. |
5236 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now(); | 5271 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now(); |
5237 bool is_reload = IsReload(common_params.navigation_type); | 5272 bool is_reload = IsReload(common_params.navigation_type); |
5238 bool is_history_navigation = request_params.page_state.IsValid(); | 5273 bool is_history_navigation = request_params.page_state.IsValid(); |
5239 WebCachePolicy cache_policy = WebCachePolicy::UseProtocolCachePolicy; | 5274 WebCachePolicy cache_policy = WebCachePolicy::UseProtocolCachePolicy; |
5240 RenderFrameImpl::PrepareRenderViewForNavigation( | 5275 RenderFrameImpl::PrepareRenderViewForNavigation( |
5241 common_params.url, request_params); | 5276 common_params.url, request_params); |
5242 | 5277 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5283 ? blink::WebFrameLoadType::ReplaceCurrentItem | 5318 ? blink::WebFrameLoadType::ReplaceCurrentItem |
5284 : blink::WebFrameLoadType::Standard; | 5319 : blink::WebFrameLoadType::Standard; |
5285 blink::WebHistoryLoadType history_load_type = | 5320 blink::WebHistoryLoadType history_load_type = |
5286 blink::WebHistoryDifferentDocumentLoad; | 5321 blink::WebHistoryDifferentDocumentLoad; |
5287 bool should_load_request = false; | 5322 bool should_load_request = false; |
5288 WebHistoryItem item_for_history_navigation; | 5323 WebHistoryItem item_for_history_navigation; |
5289 WebURLRequest request = | 5324 WebURLRequest request = |
5290 CreateURLRequestForNavigation(common_params, std::move(stream_params), | 5325 CreateURLRequestForNavigation(common_params, std::move(stream_params), |
5291 frame_->isViewSourceModeEnabled()); | 5326 frame_->isViewSourceModeEnabled()); |
5292 | 5327 |
| 5328 if (IsBrowserSideNavigationEnabled() && post_data) |
| 5329 AddHTTPBodyToRequest(&request, post_data); |
| 5330 |
5293 // Used to determine whether this frame is actually loading a request as part | 5331 // Used to determine whether this frame is actually loading a request as part |
5294 // of a history navigation. | 5332 // of a history navigation. |
5295 bool has_history_navigation_in_frame = false; | 5333 bool has_history_navigation_in_frame = false; |
5296 | 5334 |
5297 #if defined(OS_ANDROID) | 5335 #if defined(OS_ANDROID) |
5298 request.setHasUserGesture(start_params.has_user_gesture); | 5336 request.setHasUserGesture(start_params.has_user_gesture); |
5299 #endif | 5337 #endif |
5300 | 5338 |
5301 // PlzNavigate: Make sure that Blink's loader will not try to use browser side | 5339 // PlzNavigate: Make sure that Blink's loader will not try to use browser side |
5302 // navigation for this request (since it already went to the browser). | 5340 // navigation for this request (since it already went to the browser). |
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6033 int match_count, | 6071 int match_count, |
6034 int ordinal, | 6072 int ordinal, |
6035 const WebRect& selection_rect, | 6073 const WebRect& selection_rect, |
6036 bool final_status_update) { | 6074 bool final_status_update) { |
6037 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count, | 6075 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count, |
6038 selection_rect, ordinal, | 6076 selection_rect, ordinal, |
6039 final_status_update)); | 6077 final_status_update)); |
6040 } | 6078 } |
6041 | 6079 |
6042 } // namespace content | 6080 } // namespace content |
OLD | NEW |