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

Unified Diff: ios/web/navigation/crw_session_controller.mm

Issue 2485753002: [ios] Unified CRWSessionController navigation logic. (Closed)
Patch Set: Rebased to origin/master Created 4 years, 1 month 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/web/navigation/crw_session_controller.mm
diff --git a/ios/web/navigation/crw_session_controller.mm b/ios/web/navigation/crw_session_controller.mm
index 430ff519e3430404bca69eb035a1ce4f253c4084..9f38b2ac70d337b9e3f2f6edafff38fd1c3b04ca 100644
--- a/ios/web/navigation/crw_session_controller.mm
+++ b/ios/web/navigation/crw_session_controller.mm
@@ -636,39 +636,36 @@ NSString* const kXCallbackParametersKey = @"xCallbackParameters";
}
- (void)goDelta:(int)delta {
- if (delta == 0 || ![self canGoDelta:delta])
- return;
+ if (delta != 0 && [self canGoDelta:delta]) {
+ NSInteger newNavigationIndex = [self indexOfEntryForDelta:delta];
+ [self goToEntry:_entries[newNavigationIndex]];
+ }
+}
- NSInteger oldNavigationIndex = self.currentNavigationIndex;
- NSInteger newNavigationIndex = [self indexOfEntryForDelta:delta];
+- (void)goToEntry:(CRWSessionEntry*)entry {
+ DCHECK(entry);
+ if (![_entries containsObject:entry])
+ return;
+ NSInteger newNavigationIndex = [_entries indexOfObject:entry];
+ NSInteger delta = newNavigationIndex - _currentNavigationIndex;
if (delta < 0) {
- [self discardNonCommittedEntries];
for (int i = delta; i < 0; i++) {
base::RecordAction(UserMetricsAction("Back"));
}
- } else if (delta > 0) {
- [self discardTransientEntry];
+ [self discardNonCommittedEntries];
+ } else if (0 < delta) {
for (int i = 0; i < delta; i++) {
base::RecordAction(UserMetricsAction("Forward"));
}
+ [self discardTransientEntry];
+ } else {
+ // delta is 0, no need to change current navigation index.
+ return;
}
+ _previousNavigationIndex = _currentNavigationIndex;
_currentNavigationIndex = newNavigationIndex;
- _previousNavigationIndex = oldNavigationIndex;
-}
-
-- (void)goToEntry:(CRWSessionEntry*)entry {
- DCHECK(entry);
-
- [self discardTransientEntry];
-
- // Check that |entries_| still contains |entry|. |entry| could have been
- // removed by -clearForwardEntries.
- if ([_entries containsObject:entry]) {
- _previousNavigationIndex = self.currentNavigationIndex;
- self.currentNavigationIndex = [_entries indexOfObject:entry];
- }
}
- (void)removeEntryAtIndex:(NSInteger)index {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698