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

Side by Side Diff: content/browser/frame_host/navigator_impl.cc

Issue 232463007: Don't leave aborted URLs in the omnibox unless we're on a new tab. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 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 | Annotate | Revision Log
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/browser/frame_host/navigator_impl.h" 5 #include "content/browser/frame_host/navigator_impl.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "content/browser/frame_host/frame_tree.h" 8 #include "content/browser/frame_host/frame_tree.h"
9 #include "content/browser/frame_host/frame_tree_node.h" 9 #include "content/browser/frame_host/frame_tree_node.h"
10 #include "content/browser/frame_host/navigation_controller_impl.h" 10 #include "content/browser/frame_host/navigation_controller_impl.h"
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 223
224 // We used to cancel the pending renderer here for cross-site downloads. 224 // We used to cancel the pending renderer here for cross-site downloads.
225 // However, it's not safe to do that because the download logic repeatedly 225 // However, it's not safe to do that because the download logic repeatedly
226 // looks for this WebContents based on a render ID. Instead, we just 226 // looks for this WebContents based on a render ID. Instead, we just
227 // leave the pending renderer around until the next navigation event 227 // leave the pending renderer around until the next navigation event
228 // (Navigate, DidNavigate, etc), which will clean it up properly. 228 // (Navigate, DidNavigate, etc), which will clean it up properly.
229 // 229 //
230 // TODO(creis): Find a way to cancel any pending RFH here. 230 // TODO(creis): Find a way to cancel any pending RFH here.
231 } 231 }
232 232
233 // Do not usually clear the pending entry if one exists, so that the user's 233 // We usually clear the pending entry when it fails, so that an arbitrary URL
234 // typed URL is not lost when a navigation fails or is aborted. However, in 234 // isn't left visible above a committed page. This must be enforced when
235 // cases that we don't show the pending entry (e.g., renderer-initiated 235 // the pending entry isn't visible (e.g., renderer-initiated navigations) to
236 // navigations in an existing tab), we don't keep it around. That prevents 236 // prevent URL spoofs for in-page navigations that don't go through
237 // spoofs on in-page navigations that don't go through
238 // DidStartProvisionalLoadForFrame. 237 // DidStartProvisionalLoadForFrame.
239 // In general, we allow the view to clear the pending entry and typed URL if 238 //
240 // the user requests (e.g., hitting Escape with focus in the address bar). 239 // However, we do preserve the pending entry in some cases, such as on the
240 // initial navigation of an unmodified blank tab. We also allow the delegate
241 // to say when it's safe to leave aborted URLs in the omnibox, to let the user
242 // edit the URL and try again. This may be useful in cases that the committed
243 // page cannot be attacker-controlled. In these cases, we still allow the
244 // view to clear the pending entry and typed URL if the user requests
245 // (e.g., hitting Escape with focus in the address bar).
246 //
241 // Note: don't touch the transient entry, since an interstitial may exist. 247 // Note: don't touch the transient entry, since an interstitial may exist.
242 if (controller_->GetPendingEntry() != controller_->GetVisibleEntry()) 248 bool should_preserve_entry = controller_->IsUnmodifiedBlankTab() ||
249 delegate_->ShouldPreserveAbortedURLs();
250 if (controller_->GetPendingEntry() != controller_->GetVisibleEntry() ||
251 !should_preserve_entry) {
243 controller_->DiscardPendingEntry(); 252 controller_->DiscardPendingEntry();
244 253
254 // Also force the UI to refresh.
255 controller_->delegate()->NotifyNavigationStateChanged(INVALIDATE_TYPE_URL);
256 }
257
245 if (delegate_) 258 if (delegate_)
246 delegate_->DidFailProvisionalLoadWithError(render_frame_host, params); 259 delegate_->DidFailProvisionalLoadWithError(render_frame_host, params);
247 } 260 }
248 261
249 void NavigatorImpl::DidFailLoadWithError( 262 void NavigatorImpl::DidFailLoadWithError(
250 RenderFrameHostImpl* render_frame_host, 263 RenderFrameHostImpl* render_frame_host,
251 const GURL& url, 264 const GURL& url,
252 int error_code, 265 int error_code,
253 const base::string16& error_description) { 266 const base::string16& error_description) {
254 if (delegate_) { 267 if (delegate_) {
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 604
592 // Navigations in Web UI pages count as browser-initiated navigations. 605 // Navigations in Web UI pages count as browser-initiated navigations.
593 params.is_renderer_initiated = false; 606 params.is_renderer_initiated = false;
594 } 607 }
595 608
596 if (delegate_) 609 if (delegate_)
597 delegate_->RequestOpenURL(render_frame_host, params); 610 delegate_->RequestOpenURL(render_frame_host, params);
598 } 611 }
599 612
600 } // namespace content 613 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/navigator_delegate.cc ('k') | content/browser/frame_host/render_frame_host_manager_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698