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

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

Issue 12052023: Add "frame to navigate" to NavigationEntry and plumb it to the RenderViewImpl (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates Created 7 years, 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_view_impl.h" 5 #include "content/renderer/render_view_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 1114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1125 history_list_offset_ = params.current_history_list_offset; 1125 history_list_offset_ = params.current_history_list_offset;
1126 history_list_length_ = params.current_history_list_length; 1126 history_list_length_ = params.current_history_list_length;
1127 if (history_list_length_ >= 0) 1127 if (history_list_length_ >= 0)
1128 history_page_ids_.resize(history_list_length_, -1); 1128 history_page_ids_.resize(history_list_length_, -1);
1129 if (params.pending_history_list_offset >= 0 && 1129 if (params.pending_history_list_offset >= 0 &&
1130 params.pending_history_list_offset < history_list_length_) 1130 params.pending_history_list_offset < history_list_length_)
1131 history_page_ids_[params.pending_history_list_offset] = params.page_id; 1131 history_page_ids_[params.pending_history_list_offset] = params.page_id;
1132 1132
1133 GetContentClient()->SetActiveURL(params.url); 1133 GetContentClient()->SetActiveURL(params.url);
1134 1134
1135 WebFrame* main_frame = webview()->mainFrame(); 1135 WebFrame* frame = webview()->mainFrame();
1136 if (is_reload && main_frame->currentHistoryItem().isNull()) { 1136 if (!params.frame_to_navigate.empty()) {
1137 frame = webview()->findFrameByName(
1138 WebString::fromUTF8(params.frame_to_navigate));
1139 if (!frame)
1140 return;
Charlie Reis 2013/01/23 01:38:45 Is there any way to trigger a navigation error ins
jochen (gone - plz use gerrit) 2013/01/23 08:22:42 There is no code path to report an error back. If
Charlie Reis 2013/01/23 18:38:17 Ok, since it's just for tests, that seems like it
1141 }
1142
1143 if (is_reload && frame->currentHistoryItem().isNull()) {
1137 // We cannot reload if we do not have any history state. This happens, for 1144 // We cannot reload if we do not have any history state. This happens, for
1138 // example, when recovering from a crash. Our workaround here is a bit of 1145 // example, when recovering from a crash. Our workaround here is a bit of
1139 // a hack since it means that reload after a crashed tab does not cause an 1146 // a hack since it means that reload after a crashed tab does not cause an
1140 // end-to-end cache validation. 1147 // end-to-end cache validation.
1141 is_reload = false; 1148 is_reload = false;
1142 } 1149 }
1143 1150
1144 pending_navigation_params_.reset(new ViewMsg_Navigate_Params(params)); 1151 pending_navigation_params_.reset(new ViewMsg_Navigate_Params(params));
1145 1152
1146 // If we are reloading, then WebKit will use the history state of the current 1153 // If we are reloading, then WebKit will use the history state of the current
1147 // page, so we should just ignore any given history state. Otherwise, if we 1154 // page, so we should just ignore any given history state. Otherwise, if we
1148 // have history state, then we need to navigate to it, which corresponds to a 1155 // have history state, then we need to navigate to it, which corresponds to a
1149 // back/forward navigation event. 1156 // back/forward navigation event.
1150 if (is_reload) { 1157 if (is_reload) {
1151 bool reload_original_url = 1158 bool reload_original_url =
1152 (params.navigation_type == 1159 (params.navigation_type ==
1153 ViewMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL); 1160 ViewMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL);
1154 bool ignore_cache = (params.navigation_type == 1161 bool ignore_cache = (params.navigation_type ==
1155 ViewMsg_Navigate_Type::RELOAD_IGNORING_CACHE); 1162 ViewMsg_Navigate_Type::RELOAD_IGNORING_CACHE);
1156 1163
1157 if (reload_original_url) 1164 if (reload_original_url)
1158 main_frame->reloadWithOverrideURL(params.url, true); 1165 frame->reloadWithOverrideURL(params.url, true);
1159 else 1166 else
1160 main_frame->reload(ignore_cache); 1167 frame->reload(ignore_cache);
1161 } else if (!params.state.empty()) { 1168 } else if (!params.state.empty()) {
1162 // We must know the page ID of the page we are navigating back to. 1169 // We must know the page ID of the page we are navigating back to.
1163 DCHECK_NE(params.page_id, -1); 1170 DCHECK_NE(params.page_id, -1);
1164 WebHistoryItem item = webkit_glue::HistoryItemFromString(params.state); 1171 WebHistoryItem item = webkit_glue::HistoryItemFromString(params.state);
1165 if (!item.isNull()) { 1172 if (!item.isNull()) {
1166 // Ensure we didn't save the swapped out URL in UpdateState, since the 1173 // Ensure we didn't save the swapped out URL in UpdateState, since the
1167 // browser should never be telling us to navigate to swappedout://. 1174 // browser should never be telling us to navigate to swappedout://.
1168 CHECK(item.urlString() != WebString::fromUTF8(kSwappedOutURL)); 1175 CHECK(item.urlString() != WebString::fromUTF8(kSwappedOutURL));
1169 main_frame->loadHistoryItem(item); 1176 frame->loadHistoryItem(item);
1170 } 1177 }
1171 } else if (!params.base_url_for_data_url.is_empty()) { 1178 } else if (!params.base_url_for_data_url.is_empty()) {
1172 // A loadData request with a specified base URL. 1179 // A loadData request with a specified base URL.
1173 std::string mime_type, charset, data; 1180 std::string mime_type, charset, data;
1174 if (net::DataURL::Parse(params.url, &mime_type, &charset, &data)) { 1181 if (net::DataURL::Parse(params.url, &mime_type, &charset, &data)) {
1175 main_frame->loadData( 1182 frame->loadData(
1176 WebData(data.c_str(), data.length()), 1183 WebData(data.c_str(), data.length()),
1177 WebString::fromUTF8(mime_type), 1184 WebString::fromUTF8(mime_type),
1178 WebString::fromUTF8(charset), 1185 WebString::fromUTF8(charset),
1179 params.base_url_for_data_url, 1186 params.base_url_for_data_url,
1180 params.history_url_for_data_url, 1187 params.history_url_for_data_url,
1181 false); 1188 false);
1182 } else { 1189 } else {
1183 CHECK(false) << 1190 CHECK(false) <<
1184 "Invalid URL passed: " << params.url.possibly_invalid_spec(); 1191 "Invalid URL passed: " << params.url.possibly_invalid_spec();
1185 } 1192 }
1186 } else { 1193 } else {
1187 // Navigate to the given URL. 1194 // Navigate to the given URL.
1188 WebURLRequest request(params.url); 1195 WebURLRequest request(params.url);
1189 1196
1190 // A session history navigation should have been accompanied by state. 1197 // A session history navigation should have been accompanied by state.
1191 CHECK_EQ(params.page_id, -1); 1198 CHECK_EQ(params.page_id, -1);
1192 1199
1193 if (main_frame->isViewSourceModeEnabled()) 1200 if (frame->isViewSourceModeEnabled())
Charlie Reis 2013/01/23 01:38:45 Do subframes return true here when the main frame
jochen (gone - plz use gerrit) 2013/01/23 08:22:42 a view-source page can't have frames
1194 request.setCachePolicy(WebURLRequest::ReturnCacheDataElseLoad); 1201 request.setCachePolicy(WebURLRequest::ReturnCacheDataElseLoad);
1195 1202
1196 if (params.referrer.url.is_valid()) { 1203 if (params.referrer.url.is_valid()) {
1197 WebString referrer = WebSecurityPolicy::generateReferrerHeader( 1204 WebString referrer = WebSecurityPolicy::generateReferrerHeader(
1198 params.referrer.policy, 1205 params.referrer.policy,
1199 params.url, 1206 params.url,
1200 WebString::fromUTF8(params.referrer.url.spec())); 1207 WebString::fromUTF8(params.referrer.url.spec()));
1201 if (!referrer.isEmpty()) 1208 if (!referrer.isEmpty())
1202 request.setHTTPHeaderField(WebString::fromUTF8("Referer"), referrer); 1209 request.setHTTPHeaderField(WebString::fromUTF8("Referer"), referrer);
1203 } 1210 }
(...skipping 13 matching lines...) Expand all
1217 // Set post data. 1224 // Set post data.
1218 WebHTTPBody http_body; 1225 WebHTTPBody http_body;
1219 http_body.initialize(); 1226 http_body.initialize();
1220 http_body.appendData(WebData( 1227 http_body.appendData(WebData(
1221 reinterpret_cast<const char*>( 1228 reinterpret_cast<const char*>(
1222 &params.browser_initiated_post_data.front()), 1229 &params.browser_initiated_post_data.front()),
1223 params.browser_initiated_post_data.size())); 1230 params.browser_initiated_post_data.size()));
1224 request.setHTTPBody(http_body); 1231 request.setHTTPBody(http_body);
1225 } 1232 }
1226 1233
1227 main_frame->loadRequest(request); 1234 frame->loadRequest(request);
1228 } 1235 }
1229 1236
1230 // In case LoadRequest failed before DidCreateDataSource was called. 1237 // In case LoadRequest failed before DidCreateDataSource was called.
1231 pending_navigation_params_.reset(); 1238 pending_navigation_params_.reset();
1232 } 1239 }
1233 1240
1234 bool RenderViewImpl::IsBackForwardToStaleEntry( 1241 bool RenderViewImpl::IsBackForwardToStaleEntry(
1235 const ViewMsg_Navigate_Params& params, 1242 const ViewMsg_Navigate_Params& params,
1236 bool is_reload) { 1243 bool is_reload) {
1237 // Make sure this isn't a back/forward to an entry we have already cropped 1244 // Make sure this isn't a back/forward to an entry we have already cropped
(...skipping 5357 matching lines...) Expand 10 before | Expand all | Expand 10 after
6595 } 6602 }
6596 #endif 6603 #endif
6597 6604
6598 void RenderViewImpl::OnReleaseDisambiguationPopupDIB( 6605 void RenderViewImpl::OnReleaseDisambiguationPopupDIB(
6599 TransportDIB::Handle dib_handle) { 6606 TransportDIB::Handle dib_handle) {
6600 TransportDIB* dib = TransportDIB::CreateWithHandle(dib_handle); 6607 TransportDIB* dib = TransportDIB::CreateWithHandle(dib_handle);
6601 RenderProcess::current()->ReleaseTransportDIB(dib); 6608 RenderProcess::current()->ReleaseTransportDIB(dib);
6602 } 6609 }
6603 6610
6604 } // namespace content 6611 } // namespace content
OLDNEW
« content/public/browser/navigation_entry.h ('K') | « content/renderer/render_view_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698