Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(792)

Side by Side Diff: content/renderer/render_frame_impl.cc

Issue 1104603002: Pick frame to navigate in the browser process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add test cases Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/public/browser/navigation_entry.h ('k') | content/renderer/render_view_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1073 matching lines...) Expand 10 before | Expand all | Expand 10 after
1084 WebURLRequest::UseProtocolCachePolicy; 1084 WebURLRequest::UseProtocolCachePolicy;
1085 if (!RenderFrameImpl::PrepareRenderViewForNavigation( 1085 if (!RenderFrameImpl::PrepareRenderViewForNavigation(
1086 common_params.url, is_history_navigation, request_params, &is_reload, 1086 common_params.url, is_history_navigation, request_params, &is_reload,
1087 &cache_policy)) { 1087 &cache_policy)) {
1088 Send(new FrameHostMsg_DidDropNavigation(routing_id_)); 1088 Send(new FrameHostMsg_DidDropNavigation(routing_id_));
1089 return; 1089 return;
1090 } 1090 }
1091 1091
1092 GetContentClient()->SetActiveURL(common_params.url); 1092 GetContentClient()->SetActiveURL(common_params.url);
1093 1093
1094 WebFrame* frame = frame_;
1095 if (!request_params.frame_to_navigate.empty()) {
1096 // TODO(nasko): Move this lookup to the browser process.
1097 frame = render_view_->webview()->findFrameByName(
1098 WebString::fromUTF8(request_params.frame_to_navigate));
1099 CHECK(frame) << "Invalid frame name passed: "
1100 << request_params.frame_to_navigate;
1101 }
1102
1103 // If this frame isn't in the same process as its parent, it will naively 1094 // If this frame isn't in the same process as its parent, it will naively
1104 // assume that this is the first navigation in the iframe, but this may not 1095 // assume that this is the first navigation in the iframe, but this may not
1105 // actually be the case. The PageTransition differentiates between the first 1096 // actually be the case. The PageTransition differentiates between the first
1106 // navigation in a subframe and subsequent navigations, so if this is a 1097 // navigation in a subframe and subsequent navigations, so if this is a
1107 // subsequent navigation, force the frame's state machine forward. 1098 // subsequent navigation, force the frame's state machine forward.
1108 if (ui::PageTransitionCoreTypeIs(common_params.transition, 1099 if (ui::PageTransitionCoreTypeIs(common_params.transition,
1109 ui::PAGE_TRANSITION_MANUAL_SUBFRAME)) { 1100 ui::PAGE_TRANSITION_MANUAL_SUBFRAME)) {
1110 CHECK(frame_->parent()); 1101 CHECK(frame_->parent());
1111 if (frame_->parent()->isWebRemoteFrame()) { 1102 if (frame_->parent()->isWebRemoteFrame()) {
1112 CHECK_EQ(frame, frame_);
1113 frame_->setCommittedFirstRealLoad(); 1103 frame_->setCommittedFirstRealLoad();
1114 } 1104 }
1115 } 1105 }
1116 1106
1117 if (is_reload && !render_view_->history_controller()->GetCurrentEntry()) { 1107 if (is_reload && !render_view_->history_controller()->GetCurrentEntry()) {
1118 // We cannot reload if we do not have any history state. This happens, for 1108 // We cannot reload if we do not have any history state. This happens, for
1119 // example, when recovering from a crash. 1109 // example, when recovering from a crash.
1120 is_reload = false; 1110 is_reload = false;
1121 cache_policy = WebURLRequest::ReloadIgnoringCacheData; 1111 cache_policy = WebURLRequest::ReloadIgnoringCacheData;
1122 } 1112 }
1123 1113
1124 pending_navigation_params_.reset( 1114 pending_navigation_params_.reset(
1125 new NavigationParams(common_params, start_params, request_params)); 1115 new NavigationParams(common_params, start_params, request_params));
1126 1116
1127 // If we are reloading, then WebKit will use the history state of the current 1117 // If we are reloading, then WebKit will use the history state of the current
1128 // page, so we should just ignore any given history state. Otherwise, if we 1118 // page, so we should just ignore any given history state. Otherwise, if we
1129 // have history state, then we need to navigate to it, which corresponds to a 1119 // have history state, then we need to navigate to it, which corresponds to a
1130 // back/forward navigation event. 1120 // back/forward navigation event.
1131 if (is_reload) { 1121 if (is_reload) {
1132 bool reload_original_url = 1122 bool reload_original_url =
1133 (common_params.navigation_type == 1123 (common_params.navigation_type ==
1134 FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL); 1124 FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL);
1135 bool ignore_cache = (common_params.navigation_type == 1125 bool ignore_cache = (common_params.navigation_type ==
1136 FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE); 1126 FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE);
1137 1127
1138 if (reload_original_url) 1128 if (reload_original_url)
1139 frame->reloadWithOverrideURL(common_params.url, true); 1129 frame_->reloadWithOverrideURL(common_params.url, true);
1140 else 1130 else
1141 frame->reload(ignore_cache); 1131 frame_->reload(ignore_cache);
1142 } else if (is_history_navigation) { 1132 } else if (is_history_navigation) {
1143 // 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.
1144 DCHECK_NE(request_params.page_id, -1); 1134 DCHECK_NE(request_params.page_id, -1);
1145 scoped_ptr<HistoryEntry> entry = 1135 scoped_ptr<HistoryEntry> entry =
1146 PageStateToHistoryEntry(request_params.page_state); 1136 PageStateToHistoryEntry(request_params.page_state);
1147 if (entry) { 1137 if (entry) {
1148 // 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
1149 // browser should never be telling us to navigate to swappedout://. 1139 // browser should never be telling us to navigate to swappedout://.
1150 CHECK(entry->root().urlString() != WebString::fromUTF8(kSwappedOutURL)); 1140 CHECK(entry->root().urlString() != WebString::fromUTF8(kSwappedOutURL));
1151 scoped_ptr<NavigationParams> navigation_params( 1141 scoped_ptr<NavigationParams> navigation_params(
1152 new NavigationParams(*pending_navigation_params_.get())); 1142 new NavigationParams(*pending_navigation_params_.get()));
1153 render_view_->history_controller()->GoToEntry( 1143 render_view_->history_controller()->GoToEntry(
1154 entry.Pass(), navigation_params.Pass(), cache_policy); 1144 entry.Pass(), navigation_params.Pass(), cache_policy);
1155 } 1145 }
1156 } else if (!common_params.base_url_for_data_url.is_empty()) { 1146 } else if (!common_params.base_url_for_data_url.is_empty()) {
1157 LoadDataURL(common_params, frame); 1147 LoadDataURL(common_params, frame_);
1158 } else { 1148 } else {
1159 // Navigate to the given URL. 1149 // Navigate to the given URL.
1160 WebURLRequest request = CreateURLRequestForNavigation( 1150 WebURLRequest request = CreateURLRequestForNavigation(
1161 common_params, scoped_ptr<StreamOverrideParameters>(), 1151 common_params, scoped_ptr<StreamOverrideParameters>(),
1162 frame->isViewSourceModeEnabled()); 1152 frame_->isViewSourceModeEnabled());
1163 1153
1164 if (!start_params.extra_headers.empty()) { 1154 if (!start_params.extra_headers.empty()) {
1165 for (net::HttpUtil::HeadersIterator i(start_params.extra_headers.begin(), 1155 for (net::HttpUtil::HeadersIterator i(start_params.extra_headers.begin(),
1166 start_params.extra_headers.end(), 1156 start_params.extra_headers.end(),
1167 "\n"); 1157 "\n");
1168 i.GetNext();) { 1158 i.GetNext();) {
1169 request.addHTTPHeaderField(WebString::fromUTF8(i.name()), 1159 request.addHTTPHeaderField(WebString::fromUTF8(i.name()),
1170 WebString::fromUTF8(i.values())); 1160 WebString::fromUTF8(i.values()));
1171 } 1161 }
1172 } 1162 }
(...skipping 13 matching lines...) Expand all
1186 WebData(data, start_params.browser_initiated_post_data.size())); 1176 WebData(data, start_params.browser_initiated_post_data.size()));
1187 request.setHTTPBody(http_body); 1177 request.setHTTPBody(http_body);
1188 } 1178 }
1189 1179
1190 // A session history navigation should have been accompanied by state. 1180 // A session history navigation should have been accompanied by state.
1191 CHECK_EQ(request_params.page_id, -1); 1181 CHECK_EQ(request_params.page_id, -1);
1192 1182
1193 // Record this before starting the load, we need a lower bound of this time 1183 // Record this before starting the load, we need a lower bound of this time
1194 // to sanitize the navigationStart override set below. 1184 // to sanitize the navigationStart override set below.
1195 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now(); 1185 base::TimeTicks renderer_navigation_start = base::TimeTicks::Now();
1196 frame->loadRequest(request); 1186 frame_->loadRequest(request);
1197 1187
1198 UpdateFrameNavigationTiming(frame, request_params.browser_navigation_start, 1188 UpdateFrameNavigationTiming(frame_, request_params.browser_navigation_start,
1199 renderer_navigation_start); 1189 renderer_navigation_start);
1200 } 1190 }
1201 1191
1202 // In case LoadRequest failed before didCreateDataSource was called. 1192 // In case LoadRequest failed before didCreateDataSource was called.
1203 pending_navigation_params_.reset(); 1193 pending_navigation_params_.reset();
1204 } 1194 }
1205 1195
1206 void RenderFrameImpl::NavigateToSwappedOutURL() { 1196 void RenderFrameImpl::NavigateToSwappedOutURL() {
1207 // We use loadRequest instead of loadHTMLString because the former commits 1197 // We use loadRequest instead of loadHTMLString because the former commits
1208 // synchronously. Otherwise a new navigation can interrupt the navigation 1198 // synchronously. Otherwise a new navigation can interrupt the navigation
(...skipping 3672 matching lines...) Expand 10 before | Expand all | Expand 10 after
4881 #elif defined(ENABLE_BROWSER_CDMS) 4871 #elif defined(ENABLE_BROWSER_CDMS)
4882 cdm_manager_, 4872 cdm_manager_,
4883 #endif 4873 #endif
4884 this); 4874 this);
4885 } 4875 }
4886 4876
4887 return cdm_factory_; 4877 return cdm_factory_;
4888 } 4878 }
4889 4879
4890 } // namespace content 4880 } // namespace content
OLDNEW
« no previous file with comments | « content/public/browser/navigation_entry.h ('k') | content/renderer/render_view_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698