| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "ios/web/navigation/navigation_manager_impl.h" | 5 #include "ios/web/navigation/navigation_manager_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #import "ios/web/navigation/crw_session_controller+private_constructors.h" | 12 #import "ios/web/navigation/crw_session_controller+private_constructors.h" |
| 13 #import "ios/web/navigation/crw_session_controller.h" | 13 #import "ios/web/navigation/crw_session_controller.h" |
| 14 #import "ios/web/navigation/crw_session_entry.h" | 14 #import "ios/web/navigation/crw_session_entry.h" |
| 15 #include "ios/web/navigation/navigation_item_impl.h" | 15 #include "ios/web/navigation/navigation_item_impl.h" |
| 16 #include "ios/web/navigation/navigation_manager_delegate.h" | 16 #include "ios/web/navigation/navigation_manager_delegate.h" |
| 17 #import "ios/web/navigation/navigation_manager_facade_delegate.h" | 17 #import "ios/web/navigation/navigation_manager_facade_delegate.h" |
| 18 #include "ios/web/public/load_committed_details.h" | 18 #include "ios/web/public/load_committed_details.h" |
| 19 #include "ios/web/public/navigation_item.h" | 19 #include "ios/web/public/navigation_item.h" |
| 20 #include "ios/web/public/web_state/web_state.h" | 20 #include "ios/web/public/web_state/web_state.h" |
| 21 #include "ui/base/page_transition_types.h" | 21 #include "ui/base/page_transition_types.h" |
| 22 | 22 |
| 23 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 24 #error "This file requires ARC support." |
| 25 #endif |
| 26 |
| 23 namespace { | 27 namespace { |
| 24 | 28 |
| 25 // Checks whether or not two URL are an in-page navigation (differing only | 29 // Checks whether or not two URL are an in-page navigation (differing only |
| 26 // in the fragment). | 30 // in the fragment). |
| 27 bool AreURLsInPageNavigation(const GURL& existing_url, const GURL& new_url) { | 31 bool AreURLsInPageNavigation(const GURL& existing_url, const GURL& new_url) { |
| 28 if (existing_url == new_url || !new_url.has_ref()) | 32 if (existing_url == new_url || !new_url.has_ref()) |
| 29 return false; | 33 return false; |
| 30 | 34 |
| 31 url::Replacements<char> replacements; | 35 url::Replacements<char> replacements; |
| 32 replacements.ClearRef(); | 36 replacements.ClearRef(); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 | 81 |
| 78 NavigationManagerImpl::~NavigationManagerImpl() { | 82 NavigationManagerImpl::~NavigationManagerImpl() { |
| 79 // The facade layer should be deleted before this object. | 83 // The facade layer should be deleted before this object. |
| 80 DCHECK(!facade_delegate_); | 84 DCHECK(!facade_delegate_); |
| 81 | 85 |
| 82 [session_controller_ setNavigationManager:nullptr]; | 86 [session_controller_ setNavigationManager:nullptr]; |
| 83 } | 87 } |
| 84 | 88 |
| 85 void NavigationManagerImpl::SetSessionController( | 89 void NavigationManagerImpl::SetSessionController( |
| 86 CRWSessionController* session_controller) { | 90 CRWSessionController* session_controller) { |
| 87 session_controller_.reset([session_controller retain]); | 91 session_controller_.reset(session_controller); |
| 88 [session_controller_ setNavigationManager:this]; | 92 [session_controller_ setNavigationManager:this]; |
| 89 } | 93 } |
| 90 | 94 |
| 91 void NavigationManagerImpl::InitializeSession(NSString* window_name, | 95 void NavigationManagerImpl::InitializeSession(NSString* window_name, |
| 92 NSString* opener_id, | 96 NSString* opener_id, |
| 93 BOOL opened_by_dom, | 97 BOOL opened_by_dom, |
| 94 int opener_navigation_index) { | 98 int opener_navigation_index) { |
| 95 SetSessionController([[[CRWSessionController alloc] | 99 SetSessionController([[CRWSessionController alloc] |
| 96 initWithWindowName:window_name | 100 initWithWindowName:window_name |
| 97 openerId:opener_id | 101 openerId:opener_id |
| 98 openedByDOM:opened_by_dom | 102 openedByDOM:opened_by_dom |
| 99 openerNavigationIndex:opener_navigation_index | 103 openerNavigationIndex:opener_navigation_index |
| 100 browserState:browser_state_] autorelease]); | 104 browserState:browser_state_]); |
| 101 } | 105 } |
| 102 | 106 |
| 103 void NavigationManagerImpl::ReplaceSessionHistory( | 107 void NavigationManagerImpl::ReplaceSessionHistory( |
| 104 ScopedVector<web::NavigationItem> items, | 108 ScopedVector<web::NavigationItem> items, |
| 105 int current_index) { | 109 int current_index) { |
| 106 SetSessionController([[[CRWSessionController alloc] | 110 SetSessionController([[CRWSessionController alloc] |
| 107 initWithNavigationItems:std::move(items) | 111 initWithNavigationItems:std::move(items) |
| 108 currentIndex:current_index | 112 currentIndex:current_index |
| 109 browserState:browser_state_] autorelease]); | 113 browserState:browser_state_]); |
| 110 } | 114 } |
| 111 | 115 |
| 112 void NavigationManagerImpl::SetFacadeDelegate( | 116 void NavigationManagerImpl::SetFacadeDelegate( |
| 113 NavigationManagerFacadeDelegate* facade_delegate) { | 117 NavigationManagerFacadeDelegate* facade_delegate) { |
| 114 facade_delegate_ = facade_delegate; | 118 facade_delegate_ = facade_delegate; |
| 115 } | 119 } |
| 116 | 120 |
| 117 NavigationManagerFacadeDelegate* NavigationManagerImpl::GetFacadeDelegate() | 121 NavigationManagerFacadeDelegate* NavigationManagerImpl::GetFacadeDelegate() |
| 118 const { | 122 const { |
| 119 return facade_delegate_; | 123 return facade_delegate_; |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 NavigationManagerImpl::GetTransientURLRewriters() { | 319 NavigationManagerImpl::GetTransientURLRewriters() { |
| 316 return std::move(transient_url_rewriters_); | 320 return std::move(transient_url_rewriters_); |
| 317 } | 321 } |
| 318 | 322 |
| 319 void NavigationManagerImpl::RemoveTransientURLRewriters() { | 323 void NavigationManagerImpl::RemoveTransientURLRewriters() { |
| 320 transient_url_rewriters_.reset(); | 324 transient_url_rewriters_.reset(); |
| 321 } | 325 } |
| 322 | 326 |
| 323 void NavigationManagerImpl::CopyState( | 327 void NavigationManagerImpl::CopyState( |
| 324 NavigationManagerImpl* navigation_manager) { | 328 NavigationManagerImpl* navigation_manager) { |
| 325 SetSessionController( | 329 SetSessionController([navigation_manager->GetSessionController() copy]); |
| 326 [[navigation_manager->GetSessionController() copy] autorelease]); | |
| 327 } | 330 } |
| 328 | 331 |
| 329 } // namespace web | 332 } // namespace web |
| OLD | NEW |