| 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> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/format_macros.h" | 13 #include "base/format_macros.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/mac/objc_property_releaser.h" | 15 #include "base/mac/objc_property_releaser.h" |
| 16 #import "base/mac/scoped_nsobject.h" | 16 #import "base/mac/scoped_nsobject.h" |
| 17 #include "base/metrics/user_metrics.h" |
| 17 #include "base/metrics/user_metrics_action.h" | 18 #include "base/metrics/user_metrics_action.h" |
| 18 #include "base/strings/sys_string_conversions.h" | 19 #include "base/strings/sys_string_conversions.h" |
| 19 #import "ios/web/history_state_util.h" | 20 #import "ios/web/history_state_util.h" |
| 20 #import "ios/web/navigation/crw_session_certificate_policy_manager.h" | 21 #import "ios/web/navigation/crw_session_certificate_policy_manager.h" |
| 21 #import "ios/web/navigation/crw_session_controller+private_constructors.h" | 22 #import "ios/web/navigation/crw_session_controller+private_constructors.h" |
| 22 #import "ios/web/navigation/crw_session_entry.h" | 23 #import "ios/web/navigation/crw_session_entry.h" |
| 23 #include "ios/web/navigation/navigation_item_impl.h" | 24 #include "ios/web/navigation/navigation_item_impl.h" |
| 24 #import "ios/web/navigation/navigation_manager_facade_delegate.h" | 25 #import "ios/web/navigation/navigation_manager_facade_delegate.h" |
| 25 #import "ios/web/navigation/navigation_manager_impl.h" | 26 #import "ios/web/navigation/navigation_manager_impl.h" |
| 26 #include "ios/web/navigation/time_smoother.h" | 27 #include "ios/web/navigation/time_smoother.h" |
| 27 #include "ios/web/public/browser_state.h" | 28 #include "ios/web/public/browser_state.h" |
| 28 #include "ios/web/public/browser_url_rewriter.h" | 29 #include "ios/web/public/browser_url_rewriter.h" |
| 29 #include "ios/web/public/referrer.h" | 30 #include "ios/web/public/referrer.h" |
| 30 #include "ios/web/public/ssl_status.h" | 31 #include "ios/web/public/ssl_status.h" |
| 31 #include "ios/web/public/user_metrics.h" | |
| 32 | 32 |
| 33 using base::UserMetricsAction; | 33 using base::UserMetricsAction; |
| 34 | 34 |
| 35 namespace { | 35 namespace { |
| 36 NSString* const kCertificatePolicyManagerKey = @"certificatePolicyManager"; | 36 NSString* const kCertificatePolicyManagerKey = @"certificatePolicyManager"; |
| 37 NSString* const kCurrentNavigationIndexKey = @"currentNavigationIndex"; | 37 NSString* const kCurrentNavigationIndexKey = @"currentNavigationIndex"; |
| 38 NSString* const kEntriesKey = @"entries"; | 38 NSString* const kEntriesKey = @"entries"; |
| 39 NSString* const kLastVisitedTimestampKey = @"lastVisitedTimestamp"; | 39 NSString* const kLastVisitedTimestampKey = @"lastVisitedTimestamp"; |
| 40 NSString* const kOpenerIdKey = @"openerId"; | 40 NSString* const kOpenerIdKey = @"openerId"; |
| 41 NSString* const kOpenedByDOMKey = @"openedByDOM"; | 41 NSString* const kOpenedByDOMKey = @"openedByDOM"; |
| (...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 663 | 663 |
| 664 BOOL hadTransientEntry = _transientEntry != nil; | 664 BOOL hadTransientEntry = _transientEntry != nil; |
| 665 | 665 |
| 666 [self discardNonCommittedEntries]; | 666 [self discardNonCommittedEntries]; |
| 667 | 667 |
| 668 // Going back from a transient entry doesn't require anything beyond | 668 // Going back from a transient entry doesn't require anything beyond |
| 669 // discarding the pending entry. | 669 // discarding the pending entry. |
| 670 if (hadTransientEntry) | 670 if (hadTransientEntry) |
| 671 return; | 671 return; |
| 672 | 672 |
| 673 web::RecordAction(UserMetricsAction("Back")); | 673 base::RecordAction(UserMetricsAction("Back")); |
| 674 _previousNavigationIndex = _currentNavigationIndex; | 674 _previousNavigationIndex = _currentNavigationIndex; |
| 675 // To stop the user getting 'stuck' on redirecting pages they weren't even | 675 // To stop the user getting 'stuck' on redirecting pages they weren't even |
| 676 // aware existed, it is necessary to pass over pages that would immediately | 676 // aware existed, it is necessary to pass over pages that would immediately |
| 677 // result in a redirect (the entry *before* the redirected page). | 677 // result in a redirect (the entry *before* the redirected page). |
| 678 while (_currentNavigationIndex && | 678 while (_currentNavigationIndex && |
| 679 [self transitionForIndex:_currentNavigationIndex] & | 679 [self transitionForIndex:_currentNavigationIndex] & |
| 680 ui::PAGE_TRANSITION_IS_REDIRECT_MASK) { | 680 ui::PAGE_TRANSITION_IS_REDIRECT_MASK) { |
| 681 --_currentNavigationIndex; | 681 --_currentNavigationIndex; |
| 682 } | 682 } |
| 683 | 683 |
| 684 if (_currentNavigationIndex) | 684 if (_currentNavigationIndex) |
| 685 --_currentNavigationIndex; | 685 --_currentNavigationIndex; |
| 686 } | 686 } |
| 687 | 687 |
| 688 - (void)goForward { | 688 - (void)goForward { |
| 689 [self discardTransientEntry]; | 689 [self discardTransientEntry]; |
| 690 | 690 |
| 691 web::RecordAction(UserMetricsAction("Forward")); | 691 base::RecordAction(UserMetricsAction("Forward")); |
| 692 if (_currentNavigationIndex + 1 < static_cast<NSInteger>([_entries count])) { | 692 if (_currentNavigationIndex + 1 < static_cast<NSInteger>([_entries count])) { |
| 693 _previousNavigationIndex = _currentNavigationIndex; | 693 _previousNavigationIndex = _currentNavigationIndex; |
| 694 ++_currentNavigationIndex; | 694 ++_currentNavigationIndex; |
| 695 } | 695 } |
| 696 // To reduce the chance of a redirect kicking in (truncating the history | 696 // To reduce the chance of a redirect kicking in (truncating the history |
| 697 // stack) we skip over any pages that might do this; we detect this by | 697 // stack) we skip over any pages that might do this; we detect this by |
| 698 // looking for when the *next* page had rediection transition type (was | 698 // looking for when the *next* page had rediection transition type (was |
| 699 // auto redirected to). | 699 // auto redirected to). |
| 700 while (_currentNavigationIndex + 1 < | 700 while (_currentNavigationIndex + 1 < |
| 701 (static_cast<NSInteger>([_entries count])) && | 701 (static_cast<NSInteger>([_entries count])) && |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 888 item->SetURL(loaded_url); | 888 item->SetURL(loaded_url); |
| 889 item->SetReferrer(referrer); | 889 item->SetReferrer(referrer); |
| 890 item->SetTransitionType(transition); | 890 item->SetTransitionType(transition); |
| 891 item->SetIsOverridingUserAgent(useDesktopUserAgent); | 891 item->SetIsOverridingUserAgent(useDesktopUserAgent); |
| 892 item->set_is_renderer_initiated(rendererInitiated); | 892 item->set_is_renderer_initiated(rendererInitiated); |
| 893 return [[[CRWSessionEntry alloc] initWithNavigationItem:std::move(item)] | 893 return [[[CRWSessionEntry alloc] initWithNavigationItem:std::move(item)] |
| 894 autorelease]; | 894 autorelease]; |
| 895 } | 895 } |
| 896 | 896 |
| 897 @end | 897 @end |
| OLD | NEW |