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

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

Issue 23022006: Remove GetActiveEntry usage from content. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 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/browser/web_contents/navigation_controller_impl.h" 5 #include "content/browser/web_contents/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 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 } 261 }
262 void NavigationControllerImpl::ReloadOriginalRequestURL(bool check_for_repost) { 262 void NavigationControllerImpl::ReloadOriginalRequestURL(bool check_for_repost) {
263 ReloadInternal(check_for_repost, RELOAD_ORIGINAL_REQUEST_URL); 263 ReloadInternal(check_for_repost, RELOAD_ORIGINAL_REQUEST_URL);
264 } 264 }
265 265
266 void NavigationControllerImpl::ReloadInternal(bool check_for_repost, 266 void NavigationControllerImpl::ReloadInternal(bool check_for_repost,
267 ReloadType reload_type) { 267 ReloadType reload_type) {
268 if (transient_entry_index_ != -1) { 268 if (transient_entry_index_ != -1) {
269 // If an interstitial is showing, treat a reload as a navigation to the 269 // If an interstitial is showing, treat a reload as a navigation to the
270 // transient entry's URL. 270 // transient entry's URL.
271 NavigationEntryImpl* active_entry = 271 NavigationEntryImpl* active_entry =
Charlie Reis 2013/08/16 22:10:14 nit: visible_entry Actually, should we just make
nasko 2013/09/12 17:56:31 Done.
272 NavigationEntryImpl::FromNavigationEntry(GetActiveEntry()); 272 NavigationEntryImpl::FromNavigationEntry(GetVisibleEntry());
273 if (!active_entry) 273 if (!active_entry)
274 return; 274 return;
275 LoadURL(active_entry->GetURL(), 275 LoadURL(active_entry->GetURL(),
276 Referrer(), 276 Referrer(),
277 PAGE_TRANSITION_RELOAD, 277 PAGE_TRANSITION_RELOAD,
278 active_entry->extra_headers()); 278 active_entry->extra_headers());
279 return; 279 return;
280 } 280 }
281 281
282 NavigationEntryImpl* entry = NULL; 282 NavigationEntryImpl* entry = NULL;
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 NavigationEntry* NavigationControllerImpl::GetLastCommittedEntry() const { 455 NavigationEntry* NavigationControllerImpl::GetLastCommittedEntry() const {
456 if (last_committed_entry_index_ == -1) 456 if (last_committed_entry_index_ == -1)
457 return NULL; 457 return NULL;
458 return entries_[last_committed_entry_index_].get(); 458 return entries_[last_committed_entry_index_].get();
459 } 459 }
460 460
461 bool NavigationControllerImpl::CanViewSource() const { 461 bool NavigationControllerImpl::CanViewSource() const {
462 const std::string& mime_type = web_contents_->GetContentsMimeType(); 462 const std::string& mime_type = web_contents_->GetContentsMimeType();
463 bool is_viewable_mime_type = net::IsSupportedNonImageMimeType(mime_type) && 463 bool is_viewable_mime_type = net::IsSupportedNonImageMimeType(mime_type) &&
464 !net::IsSupportedMediaMimeType(mime_type); 464 !net::IsSupportedMediaMimeType(mime_type);
465 NavigationEntry* active_entry = GetActiveEntry(); 465 NavigationEntry* active_entry = GetVisibleEntry();
Charlie Reis 2013/08/16 22:10:14 nit: visible_entry
nasko 2013/09/12 17:56:31 Done.
466 return active_entry && !active_entry->IsViewSourceMode() && 466 return active_entry && !active_entry->IsViewSourceMode() &&
467 is_viewable_mime_type && !web_contents_->GetInterstitialPage(); 467 is_viewable_mime_type && !web_contents_->GetInterstitialPage();
468 } 468 }
469 469
470 int NavigationControllerImpl::GetLastCommittedEntryIndex() const { 470 int NavigationControllerImpl::GetLastCommittedEntryIndex() const {
471 return last_committed_entry_index_; 471 return last_committed_entry_index_;
472 } 472 }
473 473
474 int NavigationControllerImpl::GetEntryCount() const { 474 int NavigationControllerImpl::GetEntryCount() const {
475 DCHECK(entries_.size() <= max_entry_count()); 475 DCHECK(entries_.size() <= max_entry_count());
(...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after
1311 return true; 1311 return true;
1312 } 1312 }
1313 1313
1314 void NavigationControllerImpl::PruneAllButVisible() { 1314 void NavigationControllerImpl::PruneAllButVisible() {
1315 PruneAllButVisibleInternal(); 1315 PruneAllButVisibleInternal();
1316 1316
1317 // We should still have a last committed entry. 1317 // We should still have a last committed entry.
1318 DCHECK_NE(-1, last_committed_entry_index_); 1318 DCHECK_NE(-1, last_committed_entry_index_);
1319 1319
1320 NavigationEntryImpl* entry = 1320 NavigationEntryImpl* entry =
1321 NavigationEntryImpl::FromNavigationEntry(GetActiveEntry()); 1321 NavigationEntryImpl::FromNavigationEntry(GetVisibleEntry());
Charlie Reis 2013/08/16 22:10:14 This scares me. We may have to come back to this
1322 // We pass 0 instead of GetEntryCount() for the history_length parameter of 1322 // We pass 0 instead of GetEntryCount() for the history_length parameter of
1323 // SetHistoryLengthAndPrune, because it will create history_length additional 1323 // SetHistoryLengthAndPrune, because it will create history_length additional
1324 // history entries. 1324 // history entries.
1325 // TODO(jochen): This API is confusing and we should clean it up. 1325 // TODO(jochen): This API is confusing and we should clean it up.
1326 // http://crbug.com/178491 1326 // http://crbug.com/178491
1327 web_contents_->SetHistoryLengthAndPrune( 1327 web_contents_->SetHistoryLengthAndPrune(
1328 entry->site_instance(), 0, entry->GetPageID()); 1328 entry->site_instance(), 0, entry->GetPageID());
1329 } 1329 }
1330 1330
1331 void NavigationControllerImpl::PruneAllButVisibleInternal() { 1331 void NavigationControllerImpl::PruneAllButVisibleInternal() {
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
1549 if (pending_entry_ && !pending_entry_->site_instance() && 1549 if (pending_entry_ && !pending_entry_->site_instance() &&
1550 pending_entry_->restore_type() != NavigationEntryImpl::RESTORE_NONE) { 1550 pending_entry_->restore_type() != NavigationEntryImpl::RESTORE_NONE) {
1551 pending_entry_->set_site_instance(static_cast<SiteInstanceImpl*>( 1551 pending_entry_->set_site_instance(static_cast<SiteInstanceImpl*>(
1552 web_contents_->GetPendingSiteInstance())); 1552 web_contents_->GetPendingSiteInstance()));
1553 pending_entry_->set_restore_type(NavigationEntryImpl::RESTORE_NONE); 1553 pending_entry_->set_restore_type(NavigationEntryImpl::RESTORE_NONE);
1554 } 1554 }
1555 } 1555 }
1556 1556
1557 void NavigationControllerImpl::NotifyNavigationEntryCommitted( 1557 void NavigationControllerImpl::NotifyNavigationEntryCommitted(
1558 LoadCommittedDetails* details) { 1558 LoadCommittedDetails* details) {
1559 details->entry = GetActiveEntry(); 1559 details->entry = GetVisibleEntry();
Charlie Reis 2013/08/16 22:10:14 GetLastCommittedEntry, perhaps? How would we have
nasko 2013/09/12 17:56:31 I'm not sure we can have a transient entry at the
1560 NotificationDetails notification_details = 1560 NotificationDetails notification_details =
1561 Details<LoadCommittedDetails>(details); 1561 Details<LoadCommittedDetails>(details);
1562 1562
1563 // We need to notify the ssl_manager_ before the web_contents_ so the 1563 // We need to notify the ssl_manager_ before the web_contents_ so the
1564 // location bar will have up-to-date information about the security style 1564 // location bar will have up-to-date information about the security style
1565 // when it wants to draw. See http://crbug.com/11157 1565 // when it wants to draw. See http://crbug.com/11157
1566 ssl_manager_.DidCommitProvisionalLoad(notification_details); 1566 ssl_manager_.DidCommitProvisionalLoad(notification_details);
1567 1567
1568 // TODO(pkasting): http://b/1113079 Probably these explicit notification paths 1568 // TODO(pkasting): http://b/1113079 Probably these explicit notification paths
1569 // should be removed, and interested parties should just listen for the 1569 // should be removed, and interested parties should just listen for the
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1684 } 1684 }
1685 } 1685 }
1686 } 1686 }
1687 1687
1688 void NavigationControllerImpl::SetGetTimestampCallbackForTest( 1688 void NavigationControllerImpl::SetGetTimestampCallbackForTest(
1689 const base::Callback<base::Time()>& get_timestamp_callback) { 1689 const base::Callback<base::Time()>& get_timestamp_callback) {
1690 get_timestamp_callback_ = get_timestamp_callback; 1690 get_timestamp_callback_ = get_timestamp_callback;
1691 } 1691 }
1692 1692
1693 } // namespace content 1693 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698