| 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); | |
| 1139 scoped_ptr<HistoryEntry> entry = | 1135 scoped_ptr<HistoryEntry> entry = |
| 1140 PageStateToHistoryEntry(request_params.page_state); | 1136 PageStateToHistoryEntry(request_params.page_state); |
| 1141 if (entry) { | 1137 if (entry) { |
| 1142 // Ensure we didn't save the swapped out URL in UpdateState, since the | 1138 // Ensure we didn't save the swapped out URL in UpdateState, since the |
| 1143 // browser should never be telling us to navigate to swappedout://. | 1139 // browser should never be telling us to navigate to swappedout://. |
| 1144 CHECK(entry->root().urlString() != WebString::fromUTF8(kSwappedOutURL)); | 1140 CHECK(entry->root().urlString() != WebString::fromUTF8(kSwappedOutURL)); |
| 1145 scoped_ptr<NavigationParams> navigation_params( | 1141 scoped_ptr<NavigationParams> navigation_params( |
| 1146 new NavigationParams(*pending_navigation_params_.get())); | 1142 new NavigationParams(*pending_navigation_params_.get())); |
| 1147 render_view_->history_controller()->GoToEntry( | 1143 render_view_->history_controller()->GoToEntry( |
| 1148 entry.Pass(), navigation_params.Pass(), cache_policy); | 1144 entry.Pass(), navigation_params.Pass(), cache_policy); |
| (...skipping 1455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2604 const blink::WebURLError& error, | 2600 const blink::WebURLError& error, |
| 2605 blink::WebHistoryCommitType commit_type) { | 2601 blink::WebHistoryCommitType commit_type) { |
| 2606 TRACE_EVENT1("navigation", "RenderFrameImpl::didFailProvisionalLoad", | 2602 TRACE_EVENT1("navigation", "RenderFrameImpl::didFailProvisionalLoad", |
| 2607 "id", routing_id_); | 2603 "id", routing_id_); |
| 2608 DCHECK(!frame_ || frame_ == frame); | 2604 DCHECK(!frame_ || frame_ == frame); |
| 2609 WebDataSource* ds = frame->provisionalDataSource(); | 2605 WebDataSource* ds = frame->provisionalDataSource(); |
| 2610 DCHECK(ds); | 2606 DCHECK(ds); |
| 2611 | 2607 |
| 2612 const WebURLRequest& failed_request = ds->request(); | 2608 const WebURLRequest& failed_request = ds->request(); |
| 2613 | 2609 |
| 2614 DocumentState* document_state = DocumentState::FromDataSource(ds); | |
| 2615 NavigationStateImpl* navigation_state = | |
| 2616 static_cast<NavigationStateImpl*>(document_state->navigation_state()); | |
| 2617 | |
| 2618 // Notify the browser that we failed a provisional load with an error. | 2610 // Notify the browser that we failed a provisional load with an error. |
| 2619 // | 2611 // |
| 2620 // Note: It is important this notification occur before DidStopLoading so the | 2612 // Note: It is important this notification occur before DidStopLoading so the |
| 2621 // SSL manager can react to the provisional load failure before being | 2613 // SSL manager can react to the provisional load failure before being |
| 2622 // notified the load stopped. | 2614 // notified the load stopped. |
| 2623 // | 2615 // |
| 2624 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), | 2616 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers(), |
| 2625 DidFailProvisionalLoad(frame, error)); | 2617 DidFailProvisionalLoad(frame, error)); |
| 2626 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, | 2618 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, |
| 2627 DidFailProvisionalLoad(error)); | 2619 DidFailProvisionalLoad(error)); |
| 2628 | 2620 |
| 2629 SendFailedProvisionalLoad(failed_request, error, frame); | 2621 SendFailedProvisionalLoad(failed_request, error, frame); |
| 2630 | 2622 |
| 2631 if (!ShouldDisplayErrorPageForFailedLoad(error.reason, error.unreachableURL)) | 2623 if (!ShouldDisplayErrorPageForFailedLoad(error.reason, error.unreachableURL)) |
| 2632 return; | 2624 return; |
| 2633 | 2625 |
| 2634 // Make sure we never show errors in view source mode. | 2626 // Make sure we never show errors in view source mode. |
| 2635 frame->enableViewSourceMode(false); | 2627 frame->enableViewSourceMode(false); |
| 2636 | 2628 |
| 2629 DocumentState* document_state = DocumentState::FromDataSource(ds); |
| 2630 NavigationStateImpl* navigation_state = |
| 2631 static_cast<NavigationStateImpl*>(document_state->navigation_state()); |
| 2632 |
| 2637 // If this is a failed back/forward/reload navigation, then we need to do a | 2633 // If this is a failed back/forward/reload navigation, then we need to do a |
| 2638 // 'replace' load. This is necessary to avoid messing up session history. | 2634 // 'replace' load. This is necessary to avoid messing up session history. |
| 2639 // Otherwise, we do a normal load, which simulates a 'go' navigation as far | 2635 // Otherwise, we do a normal load, which simulates a 'go' navigation as far |
| 2640 // as session history is concerned. | 2636 // as session history is concerned. |
| 2641 bool replace = commit_type != blink::WebStandardCommit; | 2637 bool replace = commit_type != blink::WebStandardCommit; |
| 2642 | 2638 |
| 2643 // If we failed on a browser initiated request, then make sure that our error | 2639 // If we failed on a browser initiated request, then make sure that our error |
| 2644 // page load is regarded as the same browser initiated request. | 2640 // page load is regarded as the same browser initiated request. |
| 2645 if (!navigation_state->IsContentInitiated()) { | 2641 if (!navigation_state->IsContentInitiated()) { |
| 2646 pending_navigation_params_.reset(new NavigationParams( | 2642 pending_navigation_params_.reset(new NavigationParams( |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2713 !navigation_state->start_params().should_replace_current_entry) { | 2709 !navigation_state->start_params().should_replace_current_entry) { |
| 2714 // Advance our offset in session history, applying the length limit. | 2710 // Advance our offset in session history, applying the length limit. |
| 2715 // There is now no forward history. | 2711 // There is now no forward history. |
| 2716 render_view_->history_list_offset_++; | 2712 render_view_->history_list_offset_++; |
| 2717 if (render_view_->history_list_offset_ >= kMaxSessionHistoryEntries) | 2713 if (render_view_->history_list_offset_ >= kMaxSessionHistoryEntries) |
| 2718 render_view_->history_list_offset_ = kMaxSessionHistoryEntries - 1; | 2714 render_view_->history_list_offset_ = kMaxSessionHistoryEntries - 1; |
| 2719 render_view_->history_list_length_ = | 2715 render_view_->history_list_length_ = |
| 2720 render_view_->history_list_offset_ + 1; | 2716 render_view_->history_list_offset_ + 1; |
| 2721 } | 2717 } |
| 2722 } else { | 2718 } else { |
| 2723 if (navigation_state->request_params().page_id != -1) { | 2719 // Inspect the navigation_state on this frame to see if the navigation |
| 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_) { |
| 2724 // This is a successful session history navigation! | 2731 // This is a successful session history navigation! |
| 2725 render_view_->page_id_ = navigation_state->request_params().page_id; | 2732 render_view_->page_id_ = navigation_state->request_params().page_id; |
| 2726 | 2733 |
| 2727 render_view_->history_list_offset_ = | 2734 render_view_->history_list_offset_ = |
| 2728 navigation_state->request_params().pending_history_list_offset; | 2735 navigation_state->request_params().pending_history_list_offset; |
| 2729 } | 2736 } |
| 2730 } | 2737 } |
| 2731 | 2738 |
| 2732 bool sent = Send( | 2739 bool sent = Send( |
| 2733 new FrameHostMsg_DidAssignPageId(routing_id_, render_view_->page_id_)); | 2740 new FrameHostMsg_DidAssignPageId(routing_id_, render_view_->page_id_)); |
| (...skipping 1136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3870 DocumentState* document_state = DocumentState::FromDataSource(ds); | 3877 DocumentState* document_state = DocumentState::FromDataSource(ds); |
| 3871 NavigationStateImpl* navigation_state = | 3878 NavigationStateImpl* navigation_state = |
| 3872 static_cast<NavigationStateImpl*>(document_state->navigation_state()); | 3879 static_cast<NavigationStateImpl*>(document_state->navigation_state()); |
| 3873 InternalDocumentStateData* internal_data = | 3880 InternalDocumentStateData* internal_data = |
| 3874 InternalDocumentStateData::FromDocumentState(document_state); | 3881 InternalDocumentStateData::FromDocumentState(document_state); |
| 3875 | 3882 |
| 3876 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 3883 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
| 3877 params.http_status_code = response.httpStatusCode(); | 3884 params.http_status_code = response.httpStatusCode(); |
| 3878 params.url_is_unreachable = ds->hasUnreachableURL(); | 3885 params.url_is_unreachable = ds->hasUnreachableURL(); |
| 3879 params.is_post = false; | 3886 params.is_post = false; |
| 3880 params.intended_as_new_entry = | |
| 3881 navigation_state->request_params().intended_as_new_entry; | |
| 3882 params.did_create_new_entry = commit_type == blink::WebStandardCommit; | |
| 3883 params.post_id = -1; | 3887 params.post_id = -1; |
| 3884 params.page_id = render_view_->page_id_; | 3888 params.page_id = render_view_->page_id_; |
| 3885 params.nav_entry_id = navigation_state->request_params().nav_entry_id; | |
| 3886 // We need to track the RenderViewHost routing_id because of downstream | 3889 // We need to track the RenderViewHost routing_id because of downstream |
| 3887 // dependencies (crbug.com/392171 DownloadRequestHandle, SaveFileManager, | 3890 // dependencies (crbug.com/392171 DownloadRequestHandle, SaveFileManager, |
| 3888 // ResourceDispatcherHostImpl, MediaStreamUIProxy, | 3891 // ResourceDispatcherHostImpl, MediaStreamUIProxy, |
| 3889 // SpeechRecognitionDispatcherHost and possibly others). They look up the view | 3892 // SpeechRecognitionDispatcherHost and possibly others). They look up the view |
| 3890 // 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 |
| 3891 // 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 |
| 3892 // client to be based on the routing_id of the RenderFrameHost. | 3895 // client to be based on the routing_id of the RenderFrameHost. |
| 3893 params.render_view_routing_id = render_view_->routing_id(); | 3896 params.render_view_routing_id = render_view_->routing_id(); |
| 3894 params.socket_address.set_host(response.remoteIPAddress().utf8()); | 3897 params.socket_address.set_host(response.remoteIPAddress().utf8()); |
| 3895 params.socket_address.set_port(response.remotePort()); | 3898 params.socket_address.set_port(response.remotePort()); |
| (...skipping 972 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4868 #elif defined(ENABLE_BROWSER_CDMS) | 4871 #elif defined(ENABLE_BROWSER_CDMS) |
| 4869 cdm_manager_, | 4872 cdm_manager_, |
| 4870 #endif | 4873 #endif |
| 4871 this); | 4874 this); |
| 4872 } | 4875 } |
| 4873 | 4876 |
| 4874 return cdm_factory_; | 4877 return cdm_factory_; |
| 4875 } | 4878 } |
| 4876 | 4879 |
| 4877 } // namespace content | 4880 } // namespace content |
| OLD | NEW |