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

Side by Side Diff: ios/web/navigation/crw_session_controller.mm

Issue 2838003002: Fix missing back navigation item when pending item is displayed. (Closed)
Patch Set: To match desktop behavior: do not include pending item in session history Created 3 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
« no previous file with comments | « no previous file | ios/web/navigation/crw_session_controller_unittest.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 #import "ios/web/navigation/crw_session_controller.h" 5 #import "ios/web/navigation/crw_session_controller.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <utility> 10 #include <utility>
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 return index == -1 ? nullptr : self.items[index].get(); 195 return index == -1 ? nullptr : self.items[index].get();
196 } 196 }
197 197
198 - (web::NavigationItemImpl*)previousItem { 198 - (web::NavigationItemImpl*)previousItem {
199 NSInteger index = self.previousItemIndex; 199 NSInteger index = self.previousItemIndex;
200 return index == -1 || self.items.empty() ? nullptr : self.items[index].get(); 200 return index == -1 || self.items.empty() ? nullptr : self.items[index].get();
201 } 201 }
202 202
203 - (web::NavigationItemList)backwardItems { 203 - (web::NavigationItemList)backwardItems {
204 web::NavigationItemList items; 204 web::NavigationItemList items;
205
206 // If the current navigation item is a transient item (e.g. SSL interstitial),
207 // the last committed item should also be considered part of the backward
208 // history.
209 if (self.transientItem) {
210 items.push_back(self.items[_lastCommittedItemIndex].get());
kkhorimoto 2017/04/26 10:50:37 Optional nit: items.push_back(self.lastCommittedIt
211 }
212
205 for (size_t index = _lastCommittedItemIndex; index > 0; --index) { 213 for (size_t index = _lastCommittedItemIndex; index > 0; --index) {
206 if (![self isRedirectTransitionForItemAtIndex:index]) 214 if (![self isRedirectTransitionForItemAtIndex:index])
207 items.push_back(self.items[index - 1].get()); 215 items.push_back(self.items[index - 1].get());
208 } 216 }
209 return items; 217 return items;
210 } 218 }
211 219
212 - (web::NavigationItemList)forwardItems { 220 - (web::NavigationItemList)forwardItems {
213 web::NavigationItemList items; 221 web::NavigationItemList items;
214 NSUInteger lastNonRedirectedIndex = _lastCommittedItemIndex + 1; 222 NSUInteger lastNonRedirectedIndex = _lastCommittedItemIndex + 1;
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 return item; 665 return item;
658 } 666 }
659 667
660 - (BOOL)isRedirectTransitionForItemAtIndex:(size_t)index { 668 - (BOOL)isRedirectTransitionForItemAtIndex:(size_t)index {
661 DCHECK_LT(index, self.items.size()); 669 DCHECK_LT(index, self.items.size());
662 ui::PageTransition transition = self.items[index]->GetTransitionType(); 670 ui::PageTransition transition = self.items[index]->GetTransitionType();
663 return (transition & ui::PAGE_TRANSITION_IS_REDIRECT_MASK) ? YES : NO; 671 return (transition & ui::PAGE_TRANSITION_IS_REDIRECT_MASK) ? YES : NO;
664 } 672 }
665 673
666 @end 674 @end
OLDNEW
« no previous file with comments | « no previous file | ios/web/navigation/crw_session_controller_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698