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

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

Issue 2756483006: Adds NavigationManager util functions to ios/chrome/browser/web/ (Closed)
Patch Set: changed #include to #import and minor renaming. Created 3 years, 9 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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 - (web::NavigationItemImpl*)lastCommittedItem { 199 - (web::NavigationItemImpl*)lastCommittedItem {
200 NSInteger index = self.currentNavigationIndex; 200 NSInteger index = self.currentNavigationIndex;
201 return index == -1 ? nullptr : self.items[index].get(); 201 return index == -1 ? nullptr : self.items[index].get();
202 } 202 }
203 203
204 - (web::NavigationItemImpl*)previousItem { 204 - (web::NavigationItemImpl*)previousItem {
205 NSInteger index = self.previousNavigationIndex; 205 NSInteger index = self.previousNavigationIndex;
206 return index == -1 || self.items.empty() ? nullptr : self.items[index].get(); 206 return index == -1 || self.items.empty() ? nullptr : self.items[index].get();
207 } 207 }
208 208
209 - (web::NavigationItemImpl*)lastUserItem {
210 if (self.items.empty())
211 return nil;
212
213 NSInteger index = self.currentNavigationIndex;
214 // This will return the first NavigationItem if all other items are
215 // redirects, regardless of the transition state of the first item.
216 while (index > 0 && [self isRedirectTransitionForItemAtIndex:index])
217 --index;
218
219 return self.items[index].get();
220 }
221
222 - (web::NavigationItemList)backwardItems { 209 - (web::NavigationItemList)backwardItems {
223 web::NavigationItemList items; 210 web::NavigationItemList items;
224 for (size_t index = _currentNavigationIndex; index > 0; --index) { 211 for (size_t index = _currentNavigationIndex; index > 0; --index) {
225 if (![self isRedirectTransitionForItemAtIndex:index]) 212 if (![self isRedirectTransitionForItemAtIndex:index])
226 items.push_back(self.items[index - 1].get()); 213 items.push_back(self.items[index - 1].get());
227 } 214 }
228 return items; 215 return items;
229 } 216 }
230 217
231 - (web::NavigationItemList)forwardItems { 218 - (web::NavigationItemList)forwardItems {
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 return item; 626 return item;
640 } 627 }
641 628
642 - (BOOL)isRedirectTransitionForItemAtIndex:(size_t)index { 629 - (BOOL)isRedirectTransitionForItemAtIndex:(size_t)index {
643 DCHECK_LT(index, self.items.size()); 630 DCHECK_LT(index, self.items.size());
644 ui::PageTransition transition = self.items[index]->GetTransitionType(); 631 ui::PageTransition transition = self.items[index]->GetTransitionType();
645 return (transition & ui::PAGE_TRANSITION_IS_REDIRECT_MASK) ? YES : NO; 632 return (transition & ui::PAGE_TRANSITION_IS_REDIRECT_MASK) ? YES : NO;
646 } 633 }
647 634
648 @end 635 @end
OLDNEW
« no previous file with comments | « ios/web/navigation/crw_session_controller.h ('k') | ios/web/navigation/navigation_manager_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698