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

Unified Diff: ios/chrome/browser/tabs/tab.mm

Issue 2724103005: Remove Tab -currentNavigationItem. (Closed)
Patch Set: Rebase. Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ios/chrome/browser/tabs/tab_private.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/tabs/tab.mm
diff --git a/ios/chrome/browser/tabs/tab.mm b/ios/chrome/browser/tabs/tab.mm
index ecaf6d83caf592f9d55d4303377fe7c7529b1020..345720ae7c4cbed7532cfb0805733e4473d52ef6 100644
--- a/ios/chrome/browser/tabs/tab.mm
+++ b/ios/chrome/browser/tabs/tab.mm
@@ -328,12 +328,6 @@ enum class RendererTerminationTabState {
std::unique_ptr<TabInfoBarObserver> tabInfoBarObserver_;
}
-// Returns the current NavigationItem for the sesionController associated with
-// this tab. Don't use this to get the underlying NavigationItem; instead
-// go through the NavigationManager.
-// This is nil if there's no NavigationManager.
-@property(nonatomic, readonly) web::NavigationItem* currentNavigationItem;
-
// Returns the tab's reader mode controller. May contain nil if the feature is
// disabled.
@property(nonatomic, readonly) ReaderModeController* readerModeController;
@@ -764,7 +758,8 @@ void TabInfoBarObserver::OnInfoBarReplaced(infobars::InfoBar* old_infobar,
- (const GURL&)url {
// See note in header; this method should be removed.
- web::NavigationItem* item = [self currentNavigationItem];
+ web::NavigationItem* item =
+ [[self navigationManagerImpl]->GetSessionController() currentItem];
return item ? item->GetVirtualURL() : GURL::EmptyGURL();
}
@@ -1046,7 +1041,7 @@ void TabInfoBarObserver::OnInfoBarReplaced(infobars::InfoBar* old_infobar,
}
- (void)addCurrentEntryToHistoryDB {
- DCHECK(self.currentNavigationItem);
+ DCHECK([self navigationManager]->GetVisibleItem());
// If incognito, don't update history.
if (browserState_->IsOffTheRecord())
return;
@@ -1169,8 +1164,17 @@ void TabInfoBarObserver::OnInfoBarReplaced(infobars::InfoBar* old_infobar,
// Reset |isVoiceSearchResultsTab| since a new page is being navigated to.
self.isVoiceSearchResultsTab = NO;
+ web::NavigationItem* navigationItem =
+ [self navigationManager]->GetPendingItem();
+
+ // TODO(crbug.com/676129): the pending item is not correctly set when the
+ // page is reloading, use the last committed item if pending item is null.
+ // Remove this once tracking bug is fixed.
+ if (!navigationItem)
+ navigationItem = [self navigationManager]->GetLastCommittedItem();
+
[[OmniboxGeolocationController sharedInstance]
- addLocationToNavigationItem:self.currentNavigationItem
+ addLocationToNavigationItem:navigationItem
browserState:browserState_];
}
@@ -1276,12 +1280,6 @@ void TabInfoBarObserver::OnInfoBarReplaced(infobars::InfoBar* old_infobar,
[self.webController dismissModals];
}
-- (web::NavigationItem*)currentNavigationItem {
- if (![self navigationManager])
- return nil;
- return [[self navigationManagerImpl]->GetSessionController() currentItem];
-}
-
- (void)setShouldObserveInfoBarManager:(BOOL)shouldObserveInfoBarManager {
tabInfoBarObserver_->SetShouldObserveInfoBarManager(
shouldObserveInfoBarManager);
@@ -1745,9 +1743,13 @@ void TabInfoBarObserver::OnInfoBarReplaced(infobars::InfoBar* old_infobar,
}
bool wasPost = false;
- if (self.currentNavigationItem)
- wasPost = self.currentNavigationItem->HasPostData();
- GURL lastCommittedURL = self.webState->GetLastCommittedURL();
+ GURL lastCommittedURL;
+ web::NavigationItem* lastCommittedItem =
+ [self navigationManager]->GetLastCommittedItem();
+ if (lastCommittedItem) {
+ wasPost = lastCommittedItem->HasPostData();
+ lastCommittedURL = lastCommittedItem->GetVirtualURL();
+ }
if (loadSuccess)
[autoReloadBridge_ loadFinishedForURL:lastCommittedURL wasPost:wasPost];
else
« no previous file with comments | « no previous file | ios/chrome/browser/tabs/tab_private.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698