| 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 1024 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1035 IPC_MESSAGE_HANDLER(InputMsg_CopyToFindPboard, OnCopyToFindPboard) | 1035 IPC_MESSAGE_HANDLER(InputMsg_CopyToFindPboard, OnCopyToFindPboard) |
| 1036 #endif | 1036 #endif |
| 1037 IPC_END_MESSAGE_MAP() | 1037 IPC_END_MESSAGE_MAP() |
| 1038 | 1038 |
| 1039 return handled; | 1039 return handled; |
| 1040 } | 1040 } |
| 1041 | 1041 |
| 1042 void RenderFrameImpl::OnNavigate( | 1042 void RenderFrameImpl::OnNavigate( |
| 1043 const CommonNavigationParams& common_params, | 1043 const CommonNavigationParams& common_params, |
| 1044 const StartNavigationParams& start_params, | 1044 const StartNavigationParams& start_params, |
| 1045 const CommitNavigationParams& commit_params, | 1045 const RequestNavigationParams& request_params) { |
| 1046 const HistoryNavigationParams& history_params) { | |
| 1047 TRACE_EVENT2("navigation", "RenderFrameImpl::OnNavigate", "id", routing_id_, | 1046 TRACE_EVENT2("navigation", "RenderFrameImpl::OnNavigate", "id", routing_id_, |
| 1048 "url", common_params.url.possibly_invalid_spec()); | 1047 "url", common_params.url.possibly_invalid_spec()); |
| 1049 | 1048 |
| 1050 bool is_reload = RenderViewImpl::IsReload(common_params.navigation_type); | 1049 bool is_reload = RenderViewImpl::IsReload(common_params.navigation_type); |
| 1051 bool is_history_navigation = history_params.page_state.IsValid(); | 1050 bool is_history_navigation = request_params.page_state.IsValid(); |
| 1052 WebURLRequest::CachePolicy cache_policy = | 1051 WebURLRequest::CachePolicy cache_policy = |
| 1053 WebURLRequest::UseProtocolCachePolicy; | 1052 WebURLRequest::UseProtocolCachePolicy; |
| 1054 if (!RenderFrameImpl::PrepareRenderViewForNavigation( | 1053 if (!RenderFrameImpl::PrepareRenderViewForNavigation( |
| 1055 common_params.url, is_history_navigation, history_params, &is_reload, | 1054 common_params.url, is_history_navigation, request_params, &is_reload, |
| 1056 &cache_policy)) { | 1055 &cache_policy)) { |
| 1057 Send(new FrameHostMsg_DidDropNavigation(routing_id_)); | 1056 Send(new FrameHostMsg_DidDropNavigation(routing_id_)); |
| 1058 return; | 1057 return; |
| 1059 } | 1058 } |
| 1060 | 1059 |
| 1061 GetContentClient()->SetActiveURL(common_params.url); | 1060 GetContentClient()->SetActiveURL(common_params.url); |
| 1062 | 1061 |
| 1063 WebFrame* frame = frame_; | 1062 WebFrame* frame = frame_; |
| 1064 if (!commit_params.frame_to_navigate.empty()) { | 1063 if (!request_params.frame_to_navigate.empty()) { |
| 1065 // TODO(nasko): Move this lookup to the browser process. | 1064 // TODO(nasko): Move this lookup to the browser process. |
| 1066 frame = render_view_->webview()->findFrameByName( | 1065 frame = render_view_->webview()->findFrameByName( |
| 1067 WebString::fromUTF8(commit_params.frame_to_navigate)); | 1066 WebString::fromUTF8(request_params.frame_to_navigate)); |
| 1068 CHECK(frame) << "Invalid frame name passed: " | 1067 CHECK(frame) << "Invalid frame name passed: " |
| 1069 << commit_params.frame_to_navigate; | 1068 << request_params.frame_to_navigate; |
| 1070 } | 1069 } |
| 1071 | 1070 |
| 1072 if (is_reload && !render_view_->history_controller()->GetCurrentEntry()) { | 1071 if (is_reload && !render_view_->history_controller()->GetCurrentEntry()) { |
| 1073 // We cannot reload if we do not have any history state. This happens, for | 1072 // We cannot reload if we do not have any history state. This happens, for |
| 1074 // example, when recovering from a crash. | 1073 // example, when recovering from a crash. |
| 1075 is_reload = false; | 1074 is_reload = false; |
| 1076 cache_policy = WebURLRequest::ReloadIgnoringCacheData; | 1075 cache_policy = WebURLRequest::ReloadIgnoringCacheData; |
| 1077 } | 1076 } |
| 1078 | 1077 |
| 1079 render_view_->pending_navigation_params_.reset(new NavigationParams( | 1078 render_view_->pending_navigation_params_.reset( |
| 1080 common_params, start_params, commit_params, history_params)); | 1079 new NavigationParams(common_params, start_params, request_params)); |
| 1081 | 1080 |
| 1082 // If we are reloading, then WebKit will use the history state of the current | 1081 // If we are reloading, then WebKit will use the history state of the current |
| 1083 // page, so we should just ignore any given history state. Otherwise, if we | 1082 // page, so we should just ignore any given history state. Otherwise, if we |
| 1084 // have history state, then we need to navigate to it, which corresponds to a | 1083 // have history state, then we need to navigate to it, which corresponds to a |
| 1085 // back/forward navigation event. | 1084 // back/forward navigation event. |
| 1086 if (is_reload) { | 1085 if (is_reload) { |
| 1087 bool reload_original_url = | 1086 bool reload_original_url = |
| 1088 (common_params.navigation_type == | 1087 (common_params.navigation_type == |
| 1089 FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL); | 1088 FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL); |
| 1090 bool ignore_cache = (common_params.navigation_type == | 1089 bool ignore_cache = (common_params.navigation_type == |
| 1091 FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE); | 1090 FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE); |
| 1092 | 1091 |
| 1093 if (reload_original_url) | 1092 if (reload_original_url) |
| 1094 frame->reloadWithOverrideURL(common_params.url, true); | 1093 frame->reloadWithOverrideURL(common_params.url, true); |
| 1095 else | 1094 else |
| 1096 frame->reload(ignore_cache); | 1095 frame->reload(ignore_cache); |
| 1097 } else if (is_history_navigation) { | 1096 } else if (is_history_navigation) { |
| 1098 // We must know the page ID of the page we are navigating back to. | 1097 // We must know the page ID of the page we are navigating back to. |
| 1099 DCHECK_NE(history_params.page_id, -1); | 1098 DCHECK_NE(request_params.page_id, -1); |
| 1100 scoped_ptr<HistoryEntry> entry = | 1099 scoped_ptr<HistoryEntry> entry = |
| 1101 PageStateToHistoryEntry(history_params.page_state); | 1100 PageStateToHistoryEntry(request_params.page_state); |
| 1102 if (entry) { | 1101 if (entry) { |
| 1103 // Ensure we didn't save the swapped out URL in UpdateState, since the | 1102 // Ensure we didn't save the swapped out URL in UpdateState, since the |
| 1104 // browser should never be telling us to navigate to swappedout://. | 1103 // browser should never be telling us to navigate to swappedout://. |
| 1105 CHECK(entry->root().urlString() != WebString::fromUTF8(kSwappedOutURL)); | 1104 CHECK(entry->root().urlString() != WebString::fromUTF8(kSwappedOutURL)); |
| 1106 render_view_->history_controller()->GoToEntry(entry.Pass(), cache_policy); | 1105 render_view_->history_controller()->GoToEntry(entry.Pass(), cache_policy); |
| 1107 } | 1106 } |
| 1108 } else if (!common_params.base_url_for_data_url.is_empty()) { | 1107 } else if (!common_params.base_url_for_data_url.is_empty()) { |
| 1109 LoadDataURL(common_params, frame); | 1108 LoadDataURL(common_params, frame); |
| 1110 } else { | 1109 } else { |
| 1111 // Navigate to the given URL. | 1110 // Navigate to the given URL. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1133 if (start_params.browser_initiated_post_data.size()) { | 1132 if (start_params.browser_initiated_post_data.size()) { |
| 1134 data = reinterpret_cast<const char*>( | 1133 data = reinterpret_cast<const char*>( |
| 1135 &start_params.browser_initiated_post_data.front()); | 1134 &start_params.browser_initiated_post_data.front()); |
| 1136 } | 1135 } |
| 1137 http_body.appendData( | 1136 http_body.appendData( |
| 1138 WebData(data, start_params.browser_initiated_post_data.size())); | 1137 WebData(data, start_params.browser_initiated_post_data.size())); |
| 1139 request.setHTTPBody(http_body); | 1138 request.setHTTPBody(http_body); |
| 1140 } | 1139 } |
| 1141 | 1140 |
| 1142 // A session history navigation should have been accompanied by state. | 1141 // A session history navigation should have been accompanied by state. |
| 1143 CHECK_EQ(history_params.page_id, -1); | 1142 CHECK_EQ(request_params.page_id, -1); |
| 1144 | 1143 |
| 1145 // Record this before starting the load, we need a lower bound of this time | 1144 // Record this before starting the load, we need a lower bound of this time |
| 1146 // to sanitize the navigationStart override set below. | 1145 // to sanitize the navigationStart override set below. |
| 1147 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now(); | 1146 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now(); |
| 1148 frame->loadRequest(request); | 1147 frame->loadRequest(request); |
| 1149 | 1148 |
| 1150 UpdateFrameNavigationTiming(frame, commit_params.browser_navigation_start, | 1149 UpdateFrameNavigationTiming(frame, request_params.browser_navigation_start, |
| 1151 renderer_navigation_start); | 1150 renderer_navigation_start); |
| 1152 } | 1151 } |
| 1153 | 1152 |
| 1154 // In case LoadRequest failed before DidCreateDataSource was called. | 1153 // In case LoadRequest failed before DidCreateDataSource was called. |
| 1155 render_view_->pending_navigation_params_.reset(); | 1154 render_view_->pending_navigation_params_.reset(); |
| 1156 } | 1155 } |
| 1157 | 1156 |
| 1158 void RenderFrameImpl::NavigateToSwappedOutURL() { | 1157 void RenderFrameImpl::NavigateToSwappedOutURL() { |
| 1159 // We use loadRequest instead of loadHTMLString because the former commits | 1158 // We use loadRequest instead of loadHTMLString because the former commits |
| 1160 // synchronously. Otherwise a new navigation can interrupt the navigation | 1159 // synchronously. Otherwise a new navigation can interrupt the navigation |
| (...skipping 1279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2440 // 'replace' load. This is necessary to avoid messing up session history. | 2439 // 'replace' load. This is necessary to avoid messing up session history. |
| 2441 // Otherwise, we do a normal load, which simulates a 'go' navigation as far | 2440 // Otherwise, we do a normal load, which simulates a 'go' navigation as far |
| 2442 // as session history is concerned. | 2441 // as session history is concerned. |
| 2443 // | 2442 // |
| 2444 // AUTO_SUBFRAME loads should always be treated as loads that do not advance | 2443 // AUTO_SUBFRAME loads should always be treated as loads that do not advance |
| 2445 // the page id. | 2444 // the page id. |
| 2446 // | 2445 // |
| 2447 // TODO(davidben): This should also take the failed navigation's replacement | 2446 // TODO(davidben): This should also take the failed navigation's replacement |
| 2448 // state into account, if a location.replace() failed. | 2447 // state into account, if a location.replace() failed. |
| 2449 bool replace = | 2448 bool replace = |
| 2450 navigation_state->history_params().page_id != -1 || | 2449 navigation_state->request_params().page_id != -1 || |
| 2451 ui::PageTransitionCoreTypeIs(navigation_state->GetTransitionType(), | 2450 ui::PageTransitionCoreTypeIs(navigation_state->GetTransitionType(), |
| 2452 ui::PAGE_TRANSITION_AUTO_SUBFRAME); | 2451 ui::PAGE_TRANSITION_AUTO_SUBFRAME); |
| 2453 | 2452 |
| 2454 // If we failed on a browser initiated request, then make sure that our error | 2453 // If we failed on a browser initiated request, then make sure that our error |
| 2455 // page load is regarded as the same browser initiated request. | 2454 // page load is regarded as the same browser initiated request. |
| 2456 if (!navigation_state->IsContentInitiated()) { | 2455 if (!navigation_state->IsContentInitiated()) { |
| 2457 render_view_->pending_navigation_params_.reset(new NavigationParams( | 2456 render_view_->pending_navigation_params_.reset(new NavigationParams( |
| 2458 navigation_state->common_params(), navigation_state->start_params(), | 2457 navigation_state->common_params(), navigation_state->start_params(), |
| 2459 CommitNavigationParams(false, base::TimeTicks(), std::vector<GURL>(), | 2458 navigation_state->request_params())); |
| 2460 false, std::string(), | 2459 render_view_->pending_navigation_params_->request_params.request_time = |
| 2461 document_state->request_time()), | 2460 document_state->request_time(); |
| 2462 navigation_state->history_params())); | |
| 2463 } | 2461 } |
| 2464 | 2462 |
| 2465 // Load an error page. | 2463 // Load an error page. |
| 2466 LoadNavigationErrorPage(failed_request, error, replace); | 2464 LoadNavigationErrorPage(failed_request, error, replace); |
| 2467 } | 2465 } |
| 2468 | 2466 |
| 2469 void RenderFrameImpl::didCommitProvisionalLoad( | 2467 void RenderFrameImpl::didCommitProvisionalLoad( |
| 2470 blink::WebLocalFrame* frame, | 2468 blink::WebLocalFrame* frame, |
| 2471 const blink::WebHistoryItem& item, | 2469 const blink::WebHistoryItem& item, |
| 2472 blink::WebHistoryCommitType commit_type) { | 2470 blink::WebHistoryCommitType commit_type) { |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2535 // Inspect the navigation_state on this frame to see if the navigation | 2533 // Inspect the navigation_state on this frame to see if the navigation |
| 2536 // corresponds to a session history navigation... Note: |frame| may or | 2534 // corresponds to a session history navigation... Note: |frame| may or |
| 2537 // may not be the toplevel frame, but for the case of capturing session | 2535 // may not be the toplevel frame, but for the case of capturing session |
| 2538 // history, the first committed frame suffices. We keep track of whether | 2536 // history, the first committed frame suffices. We keep track of whether |
| 2539 // we've seen this commit before so that only capture session history once | 2537 // we've seen this commit before so that only capture session history once |
| 2540 // per navigation. | 2538 // per navigation. |
| 2541 // | 2539 // |
| 2542 // Note that we need to check if the page ID changed. In the case of a | 2540 // Note that we need to check if the page ID changed. In the case of a |
| 2543 // reload, the page ID doesn't change, and UpdateSessionHistory gets the | 2541 // reload, the page ID doesn't change, and UpdateSessionHistory gets the |
| 2544 // previous URL and the current page ID, which would be wrong. | 2542 // previous URL and the current page ID, which would be wrong. |
| 2545 if (navigation_state->history_params().page_id != -1 && | 2543 if (navigation_state->request_params().page_id != -1 && |
| 2546 navigation_state->history_params().page_id != render_view_->page_id_ && | 2544 navigation_state->request_params().page_id != render_view_->page_id_ && |
| 2547 !navigation_state->request_committed()) { | 2545 !navigation_state->request_committed()) { |
| 2548 // This is a successful session history navigation! | 2546 // This is a successful session history navigation! |
| 2549 render_view_->page_id_ = navigation_state->history_params().page_id; | 2547 render_view_->page_id_ = navigation_state->request_params().page_id; |
| 2550 | 2548 |
| 2551 render_view_->history_list_offset_ = | 2549 render_view_->history_list_offset_ = |
| 2552 navigation_state->history_params().pending_history_list_offset; | 2550 navigation_state->request_params().pending_history_list_offset; |
| 2553 } | 2551 } |
| 2554 } | 2552 } |
| 2555 | 2553 |
| 2556 bool sent = Send( | 2554 bool sent = Send( |
| 2557 new FrameHostMsg_DidAssignPageId(routing_id_, render_view_->page_id_)); | 2555 new FrameHostMsg_DidAssignPageId(routing_id_, render_view_->page_id_)); |
| 2558 CHECK(sent); // http://crbug.com/407376 | 2556 CHECK(sent); // http://crbug.com/407376 |
| 2559 | 2557 |
| 2560 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers_, | 2558 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers_, |
| 2561 DidCommitProvisionalLoad(frame, is_new_navigation)); | 2559 DidCommitProvisionalLoad(frame, is_new_navigation)); |
| 2562 FOR_EACH_OBSERVER( | 2560 FOR_EACH_OBSERVER( |
| (...skipping 1279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3842 | 3840 |
| 3843 // Send the user agent override back. | 3841 // Send the user agent override back. |
| 3844 params.is_overriding_user_agent = internal_data->is_overriding_user_agent(); | 3842 params.is_overriding_user_agent = internal_data->is_overriding_user_agent(); |
| 3845 | 3843 |
| 3846 // Track the URL of the original request. We use the first entry of the | 3844 // Track the URL of the original request. We use the first entry of the |
| 3847 // redirect chain if it exists because the chain may have started in another | 3845 // redirect chain if it exists because the chain may have started in another |
| 3848 // process. | 3846 // process. |
| 3849 params.original_request_url = GetOriginalRequestURL(ds); | 3847 params.original_request_url = GetOriginalRequestURL(ds); |
| 3850 | 3848 |
| 3851 params.history_list_was_cleared = | 3849 params.history_list_was_cleared = |
| 3852 navigation_state->history_params().should_clear_history_list; | 3850 navigation_state->request_params().should_clear_history_list; |
| 3853 | 3851 |
| 3854 params.report_type = static_cast<FrameMsg_UILoadMetricsReportType::Value>( | 3852 params.report_type = static_cast<FrameMsg_UILoadMetricsReportType::Value>( |
| 3855 frame->dataSource()->request().inputPerfMetricReportPolicy()); | 3853 frame->dataSource()->request().inputPerfMetricReportPolicy()); |
| 3856 params.ui_timestamp = base::TimeTicks() + base::TimeDelta::FromSecondsD( | 3854 params.ui_timestamp = base::TimeTicks() + base::TimeDelta::FromSecondsD( |
| 3857 frame->dataSource()->request().uiStartTime()); | 3855 frame->dataSource()->request().uiStartTime()); |
| 3858 | 3856 |
| 3859 // Save some histogram data so we can compute the average memory used per | 3857 // Save some histogram data so we can compute the average memory used per |
| 3860 // page load of the glyphs. | 3858 // page load of the glyphs. |
| 3861 UMA_HISTOGRAM_COUNTS_10000("Memory.GlyphPagesPerLoad", | 3859 UMA_HISTOGRAM_COUNTS_10000("Memory.GlyphPagesPerLoad", |
| 3862 blink::WebGlyphCache::pageCount()); | 3860 blink::WebGlyphCache::pageCount()); |
| 3863 | 3861 |
| 3864 // This message needs to be sent before any of allowScripts(), | 3862 // This message needs to be sent before any of allowScripts(), |
| 3865 // allowImages(), allowPlugins() is called for the new page, so that when | 3863 // allowImages(), allowPlugins() is called for the new page, so that when |
| 3866 // these functions send a ViewHostMsg_ContentBlocked message, it arrives | 3864 // these functions send a ViewHostMsg_ContentBlocked message, it arrives |
| 3867 // after the FrameHostMsg_DidCommitProvisionalLoad message. | 3865 // after the FrameHostMsg_DidCommitProvisionalLoad message. |
| 3868 Send(new FrameHostMsg_DidCommitProvisionalLoad(routing_id_, params)); | 3866 Send(new FrameHostMsg_DidCommitProvisionalLoad(routing_id_, params)); |
| 3869 } else { | 3867 } else { |
| 3870 // Subframe navigation: the type depends on whether this navigation | 3868 // Subframe navigation: the type depends on whether this navigation |
| 3871 // generated a new session history entry. When they do generate a session | 3869 // generated a new session history entry. When they do generate a session |
| 3872 // history entry, it means the user initiated the navigation and we should | 3870 // history entry, it means the user initiated the navigation and we should |
| 3873 // mark it as such. | 3871 // mark it as such. |
| 3874 if (commit_type == blink::WebStandardCommit) | 3872 if (commit_type == blink::WebStandardCommit) |
| 3875 params.transition = ui::PAGE_TRANSITION_MANUAL_SUBFRAME; | 3873 params.transition = ui::PAGE_TRANSITION_MANUAL_SUBFRAME; |
| 3876 else | 3874 else |
| 3877 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; | 3875 params.transition = ui::PAGE_TRANSITION_AUTO_SUBFRAME; |
| 3878 | 3876 |
| 3879 DCHECK(!navigation_state->history_params().should_clear_history_list); | 3877 DCHECK(!navigation_state->request_params().should_clear_history_list); |
| 3880 params.history_list_was_cleared = false; | 3878 params.history_list_was_cleared = false; |
| 3881 params.report_type = FrameMsg_UILoadMetricsReportType::NO_REPORT; | 3879 params.report_type = FrameMsg_UILoadMetricsReportType::NO_REPORT; |
| 3882 | 3880 |
| 3883 // Don't send this message while the subframe is swapped out. | 3881 // Don't send this message while the subframe is swapped out. |
| 3884 if (!is_swapped_out()) | 3882 if (!is_swapped_out()) |
| 3885 Send(new FrameHostMsg_DidCommitProvisionalLoad(routing_id_, params)); | 3883 Send(new FrameHostMsg_DidCommitProvisionalLoad(routing_id_, params)); |
| 3886 } | 3884 } |
| 3887 | 3885 |
| 3888 // If we end up reusing this WebRequest (for example, due to a #ref click), | 3886 // If we end up reusing this WebRequest (for example, due to a #ref click), |
| 3889 // we don't want the transition type to persist. Just clear it. | 3887 // we don't want the transition type to persist. Just clear it. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3921 void RenderFrameImpl::FocusedNodeChangedForAccessibility(const WebNode& node) { | 3919 void RenderFrameImpl::FocusedNodeChangedForAccessibility(const WebNode& node) { |
| 3922 if (renderer_accessibility()) | 3920 if (renderer_accessibility()) |
| 3923 renderer_accessibility()->AccessibilityFocusedNodeChanged(node); | 3921 renderer_accessibility()->AccessibilityFocusedNodeChanged(node); |
| 3924 } | 3922 } |
| 3925 | 3923 |
| 3926 // PlzNavigate | 3924 // PlzNavigate |
| 3927 void RenderFrameImpl::OnCommitNavigation( | 3925 void RenderFrameImpl::OnCommitNavigation( |
| 3928 const ResourceResponseHead& response, | 3926 const ResourceResponseHead& response, |
| 3929 const GURL& stream_url, | 3927 const GURL& stream_url, |
| 3930 const CommonNavigationParams& common_params, | 3928 const CommonNavigationParams& common_params, |
| 3931 const CommitNavigationParams& commit_params, | 3929 const RequestNavigationParams& request_params) { |
| 3932 const HistoryNavigationParams& history_params) { | |
| 3933 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( | 3930 CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 3934 switches::kEnableBrowserSideNavigation)); | 3931 switches::kEnableBrowserSideNavigation)); |
| 3935 bool is_reload = false; | 3932 bool is_reload = false; |
| 3936 bool is_history_navigation = history_params.page_state.IsValid(); | 3933 bool is_history_navigation = request_params.page_state.IsValid(); |
| 3937 WebURLRequest::CachePolicy cache_policy = | 3934 WebURLRequest::CachePolicy cache_policy = |
| 3938 WebURLRequest::UseProtocolCachePolicy; | 3935 WebURLRequest::UseProtocolCachePolicy; |
| 3939 if (!RenderFrameImpl::PrepareRenderViewForNavigation( | 3936 if (!RenderFrameImpl::PrepareRenderViewForNavigation( |
| 3940 common_params.url, is_history_navigation, history_params, &is_reload, | 3937 common_params.url, is_history_navigation, request_params, &is_reload, |
| 3941 &cache_policy)) { | 3938 &cache_policy)) { |
| 3942 return; | 3939 return; |
| 3943 } | 3940 } |
| 3944 | 3941 |
| 3945 GetContentClient()->SetActiveURL(common_params.url); | 3942 GetContentClient()->SetActiveURL(common_params.url); |
| 3946 | 3943 |
| 3947 render_view_->pending_navigation_params_.reset(new NavigationParams( | 3944 render_view_->pending_navigation_params_.reset(new NavigationParams( |
| 3948 common_params, StartNavigationParams(), commit_params, history_params)); | 3945 common_params, StartNavigationParams(), request_params)); |
| 3949 | 3946 |
| 3950 if (!common_params.base_url_for_data_url.is_empty() || | 3947 if (!common_params.base_url_for_data_url.is_empty() || |
| 3951 common_params.url.SchemeIs(url::kDataScheme)) { | 3948 common_params.url.SchemeIs(url::kDataScheme)) { |
| 3952 LoadDataURL(common_params, frame_); | 3949 LoadDataURL(common_params, frame_); |
| 3953 return; | 3950 return; |
| 3954 } | 3951 } |
| 3955 | 3952 |
| 3956 // Create a WebURLRequest that blink can use to get access to the body of the | 3953 // Create a WebURLRequest that blink can use to get access to the body of the |
| 3957 // response through a stream in the browser. Blink will then commit the | 3954 // response through a stream in the browser. Blink will then commit the |
| 3958 // navigation. | 3955 // navigation. |
| 3959 // TODO(clamy): Have the navigation commit directly, without going through | 3956 // TODO(clamy): Have the navigation commit directly, without going through |
| 3960 // loading a WebURLRequest. | 3957 // loading a WebURLRequest. |
| 3961 scoped_ptr<StreamOverrideParameters> stream_override( | 3958 scoped_ptr<StreamOverrideParameters> stream_override( |
| 3962 new StreamOverrideParameters()); | 3959 new StreamOverrideParameters()); |
| 3963 stream_override->stream_url = stream_url; | 3960 stream_override->stream_url = stream_url; |
| 3964 stream_override->response = response; | 3961 stream_override->response = response; |
| 3965 WebURLRequest request = | 3962 WebURLRequest request = |
| 3966 CreateURLRequestForNavigation(common_params, | 3963 CreateURLRequestForNavigation(common_params, |
| 3967 stream_override.Pass(), | 3964 stream_override.Pass(), |
| 3968 frame_->isViewSourceModeEnabled()); | 3965 frame_->isViewSourceModeEnabled()); |
| 3969 | 3966 |
| 3970 // Make sure that blink loader will not try to use browser side navigation for | 3967 // Make sure that blink loader will not try to use browser side navigation for |
| 3971 // this request (since it already went to the browser). | 3968 // this request (since it already went to the browser). |
| 3972 request.setCheckForBrowserSideNavigation(false); | 3969 request.setCheckForBrowserSideNavigation(false); |
| 3973 | 3970 |
| 3974 // Record this before starting the load. A lower bound of this time is needed | 3971 // Record this before starting the load. A lower bound of this time is needed |
| 3975 // to sanitize the navigationStart override set below. | 3972 // to sanitize the navigationStart override set below. |
| 3976 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now(); | 3973 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now(); |
| 3977 frame_->loadRequest(request); | 3974 frame_->loadRequest(request); |
| 3978 UpdateFrameNavigationTiming( | 3975 UpdateFrameNavigationTiming(frame_, request_params.browser_navigation_start, |
| 3979 frame_, commit_params.browser_navigation_start, | 3976 renderer_navigation_start); |
| 3980 renderer_navigation_start); | |
| 3981 } | 3977 } |
| 3982 | 3978 |
| 3983 WebNavigationPolicy RenderFrameImpl::DecidePolicyForNavigation( | 3979 WebNavigationPolicy RenderFrameImpl::DecidePolicyForNavigation( |
| 3984 RenderFrame* render_frame, | 3980 RenderFrame* render_frame, |
| 3985 const NavigationPolicyInfo& info) { | 3981 const NavigationPolicyInfo& info) { |
| 3986 #ifdef OS_ANDROID | 3982 #ifdef OS_ANDROID |
| 3987 // The handlenavigation API is deprecated and will be removed once | 3983 // The handlenavigation API is deprecated and will be removed once |
| 3988 // crbug.com/325351 is resolved. | 3984 // crbug.com/325351 is resolved. |
| 3989 if (info.urlRequest.url() != GURL(kSwappedOutURL) && | 3985 if (info.urlRequest.url() != GURL(kSwappedOutURL) && |
| 3990 GetContentClient()->renderer()->HandleNavigation( | 3986 GetContentClient()->renderer()->HandleNavigation( |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4365 new MediaStreamRendererFactory()); | 4361 new MediaStreamRendererFactory()); |
| 4366 #else | 4362 #else |
| 4367 return scoped_ptr<MediaStreamRendererFactory>( | 4363 return scoped_ptr<MediaStreamRendererFactory>( |
| 4368 static_cast<MediaStreamRendererFactory*>(NULL)); | 4364 static_cast<MediaStreamRendererFactory*>(NULL)); |
| 4369 #endif | 4365 #endif |
| 4370 } | 4366 } |
| 4371 | 4367 |
| 4372 bool RenderFrameImpl::PrepareRenderViewForNavigation( | 4368 bool RenderFrameImpl::PrepareRenderViewForNavigation( |
| 4373 const GURL& url, | 4369 const GURL& url, |
| 4374 bool is_history_navigation, | 4370 bool is_history_navigation, |
| 4375 const HistoryNavigationParams& history_params, | 4371 const RequestNavigationParams& request_params, |
| 4376 bool* is_reload, | 4372 bool* is_reload, |
| 4377 WebURLRequest::CachePolicy* cache_policy) { | 4373 WebURLRequest::CachePolicy* cache_policy) { |
| 4378 MaybeHandleDebugURL(url); | 4374 MaybeHandleDebugURL(url); |
| 4379 if (!render_view_->webview()) | 4375 if (!render_view_->webview()) |
| 4380 return false; | 4376 return false; |
| 4381 | 4377 |
| 4382 FOR_EACH_OBSERVER( | 4378 FOR_EACH_OBSERVER( |
| 4383 RenderViewObserver, render_view_->observers_, Navigate(url)); | 4379 RenderViewObserver, render_view_->observers_, Navigate(url)); |
| 4384 | 4380 |
| 4385 // If this is a stale back/forward (due to a recent navigation the browser | 4381 // If this is a stale back/forward (due to a recent navigation the browser |
| 4386 // didn't know about), ignore it. Only check if swapped in because if the | 4382 // didn't know about), ignore it. Only check if swapped in because if the |
| 4387 // frame is swapped out, it won't commit before asking the browser. | 4383 // frame is swapped out, it won't commit before asking the browser. |
| 4388 if (!render_view_->is_swapped_out() && is_history_navigation && | 4384 if (!render_view_->is_swapped_out() && is_history_navigation && |
| 4389 render_view_->history_list_offset_ != | 4385 render_view_->history_list_offset_ != |
| 4390 history_params.current_history_list_offset) { | 4386 request_params.current_history_list_offset) { |
| 4391 return false; | 4387 return false; |
| 4392 } | 4388 } |
| 4393 | 4389 |
| 4394 render_view_->history_list_offset_ = | 4390 render_view_->history_list_offset_ = |
| 4395 history_params.current_history_list_offset; | 4391 request_params.current_history_list_offset; |
| 4396 render_view_->history_list_length_ = | 4392 render_view_->history_list_length_ = |
| 4397 history_params.current_history_list_length; | 4393 request_params.current_history_list_length; |
| 4398 if (history_params.should_clear_history_list) { | 4394 if (request_params.should_clear_history_list) { |
| 4399 CHECK_EQ(-1, render_view_->history_list_offset_); | 4395 CHECK_EQ(-1, render_view_->history_list_offset_); |
| 4400 CHECK_EQ(0, render_view_->history_list_length_); | 4396 CHECK_EQ(0, render_view_->history_list_length_); |
| 4401 } | 4397 } |
| 4402 | 4398 |
| 4403 if (!is_swapped_out_ || frame_->parent()) | 4399 if (!is_swapped_out_ || frame_->parent()) |
| 4404 return true; | 4400 return true; |
| 4405 | 4401 |
| 4406 // This is a swapped out main frame, so swap the renderer back in. | 4402 // This is a swapped out main frame, so swap the renderer back in. |
| 4407 // We marked the view as hidden when swapping the view out, so be sure to | 4403 // We marked the view as hidden when swapping the view out, so be sure to |
| 4408 // reset the visibility state before navigating to the new URL. | 4404 // reset the visibility state before navigating to the new URL. |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4541 | 4537 |
| 4542 #if defined(ENABLE_BROWSER_CDMS) | 4538 #if defined(ENABLE_BROWSER_CDMS) |
| 4543 RendererCdmManager* RenderFrameImpl::GetCdmManager() { | 4539 RendererCdmManager* RenderFrameImpl::GetCdmManager() { |
| 4544 if (!cdm_manager_) | 4540 if (!cdm_manager_) |
| 4545 cdm_manager_ = new RendererCdmManager(this); | 4541 cdm_manager_ = new RendererCdmManager(this); |
| 4546 return cdm_manager_; | 4542 return cdm_manager_; |
| 4547 } | 4543 } |
| 4548 #endif // defined(ENABLE_BROWSER_CDMS) | 4544 #endif // defined(ENABLE_BROWSER_CDMS) |
| 4549 | 4545 |
| 4550 } // namespace content | 4546 } // namespace content |
| OLD | NEW |