| 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 |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 | 288 |
| 289 bool NavigationManagerImpl::CanGoBack() const { | 289 bool NavigationManagerImpl::CanGoBack() const { |
| 290 return CanGoToOffset(-1); | 290 return CanGoToOffset(-1); |
| 291 } | 291 } |
| 292 | 292 |
| 293 bool NavigationManagerImpl::CanGoForward() const { | 293 bool NavigationManagerImpl::CanGoForward() const { |
| 294 return CanGoToOffset(1); | 294 return CanGoToOffset(1); |
| 295 } | 295 } |
| 296 | 296 |
| 297 bool NavigationManagerImpl::CanGoToOffset(int offset) const { | 297 bool NavigationManagerImpl::CanGoToOffset(int offset) const { |
| 298 return [session_controller_ canGoDelta:offset]; | 298 int index = GetIndexForOffset(offset); |
| 299 return 0 <= index && index < GetItemCount(); |
| 299 } | 300 } |
| 300 | 301 |
| 301 void NavigationManagerImpl::GoBack() { | 302 void NavigationManagerImpl::GoBack() { |
| 302 delegate_->GoToIndex(GetIndexForOffset(-1)); | 303 delegate_->GoToIndex(GetIndexForOffset(-1)); |
| 303 } | 304 } |
| 304 | 305 |
| 305 void NavigationManagerImpl::GoForward() { | 306 void NavigationManagerImpl::GoForward() { |
| 306 delegate_->GoToIndex(GetIndexForOffset(1)); | 307 delegate_->GoToIndex(GetIndexForOffset(1)); |
| 307 } | 308 } |
| 308 | 309 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 335 void NavigationManagerImpl::CopyState( | 336 void NavigationManagerImpl::CopyState( |
| 336 NavigationManagerImpl* navigation_manager) { | 337 NavigationManagerImpl* navigation_manager) { |
| 337 SetSessionController([navigation_manager->GetSessionController() copy]); | 338 SetSessionController([navigation_manager->GetSessionController() copy]); |
| 338 } | 339 } |
| 339 | 340 |
| 340 int NavigationManagerImpl::GetIndexForOffset(int offset) const { | 341 int NavigationManagerImpl::GetIndexForOffset(int offset) const { |
| 341 return [session_controller_ indexOfEntryForDelta:offset]; | 342 return [session_controller_ indexOfEntryForDelta:offset]; |
| 342 } | 343 } |
| 343 | 344 |
| 344 } // namespace web | 345 } // namespace web |
| OLD | NEW |