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

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: patch for landing 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
« no previous file with comments | « content/renderer/render_view_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 CHECK(frame) << "Invalid frame name passed: " << params.frame_to_navigate;
1140 }
1141
1142 if (is_reload && frame->currentHistoryItem().isNull()) {
1137 // We cannot reload if we do not have any history state. This happens, for 1143 // 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 1144 // 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 1145 // a hack since it means that reload after a crashed tab does not cause an
1140 // end-to-end cache validation. 1146 // end-to-end cache validation.
1141 is_reload = false; 1147 is_reload = false;
1142 } 1148 }
1143 1149
1144 pending_navigation_params_.reset(new ViewMsg_Navigate_Params(params)); 1150 pending_navigation_params_.reset(new ViewMsg_Navigate_Params(params));
1145 1151
1146 // If we are reloading, then WebKit will use the history state of the current 1152 // 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 1153 // 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 1154 // have history state, then we need to navigate to it, which corresponds to a
1149 // back/forward navigation event. 1155 // back/forward navigation event.
1150 if (is_reload) { 1156 if (is_reload) {
1151 bool reload_original_url = 1157 bool reload_original_url =
1152 (params.navigation_type == 1158 (params.navigation_type ==
1153 ViewMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL); 1159 ViewMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL);
1154 bool ignore_cache = (params.navigation_type == 1160 bool ignore_cache = (params.navigation_type ==
1155 ViewMsg_Navigate_Type::RELOAD_IGNORING_CACHE); 1161 ViewMsg_Navigate_Type::RELOAD_IGNORING_CACHE);
1156 1162
1157 if (reload_original_url) 1163 if (reload_original_url)
1158 main_frame->reloadWithOverrideURL(params.url, true); 1164 frame->reloadWithOverrideURL(params.url, true);
1159 else 1165 else
1160 main_frame->reload(ignore_cache); 1166 frame->reload(ignore_cache);
1161 } else if (!params.state.empty()) { 1167 } else if (!params.state.empty()) {
1162 // We must know the page ID of the page we are navigating back to. 1168 // We must know the page ID of the page we are navigating back to.
1163 DCHECK_NE(params.page_id, -1); 1169 DCHECK_NE(params.page_id, -1);
1164 WebHistoryItem item = webkit_glue::HistoryItemFromString(params.state); 1170 WebHistoryItem item = webkit_glue::HistoryItemFromString(params.state);
1165 if (!item.isNull()) { 1171 if (!item.isNull()) {
1166 // Ensure we didn't save the swapped out URL in UpdateState, since the 1172 // Ensure we didn't save the swapped out URL in UpdateState, since the
1167 // browser should never be telling us to navigate to swappedout://. 1173 // browser should never be telling us to navigate to swappedout://.
1168 CHECK(item.urlString() != WebString::fromUTF8(kSwappedOutURL)); 1174 CHECK(item.urlString() != WebString::fromUTF8(kSwappedOutURL));
1169 main_frame->loadHistoryItem(item); 1175 frame->loadHistoryItem(item);
1170 } 1176 }
1171 } else if (!params.base_url_for_data_url.is_empty()) { 1177 } else if (!params.base_url_for_data_url.is_empty()) {
1172 // A loadData request with a specified base URL. 1178 // A loadData request with a specified base URL.
1173 std::string mime_type, charset, data; 1179 std::string mime_type, charset, data;
1174 if (net::DataURL::Parse(params.url, &mime_type, &charset, &data)) { 1180 if (net::DataURL::Parse(params.url, &mime_type, &charset, &data)) {
1175 main_frame->loadData( 1181 frame->loadData(
1176 WebData(data.c_str(), data.length()), 1182 WebData(data.c_str(), data.length()),
1177 WebString::fromUTF8(mime_type), 1183 WebString::fromUTF8(mime_type),
1178 WebString::fromUTF8(charset), 1184 WebString::fromUTF8(charset),
1179 params.base_url_for_data_url, 1185 params.base_url_for_data_url,
1180 params.history_url_for_data_url, 1186 params.history_url_for_data_url,
1181 false); 1187 false);
1182 } else { 1188 } else {
1183 CHECK(false) << 1189 CHECK(false) <<
1184 "Invalid URL passed: " << params.url.possibly_invalid_spec(); 1190 "Invalid URL passed: " << params.url.possibly_invalid_spec();
1185 } 1191 }
1186 } else { 1192 } else {
1187 // Navigate to the given URL. 1193 // Navigate to the given URL.
1188 WebURLRequest request(params.url); 1194 WebURLRequest request(params.url);
1189 1195
1190 // A session history navigation should have been accompanied by state. 1196 // A session history navigation should have been accompanied by state.
1191 CHECK_EQ(params.page_id, -1); 1197 CHECK_EQ(params.page_id, -1);
1192 1198
1193 if (main_frame->isViewSourceModeEnabled()) 1199 if (frame->isViewSourceModeEnabled())
1194 request.setCachePolicy(WebURLRequest::ReturnCacheDataElseLoad); 1200 request.setCachePolicy(WebURLRequest::ReturnCacheDataElseLoad);
1195 1201
1196 if (params.referrer.url.is_valid()) { 1202 if (params.referrer.url.is_valid()) {
1197 WebString referrer = WebSecurityPolicy::generateReferrerHeader( 1203 WebString referrer = WebSecurityPolicy::generateReferrerHeader(
1198 params.referrer.policy, 1204 params.referrer.policy,
1199 params.url, 1205 params.url,
1200 WebString::fromUTF8(params.referrer.url.spec())); 1206 WebString::fromUTF8(params.referrer.url.spec()));
1201 if (!referrer.isEmpty()) 1207 if (!referrer.isEmpty())
1202 request.setHTTPHeaderField(WebString::fromUTF8("Referer"), referrer); 1208 request.setHTTPHeaderField(WebString::fromUTF8("Referer"), referrer);
1203 } 1209 }
(...skipping 13 matching lines...) Expand all
1217 // Set post data. 1223 // Set post data.
1218 WebHTTPBody http_body; 1224 WebHTTPBody http_body;
1219 http_body.initialize(); 1225 http_body.initialize();
1220 http_body.appendData(WebData( 1226 http_body.appendData(WebData(
1221 reinterpret_cast<const char*>( 1227 reinterpret_cast<const char*>(
1222 &params.browser_initiated_post_data.front()), 1228 &params.browser_initiated_post_data.front()),
1223 params.browser_initiated_post_data.size())); 1229 params.browser_initiated_post_data.size()));
1224 request.setHTTPBody(http_body); 1230 request.setHTTPBody(http_body);
1225 } 1231 }
1226 1232
1227 main_frame->loadRequest(request); 1233 frame->loadRequest(request);
1228 } 1234 }
1229 1235
1230 // In case LoadRequest failed before DidCreateDataSource was called. 1236 // In case LoadRequest failed before DidCreateDataSource was called.
1231 pending_navigation_params_.reset(); 1237 pending_navigation_params_.reset();
1232 } 1238 }
1233 1239
1234 bool RenderViewImpl::IsBackForwardToStaleEntry( 1240 bool RenderViewImpl::IsBackForwardToStaleEntry(
1235 const ViewMsg_Navigate_Params& params, 1241 const ViewMsg_Navigate_Params& params,
1236 bool is_reload) { 1242 bool is_reload) {
1237 // Make sure this isn't a back/forward to an entry we have already cropped 1243 // Make sure this isn't a back/forward to an entry we have already cropped
(...skipping 5359 matching lines...) Expand 10 before | Expand all | Expand 10 after
6597 } 6603 }
6598 #endif 6604 #endif
6599 6605
6600 void RenderViewImpl::OnReleaseDisambiguationPopupDIB( 6606 void RenderViewImpl::OnReleaseDisambiguationPopupDIB(
6601 TransportDIB::Handle dib_handle) { 6607 TransportDIB::Handle dib_handle) {
6602 TransportDIB* dib = TransportDIB::CreateWithHandle(dib_handle); 6608 TransportDIB* dib = TransportDIB::CreateWithHandle(dib_handle);
6603 RenderProcess::current()->ReleaseTransportDIB(dib); 6609 RenderProcess::current()->ReleaseTransportDIB(dib);
6604 } 6610 }
6605 6611
6606 } // namespace content 6612 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_view_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698