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

Side by Side Diff: content/browser/frame_host/navigation_controller_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/navigation_controller_impl.h" 5 #include "content/browser/frame_host/navigation_controller_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/strings/string_number_conversions.h" // Temporary 10 #include "base/strings/string_number_conversions.h" // Temporary
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 if (transient_entry_index_ != -1) 422 if (transient_entry_index_ != -1)
423 return entries_[transient_entry_index_].get(); 423 return entries_[transient_entry_index_].get();
424 // The pending entry is safe to return for new (non-history), browser- 424 // The pending entry is safe to return for new (non-history), browser-
425 // initiated navigations. Most renderer-initiated navigations should not 425 // initiated navigations. Most renderer-initiated navigations should not
426 // show the pending entry, to prevent URL spoof attacks. 426 // show the pending entry, to prevent URL spoof attacks.
427 // 427 //
428 // We make an exception for renderer-initiated navigations in new tabs, as 428 // We make an exception for renderer-initiated navigations in new tabs, as
429 // long as no other page has tried to access the initial empty document in 429 // long as no other page has tried to access the initial empty document in
430 // the new tab. If another page modifies this blank page, a URL spoof is 430 // the new tab. If another page modifies this blank page, a URL spoof is
431 // possible, so we must stop showing the pending entry. 431 // possible, so we must stop showing the pending entry.
432 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>(
433 delegate_->GetRenderViewHost());
434 bool safe_to_show_pending = 432 bool safe_to_show_pending =
435 pending_entry_ && 433 pending_entry_ &&
436 // Require a new navigation. 434 // Require a new navigation.
437 pending_entry_->GetPageID() == -1 && 435 pending_entry_->GetPageID() == -1 &&
438 // Require either browser-initiated or an unmodified new tab. 436 // Require either browser-initiated or an unmodified new tab.
439 (!pending_entry_->is_renderer_initiated() || 437 (!pending_entry_->is_renderer_initiated() || IsUnmodifiedBlankTab());
440 (IsInitialNavigation() &&
441 !GetLastCommittedEntry() &&
442 !rvh->has_accessed_initial_document()));
443 438
444 // Also allow showing the pending entry for history navigations in a new tab, 439 // Also allow showing the pending entry for history navigations in a new tab,
445 // such as Ctrl+Back. In this case, no existing page is visible and no one 440 // such as Ctrl+Back. In this case, no existing page is visible and no one
446 // can script the new tab before it commits. 441 // can script the new tab before it commits.
447 if (!safe_to_show_pending && 442 if (!safe_to_show_pending &&
448 pending_entry_ && 443 pending_entry_ &&
449 pending_entry_->GetPageID() != -1 && 444 pending_entry_->GetPageID() != -1 &&
450 IsInitialNavigation() && 445 IsInitialNavigation() &&
451 !pending_entry_->is_renderer_initiated()) 446 !pending_entry_->is_renderer_initiated())
452 safe_to_show_pending = true; 447 safe_to_show_pending = true;
(...skipping 948 matching lines...) Expand 10 before | Expand all | Expand 10 after
1401 } 1396 }
1402 1397
1403 void NavigationControllerImpl::SetMaxRestoredPageID(int32 max_id) { 1398 void NavigationControllerImpl::SetMaxRestoredPageID(int32 max_id) {
1404 max_restored_page_id_ = max_id; 1399 max_restored_page_id_ = max_id;
1405 } 1400 }
1406 1401
1407 int32 NavigationControllerImpl::GetMaxRestoredPageID() const { 1402 int32 NavigationControllerImpl::GetMaxRestoredPageID() const {
1408 return max_restored_page_id_; 1403 return max_restored_page_id_;
1409 } 1404 }
1410 1405
1406 bool NavigationControllerImpl::IsUnmodifiedBlankTab() const {
1407 // TODO(creis): Move has_accessed_initial_document from RenderViewHost to
1408 // WebContents and NavigationControllerDelegate.
1409 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>(
1410 delegate_->GetRenderViewHost());
1411 return IsInitialNavigation() &&
1412 !GetLastCommittedEntry() &&
1413 !rvh->has_accessed_initial_document();
1414 }
1415
1411 SessionStorageNamespace* 1416 SessionStorageNamespace*
1412 NavigationControllerImpl::GetSessionStorageNamespace(SiteInstance* instance) { 1417 NavigationControllerImpl::GetSessionStorageNamespace(SiteInstance* instance) {
1413 std::string partition_id; 1418 std::string partition_id;
1414 if (instance) { 1419 if (instance) {
1415 // TODO(ajwong): When GetDefaultSessionStorageNamespace() goes away, remove 1420 // TODO(ajwong): When GetDefaultSessionStorageNamespace() goes away, remove
1416 // this if statement so |instance| must not be NULL. 1421 // this if statement so |instance| must not be NULL.
1417 partition_id = 1422 partition_id =
1418 GetContentClient()->browser()->GetStoragePartitionIdForSite( 1423 GetContentClient()->browser()->GetStoragePartitionIdForSite(
1419 browser_context_, instance->GetSiteURL()); 1424 browser_context_, instance->GetSiteURL());
1420 } 1425 }
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
1737 } 1742 }
1738 } 1743 }
1739 } 1744 }
1740 1745
1741 void NavigationControllerImpl::SetGetTimestampCallbackForTest( 1746 void NavigationControllerImpl::SetGetTimestampCallbackForTest(
1742 const base::Callback<base::Time()>& get_timestamp_callback) { 1747 const base::Callback<base::Time()>& get_timestamp_callback) {
1743 get_timestamp_callback_ = get_timestamp_callback; 1748 get_timestamp_callback_ = get_timestamp_callback;
1744 } 1749 }
1745 1750
1746 } // namespace content 1751 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698