| 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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 _currentNavigationIndex, | 214 _currentNavigationIndex, |
| 215 _previousNavigationIndex, _pendingItemIndex, | 215 _previousNavigationIndex, _pendingItemIndex, |
| 216 _entries, _pendingEntry.get(), | 216 _entries, _pendingEntry.get(), |
| 217 _transientEntry.get()]; | 217 _transientEntry.get()]; |
| 218 } | 218 } |
| 219 | 219 |
| 220 - (web::NavigationItemList)items { | 220 - (web::NavigationItemList)items { |
| 221 return [self itemListForEntryList:self.entries]; | 221 return [self itemListForEntryList:self.entries]; |
| 222 } | 222 } |
| 223 | 223 |
| 224 - (NSUInteger)itemCount { |
| 225 return self.entries.count; |
| 226 } |
| 227 |
| 224 - (web::NavigationItemImpl*)currentItem { | 228 - (web::NavigationItemImpl*)currentItem { |
| 225 return self.currentEntry.navigationItemImpl; | 229 return self.currentEntry.navigationItemImpl; |
| 226 } | 230 } |
| 227 | 231 |
| 228 - (web::NavigationItemImpl*)visibleItem { | 232 - (web::NavigationItemImpl*)visibleItem { |
| 229 return self.visibleEntry.navigationItemImpl; | 233 return self.visibleEntry.navigationItemImpl; |
| 230 } | 234 } |
| 231 | 235 |
| 232 - (web::NavigationItemImpl*)pendingItem { | 236 - (web::NavigationItemImpl*)pendingItem { |
| 233 return self.pendingEntry.navigationItemImpl; | 237 return self.pendingEntry.navigationItemImpl; |
| (...skipping 400 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 index = 0; index < self.entries.count; ++index) { |
| 645 for (NSInteger i = 0; i < static_cast<NSInteger>(items.size()); ++i) { | 649 if ([self.entries[index] navigationItem] == item) |
| 646 if (items[i] == item) | 650 return static_cast<NSInteger>(index); |
| 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 28 matching lines...) Expand all Loading... |
| 690 } | 700 } |
| 691 | 701 |
| 692 - (web::NavigationItemList)itemListForEntryList:(NSArray*)entries { | 702 - (web::NavigationItemList)itemListForEntryList:(NSArray*)entries { |
| 693 web::NavigationItemList list(entries.count); | 703 web::NavigationItemList list(entries.count); |
| 694 for (size_t index = 0; index < entries.count; ++index) | 704 for (size_t index = 0; index < entries.count; ++index) |
| 695 list[index] = [entries[index] navigationItem]; | 705 list[index] = [entries[index] navigationItem]; |
| 696 return list; | 706 return list; |
| 697 } | 707 } |
| 698 | 708 |
| 699 @end | 709 @end |
| OLD | NEW |