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 1114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1125 bool ignore_cache = (common_params.navigation_type == | 1125 bool ignore_cache = (common_params.navigation_type == |
1126 FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE); | 1126 FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE); |
1127 | 1127 |
1128 if (reload_original_url) | 1128 if (reload_original_url) |
1129 frame_->reloadWithOverrideURL(common_params.url, true); | 1129 frame_->reloadWithOverrideURL(common_params.url, true); |
1130 else | 1130 else |
1131 frame_->reload(ignore_cache); | 1131 frame_->reload(ignore_cache); |
1132 } else if (is_history_navigation) { | 1132 } else if (is_history_navigation) { |
1133 // We must know the page ID of the page we are navigating back to. | 1133 // We must know the page ID of the page we are navigating back to. |
1134 DCHECK_NE(request_params.page_id, -1); | 1134 DCHECK_NE(request_params.page_id, -1); |
| 1135 // We must know the nav entry ID of the page we are navigating back to, |
| 1136 // which should be the case because history navigations are routed via the |
| 1137 // browser. |
| 1138 DCHECK_NE(0, request_params.nav_entry_id); |
1135 scoped_ptr<HistoryEntry> entry = | 1139 scoped_ptr<HistoryEntry> entry = |
1136 PageStateToHistoryEntry(request_params.page_state); | 1140 PageStateToHistoryEntry(request_params.page_state); |
1137 if (entry) { | 1141 if (entry) { |
1138 // Ensure we didn't save the swapped out URL in UpdateState, since the | 1142 // Ensure we didn't save the swapped out URL in UpdateState, since the |
1139 // browser should never be telling us to navigate to swappedout://. | 1143 // browser should never be telling us to navigate to swappedout://. |
1140 CHECK(entry->root().urlString() != WebString::fromUTF8(kSwappedOutURL)); | 1144 CHECK(entry->root().urlString() != WebString::fromUTF8(kSwappedOutURL)); |
1141 scoped_ptr<NavigationParams> navigation_params( | 1145 scoped_ptr<NavigationParams> navigation_params( |
1142 new NavigationParams(*pending_navigation_params_.get())); | 1146 new NavigationParams(*pending_navigation_params_.get())); |
1143 render_view_->history_controller()->GoToEntry( | 1147 render_view_->history_controller()->GoToEntry( |
1144 entry.Pass(), navigation_params.Pass(), cache_policy); | 1148 entry.Pass(), navigation_params.Pass(), cache_policy); |
(...skipping 1455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2600 const blink::WebURLError& error, | 2604 const blink::WebURLError& error, |
2601 blink::WebHistoryCommitType commit_type) { | 2605 blink::WebHistoryCommitType commit_type) { |
2602 TRACE_EVENT1("navigation", "RenderFrameImpl::didFailProvisionalLoad", | 2606 TRACE_EVENT1("navigation", "RenderFrameImpl::didFailProvisionalLoad", |
2603 "id", routing_id_); | 2607 "id", routing_id_); |
2604 DCHECK(!frame_ || frame_ == frame); | 2608 DCHECK(!frame_ || frame_ == frame); |
2605 WebDataSource* ds = frame->provisionalDataSource(); | 2609 WebDataSource* ds = frame->provisionalDataSource(); |
2606 DCHECK(ds); | 2610 DCHECK(ds); |
2607 | 2611 |
2608 const WebURLRequest& failed_request = ds->request(); | 2612 const WebURLRequest& failed_request = ds->request(); |
2609 | 2613 |
| 2614 DocumentState* document_state = DocumentState::FromDataSource(ds); |
| 2615 NavigationStateImpl* navigation_state = |
| 2616 static_cast<NavigationStateImpl*>(document_state->navigation_state()); |
| 2617 |
2610 // Notify the browser that we failed a provisional load with an error. | 2618 // Notify the browser that we failed a provisional load with an error. |
2611 // | 2619 // |
2612 // Note: It is important this notification occur before DidStopLoading so the | 2620 // Note: It is important this notification occur before DidStopLoading so the |
2613 // SSL manager can react to the provisional load failure before being | 2621 // SSL manager can react to the provisional load failure before being |
2614 // notified the load stopped. | 2622 // notified the load stopped. |
2615 // | 2623 // |
2616 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), | 2624 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), |
2617 DidFailProvisionalLoad(frame, error)); | 2625 DidFailProvisionalLoad(frame, error)); |
2618 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, | 2626 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, |
2619 DidFailProvisionalLoad(error)); | 2627 DidFailProvisionalLoad(error)); |
2620 | 2628 |
2621 SendFailedProvisionalLoad(failed_request, error, frame); | 2629 SendFailedProvisionalLoad(failed_request, |
| 2630 error, |
| 2631 navigation_state->request_params().nav_entry_id, |
| 2632 frame); |
2622 | 2633 |
2623 if (!ShouldDisplayErrorPageForFailedLoad(error.reason, error.unreachableURL)) | 2634 if (!ShouldDisplayErrorPageForFailedLoad(error.reason, error.unreachableURL)) |
2624 return; | 2635 return; |
2625 | 2636 |
2626 // Make sure we never show errors in view source mode. | 2637 // Make sure we never show errors in view source mode. |
2627 frame->enableViewSourceMode(false); | 2638 frame->enableViewSourceMode(false); |
2628 | 2639 |
2629 DocumentState* document_state = DocumentState::FromDataSource(ds); | |
2630 NavigationStateImpl* navigation_state = | |
2631 static_cast<NavigationStateImpl*>(document_state->navigation_state()); | |
2632 | |
2633 // If this is a failed back/forward/reload navigation, then we need to do a | 2640 // If this is a failed back/forward/reload navigation, then we need to do a |
2634 // 'replace' load. This is necessary to avoid messing up session history. | 2641 // 'replace' load. This is necessary to avoid messing up session history. |
2635 // Otherwise, we do a normal load, which simulates a 'go' navigation as far | 2642 // Otherwise, we do a normal load, which simulates a 'go' navigation as far |
2636 // as session history is concerned. | 2643 // as session history is concerned. |
2637 bool replace = commit_type != blink::WebStandardCommit; | 2644 bool replace = commit_type != blink::WebStandardCommit; |
2638 | 2645 |
2639 // If we failed on a browser initiated request, then make sure that our error | 2646 // If we failed on a browser initiated request, then make sure that our error |
2640 // page load is regarded as the same browser initiated request. | 2647 // page load is regarded as the same browser initiated request. |
2641 if (!navigation_state->IsContentInitiated()) { | 2648 if (!navigation_state->IsContentInitiated()) { |
2642 pending_navigation_params_.reset(new NavigationParams( | 2649 pending_navigation_params_.reset(new NavigationParams( |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2709 !navigation_state->start_params().should_replace_current_entry) { | 2716 !navigation_state->start_params().should_replace_current_entry) { |
2710 // Advance our offset in session history, applying the length limit. | 2717 // Advance our offset in session history, applying the length limit. |
2711 // There is now no forward history. | 2718 // There is now no forward history. |
2712 render_view_->history_list_offset_++; | 2719 render_view_->history_list_offset_++; |
2713 if (render_view_->history_list_offset_ >= kMaxSessionHistoryEntries) | 2720 if (render_view_->history_list_offset_ >= kMaxSessionHistoryEntries) |
2714 render_view_->history_list_offset_ = kMaxSessionHistoryEntries - 1; | 2721 render_view_->history_list_offset_ = kMaxSessionHistoryEntries - 1; |
2715 render_view_->history_list_length_ = | 2722 render_view_->history_list_length_ = |
2716 render_view_->history_list_offset_ + 1; | 2723 render_view_->history_list_offset_ + 1; |
2717 } | 2724 } |
2718 } else { | 2725 } else { |
2719 // Inspect the navigation_state on this frame to see if the navigation | 2726 if (navigation_state->request_params().page_id != -1) { |
2720 // corresponds to a session history navigation... Note: |frame| may or | |
2721 // may not be the toplevel frame, but for the case of capturing session | |
2722 // history, the first committed frame suffices. We keep track of whether | |
2723 // we've seen this commit before so that only capture session history once | |
2724 // per navigation. | |
2725 // | |
2726 // Note that we need to check if the page ID changed. In the case of a | |
2727 // reload, the page ID doesn't change, and UpdateSessionHistory gets the | |
2728 // previous URL and the current page ID, which would be wrong. | |
2729 if (navigation_state->request_params().page_id != -1 && | |
2730 navigation_state->request_params().page_id != render_view_->page_id_) { | |
2731 // This is a successful session history navigation! | 2727 // This is a successful session history navigation! |
2732 render_view_->page_id_ = navigation_state->request_params().page_id; | 2728 render_view_->page_id_ = navigation_state->request_params().page_id; |
2733 | 2729 |
2734 render_view_->history_list_offset_ = | 2730 render_view_->history_list_offset_ = |
2735 navigation_state->request_params().pending_history_list_offset; | 2731 navigation_state->request_params().pending_history_list_offset; |
2736 } | 2732 } |
2737 } | 2733 } |
2738 | 2734 |
2739 bool sent = Send( | 2735 bool sent = Send( |
2740 new FrameHostMsg_DidAssignPageId(routing_id_, render_view_->page_id_)); | 2736 new FrameHostMsg_DidAssignPageId(routing_id_, render_view_->page_id_)); |
(...skipping 1136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3877 DocumentState* document_state = DocumentState::FromDataSource(ds); | 3873 DocumentState* document_state = DocumentState::FromDataSource(ds); |
3878 NavigationStateImpl* navigation_state = | 3874 NavigationStateImpl* navigation_state = |
3879 static_cast<NavigationStateImpl*>(document_state->navigation_state()); | 3875 static_cast<NavigationStateImpl*>(document_state->navigation_state()); |
3880 InternalDocumentStateData* internal_data = | 3876 InternalDocumentStateData* internal_data = |
3881 InternalDocumentStateData::FromDocumentState(document_state); | 3877 InternalDocumentStateData::FromDocumentState(document_state); |
3882 | 3878 |
3883 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 3879 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
3884 params.http_status_code = response.httpStatusCode(); | 3880 params.http_status_code = response.httpStatusCode(); |
3885 params.url_is_unreachable = ds->hasUnreachableURL(); | 3881 params.url_is_unreachable = ds->hasUnreachableURL(); |
3886 params.is_post = false; | 3882 params.is_post = false; |
| 3883 params.intended_as_new_entry = |
| 3884 navigation_state->request_params().intended_as_new_entry; |
| 3885 params.did_create_new_entry = commit_type == blink::WebStandardCommit; |
3887 params.post_id = -1; | 3886 params.post_id = -1; |
3888 params.page_id = render_view_->page_id_; | 3887 params.page_id = render_view_->page_id_; |
| 3888 params.nav_entry_id = navigation_state->request_params().nav_entry_id; |
3889 // We need to track the RenderViewHost routing_id because of downstream | 3889 // We need to track the RenderViewHost routing_id because of downstream |
3890 // dependencies (crbug.com/392171 DownloadRequestHandle, SaveFileManager, | 3890 // dependencies (crbug.com/392171 DownloadRequestHandle, SaveFileManager, |
3891 // ResourceDispatcherHostImpl, MediaStreamUIProxy, | 3891 // ResourceDispatcherHostImpl, MediaStreamUIProxy, |
3892 // SpeechRecognitionDispatcherHost and possibly others). They look up the view | 3892 // SpeechRecognitionDispatcherHost and possibly others). They look up the view |
3893 // based on the ID stored in the resource requests. Once those dependencies | 3893 // based on the ID stored in the resource requests. Once those dependencies |
3894 // are unwound or moved to RenderFrameHost (crbug.com/304341) we can move the | 3894 // are unwound or moved to RenderFrameHost (crbug.com/304341) we can move the |
3895 // client to be based on the routing_id of the RenderFrameHost. | 3895 // client to be based on the routing_id of the RenderFrameHost. |
3896 params.render_view_routing_id = render_view_->routing_id(); | 3896 params.render_view_routing_id = render_view_->routing_id(); |
3897 params.socket_address.set_host(response.remoteIPAddress().utf8()); | 3897 params.socket_address.set_host(response.remoteIPAddress().utf8()); |
3898 params.socket_address.set_port(response.remotePort()); | 3898 params.socket_address.set_port(response.remotePort()); |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4170 // TODO(clamy): Properly set is_transition_navigation. | 4170 // TODO(clamy): Properly set is_transition_navigation. |
4171 Send(new FrameHostMsg_DidStartProvisionalLoadForFrame( | 4171 Send(new FrameHostMsg_DidStartProvisionalLoadForFrame( |
4172 routing_id_, common_params.url, false)); | 4172 routing_id_, common_params.url, false)); |
4173 | 4173 |
4174 // Send the provisional load failure. | 4174 // Send the provisional load failure. |
4175 blink::WebURLError error = | 4175 blink::WebURLError error = |
4176 CreateWebURLError(common_params.url, has_stale_copy_in_cache, error_code); | 4176 CreateWebURLError(common_params.url, has_stale_copy_in_cache, error_code); |
4177 WebURLRequest failed_request = CreateURLRequestForNavigation( | 4177 WebURLRequest failed_request = CreateURLRequestForNavigation( |
4178 common_params, scoped_ptr<StreamOverrideParameters>(), | 4178 common_params, scoped_ptr<StreamOverrideParameters>(), |
4179 frame_->isViewSourceModeEnabled()); | 4179 frame_->isViewSourceModeEnabled()); |
4180 SendFailedProvisionalLoad(failed_request, error, frame_); | 4180 SendFailedProvisionalLoad( |
| 4181 failed_request, error, request_params.nav_entry_id, frame_); |
4181 | 4182 |
4182 if (!ShouldDisplayErrorPageForFailedLoad(error_code, common_params.url)) { | 4183 if (!ShouldDisplayErrorPageForFailedLoad(error_code, common_params.url)) { |
4183 Send(new FrameHostMsg_DidDropNavigation(routing_id_)); | 4184 Send(new FrameHostMsg_DidDropNavigation(routing_id_)); |
4184 return; | 4185 return; |
4185 } | 4186 } |
4186 | 4187 |
4187 // Make sure errors are not shown in view source mode. | 4188 // Make sure errors are not shown in view source mode. |
4188 frame_->enableViewSourceMode(false); | 4189 frame_->enableViewSourceMode(false); |
4189 | 4190 |
4190 // Replace the current history entry in reloads, history navigations and loads | 4191 // Replace the current history entry in reloads, history navigations and loads |
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4690 false); | 4691 false); |
4691 } else { | 4692 } else { |
4692 CHECK(false) << "Invalid URL passed: " | 4693 CHECK(false) << "Invalid URL passed: " |
4693 << params.url.possibly_invalid_spec(); | 4694 << params.url.possibly_invalid_spec(); |
4694 } | 4695 } |
4695 } | 4696 } |
4696 | 4697 |
4697 void RenderFrameImpl::SendFailedProvisionalLoad( | 4698 void RenderFrameImpl::SendFailedProvisionalLoad( |
4698 const blink::WebURLRequest& request, | 4699 const blink::WebURLRequest& request, |
4699 const blink::WebURLError& error, | 4700 const blink::WebURLError& error, |
| 4701 int nav_entry_id, |
4700 blink::WebLocalFrame* frame) { | 4702 blink::WebLocalFrame* frame) { |
4701 bool show_repost_interstitial = (error.reason == net::ERR_CACHE_MISS && | 4703 bool show_repost_interstitial = (error.reason == net::ERR_CACHE_MISS && |
4702 EqualsASCII(request.httpMethod(), "POST")); | 4704 EqualsASCII(request.httpMethod(), "POST")); |
4703 | 4705 |
4704 FrameHostMsg_DidFailProvisionalLoadWithError_Params params; | 4706 FrameHostMsg_DidFailProvisionalLoadWithError_Params params; |
4705 params.error_code = error.reason; | 4707 params.error_code = error.reason; |
| 4708 params.nav_entry_id = nav_entry_id; |
4706 GetContentClient()->renderer()->GetNavigationErrorStrings( | 4709 GetContentClient()->renderer()->GetNavigationErrorStrings( |
4707 render_view_.get(), frame, request, error, NULL, | 4710 render_view_.get(), frame, request, error, NULL, |
4708 ¶ms.error_description); | 4711 ¶ms.error_description); |
4709 params.url = error.unreachableURL; | 4712 params.url = error.unreachableURL; |
4710 params.showing_repost_interstitial = show_repost_interstitial; | 4713 params.showing_repost_interstitial = show_repost_interstitial; |
4711 Send(new FrameHostMsg_DidFailProvisionalLoadWithError(routing_id_, params)); | 4714 Send(new FrameHostMsg_DidFailProvisionalLoadWithError(routing_id_, params)); |
4712 } | 4715 } |
4713 | 4716 |
4714 bool RenderFrameImpl::ShouldDisplayErrorPageForFailedLoad( | 4717 bool RenderFrameImpl::ShouldDisplayErrorPageForFailedLoad( |
4715 int error_code, | 4718 int error_code, |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4871 #elif defined(ENABLE_BROWSER_CDMS) | 4874 #elif defined(ENABLE_BROWSER_CDMS) |
4872 cdm_manager_, | 4875 cdm_manager_, |
4873 #endif | 4876 #endif |
4874 this); | 4877 this); |
4875 } | 4878 } |
4876 | 4879 |
4877 return cdm_factory_; | 4880 return cdm_factory_; |
4878 } | 4881 } |
4879 | 4882 |
4880 } // namespace content | 4883 } // namespace content |
OLD | NEW |