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

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: Fixing android compile break. Created 7 years, 3 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* transient_entry =
272 NavigationEntryImpl::FromNavigationEntry(GetActiveEntry()); 272 NavigationEntryImpl::FromNavigationEntry(GetTransientEntry());
273 if (!active_entry) 273 if (!transient_entry)
274 return; 274 return;
275 LoadURL(active_entry->GetURL(), 275 LoadURL(transient_entry->GetURL(),
276 Referrer(), 276 Referrer(),
277 PAGE_TRANSITION_RELOAD, 277 PAGE_TRANSITION_RELOAD,
278 active_entry->extra_headers()); 278 transient_entry->extra_headers());
279 return; 279 return;
280 } 280 }
281 281
282 NavigationEntryImpl* entry = NULL; 282 NavigationEntryImpl* entry = NULL;
283 int current_index = -1; 283 int current_index = -1;
284 284
285 // If we are reloading the initial navigation, just use the current 285 // If we are reloading the initial navigation, just use the current
286 // pending entry. Otherwise look up the current entry. 286 // pending entry. Otherwise look up the current entry.
287 if (IsInitialNavigation() && pending_entry_) { 287 if (IsInitialNavigation() && pending_entry_) {
288 entry = pending_entry_; 288 entry = pending_entry_;
(...skipping 166 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* visible_entry = GetVisibleEntry();
466 return active_entry && !active_entry->IsViewSourceMode() && 466 return visible_entry && !visible_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());
476 return static_cast<int>(entries_.size()); 476 return static_cast<int>(entries_.size());
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after
1311 1311
1312 return true; 1312 return true;
1313 } 1313 }
1314 1314
1315 void NavigationControllerImpl::PruneAllButVisible() { 1315 void NavigationControllerImpl::PruneAllButVisible() {
1316 PruneAllButVisibleInternal(); 1316 PruneAllButVisibleInternal();
1317 1317
1318 // We should still have a last committed entry. 1318 // We should still have a last committed entry.
1319 DCHECK_NE(-1, last_committed_entry_index_); 1319 DCHECK_NE(-1, last_committed_entry_index_);
1320 1320
1321 NavigationEntryImpl* entry =
1322 NavigationEntryImpl::FromNavigationEntry(GetActiveEntry());
1323 // We pass 0 instead of GetEntryCount() for the history_length parameter of 1321 // We pass 0 instead of GetEntryCount() for the history_length parameter of
1324 // SetHistoryLengthAndPrune, because it will create history_length additional 1322 // SetHistoryLengthAndPrune, because it will create history_length additional
1325 // history entries. 1323 // history entries.
1326 // TODO(jochen): This API is confusing and we should clean it up. 1324 // TODO(jochen): This API is confusing and we should clean it up.
1327 // http://crbug.com/178491 1325 // http://crbug.com/178491
1326 NavigationEntryImpl* entry =
1327 NavigationEntryImpl::FromNavigationEntry(GetVisibleEntry());
1328 web_contents_->SetHistoryLengthAndPrune( 1328 web_contents_->SetHistoryLengthAndPrune(
1329 entry->site_instance(), 0, entry->GetPageID()); 1329 entry->site_instance(), 0, entry->GetPageID());
1330 } 1330 }
1331 1331
1332 void NavigationControllerImpl::PruneAllButVisibleInternal() { 1332 void NavigationControllerImpl::PruneAllButVisibleInternal() {
1333 // It is up to callers to check the invariants before calling this. 1333 // It is up to callers to check the invariants before calling this.
1334 CHECK(CanPruneAllButVisible()); 1334 CHECK(CanPruneAllButVisible());
1335 1335
1336 // Erase all entries but the last committed entry. There may still be a 1336 // Erase all entries but the last committed entry. There may still be a
1337 // new pending entry after this. 1337 // new pending entry after this.
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
1550 if (pending_entry_ && !pending_entry_->site_instance() && 1550 if (pending_entry_ && !pending_entry_->site_instance() &&
1551 pending_entry_->restore_type() != NavigationEntryImpl::RESTORE_NONE) { 1551 pending_entry_->restore_type() != NavigationEntryImpl::RESTORE_NONE) {
1552 pending_entry_->set_site_instance(static_cast<SiteInstanceImpl*>( 1552 pending_entry_->set_site_instance(static_cast<SiteInstanceImpl*>(
1553 web_contents_->GetPendingSiteInstance())); 1553 web_contents_->GetPendingSiteInstance()));
1554 pending_entry_->set_restore_type(NavigationEntryImpl::RESTORE_NONE); 1554 pending_entry_->set_restore_type(NavigationEntryImpl::RESTORE_NONE);
1555 } 1555 }
1556 } 1556 }
1557 1557
1558 void NavigationControllerImpl::NotifyNavigationEntryCommitted( 1558 void NavigationControllerImpl::NotifyNavigationEntryCommitted(
1559 LoadCommittedDetails* details) { 1559 LoadCommittedDetails* details) {
1560 details->entry = GetActiveEntry(); 1560 details->entry = GetLastCommittedEntry();
1561 1561
1562 // We need to notify the ssl_manager_ before the web_contents_ so the 1562 // We need to notify the ssl_manager_ before the web_contents_ so the
1563 // location bar will have up-to-date information about the security style 1563 // location bar will have up-to-date information about the security style
1564 // when it wants to draw. See http://crbug.com/11157 1564 // when it wants to draw. See http://crbug.com/11157
1565 ssl_manager_.DidCommitProvisionalLoad(*details); 1565 ssl_manager_.DidCommitProvisionalLoad(*details);
1566 1566
1567 web_contents_->NotifyNavigationStateChanged(kInvalidateAll); 1567 web_contents_->NotifyNavigationStateChanged(kInvalidateAll);
1568 web_contents_->NotifyNavigationEntryCommitted(*details); 1568 web_contents_->NotifyNavigationEntryCommitted(*details);
1569 1569
1570 // TODO(avi): Remove. http://crbug.com/170921 1570 // TODO(avi): Remove. http://crbug.com/170921
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1685 } 1685 }
1686 } 1686 }
1687 } 1687 }
1688 1688
1689 void NavigationControllerImpl::SetGetTimestampCallbackForTest( 1689 void NavigationControllerImpl::SetGetTimestampCallbackForTest(
1690 const base::Callback<base::Time()>& get_timestamp_callback) { 1690 const base::Callback<base::Time()>& get_timestamp_callback) {
1691 get_timestamp_callback_ = get_timestamp_callback; 1691 get_timestamp_callback_ = get_timestamp_callback;
1692 } 1692 }
1693 1693
1694 } // namespace content 1694 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698