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

Side by Side Diff: content/browser/web_contents/web_contents_impl.cc

Issue 27045005: When a page is reloaded using the original request URL, ensure that the RVH picked to render it is … (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 2 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/browser/web_contents/navigation_controller_impl_unittest.cc ('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/browser/web_contents/web_contents_impl.h" 5 #include "content/browser/web_contents/web_contents_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 // fully clear the RenderView's view of the session history. 217 // fully clear the RenderView's view of the session history.
218 params->pending_history_list_offset = -1; 218 params->pending_history_list_offset = -1;
219 params->current_history_list_offset = -1; 219 params->current_history_list_offset = -1;
220 params->current_history_list_length = 0; 220 params->current_history_list_length = 0;
221 } else { 221 } else {
222 params->pending_history_list_offset = controller.GetIndexOfEntry(&entry); 222 params->pending_history_list_offset = controller.GetIndexOfEntry(&entry);
223 params->current_history_list_offset = 223 params->current_history_list_offset =
224 controller.GetLastCommittedEntryIndex(); 224 controller.GetLastCommittedEntryIndex();
225 params->current_history_list_length = controller.GetEntryCount(); 225 params->current_history_list_length = controller.GetEntryCount();
226 } 226 }
227 params->url = entry.GetURL();
227 if (!entry.GetBaseURLForDataURL().is_empty()) { 228 if (!entry.GetBaseURLForDataURL().is_empty()) {
228 params->base_url_for_data_url = entry.GetBaseURLForDataURL(); 229 params->base_url_for_data_url = entry.GetBaseURLForDataURL();
229 params->history_url_for_data_url = entry.GetVirtualURL(); 230 params->history_url_for_data_url = entry.GetVirtualURL();
230 } 231 }
231 params->referrer = entry.GetReferrer(); 232 params->referrer = entry.GetReferrer();
232 params->transition = entry.GetTransitionType(); 233 params->transition = entry.GetTransitionType();
233 params->page_state = entry.GetPageState(); 234 params->page_state = entry.GetPageState();
234 params->navigation_type = 235 params->navigation_type =
235 GetNavigationType(controller.GetBrowserContext(), entry, reload_type); 236 GetNavigationType(controller.GetBrowserContext(), entry, reload_type);
236 params->request_time = base::Time::Now(); 237 params->request_time = base::Time::Now();
237 params->extra_headers = entry.extra_headers(); 238 params->extra_headers = entry.extra_headers();
238 params->transferred_request_child_id = 239 params->transferred_request_child_id =
239 entry.transferred_global_request_id().child_id; 240 entry.transferred_global_request_id().child_id;
240 params->transferred_request_request_id = 241 params->transferred_request_request_id =
241 entry.transferred_global_request_id().request_id; 242 entry.transferred_global_request_id().request_id;
242 params->is_overriding_user_agent = entry.GetIsOverridingUserAgent(); 243 params->is_overriding_user_agent = entry.GetIsOverridingUserAgent();
243 // Avoid downloading when in view-source mode. 244 // Avoid downloading when in view-source mode.
244 params->allow_download = !entry.IsViewSourceMode(); 245 params->allow_download = !entry.IsViewSourceMode();
245 params->is_post = entry.GetHasPostData(); 246 params->is_post = entry.GetHasPostData();
246 if(entry.GetBrowserInitiatedPostData()) { 247 if (entry.GetBrowserInitiatedPostData()) {
247 params->browser_initiated_post_data.assign( 248 params->browser_initiated_post_data.assign(
248 entry.GetBrowserInitiatedPostData()->front(), 249 entry.GetBrowserInitiatedPostData()->front(),
249 entry.GetBrowserInitiatedPostData()->front() + 250 entry.GetBrowserInitiatedPostData()->front() +
250 entry.GetBrowserInitiatedPostData()->size()); 251 entry.GetBrowserInitiatedPostData()->size());
251
252 }
253
254 if (reload_type == NavigationControllerImpl::RELOAD_ORIGINAL_REQUEST_URL &&
255 entry.GetOriginalRequestURL().is_valid() && !entry.GetHasPostData()) {
256 // We may have been redirected when navigating to the current URL.
257 // Use the URL the user originally intended to visit, if it's valid and if a
258 // POST wasn't involved; the latter case avoids issues with sending data to
259 // the wrong page.
260 params->url = entry.GetOriginalRequestURL();
261 } else {
262 params->url = entry.GetURL();
263 } 252 }
264 253
265 params->can_load_local_resources = entry.GetCanLoadLocalResources(); 254 params->can_load_local_resources = entry.GetCanLoadLocalResources();
266 params->frame_to_navigate = entry.GetFrameToNavigate(); 255 params->frame_to_navigate = entry.GetFrameToNavigate();
267 256
268 if (delegate) 257 if (delegate)
269 delegate->AddNavigationHeaders(params->url, &params->extra_headers); 258 delegate->AddNavigationHeaders(params->url, &params->extra_headers);
270 } 259 }
271 260
272 void NotifyCacheOnIO( 261 void NotifyCacheOnIO(
(...skipping 1540 matching lines...) Expand 10 before | Expand all | Expand 10 after
1813 } 1802 }
1814 1803
1815 void WebContentsImpl::DetachInterstitialPage() { 1804 void WebContentsImpl::DetachInterstitialPage() {
1816 if (GetInterstitialPage()) 1805 if (GetInterstitialPage())
1817 render_manager_.remove_interstitial_page(); 1806 render_manager_.remove_interstitial_page();
1818 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 1807 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
1819 DidDetachInterstitialPage()); 1808 DidDetachInterstitialPage());
1820 } 1809 }
1821 1810
1822 bool WebContentsImpl::NavigateToEntry( 1811 bool WebContentsImpl::NavigateToEntry(
1823 const NavigationEntryImpl& entry, 1812 const NavigationEntryImpl& entry_in,
1824 NavigationController::ReloadType reload_type) { 1813 NavigationController::ReloadType reload_type) {
1825 TRACE_EVENT0("browser", "WebContentsImpl::NavigateToEntry"); 1814 TRACE_EVENT0("browser", "WebContentsImpl::NavigateToEntry");
1826 1815
1816 NavigationEntryImpl entry(entry_in);
Charlie Reis 2013/10/11 21:22:27 After taking a closer look, I wonder if we just wa
jam 2013/10/11 22:24:49 Done.
1817 if (reload_type == NavigationControllerImpl::RELOAD_ORIGINAL_REQUEST_URL &&
1818 entry.GetOriginalRequestURL().is_valid() && !entry.GetHasPostData()) {
1819 // We may have been redirected when navigating to the current URL.
1820 // Use the URL the user originally intended to visit, if it's valid and if a
1821 // POST wasn't involved; the latter case avoids issues with sending data to
1822 // the wrong page.
1823 entry.SetURL(entry.GetOriginalRequestURL());
1824 }
1825
1827 // The renderer will reject IPC messages with URLs longer than 1826 // The renderer will reject IPC messages with URLs longer than
1828 // this limit, so don't attempt to navigate with a longer URL. 1827 // this limit, so don't attempt to navigate with a longer URL.
1829 if (entry.GetURL().spec().size() > kMaxURLChars) { 1828 if (entry.GetURL().spec().size() > kMaxURLChars) {
1830 LOG(WARNING) << "Refusing to load URL as it exceeds " << kMaxURLChars 1829 LOG(WARNING) << "Refusing to load URL as it exceeds " << kMaxURLChars
1831 << " characters."; 1830 << " characters.";
1832 return false; 1831 return false;
1833 } 1832 }
1834 1833
1835 RenderViewHostImpl* dest_render_view_host = 1834 RenderViewHostImpl* dest_render_view_host =
1836 static_cast<RenderViewHostImpl*>(render_manager_.Navigate(entry)); 1835 static_cast<RenderViewHostImpl*>(render_manager_.Navigate(entry));
(...skipping 1997 matching lines...) Expand 10 before | Expand all | Expand 10 after
3834 } 3833 }
3835 3834
3836 void WebContentsImpl::OnFrameRemoved( 3835 void WebContentsImpl::OnFrameRemoved(
3837 RenderViewHostImpl* render_view_host, 3836 RenderViewHostImpl* render_view_host,
3838 int64 frame_id) { 3837 int64 frame_id) {
3839 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 3838 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
3840 FrameDetached(render_view_host, frame_id)); 3839 FrameDetached(render_view_host, frame_id));
3841 } 3840 }
3842 3841
3843 } // namespace content 3842 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/navigation_controller_impl_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698