| 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 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 646 CRWSessionEntry* entry = [_entries objectAtIndex:lastNonRedirectedIndex]; | 646 CRWSessionEntry* entry = [_entries objectAtIndex:lastNonRedirectedIndex]; |
| 647 if (!ui::PageTransitionIsRedirect( | 647 if (!ui::PageTransitionIsRedirect( |
| 648 entry.navigationItem->GetTransitionType())) { | 648 entry.navigationItem->GetTransitionType())) { |
| 649 [entries addObject:entry]; | 649 [entries addObject:entry]; |
| 650 } | 650 } |
| 651 ++lastNonRedirectedIndex; | 651 ++lastNonRedirectedIndex; |
| 652 } | 652 } |
| 653 return entries; | 653 return entries; |
| 654 } | 654 } |
| 655 | 655 |
| 656 - (std::vector<GURL>)currentRedirectedUrls { | |
| 657 std::vector<GURL> results; | |
| 658 if (_pendingEntry) { | |
| 659 web::NavigationItem* item = [_pendingEntry navigationItem]; | |
| 660 results.push_back(item->GetURL()); | |
| 661 | |
| 662 if (!ui::PageTransitionIsRedirect(item->GetTransitionType())) | |
| 663 return results; | |
| 664 } | |
| 665 | |
| 666 if (![_entries count]) | |
| 667 return results; | |
| 668 | |
| 669 NSInteger index = _currentNavigationIndex; | |
| 670 // Add urls in the redirected entries. | |
| 671 while (index >= 0) { | |
| 672 web::NavigationItem* item = [[_entries objectAtIndex:index] navigationItem]; | |
| 673 if (!ui::PageTransitionIsRedirect(item->GetTransitionType())) | |
| 674 break; | |
| 675 results.push_back(item->GetURL()); | |
| 676 --index; | |
| 677 } | |
| 678 // Add the last non-redirected entry. | |
| 679 if (index >= 0) { | |
| 680 web::NavigationItem* item = [[_entries objectAtIndex:index] navigationItem]; | |
| 681 results.push_back(item->GetURL()); | |
| 682 } | |
| 683 return results; | |
| 684 } | |
| 685 | |
| 686 - (BOOL)isSameDocumentNavigationBetweenEntry:(CRWSessionEntry*)firstEntry | 656 - (BOOL)isSameDocumentNavigationBetweenEntry:(CRWSessionEntry*)firstEntry |
| 687 andEntry:(CRWSessionEntry*)secondEntry { | 657 andEntry:(CRWSessionEntry*)secondEntry { |
| 688 if (!firstEntry || !secondEntry || firstEntry == secondEntry) | 658 if (!firstEntry || !secondEntry || firstEntry == secondEntry) |
| 689 return NO; | 659 return NO; |
| 690 NSUInteger firstIndex = [_entries indexOfObject:firstEntry]; | 660 NSUInteger firstIndex = [_entries indexOfObject:firstEntry]; |
| 691 NSUInteger secondIndex = [_entries indexOfObject:secondEntry]; | 661 NSUInteger secondIndex = [_entries indexOfObject:secondEntry]; |
| 692 if (firstIndex == NSNotFound || secondIndex == NSNotFound) | 662 if (firstIndex == NSNotFound || secondIndex == NSNotFound) |
| 693 return NO; | 663 return NO; |
| 694 NSUInteger startIndex = firstIndex < secondIndex ? firstIndex : secondIndex; | 664 NSUInteger startIndex = firstIndex < secondIndex ? firstIndex : secondIndex; |
| 695 NSUInteger endIndex = firstIndex < secondIndex ? secondIndex : firstIndex; | 665 NSUInteger endIndex = firstIndex < secondIndex ? secondIndex : firstIndex; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 771 return [[CRWSessionEntry alloc] initWithNavigationItem:std::move(item)]; | 741 return [[CRWSessionEntry alloc] initWithNavigationItem:std::move(item)]; |
| 772 } | 742 } |
| 773 | 743 |
| 774 - (BOOL)isRedirectTransitionForEntryAtIndex:(NSInteger)index { | 744 - (BOOL)isRedirectTransitionForEntryAtIndex:(NSInteger)index { |
| 775 ui::PageTransition transition = | 745 ui::PageTransition transition = |
| 776 [_entries[index] navigationItem]->GetTransitionType(); | 746 [_entries[index] navigationItem]->GetTransitionType(); |
| 777 return (transition & ui::PAGE_TRANSITION_IS_REDIRECT_MASK) ? YES : NO; | 747 return (transition & ui::PAGE_TRANSITION_IS_REDIRECT_MASK) ? YES : NO; |
| 778 } | 748 } |
| 779 | 749 |
| 780 @end | 750 @end |
| OLD | NEW |