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

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: Created 3 years, 7 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
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 // Under normal circumstances, |visibleItem| is |lastCommittedItem| so
207 // backward history consists of all entries that precede |lastCommittedItem|.
208 // However, if the visible navigation item is a transient or uncommitted
Eugene But (OOO till 7-30) 2017/04/25 05:49:01 Do we need to include pending item into backwardIt
danyao 2017/04/25 16:31:20 I don't think pendingItem should be included in th
Eugene But (OOO till 7-30) 2017/04/25 20:44:40 Sorry, I incorrectly phrased my question, I meant
Eugene But (OOO till 7-30) 2017/04/25 21:23:10 I think this code would be correct, unless I'm mis
209 // pending item, an example being safe browsing warning interstitials, all
Eugene But (OOO till 7-30) 2017/04/25 05:49:01 s/safe browsing warning/SSL Unlike other platform
danyao 2017/04/25 16:31:20 Done.
210 // committed items should be considered part of the backward history.
211 if (self.visibleItem != self.lastCommittedItem) {
212 items.push_back(self.items[_lastCommittedItemIndex].get());
Eugene But (OOO till 7-30) 2017/04/25 05:49:01 We probably should not include redirect item. Woul
danyao 2017/04/25 16:31:20 The current behavior (starting line 215) is to inc
Eugene But (OOO till 7-30) 2017/04/25 20:44:40 You are right. Please ignore me.
213 }
214
205 for (size_t index = _lastCommittedItemIndex; index > 0; --index) { 215 for (size_t index = _lastCommittedItemIndex; index > 0; --index) {
206 if (![self isRedirectTransitionForItemAtIndex:index]) 216 if (![self isRedirectTransitionForItemAtIndex:index])
207 items.push_back(self.items[index - 1].get()); 217 items.push_back(self.items[index - 1].get());
208 } 218 }
209 return items; 219 return items;
210 } 220 }
211 221
212 - (web::NavigationItemList)forwardItems { 222 - (web::NavigationItemList)forwardItems {
213 web::NavigationItemList items; 223 web::NavigationItemList items;
214 NSUInteger lastNonRedirectedIndex = _lastCommittedItemIndex + 1; 224 NSUInteger lastNonRedirectedIndex = _lastCommittedItemIndex + 1;
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 return item; 667 return item;
658 } 668 }
659 669
660 - (BOOL)isRedirectTransitionForItemAtIndex:(size_t)index { 670 - (BOOL)isRedirectTransitionForItemAtIndex:(size_t)index {
661 DCHECK_LT(index, self.items.size()); 671 DCHECK_LT(index, self.items.size());
662 ui::PageTransition transition = self.items[index]->GetTransitionType(); 672 ui::PageTransition transition = self.items[index]->GetTransitionType();
663 return (transition & ui::PAGE_TRANSITION_IS_REDIRECT_MASK) ? YES : NO; 673 return (transition & ui::PAGE_TRANSITION_IS_REDIRECT_MASK) ? YES : NO;
664 } 674 }
665 675
666 @end 676 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698