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) { | |
Łukasz Anforowicz
2016/05/12 02:53:59
:-) I've started creating my own version of this
clamy
2016/05/12 08:53:13
This is based on the code from content/renderer/hi
Łukasz Anforowicz
2016/05/12 19:44:12
I see. Fascinating that we have 3 separate struct
| |
548 WebHTTPBody http_body; | |
549 http_body.initialize(); | |
550 http_body.setIdentifier(body->identifier()); | |
551 for (auto element : *(body->elements())) { | |
Łukasz Anforowicz
2016/05/12 02:53:59
nit: Could you replace auto with: const ResourceRe
clamy
2016/05/12 08:53:13
Done.
| |
552 switch (element.type()) { | |
553 case storage::DataElement::TYPE_BYTES: | |
554 http_body.appendData(WebData( | |
555 reinterpret_cast<const char*>(element.bytes()), element.length())); | |
Łukasz Anforowicz
2016/05/12 02:54:00
Why is reinterpret_cast needed here? reinterpret_
clamy
2016/05/12 08:53:13
Done.
| |
556 break; | |
557 case storage::DataElement::TYPE_FILE: | |
558 http_body.appendFileRange( | |
559 element.path().AsUTF16Unsafe(), element.offset(), element.length(), | |
Łukasz Anforowicz
2016/05/12 02:54:00
Should we translate back std::numeric_limits<uint6
clamy
2016/05/12 08:53:13
Done.
| |
560 element.expected_modification_time().ToDoubleT()); | |
561 break; | |
562 case storage::DataElement::TYPE_FILE_FILESYSTEM: | |
563 http_body.appendFileSystemURLRange( | |
564 element.filesystem_url(), element.offset(), element.length(), | |
565 element.expected_modification_time().ToDoubleT()); | |
566 break; | |
567 case storage::DataElement::TYPE_BLOB: | |
568 http_body.appendBlob(WebString::fromUTF8(element.blob_uuid())); | |
569 break; | |
570 default: | |
Łukasz Anforowicz
2016/05/12 02:53:59
nit: I wonder if we should explicitly spell out ty
clamy
2016/05/12 08:53:13
Done.
| |
571 NOTREACHED(); | |
572 break; | |
573 } | |
574 } | |
575 request->setHTTPBody(http_body); | |
576 } | |
577 | |
540 // Sanitizes the navigation_start timestamp for browser-initiated navigations, | 578 // Sanitizes the navigation_start timestamp for browser-initiated navigations, |
541 // where the browser possibly has a better notion of start time than the | 579 // 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 | 580 // renderer. In the case of cross-process navigations, this carries over the |
543 // time of finishing the onbeforeunload handler of the previous page. | 581 // time of finishing the onbeforeunload handler of the previous page. |
544 // TimeTicks is sometimes not monotonic across processes, and because | 582 // TimeTicks is sometimes not monotonic across processes, and because |
545 // |browser_navigation_start| is likely before this process existed, | 583 // |browser_navigation_start| is likely before this process existed, |
546 // InterProcessTimeTicksConverter won't help. The timestamp is sanitized by | 584 // InterProcessTimeTicksConverter won't help. The timestamp is sanitized by |
547 // clamping it to renderer_navigation_start, initialized earlier in the call | 585 // clamping it to renderer_navigation_start, initialized earlier in the call |
548 // stack. | 586 // stack. |
549 base::TimeTicks SanitizeNavigationTiming( | 587 base::TimeTicks SanitizeNavigationTiming( |
(...skipping 944 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1494 } | 1532 } |
1495 | 1533 |
1496 RenderThreadImpl* render_thread_impl = RenderThreadImpl::current(); | 1534 RenderThreadImpl* render_thread_impl = RenderThreadImpl::current(); |
1497 // Can be NULL in tests. | 1535 // Can be NULL in tests. |
1498 if (render_thread_impl) | 1536 if (render_thread_impl) |
1499 render_thread_impl->GetRendererScheduler()->OnNavigationStarted(); | 1537 render_thread_impl->GetRendererScheduler()->OnNavigationStarted(); |
1500 DCHECK(!IsBrowserSideNavigationEnabled()); | 1538 DCHECK(!IsBrowserSideNavigationEnabled()); |
1501 TRACE_EVENT2("navigation", "RenderFrameImpl::OnNavigate", "id", routing_id_, | 1539 TRACE_EVENT2("navigation", "RenderFrameImpl::OnNavigate", "id", routing_id_, |
1502 "url", common_params.url.possibly_invalid_spec()); | 1540 "url", common_params.url.possibly_invalid_spec()); |
1503 NavigateInternal(common_params, start_params, request_params, | 1541 NavigateInternal(common_params, start_params, request_params, |
1504 std::unique_ptr<StreamOverrideParameters>()); | 1542 std::unique_ptr<StreamOverrideParameters>(), nullptr); |
1505 } | 1543 } |
1506 | 1544 |
1507 void RenderFrameImpl::BindServiceRegistry( | 1545 void RenderFrameImpl::BindServiceRegistry( |
1508 shell::mojom::InterfaceProviderRequest services, | 1546 shell::mojom::InterfaceProviderRequest services, |
1509 shell::mojom::InterfaceProviderPtr exposed_services) { | 1547 shell::mojom::InterfaceProviderPtr exposed_services) { |
1510 service_registry_.Bind(std::move(services)); | 1548 service_registry_.Bind(std::move(services)); |
1511 service_registry_.BindRemoteServiceProvider(std::move(exposed_services)); | 1549 service_registry_.BindRemoteServiceProvider(std::move(exposed_services)); |
1512 } | 1550 } |
1513 | 1551 |
1514 ManifestManager* RenderFrameImpl::manifest_manager() { | 1552 ManifestManager* RenderFrameImpl::manifest_manager() { |
(...skipping 3116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4631 void RenderFrameImpl::FocusedNodeChangedForAccessibility(const WebNode& node) { | 4669 void RenderFrameImpl::FocusedNodeChangedForAccessibility(const WebNode& node) { |
4632 if (renderer_accessibility()) | 4670 if (renderer_accessibility()) |
4633 renderer_accessibility()->AccessibilityFocusedNodeChanged(node); | 4671 renderer_accessibility()->AccessibilityFocusedNodeChanged(node); |
4634 } | 4672 } |
4635 | 4673 |
4636 // PlzNavigate | 4674 // PlzNavigate |
4637 void RenderFrameImpl::OnCommitNavigation( | 4675 void RenderFrameImpl::OnCommitNavigation( |
4638 const ResourceResponseHead& response, | 4676 const ResourceResponseHead& response, |
4639 const GURL& stream_url, | 4677 const GURL& stream_url, |
4640 const CommonNavigationParams& common_params, | 4678 const CommonNavigationParams& common_params, |
4641 const RequestNavigationParams& request_params) { | 4679 const RequestNavigationParams& request_params, |
4680 scoped_refptr<ResourceRequestBody> post_data) { | |
4642 CHECK(IsBrowserSideNavigationEnabled()); | 4681 CHECK(IsBrowserSideNavigationEnabled()); |
4643 // This will override the url requested by the WebURLLoader, as well as | 4682 // This will override the url requested by the WebURLLoader, as well as |
4644 // provide it with the response to the request. | 4683 // provide it with the response to the request. |
4645 std::unique_ptr<StreamOverrideParameters> stream_override( | 4684 std::unique_ptr<StreamOverrideParameters> stream_override( |
4646 new StreamOverrideParameters()); | 4685 new StreamOverrideParameters()); |
4647 stream_override->stream_url = stream_url; | 4686 stream_override->stream_url = stream_url; |
4648 stream_override->response = response; | 4687 stream_override->response = response; |
4649 | 4688 |
4650 NavigateInternal(common_params, StartNavigationParams(), request_params, | 4689 NavigateInternal(common_params, StartNavigationParams(), request_params, |
4651 std::move(stream_override)); | 4690 std::move(stream_override), post_data); |
4652 } | 4691 } |
4653 | 4692 |
4654 // PlzNavigate | 4693 // PlzNavigate |
4655 void RenderFrameImpl::OnFailedNavigation( | 4694 void RenderFrameImpl::OnFailedNavigation( |
4656 const CommonNavigationParams& common_params, | 4695 const CommonNavigationParams& common_params, |
4657 const RequestNavigationParams& request_params, | 4696 const RequestNavigationParams& request_params, |
4658 bool has_stale_copy_in_cache, | 4697 bool has_stale_copy_in_cache, |
4659 int error_code) { | 4698 int error_code) { |
4660 DCHECK(IsBrowserSideNavigationEnabled()); | 4699 DCHECK(IsBrowserSideNavigationEnabled()); |
4661 bool is_reload = IsReload(common_params.navigation_type); | 4700 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(); | 5276 params.frame_unique_name = frame_->uniqueName().utf8(); |
5238 } | 5277 } |
5239 | 5278 |
5240 Send(new FrameHostMsg_OpenURL(routing_id_, params)); | 5279 Send(new FrameHostMsg_OpenURL(routing_id_, params)); |
5241 } | 5280 } |
5242 | 5281 |
5243 void RenderFrameImpl::NavigateInternal( | 5282 void RenderFrameImpl::NavigateInternal( |
5244 const CommonNavigationParams& common_params, | 5283 const CommonNavigationParams& common_params, |
5245 const StartNavigationParams& start_params, | 5284 const StartNavigationParams& start_params, |
5246 const RequestNavigationParams& request_params, | 5285 const RequestNavigationParams& request_params, |
5247 std::unique_ptr<StreamOverrideParameters> stream_params) { | 5286 std::unique_ptr<StreamOverrideParameters> stream_params, |
5287 scoped_refptr<ResourceRequestBody> post_data) { | |
5248 bool browser_side_navigation = IsBrowserSideNavigationEnabled(); | 5288 bool browser_side_navigation = IsBrowserSideNavigationEnabled(); |
5249 | 5289 |
5250 // Lower bound for browser initiated navigation start time. | 5290 // Lower bound for browser initiated navigation start time. |
5251 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now(); | 5291 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now(); |
5252 bool is_reload = IsReload(common_params.navigation_type); | 5292 bool is_reload = IsReload(common_params.navigation_type); |
5253 bool is_history_navigation = request_params.page_state.IsValid(); | 5293 bool is_history_navigation = request_params.page_state.IsValid(); |
5254 WebCachePolicy cache_policy = WebCachePolicy::UseProtocolCachePolicy; | 5294 WebCachePolicy cache_policy = WebCachePolicy::UseProtocolCachePolicy; |
5255 RenderFrameImpl::PrepareRenderViewForNavigation( | 5295 RenderFrameImpl::PrepareRenderViewForNavigation( |
5256 common_params.url, request_params); | 5296 common_params.url, request_params); |
5257 | 5297 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5298 ? blink::WebFrameLoadType::ReplaceCurrentItem | 5338 ? blink::WebFrameLoadType::ReplaceCurrentItem |
5299 : blink::WebFrameLoadType::Standard; | 5339 : blink::WebFrameLoadType::Standard; |
5300 blink::WebHistoryLoadType history_load_type = | 5340 blink::WebHistoryLoadType history_load_type = |
5301 blink::WebHistoryDifferentDocumentLoad; | 5341 blink::WebHistoryDifferentDocumentLoad; |
5302 bool should_load_request = false; | 5342 bool should_load_request = false; |
5303 WebHistoryItem item_for_history_navigation; | 5343 WebHistoryItem item_for_history_navigation; |
5304 WebURLRequest request = | 5344 WebURLRequest request = |
5305 CreateURLRequestForNavigation(common_params, std::move(stream_params), | 5345 CreateURLRequestForNavigation(common_params, std::move(stream_params), |
5306 frame_->isViewSourceModeEnabled()); | 5346 frame_->isViewSourceModeEnabled()); |
5307 | 5347 |
5348 if (IsBrowserSideNavigationEnabled() && post_data) | |
5349 AddHTTPBodyToRequest(&request, post_data); | |
5350 | |
5308 // Used to determine whether this frame is actually loading a request as part | 5351 // Used to determine whether this frame is actually loading a request as part |
5309 // of a history navigation. | 5352 // of a history navigation. |
5310 bool has_history_navigation_in_frame = false; | 5353 bool has_history_navigation_in_frame = false; |
5311 | 5354 |
5312 #if defined(OS_ANDROID) | 5355 #if defined(OS_ANDROID) |
5313 request.setHasUserGesture(start_params.has_user_gesture); | 5356 request.setHasUserGesture(start_params.has_user_gesture); |
5314 #endif | 5357 #endif |
5315 | 5358 |
5316 // PlzNavigate: Make sure that Blink's loader will not try to use browser side | 5359 // 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). | 5360 // 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, | 6091 int match_count, |
6049 int ordinal, | 6092 int ordinal, |
6050 const WebRect& selection_rect, | 6093 const WebRect& selection_rect, |
6051 bool final_status_update) { | 6094 bool final_status_update) { |
6052 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count, | 6095 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count, |
6053 selection_rect, ordinal, | 6096 selection_rect, ordinal, |
6054 final_status_update)); | 6097 final_status_update)); |
6055 } | 6098 } |
6056 | 6099 |
6057 } // namespace content | 6100 } // namespace content |
OLD | NEW |