| 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 #import "base/mac/foundation_util.h" | 15 #import "base/mac/foundation_util.h" |
| 16 #import "base/mac/scoped_nsobject.h" | 16 #import "base/mac/scoped_nsobject.h" |
| 17 #include "base/strings/sys_string_conversions.h" | 17 #include "base/strings/sys_string_conversions.h" |
| 18 #include "ios/web/history_state_util.h" | 18 #include "ios/web/history_state_util.h" |
| 19 #import "ios/web/navigation/crw_session_certificate_policy_manager.h" | 19 #import "ios/web/navigation/crw_session_certificate_policy_manager.h" |
| 20 #import "ios/web/navigation/crw_session_controller+private_constructors.h" | 20 #import "ios/web/navigation/crw_session_controller+private_constructors.h" |
| 21 #import "ios/web/navigation/crw_session_entry.h" | 21 #import "ios/web/navigation/crw_session_entry.h" |
| 22 #import "ios/web/navigation/navigation_item_impl.h" | 22 #import "ios/web/navigation/navigation_item_impl.h" |
| 23 #include "ios/web/navigation/navigation_manager_facade_delegate.h" | 23 #include "ios/web/navigation/navigation_manager_facade_delegate.h" |
| 24 #import "ios/web/navigation/navigation_manager_impl.h" | 24 #import "ios/web/navigation/navigation_manager_impl.h" |
| 25 #include "ios/web/navigation/time_smoother.h" | 25 #include "ios/web/navigation/time_smoother.h" |
| 26 #include "ios/web/public/browser_state.h" | 26 #include "ios/web/public/browser_state.h" |
| 27 #include "ios/web/public/browser_url_rewriter.h" | 27 #include "ios/web/public/browser_url_rewriter.h" |
| 28 #include "ios/web/public/referrer.h" | 28 #include "ios/web/public/referrer.h" |
| 29 #include "ios/web/public/ssl_status.h" | 29 #include "ios/web/public/ssl_status.h" |
| 30 #import "ios/web/public/web_client.h" |
| 30 | 31 |
| 31 #if !defined(__has_feature) || !__has_feature(objc_arc) | 32 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 32 #error "This file requires ARC support." | 33 #error "This file requires ARC support." |
| 33 #endif | 34 #endif |
| 34 | 35 |
| 35 @interface CRWSessionController () { | 36 @interface CRWSessionController () { |
| 36 // Weak pointer back to the owning NavigationManager. This is to facilitate | 37 // Weak pointer back to the owning NavigationManager. This is to facilitate |
| 37 // the incremental merging of the two classes. | 38 // the incremental merging of the two classes. |
| 38 web::NavigationManagerImpl* _navigationManager; | 39 web::NavigationManagerImpl* _navigationManager; |
| 39 | 40 |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 | 467 |
| 467 web::Referrer referrer(lastCommittedItem->GetURL(), | 468 web::Referrer referrer(lastCommittedItem->GetURL(), |
| 468 web::ReferrerPolicyDefault); | 469 web::ReferrerPolicyDefault); |
| 469 base::scoped_nsobject<CRWSessionEntry> pushedEntry([self | 470 base::scoped_nsobject<CRWSessionEntry> pushedEntry([self |
| 470 sessionEntryWithURL:URL | 471 sessionEntryWithURL:URL |
| 471 referrer:referrer | 472 referrer:referrer |
| 472 transition:transition | 473 transition:transition |
| 473 initiationType:web::NavigationInitiationType::USER_INITIATED]); | 474 initiationType:web::NavigationInitiationType::USER_INITIATED]); |
| 474 | 475 |
| 475 web::NavigationItemImpl* pushedItem = [pushedEntry navigationItemImpl]; | 476 web::NavigationItemImpl* pushedItem = [pushedEntry navigationItemImpl]; |
| 476 pushedItem->SetIsOverridingUserAgent( | 477 pushedItem->SetUserAgentType(lastCommittedItem->GetUserAgentType()); |
| 477 lastCommittedItem->IsOverridingUserAgent()); | |
| 478 pushedItem->SetSerializedStateObject(stateObject); | 478 pushedItem->SetSerializedStateObject(stateObject); |
| 479 pushedItem->SetIsCreatedFromPushState(true); | 479 pushedItem->SetIsCreatedFromPushState(true); |
| 480 pushedItem->GetSSL() = lastCommittedItem->GetSSL(); | 480 pushedItem->GetSSL() = lastCommittedItem->GetSSL(); |
| 481 | 481 |
| 482 [self clearForwardItems]; | 482 [self clearForwardItems]; |
| 483 // Add the new entry at the end. | 483 // Add the new entry at the end. |
| 484 [_entries addObject:pushedEntry]; | 484 [_entries addObject:pushedEntry]; |
| 485 _previousNavigationIndex = _currentNavigationIndex; | 485 _previousNavigationIndex = _currentNavigationIndex; |
| 486 self.currentNavigationIndex = [_entries count] - 1; | 486 self.currentNavigationIndex = [_entries count] - 1; |
| 487 | 487 |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 671 web::BrowserURLRewriter::GetInstance()->RewriteURLIfNecessary( | 671 web::BrowserURLRewriter::GetInstance()->RewriteURLIfNecessary( |
| 672 &loaded_url, _browserState); | 672 &loaded_url, _browserState); |
| 673 } | 673 } |
| 674 | 674 |
| 675 std::unique_ptr<web::NavigationItemImpl> item(new web::NavigationItemImpl()); | 675 std::unique_ptr<web::NavigationItemImpl> item(new web::NavigationItemImpl()); |
| 676 item->SetOriginalRequestURL(loaded_url); | 676 item->SetOriginalRequestURL(loaded_url); |
| 677 item->SetURL(loaded_url); | 677 item->SetURL(loaded_url); |
| 678 item->SetReferrer(referrer); | 678 item->SetReferrer(referrer); |
| 679 item->SetTransitionType(transition); | 679 item->SetTransitionType(transition); |
| 680 item->SetNavigationInitiationType(initiationType); | 680 item->SetNavigationInitiationType(initiationType); |
| 681 if (web::GetWebClient()->IsAppSpecificURL(loaded_url)) |
| 682 item->SetUserAgentType(web::UserAgentType::NONE); |
| 681 return [[CRWSessionEntry alloc] initWithNavigationItem:std::move(item)]; | 683 return [[CRWSessionEntry alloc] initWithNavigationItem:std::move(item)]; |
| 682 } | 684 } |
| 683 | 685 |
| 684 - (BOOL)isRedirectTransitionForItemAtIndex:(NSInteger)index { | 686 - (BOOL)isRedirectTransitionForItemAtIndex:(NSInteger)index { |
| 685 ui::PageTransition transition = | 687 ui::PageTransition transition = |
| 686 [_entries[index] navigationItem]->GetTransitionType(); | 688 [_entries[index] navigationItem]->GetTransitionType(); |
| 687 return (transition & ui::PAGE_TRANSITION_IS_REDIRECT_MASK) ? YES : NO; | 689 return (transition & ui::PAGE_TRANSITION_IS_REDIRECT_MASK) ? YES : NO; |
| 688 } | 690 } |
| 689 | 691 |
| 690 - (web::NavigationItemList)itemListForEntryList:(NSArray*)entries { | 692 - (web::NavigationItemList)itemListForEntryList:(NSArray*)entries { |
| 691 web::NavigationItemList list(entries.count); | 693 web::NavigationItemList list(entries.count); |
| 692 for (size_t index = 0; index < entries.count; ++index) | 694 for (size_t index = 0; index < entries.count; ++index) |
| 693 list[index] = [entries[index] navigationItem]; | 695 list[index] = [entries[index] navigationItem]; |
| 694 return list; | 696 return list; |
| 695 } | 697 } |
| 696 | 698 |
| 697 @end | 699 @end |
| OLD | NEW |