Chromium Code Reviews| 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 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 463 (navigation_start - base::TimeTicks()).InSecondsF(); | 463 (navigation_start - base::TimeTicks()).InSecondsF(); |
| 464 frame->provisionalDataSource()->setNavigationStartTime( | 464 frame->provisionalDataSource()->setNavigationStartTime( |
| 465 navigation_start_seconds); | 465 navigation_start_seconds); |
| 466 // TODO(clamy): We need to provide additional timing values for the | 466 // TODO(clamy): We need to provide additional timing values for the |
| 467 // Navigation Timing API to work with browser-side navigations. | 467 // Navigation Timing API to work with browser-side navigations. |
| 468 } | 468 } |
| 469 } | 469 } |
| 470 | 470 |
| 471 // PlzNavigate | 471 // PlzNavigate |
| 472 CommonNavigationParams MakeCommonNavigationParams( | 472 CommonNavigationParams MakeCommonNavigationParams( |
| 473 blink::WebURLRequest* request) { | 473 blink::WebURLRequest* request, |
| 474 bool should_replace_current_entry) { | |
| 474 const RequestExtraData kEmptyData; | 475 const RequestExtraData kEmptyData; |
| 475 const RequestExtraData* extra_data = | 476 const RequestExtraData* extra_data = |
| 476 static_cast<RequestExtraData*>(request->extraData()); | 477 static_cast<RequestExtraData*>(request->extraData()); |
| 477 if (!extra_data) | 478 if (!extra_data) |
| 478 extra_data = &kEmptyData; | 479 extra_data = &kEmptyData; |
| 479 Referrer referrer( | 480 Referrer referrer( |
| 480 GURL(request->httpHeaderField(WebString::fromUTF8("Referer")).latin1()), | 481 GURL(request->httpHeaderField(WebString::fromUTF8("Referer")).latin1()), |
| 481 request->referrerPolicy()); | 482 request->referrerPolicy()); |
| 482 | 483 |
| 483 // Set the ui timestamp for this navigation. Currently the timestamp here is | 484 // Set the ui timestamp for this navigation. Currently the timestamp here is |
| 484 // only non empty when the navigation was triggered by an Android intent, or | 485 // only non empty when the navigation was triggered by an Android intent, or |
| 485 // by the user clicking on a link. The timestamp is converted from a double | 486 // by the user clicking on a link. The timestamp is converted from a double |
| 486 // version supported by blink. It will be passed back to the renderer in the | 487 // version supported by blink. It will be passed back to the renderer in the |
| 487 // CommitNavigation IPC, and then back to the browser again in the | 488 // CommitNavigation IPC, and then back to the browser again in the |
| 488 // DidCommitProvisionalLoad and the DocumentLoadComplete IPCs. | 489 // DidCommitProvisionalLoad and the DocumentLoadComplete IPCs. |
| 489 base::TimeTicks ui_timestamp = | 490 base::TimeTicks ui_timestamp = |
| 490 base::TimeTicks() + base::TimeDelta::FromSecondsD(request->uiStartTime()); | 491 base::TimeTicks() + base::TimeDelta::FromSecondsD(request->uiStartTime()); |
| 491 FrameMsg_UILoadMetricsReportType::Value report_type = | 492 FrameMsg_UILoadMetricsReportType::Value report_type = |
| 492 static_cast<FrameMsg_UILoadMetricsReportType::Value>( | 493 static_cast<FrameMsg_UILoadMetricsReportType::Value>( |
| 493 request->inputPerfMetricReportPolicy()); | 494 request->inputPerfMetricReportPolicy()); |
| 494 return CommonNavigationParams(request->url(), referrer, | 495 return CommonNavigationParams( |
| 495 extra_data->transition_type(), | 496 request->url(), referrer, extra_data->transition_type(), |
| 496 FrameMsg_Navigate_Type::NORMAL, true, | 497 FrameMsg_Navigate_Type::NORMAL, true, should_replace_current_entry, |
| 497 ui_timestamp, report_type, GURL(), GURL()); | 498 ui_timestamp, report_type, GURL(), GURL()); |
| 498 } | 499 } |
| 499 | 500 |
| 500 #if !defined(OS_ANDROID) || defined(ENABLE_MEDIA_PIPELINE_ON_ANDROID) | 501 #if !defined(OS_ANDROID) || defined(ENABLE_MEDIA_PIPELINE_ON_ANDROID) |
| 501 media::Context3D GetSharedMainThreadContext3D() { | 502 media::Context3D GetSharedMainThreadContext3D() { |
| 502 cc::ContextProvider* provider = | 503 cc::ContextProvider* provider = |
| 503 RenderThreadImpl::current()->SharedMainThreadContextProvider().get(); | 504 RenderThreadImpl::current()->SharedMainThreadContextProvider().get(); |
| 504 if (!provider) | 505 if (!provider) |
| 505 return media::Context3D(); | 506 return media::Context3D(); |
| 506 return media::Context3D(provider->ContextGL(), provider->GrContext()); | 507 return media::Context3D(provider->ContextGL(), provider->GrContext()); |
| 507 } | 508 } |
| (...skipping 2172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2680 // We bump our Page ID to correspond with the new session history entry. | 2681 // We bump our Page ID to correspond with the new session history entry. |
| 2681 render_view_->page_id_ = render_view_->next_page_id_++; | 2682 render_view_->page_id_ = render_view_->next_page_id_++; |
| 2682 | 2683 |
| 2683 // Don't update history list values for kSwappedOutURL, since | 2684 // Don't update history list values for kSwappedOutURL, since |
| 2684 // we don't want to forget the entry that was there, and since we will | 2685 // we don't want to forget the entry that was there, and since we will |
| 2685 // never come back to kSwappedOutURL. Note that we have to call | 2686 // never come back to kSwappedOutURL. Note that we have to call |
| 2686 // UpdateSessionHistory and update page_id_ even in this case, so that | 2687 // UpdateSessionHistory and update page_id_ even in this case, so that |
| 2687 // the current entry gets a state update and so that we don't send a | 2688 // the current entry gets a state update and so that we don't send a |
| 2688 // state update to the wrong entry when we swap back in. | 2689 // state update to the wrong entry when we swap back in. |
| 2689 DCHECK_IMPLIES( | 2690 DCHECK_IMPLIES( |
| 2690 navigation_state->start_params().should_replace_current_entry, | 2691 navigation_state->common_params().should_replace_current_entry, |
| 2691 render_view_->history_list_length_ > 0); | 2692 render_view_->history_list_length_ > 0); |
| 2692 if (GetLoadingUrl() != GURL(kSwappedOutURL) && | 2693 if (GetLoadingUrl() != GURL(kSwappedOutURL) && |
| 2693 !navigation_state->start_params().should_replace_current_entry) { | 2694 !navigation_state->common_params().should_replace_current_entry) { |
| 2694 // Advance our offset in session history, applying the length limit. | 2695 // Advance our offset in session history, applying the length limit. |
| 2695 // There is now no forward history. | 2696 // There is now no forward history. |
| 2696 render_view_->history_list_offset_++; | 2697 render_view_->history_list_offset_++; |
| 2697 if (render_view_->history_list_offset_ >= kMaxSessionHistoryEntries) | 2698 if (render_view_->history_list_offset_ >= kMaxSessionHistoryEntries) |
| 2698 render_view_->history_list_offset_ = kMaxSessionHistoryEntries - 1; | 2699 render_view_->history_list_offset_ = kMaxSessionHistoryEntries - 1; |
| 2699 render_view_->history_list_length_ = | 2700 render_view_->history_list_length_ = |
| 2700 render_view_->history_list_offset_ + 1; | 2701 render_view_->history_list_offset_ + 1; |
| 2701 } | 2702 } |
| 2702 } else { | 2703 } else { |
| 2703 const RequestNavigationParams& request_params = | 2704 const RequestNavigationParams& request_params = |
| (...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3236 bool should_replace_current_entry = false; | 3237 bool should_replace_current_entry = false; |
| 3237 if (navigation_state->IsContentInitiated()) { | 3238 if (navigation_state->IsContentInitiated()) { |
| 3238 should_replace_current_entry = data_source->replacesCurrentHistoryItem(); | 3239 should_replace_current_entry = data_source->replacesCurrentHistoryItem(); |
| 3239 } else { | 3240 } else { |
| 3240 // If the navigation is browser-initiated, the NavigationState contains the | 3241 // If the navigation is browser-initiated, the NavigationState contains the |
| 3241 // correct value instead of the WebDataSource. | 3242 // correct value instead of the WebDataSource. |
| 3242 // | 3243 // |
| 3243 // TODO(davidben): Avoid this awkward duplication of state. See comment on | 3244 // TODO(davidben): Avoid this awkward duplication of state. See comment on |
| 3244 // NavigationState::should_replace_current_entry(). | 3245 // NavigationState::should_replace_current_entry(). |
| 3245 should_replace_current_entry = | 3246 should_replace_current_entry = |
| 3246 navigation_state->start_params().should_replace_current_entry; | 3247 navigation_state->common_params().should_replace_current_entry; |
| 3247 } | 3248 } |
| 3248 | 3249 |
| 3249 int provider_id = kInvalidServiceWorkerProviderId; | 3250 int provider_id = kInvalidServiceWorkerProviderId; |
| 3250 if (request.frameType() == blink::WebURLRequest::FrameTypeTopLevel || | 3251 if (request.frameType() == blink::WebURLRequest::FrameTypeTopLevel || |
| 3251 request.frameType() == blink::WebURLRequest::FrameTypeNested) { | 3252 request.frameType() == blink::WebURLRequest::FrameTypeNested) { |
| 3252 // |provisionalDataSource| may be null in some content::ResourceFetcher | 3253 // |provisionalDataSource| may be null in some content::ResourceFetcher |
| 3253 // use cases, we don't hook those requests. | 3254 // use cases, we don't hook those requests. |
| 3254 if (frame->provisionalDataSource()) { | 3255 if (frame->provisionalDataSource()) { |
| 3255 ServiceWorkerNetworkProvider* provider = | 3256 ServiceWorkerNetworkProvider* provider = |
| 3256 ServiceWorkerNetworkProvider::FromDocumentState( | 3257 ServiceWorkerNetworkProvider::FromDocumentState( |
| (...skipping 1126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4383 params.should_replace_current_entry = | 4384 params.should_replace_current_entry = |
| 4384 ds->replacesCurrentHistoryItem() && | 4385 ds->replacesCurrentHistoryItem() && |
| 4385 render_view_->history_list_length_; | 4386 render_view_->history_list_length_; |
| 4386 } else { | 4387 } else { |
| 4387 // This is necessary to preserve the should_replace_current_entry value on | 4388 // This is necessary to preserve the should_replace_current_entry value on |
| 4388 // cross-process redirects, in the event it was set by a previous process. | 4389 // cross-process redirects, in the event it was set by a previous process. |
| 4389 // | 4390 // |
| 4390 // TODO(davidben): Avoid this awkward duplication of state. See comment on | 4391 // TODO(davidben): Avoid this awkward duplication of state. See comment on |
| 4391 // NavigationState::should_replace_current_entry(). | 4392 // NavigationState::should_replace_current_entry(). |
| 4392 params.should_replace_current_entry = | 4393 params.should_replace_current_entry = |
| 4393 navigation_state->start_params().should_replace_current_entry; | 4394 navigation_state->common_params().should_replace_current_entry; |
| 4394 } | 4395 } |
| 4395 } else { | 4396 } else { |
| 4396 params.should_replace_current_entry = false; | 4397 params.should_replace_current_entry = false; |
| 4397 } | 4398 } |
| 4398 params.user_gesture = WebUserGestureIndicator::isProcessingUserGesture(); | 4399 params.user_gesture = WebUserGestureIndicator::isProcessingUserGesture(); |
| 4399 if (GetContentClient()->renderer()->AllowPopup()) | 4400 if (GetContentClient()->renderer()->AllowPopup()) |
| 4400 params.user_gesture = true; | 4401 params.user_gesture = true; |
| 4401 | 4402 |
| 4402 if (policy == blink::WebNavigationPolicyNewBackgroundTab || | 4403 if (policy == blink::WebNavigationPolicyNewBackgroundTab || |
| 4403 policy == blink::WebNavigationPolicyNewForegroundTab || | 4404 policy == blink::WebNavigationPolicyNewForegroundTab || |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4772 // implementation of willSendRequest for the various InspectorAgents | 4773 // implementation of willSendRequest for the various InspectorAgents |
| 4773 // (devtools). | 4774 // (devtools). |
| 4774 // | 4775 // |
| 4775 // TODO(clamy): Apply devtools override. | 4776 // TODO(clamy): Apply devtools override. |
| 4776 // TODO(clamy): Make sure that navigation requests are not modified somewhere | 4777 // TODO(clamy): Make sure that navigation requests are not modified somewhere |
| 4777 // else in blink. | 4778 // else in blink. |
| 4778 willSendRequest(frame_, 0, *request, blink::WebURLResponse()); | 4779 willSendRequest(frame_, 0, *request, blink::WebURLResponse()); |
| 4779 | 4780 |
| 4780 // TODO(clamy): Same-document navigations should not be sent back to the | 4781 // TODO(clamy): Same-document navigations should not be sent back to the |
| 4781 // browser. | 4782 // browser. |
| 4783 // TODO(clamy): Data urls should not be sent back to the browser either. | |
| 4784 bool should_replace_current_entry = false; | |
| 4785 WebDataSource* provisional_data_source = frame_->provisionalDataSource(); | |
| 4786 WebDataSource* current_data_source = frame_->dataSource(); | |
| 4787 WebDataSource* data_source = | |
| 4788 provisional_data_source ? provisional_data_source : current_data_source; | |
| 4789 | |
| 4790 // The current entry can only be replaced if there already is an entry in the | |
| 4791 // history list. | |
| 4792 if (data_source && render_view_->history_list_length_ > 0 && | |
| 4793 !frame_->parent()) { | |
|
Charlie Reis
2015/07/24 18:25:41
Why is !frame_->parent() here? You can do locatio
clamy
2015/07/27 11:39:40
We were initially worried with Nasko that this wou
| |
| 4794 should_replace_current_entry = data_source->replacesCurrentHistoryItem(); | |
| 4795 } | |
| 4782 Send(new FrameHostMsg_BeginNavigation( | 4796 Send(new FrameHostMsg_BeginNavigation( |
| 4783 routing_id_, MakeCommonNavigationParams(request), | 4797 routing_id_, |
| 4784 BeginNavigationParams(request->httpMethod().latin1(), | 4798 MakeCommonNavigationParams(request, should_replace_current_entry), |
| 4785 GetWebURLRequestHeaders(*request), | 4799 BeginNavigationParams( |
| 4786 GetLoadFlagsForWebURLRequest(*request), | 4800 request->httpMethod().latin1(), GetWebURLRequestHeaders(*request), |
| 4787 request->hasUserGesture()), | 4801 GetLoadFlagsForWebURLRequest(*request), request->hasUserGesture()), |
| 4788 GetRequestBodyForWebURLRequest(*request))); | 4802 GetRequestBodyForWebURLRequest(*request))); |
| 4789 } | 4803 } |
| 4790 | 4804 |
| 4791 void RenderFrameImpl::LoadDataURL(const CommonNavigationParams& params, | 4805 void RenderFrameImpl::LoadDataURL(const CommonNavigationParams& params, |
| 4792 WebFrame* frame) { | 4806 WebFrame* frame) { |
| 4793 // A loadData request with a specified base URL. | 4807 // A loadData request with a specified base URL. |
| 4794 std::string mime_type, charset, data; | 4808 std::string mime_type, charset, data; |
| 4795 if (net::DataURL::Parse(params.url, &mime_type, &charset, &data)) { | 4809 if (net::DataURL::Parse(params.url, &mime_type, &charset, &data)) { |
| 4796 const GURL base_url = params.base_url_for_data_url.is_empty() ? | 4810 const GURL base_url = params.base_url_for_data_url.is_empty() ? |
| 4797 params.url : params.base_url_for_data_url; | 4811 params.url : params.base_url_for_data_url; |
| 4798 frame->loadData( | 4812 frame->loadData( |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5044 void RenderFrameImpl::RegisterMojoServices() { | 5058 void RenderFrameImpl::RegisterMojoServices() { |
| 5045 // Only main frame have ImageDownloader service. | 5059 // Only main frame have ImageDownloader service. |
| 5046 if (!frame_->parent()) { | 5060 if (!frame_->parent()) { |
| 5047 GetServiceRegistry()->AddService<image_downloader::ImageDownloader>( | 5061 GetServiceRegistry()->AddService<image_downloader::ImageDownloader>( |
| 5048 base::Bind(&ImageDownloaderImpl::CreateMojoService, | 5062 base::Bind(&ImageDownloaderImpl::CreateMojoService, |
| 5049 base::Unretained(this))); | 5063 base::Unretained(this))); |
| 5050 } | 5064 } |
| 5051 } | 5065 } |
| 5052 | 5066 |
| 5053 } // namespace content | 5067 } // namespace content |
| OLD | NEW |