Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 213 _currentNavigationIndex, | 213 _currentNavigationIndex, |
| 214 _previousNavigationIndex, _pendingItemIndex, | 214 _previousNavigationIndex, _pendingItemIndex, |
| 215 _entries, _pendingEntry.get(), | 215 _entries, _pendingEntry.get(), |
| 216 _transientEntry.get()]; | 216 _transientEntry.get()]; |
| 217 } | 217 } |
| 218 | 218 |
| 219 - (web::NavigationItemList)items { | 219 - (web::NavigationItemList)items { |
| 220 return [self itemListForEntryList:self.entries]; | 220 return [self itemListForEntryList:self.entries]; |
| 221 } | 221 } |
| 222 | 222 |
| 223 - (NSUInteger)itemCount { | |
| 224 return [self.entries count]; | |
|
Eugene But (OOO till 7-30)
2017/03/02 23:32:48
nit: self.entries.count
|count| is a property
| |
| 225 } | |
| 226 | |
| 223 - (web::NavigationItemImpl*)currentItem { | 227 - (web::NavigationItemImpl*)currentItem { |
| 224 return self.currentEntry.navigationItemImpl; | 228 return self.currentEntry.navigationItemImpl; |
| 225 } | 229 } |
| 226 | 230 |
| 227 - (web::NavigationItemImpl*)visibleItem { | 231 - (web::NavigationItemImpl*)visibleItem { |
| 228 return self.visibleEntry.navigationItemImpl; | 232 return self.visibleEntry.navigationItemImpl; |
| 229 } | 233 } |
| 230 | 234 |
| 231 - (web::NavigationItemImpl*)pendingItem { | 235 - (web::NavigationItemImpl*)pendingItem { |
| 232 return self.pendingEntry.navigationItemImpl; | 236 return self.pendingEntry.navigationItemImpl; |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 634 NSInteger index = _currentNavigationIndex; | 638 NSInteger index = _currentNavigationIndex; |
| 635 // This will return the first session entry if all other entries are | 639 // This will return the first session entry if all other entries are |
| 636 // redirects, regardless of the transition state of the first entry. | 640 // redirects, regardless of the transition state of the first entry. |
| 637 while (index > 0 && [self isRedirectTransitionForItemAtIndex:index]) { | 641 while (index > 0 && [self isRedirectTransitionForItemAtIndex:index]) { |
| 638 --index; | 642 --index; |
| 639 } | 643 } |
| 640 return [_entries objectAtIndex:index]; | 644 return [_entries objectAtIndex:index]; |
| 641 } | 645 } |
| 642 | 646 |
| 643 - (NSInteger)indexOfItem:(const web::NavigationItem*)item { | 647 - (NSInteger)indexOfItem:(const web::NavigationItem*)item { |
| 644 web::NavigationItemList items = self.items; | 648 for (NSUInteger i = 0; i < [self.entries count]; ++i) { |
|
Eugene But (OOO till 7-30)
2017/03/02 23:32:48
ditto
| |
| 645 for (NSInteger i = 0; i < static_cast<NSInteger>(items.size()); ++i) { | 649 if ([self.entries[i] navigationItem] == item) |
| 646 if (items[i] == item) | 650 return static_cast<NSInteger>(i); |
| 647 return i; | |
| 648 } | 651 } |
| 649 return NSNotFound; | 652 return NSNotFound; |
| 650 } | 653 } |
| 651 | 654 |
| 655 - (web::NavigationItemImpl*)itemAtIndex:(NSInteger)index { | |
| 656 if (index < 0 || [self.entries count] <= static_cast<NSUInteger>(index)) | |
| 657 return nullptr; | |
| 658 return static_cast<web::NavigationItemImpl*>( | |
| 659 [self.entries[index] navigationItem]); | |
| 660 } | |
| 661 | |
| 652 #pragma mark - | 662 #pragma mark - |
| 653 #pragma mark Private methods | 663 #pragma mark Private methods |
| 654 | 664 |
| 655 - (CRWSessionEntry*)sessionEntryWithURL:(const GURL&)url | 665 - (CRWSessionEntry*)sessionEntryWithURL:(const GURL&)url |
| 656 referrer:(const web::Referrer&)referrer | 666 referrer:(const web::Referrer&)referrer |
| 657 transition:(ui::PageTransition)transition | 667 transition:(ui::PageTransition)transition |
| 658 initiationType: | 668 initiationType: |
| 659 (web::NavigationInitiationType)initiationType { | 669 (web::NavigationInitiationType)initiationType { |
| 660 GURL loaded_url(url); | 670 GURL loaded_url(url); |
| 661 BOOL urlWasRewritten = NO; | 671 BOOL urlWasRewritten = NO; |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 688 } | 698 } |
| 689 | 699 |
| 690 - (web::NavigationItemList)itemListForEntryList:(NSArray*)entries { | 700 - (web::NavigationItemList)itemListForEntryList:(NSArray*)entries { |
| 691 web::NavigationItemList list(entries.count); | 701 web::NavigationItemList list(entries.count); |
| 692 for (size_t index = 0; index < entries.count; ++index) | 702 for (size_t index = 0; index < entries.count; ++index) |
| 693 list[index] = [entries[index] navigationItem]; | 703 list[index] = [entries[index] navigationItem]; |
| 694 return list; | 704 return list; |
| 695 } | 705 } |
| 696 | 706 |
| 697 @end | 707 @end |
| OLD | NEW |