| 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 |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 } | 386 } |
| 387 --result; | 387 --result; |
| 388 ++offset; | 388 ++offset; |
| 389 } | 389 } |
| 390 // Result may be out of bounds, so stop trying to skip redirect items and | 390 // Result may be out of bounds, so stop trying to skip redirect items and |
| 391 // simply add the remainder. | 391 // simply add the remainder. |
| 392 result += offset; | 392 result += offset; |
| 393 if (result > GetItemCount() /* overflow */) | 393 if (result > GetItemCount() /* overflow */) |
| 394 result = INT_MIN; | 394 result = INT_MIN; |
| 395 } else if (offset > 0) { | 395 } else if (offset > 0) { |
| 396 if (GetPendingItem() && [session_controller_ pendingItemIndex] == -1) { | |
| 397 // Chrome for iOS does not allow forward navigation if there is another | |
| 398 // pending navigation in progress. Returning invalid index indicates that | |
| 399 // forward navigation will not be allowed (and |INT_MAX| works for that). | |
| 400 // This is different from other platforms which allow forward navigation | |
| 401 // if pending item exist. | |
| 402 // TODO(crbug.com/661858): Remove this once back-forward navigation uses | |
| 403 // pending index. | |
| 404 return INT_MAX; | |
| 405 } | |
| 406 while (offset > 0 && result < GetItemCount()) { | 396 while (offset > 0 && result < GetItemCount()) { |
| 407 ++result; | 397 ++result; |
| 408 --offset; | 398 --offset; |
| 409 // As with going back, skip over redirects. | 399 // As with going back, skip over redirects. |
| 410 while (result + 1 < GetItemCount() && IsRedirectItemAtIndex(result + 1)) { | 400 while (result + 1 < GetItemCount() && IsRedirectItemAtIndex(result + 1)) { |
| 411 ++result; | 401 ++result; |
| 412 } | 402 } |
| 413 } | 403 } |
| 414 // Result may be out of bounds, so stop trying to skip redirect items and | 404 // Result may be out of bounds, so stop trying to skip redirect items and |
| 415 // simply add the remainder. | 405 // simply add the remainder. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 const ScopedNavigationItemImplList& items = [session_controller_ items]; | 439 const ScopedNavigationItemImplList& items = [session_controller_ items]; |
| 450 while (index >= 0) { | 440 while (index >= 0) { |
| 451 NavigationItem* item = items[index--].get(); | 441 NavigationItem* item = items[index--].get(); |
| 452 if (!client->IsAppSpecificURL(item->GetVirtualURL())) | 442 if (!client->IsAppSpecificURL(item->GetVirtualURL())) |
| 453 return item; | 443 return item; |
| 454 } | 444 } |
| 455 return nullptr; | 445 return nullptr; |
| 456 } | 446 } |
| 457 | 447 |
| 458 } // namespace web | 448 } // namespace web |
| OLD | NEW |