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 1124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1135 bool ignore_cache = (common_params.navigation_type == | 1135 bool ignore_cache = (common_params.navigation_type == |
1136 FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE); | 1136 FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE); |
1137 | 1137 |
1138 if (reload_original_url) | 1138 if (reload_original_url) |
1139 frame->reloadWithOverrideURL(common_params.url, true); | 1139 frame->reloadWithOverrideURL(common_params.url, true); |
1140 else | 1140 else |
1141 frame->reload(ignore_cache); | 1141 frame->reload(ignore_cache); |
1142 } else if (is_history_navigation) { | 1142 } else if (is_history_navigation) { |
1143 // We must know the page ID of the page we are navigating back to. | 1143 // We must know the page ID of the page we are navigating back to. |
1144 DCHECK_NE(request_params.page_id, -1); | 1144 DCHECK_NE(request_params.page_id, -1); |
1145 // We must know the nav entry ID of the page we are navigating back to, | |
1146 // which should be the case because history navigations are routed via the | |
1147 // browser. | |
1148 DCHECK_NE(0, request_params.nav_entry_id); | |
1145 scoped_ptr<HistoryEntry> entry = | 1149 scoped_ptr<HistoryEntry> entry = |
1146 PageStateToHistoryEntry(request_params.page_state); | 1150 PageStateToHistoryEntry(request_params.page_state); |
1147 if (entry) { | 1151 if (entry) { |
1148 // Ensure we didn't save the swapped out URL in UpdateState, since the | 1152 // Ensure we didn't save the swapped out URL in UpdateState, since the |
1149 // browser should never be telling us to navigate to swappedout://. | 1153 // browser should never be telling us to navigate to swappedout://. |
1150 CHECK(entry->root().urlString() != WebString::fromUTF8(kSwappedOutURL)); | 1154 CHECK(entry->root().urlString() != WebString::fromUTF8(kSwappedOutURL)); |
1151 scoped_ptr<NavigationParams> navigation_params( | 1155 scoped_ptr<NavigationParams> navigation_params( |
1152 new NavigationParams(*pending_navigation_params_.get())); | 1156 new NavigationParams(*pending_navigation_params_.get())); |
1153 render_view_->history_controller()->GoToEntry( | 1157 render_view_->history_controller()->GoToEntry( |
1154 entry.Pass(), navigation_params.Pass(), cache_policy); | 1158 entry.Pass(), navigation_params.Pass(), cache_policy); |
(...skipping 1455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2610 const blink::WebURLError& error, | 2614 const blink::WebURLError& error, |
2611 blink::WebHistoryCommitType commit_type) { | 2615 blink::WebHistoryCommitType commit_type) { |
2612 TRACE_EVENT1("navigation", "RenderFrameImpl::didFailProvisionalLoad", | 2616 TRACE_EVENT1("navigation", "RenderFrameImpl::didFailProvisionalLoad", |
2613 "id", routing_id_); | 2617 "id", routing_id_); |
2614 DCHECK(!frame_ || frame_ == frame); | 2618 DCHECK(!frame_ || frame_ == frame); |
2615 WebDataSource* ds = frame->provisionalDataSource(); | 2619 WebDataSource* ds = frame->provisionalDataSource(); |
2616 DCHECK(ds); | 2620 DCHECK(ds); |
2617 | 2621 |
2618 const WebURLRequest& failed_request = ds->request(); | 2622 const WebURLRequest& failed_request = ds->request(); |
2619 | 2623 |
2624 DocumentState* document_state = DocumentState::FromDataSource(ds); | |
2625 NavigationStateImpl* navigation_state = | |
2626 static_cast<NavigationStateImpl*>(document_state->navigation_state()); | |
2627 | |
2620 // Notify the browser that we failed a provisional load with an error. | 2628 // Notify the browser that we failed a provisional load with an error. |
2621 // | 2629 // |
2622 // Note: It is important this notification occur before DidStopLoading so the | 2630 // Note: It is important this notification occur before DidStopLoading so the |
2623 // SSL manager can react to the provisional load failure before being | 2631 // SSL manager can react to the provisional load failure before being |
2624 // notified the load stopped. | 2632 // notified the load stopped. |
2625 // | 2633 // |
2626 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), | 2634 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), |
2627 DidFailProvisionalLoad(frame, error)); | 2635 DidFailProvisionalLoad(frame, error)); |
2628 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, | 2636 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, |
2629 DidFailProvisionalLoad(error)); | 2637 DidFailProvisionalLoad(error)); |
2630 | 2638 |
2631 SendFailedProvisionalLoad(failed_request, error, frame); | 2639 SendFailedProvisionalLoad(failed_request, |
2640 error, | |
2641 navigation_state->request_params().nav_entry_id, | |
2642 frame); | |
2632 | 2643 |
2633 if (!ShouldDisplayErrorPageForFailedLoad(error.reason, error.unreachableURL)) | 2644 if (!ShouldDisplayErrorPageForFailedLoad(error.reason, error.unreachableURL)) |
2634 return; | 2645 return; |
2635 | 2646 |
2636 // Make sure we never show errors in view source mode. | 2647 // Make sure we never show errors in view source mode. |
2637 frame->enableViewSourceMode(false); | 2648 frame->enableViewSourceMode(false); |
2638 | 2649 |
2639 DocumentState* document_state = DocumentState::FromDataSource(ds); | |
2640 NavigationStateImpl* navigation_state = | |
2641 static_cast<NavigationStateImpl*>(document_state->navigation_state()); | |
2642 | |
2643 // If this is a failed back/forward/reload navigation, then we need to do a | 2650 // If this is a failed back/forward/reload navigation, then we need to do a |
2644 // 'replace' load. This is necessary to avoid messing up session history. | 2651 // 'replace' load. This is necessary to avoid messing up session history. |
2645 // Otherwise, we do a normal load, which simulates a 'go' navigation as far | 2652 // Otherwise, we do a normal load, which simulates a 'go' navigation as far |
2646 // as session history is concerned. | 2653 // as session history is concerned. |
2647 bool replace = commit_type != blink::WebStandardCommit; | 2654 bool replace = commit_type != blink::WebStandardCommit; |
2648 | 2655 |
2649 // If we failed on a browser initiated request, then make sure that our error | 2656 // If we failed on a browser initiated request, then make sure that our error |
2650 // page load is regarded as the same browser initiated request. | 2657 // page load is regarded as the same browser initiated request. |
2651 if (!navigation_state->IsContentInitiated()) { | 2658 if (!navigation_state->IsContentInitiated()) { |
2652 pending_navigation_params_.reset(new NavigationParams( | 2659 pending_navigation_params_.reset(new NavigationParams( |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2719 !navigation_state->start_params().should_replace_current_entry) { | 2726 !navigation_state->start_params().should_replace_current_entry) { |
2720 // Advance our offset in session history, applying the length limit. | 2727 // Advance our offset in session history, applying the length limit. |
2721 // There is now no forward history. | 2728 // There is now no forward history. |
2722 render_view_->history_list_offset_++; | 2729 render_view_->history_list_offset_++; |
2723 if (render_view_->history_list_offset_ >= kMaxSessionHistoryEntries) | 2730 if (render_view_->history_list_offset_ >= kMaxSessionHistoryEntries) |
2724 render_view_->history_list_offset_ = kMaxSessionHistoryEntries - 1; | 2731 render_view_->history_list_offset_ = kMaxSessionHistoryEntries - 1; |
2725 render_view_->history_list_length_ = | 2732 render_view_->history_list_length_ = |
2726 render_view_->history_list_offset_ + 1; | 2733 render_view_->history_list_offset_ + 1; |
2727 } | 2734 } |
2728 } else { | 2735 } else { |
2729 // Inspect the navigation_state on this frame to see if the navigation | 2736 if (navigation_state->request_params().page_id != -1) { |
2730 // corresponds to a session history navigation... Note: |frame| may or | |
2731 // may not be the toplevel frame, but for the case of capturing session | |
2732 // history, the first committed frame suffices. We keep track of whether | |
2733 // we've seen this commit before so that only capture session history once | |
2734 // per navigation. | |
2735 // | |
2736 // Note that we need to check if the page ID changed. In the case of a | |
2737 // reload, the page ID doesn't change, and UpdateSessionHistory gets the | |
2738 // previous URL and the current page ID, which would be wrong. | |
2739 if (navigation_state->request_params().page_id != -1 && | |
2740 navigation_state->request_params().page_id != render_view_->page_id_) { | |
2741 // This is a successful session history navigation! | 2737 // This is a successful session history navigation! |
2742 render_view_->page_id_ = navigation_state->request_params().page_id; | 2738 render_view_->page_id_ = navigation_state->request_params().page_id; |
2743 | 2739 |
2744 render_view_->history_list_offset_ = | 2740 render_view_->history_list_offset_ = |
2745 navigation_state->request_params().pending_history_list_offset; | 2741 navigation_state->request_params().pending_history_list_offset; |
2746 } | 2742 } |
2747 } | 2743 } |
2748 | 2744 |
2749 bool sent = Send( | 2745 bool sent = Send( |
2750 new FrameHostMsg_DidAssignPageId(routing_id_, render_view_->page_id_)); | 2746 new FrameHostMsg_DidAssignPageId(routing_id_, render_view_->page_id_)); |
(...skipping 1136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3887 DocumentState* document_state = DocumentState::FromDataSource(ds); | 3883 DocumentState* document_state = DocumentState::FromDataSource(ds); |
3888 NavigationStateImpl* navigation_state = | 3884 NavigationStateImpl* navigation_state = |
3889 static_cast<NavigationStateImpl*>(document_state->navigation_state()); | 3885 static_cast<NavigationStateImpl*>(document_state->navigation_state()); |
3890 InternalDocumentStateData* internal_data = | 3886 InternalDocumentStateData* internal_data = |
3891 InternalDocumentStateData::FromDocumentState(document_state); | 3887 InternalDocumentStateData::FromDocumentState(document_state); |
3892 | 3888 |
3893 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 3889 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
3894 params.http_status_code = response.httpStatusCode(); | 3890 params.http_status_code = response.httpStatusCode(); |
3895 params.url_is_unreachable = ds->hasUnreachableURL(); | 3891 params.url_is_unreachable = ds->hasUnreachableURL(); |
3896 params.is_post = false; | 3892 params.is_post = false; |
3893 params.did_create_new_entry = commit_type == blink::WebStandardCommit; | |
3894 params.intended_as_new_entry = | |
Charlie Reis
2015/04/24 22:02:02
nit: Move above did_create_new_entry if you do tha
Avi (use Gerrit)
2015/04/24 22:17:15
Done.
| |
3895 navigation_state->request_params().intended_as_new_entry; | |
3897 params.post_id = -1; | 3896 params.post_id = -1; |
3898 params.page_id = render_view_->page_id_; | 3897 params.page_id = render_view_->page_id_; |
3898 params.nav_entry_id = navigation_state->request_params().nav_entry_id; | |
3899 // We need to track the RenderViewHost routing_id because of downstream | 3899 // We need to track the RenderViewHost routing_id because of downstream |
3900 // dependencies (crbug.com/392171 DownloadRequestHandle, SaveFileManager, | 3900 // dependencies (crbug.com/392171 DownloadRequestHandle, SaveFileManager, |
3901 // ResourceDispatcherHostImpl, MediaStreamUIProxy, | 3901 // ResourceDispatcherHostImpl, MediaStreamUIProxy, |
3902 // SpeechRecognitionDispatcherHost and possibly others). They look up the view | 3902 // SpeechRecognitionDispatcherHost and possibly others). They look up the view |
3903 // based on the ID stored in the resource requests. Once those dependencies | 3903 // based on the ID stored in the resource requests. Once those dependencies |
3904 // are unwound or moved to RenderFrameHost (crbug.com/304341) we can move the | 3904 // are unwound or moved to RenderFrameHost (crbug.com/304341) we can move the |
3905 // client to be based on the routing_id of the RenderFrameHost. | 3905 // client to be based on the routing_id of the RenderFrameHost. |
3906 params.render_view_routing_id = render_view_->routing_id(); | 3906 params.render_view_routing_id = render_view_->routing_id(); |
3907 params.socket_address.set_host(response.remoteIPAddress().utf8()); | 3907 params.socket_address.set_host(response.remoteIPAddress().utf8()); |
3908 params.socket_address.set_port(response.remotePort()); | 3908 params.socket_address.set_port(response.remotePort()); |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4180 // TODO(clamy): Properly set is_transition_navigation. | 4180 // TODO(clamy): Properly set is_transition_navigation. |
4181 Send(new FrameHostMsg_DidStartProvisionalLoadForFrame( | 4181 Send(new FrameHostMsg_DidStartProvisionalLoadForFrame( |
4182 routing_id_, common_params.url, false)); | 4182 routing_id_, common_params.url, false)); |
4183 | 4183 |
4184 // Send the provisional load failure. | 4184 // Send the provisional load failure. |
4185 blink::WebURLError error = | 4185 blink::WebURLError error = |
4186 CreateWebURLError(common_params.url, has_stale_copy_in_cache, error_code); | 4186 CreateWebURLError(common_params.url, has_stale_copy_in_cache, error_code); |
4187 WebURLRequest failed_request = CreateURLRequestForNavigation( | 4187 WebURLRequest failed_request = CreateURLRequestForNavigation( |
4188 common_params, scoped_ptr<StreamOverrideParameters>(), | 4188 common_params, scoped_ptr<StreamOverrideParameters>(), |
4189 frame_->isViewSourceModeEnabled()); | 4189 frame_->isViewSourceModeEnabled()); |
4190 SendFailedProvisionalLoad(failed_request, error, frame_); | 4190 SendFailedProvisionalLoad( |
4191 failed_request, error, request_params.nav_entry_id, frame_); | |
4191 | 4192 |
4192 if (!ShouldDisplayErrorPageForFailedLoad(error_code, common_params.url)) { | 4193 if (!ShouldDisplayErrorPageForFailedLoad(error_code, common_params.url)) { |
4193 Send(new FrameHostMsg_DidDropNavigation(routing_id_)); | 4194 Send(new FrameHostMsg_DidDropNavigation(routing_id_)); |
4194 return; | 4195 return; |
4195 } | 4196 } |
4196 | 4197 |
4197 // Make sure errors are not shown in view source mode. | 4198 // Make sure errors are not shown in view source mode. |
4198 frame_->enableViewSourceMode(false); | 4199 frame_->enableViewSourceMode(false); |
4199 | 4200 |
4200 // Replace the current history entry in reloads, history navigations and loads | 4201 // Replace the current history entry in reloads, history navigations and loads |
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4700 false); | 4701 false); |
4701 } else { | 4702 } else { |
4702 CHECK(false) << "Invalid URL passed: " | 4703 CHECK(false) << "Invalid URL passed: " |
4703 << params.url.possibly_invalid_spec(); | 4704 << params.url.possibly_invalid_spec(); |
4704 } | 4705 } |
4705 } | 4706 } |
4706 | 4707 |
4707 void RenderFrameImpl::SendFailedProvisionalLoad( | 4708 void RenderFrameImpl::SendFailedProvisionalLoad( |
4708 const blink::WebURLRequest& request, | 4709 const blink::WebURLRequest& request, |
4709 const blink::WebURLError& error, | 4710 const blink::WebURLError& error, |
4711 int nav_entry_id, | |
4710 blink::WebLocalFrame* frame) { | 4712 blink::WebLocalFrame* frame) { |
4711 bool show_repost_interstitial = (error.reason == net::ERR_CACHE_MISS && | 4713 bool show_repost_interstitial = (error.reason == net::ERR_CACHE_MISS && |
4712 EqualsASCII(request.httpMethod(), "POST")); | 4714 EqualsASCII(request.httpMethod(), "POST")); |
4713 | 4715 |
4714 FrameHostMsg_DidFailProvisionalLoadWithError_Params params; | 4716 FrameHostMsg_DidFailProvisionalLoadWithError_Params params; |
4715 params.error_code = error.reason; | 4717 params.error_code = error.reason; |
4718 params.nav_entry_id = nav_entry_id; | |
4716 GetContentClient()->renderer()->GetNavigationErrorStrings( | 4719 GetContentClient()->renderer()->GetNavigationErrorStrings( |
4717 render_view_.get(), frame, request, error, NULL, | 4720 render_view_.get(), frame, request, error, NULL, |
4718 ¶ms.error_description); | 4721 ¶ms.error_description); |
4719 params.url = error.unreachableURL; | 4722 params.url = error.unreachableURL; |
4720 params.showing_repost_interstitial = show_repost_interstitial; | 4723 params.showing_repost_interstitial = show_repost_interstitial; |
4721 Send(new FrameHostMsg_DidFailProvisionalLoadWithError(routing_id_, params)); | 4724 Send(new FrameHostMsg_DidFailProvisionalLoadWithError(routing_id_, params)); |
4722 } | 4725 } |
4723 | 4726 |
4724 bool RenderFrameImpl::ShouldDisplayErrorPageForFailedLoad( | 4727 bool RenderFrameImpl::ShouldDisplayErrorPageForFailedLoad( |
4725 int error_code, | 4728 int error_code, |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4881 #elif defined(ENABLE_BROWSER_CDMS) | 4884 #elif defined(ENABLE_BROWSER_CDMS) |
4882 cdm_manager_, | 4885 cdm_manager_, |
4883 #endif | 4886 #endif |
4884 this); | 4887 this); |
4885 } | 4888 } |
4886 | 4889 |
4887 return cdm_factory_; | 4890 return cdm_factory_; |
4888 } | 4891 } |
4889 | 4892 |
4890 } // namespace content | 4893 } // namespace content |
OLD | NEW |