| 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 #import "ios/web/navigation/navigation_manager_impl.h" | 5 #import "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 #import "ios/web/navigation/navigation_item_impl.h" | 15 #import "ios/web/navigation/navigation_item_impl.h" |
| 16 #import "ios/web/navigation/navigation_manager_delegate.h" | 16 #import "ios/web/navigation/navigation_manager_delegate.h" |
| 17 #include "ios/web/navigation/navigation_manager_facade_delegate.h" | 17 #include "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 #import "ios/web/public/navigation_item.h" | 19 #import "ios/web/public/navigation_item.h" |
| 20 #import "ios/web/public/web_state/web_state.h" | 20 #import "ios/web/public/web_state/web_state.h" |
| 21 #include "net/base/url_util.h" |
| 21 #include "ui/base/page_transition_types.h" | 22 #include "ui/base/page_transition_types.h" |
| 22 | 23 |
| 23 #if !defined(__has_feature) || !__has_feature(objc_arc) | 24 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 24 #error "This file requires ARC support." | 25 #error "This file requires ARC support." |
| 25 #endif | 26 #endif |
| 26 | 27 |
| 27 namespace { | |
| 28 | |
| 29 // Checks whether or not two URL are an in-page navigation (differing only | |
| 30 // in the fragment). | |
| 31 bool AreURLsInPageNavigation(const GURL& existing_url, const GURL& new_url) { | |
| 32 if (existing_url == new_url || !new_url.has_ref()) | |
| 33 return false; | |
| 34 | |
| 35 url::Replacements<char> replacements; | |
| 36 replacements.ClearRef(); | |
| 37 return existing_url.ReplaceComponents(replacements) == | |
| 38 new_url.ReplaceComponents(replacements); | |
| 39 } | |
| 40 | |
| 41 } // anonymous namespace | |
| 42 | |
| 43 namespace web { | 28 namespace web { |
| 44 | 29 |
| 45 NavigationManager::WebLoadParams::WebLoadParams(const GURL& url) | 30 NavigationManager::WebLoadParams::WebLoadParams(const GURL& url) |
| 46 : url(url), | 31 : url(url), |
| 47 transition_type(ui::PAGE_TRANSITION_LINK), | 32 transition_type(ui::PAGE_TRANSITION_LINK), |
| 48 is_renderer_initiated(false), | 33 is_renderer_initiated(false), |
| 49 post_data(nil) {} | 34 post_data(nil) {} |
| 50 | 35 |
| 51 NavigationManager::WebLoadParams::~WebLoadParams() {} | 36 NavigationManager::WebLoadParams::~WebLoadParams() {} |
| 52 | 37 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 | 124 |
| 140 void NavigationManagerImpl::OnNavigationItemCommitted() { | 125 void NavigationManagerImpl::OnNavigationItemCommitted() { |
| 141 LoadCommittedDetails details; | 126 LoadCommittedDetails details; |
| 142 details.item = GetLastCommittedItem(); | 127 details.item = GetLastCommittedItem(); |
| 143 DCHECK(details.item); | 128 DCHECK(details.item); |
| 144 details.previous_item_index = [session_controller_ previousNavigationIndex]; | 129 details.previous_item_index = [session_controller_ previousNavigationIndex]; |
| 145 if (details.previous_item_index >= 0) { | 130 if (details.previous_item_index >= 0) { |
| 146 DCHECK([session_controller_ previousEntry]); | 131 DCHECK([session_controller_ previousEntry]); |
| 147 details.previous_url = | 132 details.previous_url = |
| 148 [session_controller_ previousEntry].navigationItem->GetURL(); | 133 [session_controller_ previousEntry].navigationItem->GetURL(); |
| 149 details.is_in_page = | 134 details.is_in_page = net::IsFragmentAddedOrUpdated(details.previous_url, |
| 150 AreURLsInPageNavigation(details.previous_url, details.item->GetURL()); | 135 details.item->GetURL()); |
| 151 } else { | 136 } else { |
| 152 details.previous_url = GURL(); | 137 details.previous_url = GURL(); |
| 153 details.is_in_page = NO; | 138 details.is_in_page = NO; |
| 154 } | 139 } |
| 155 | 140 |
| 156 delegate_->OnNavigationItemCommitted(details); | 141 delegate_->OnNavigationItemCommitted(details); |
| 157 | 142 |
| 158 if (facade_delegate_) { | 143 if (facade_delegate_) { |
| 159 facade_delegate_->OnNavigationItemCommitted(details.previous_item_index, | 144 facade_delegate_->OnNavigationItemCommitted(details.previous_item_index, |
| 160 details.is_in_page); | 145 details.is_in_page); |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 } | 382 } |
| 398 | 383 |
| 399 bool NavigationManagerImpl::IsRedirectItemAtIndex(int index) const { | 384 bool NavigationManagerImpl::IsRedirectItemAtIndex(int index) const { |
| 400 DCHECK_GT(index, 0); | 385 DCHECK_GT(index, 0); |
| 401 DCHECK_LT(index, GetItemCount()); | 386 DCHECK_LT(index, GetItemCount()); |
| 402 ui::PageTransition transition = GetItemAtIndex(index)->GetTransitionType(); | 387 ui::PageTransition transition = GetItemAtIndex(index)->GetTransitionType(); |
| 403 return transition & ui::PAGE_TRANSITION_IS_REDIRECT_MASK; | 388 return transition & ui::PAGE_TRANSITION_IS_REDIRECT_MASK; |
| 404 } | 389 } |
| 405 | 390 |
| 406 } // namespace web | 391 } // namespace web |
| OLD | NEW |