OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ios/web/navigation/navigation_manager_util.h" |
| 6 |
| 7 #import "ios/web/public/navigation_item.h" |
| 8 #import "ios/web/public/navigation_manager.h" |
| 9 |
| 10 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 11 #error "This file requires ARC support." |
| 12 #endif |
| 13 |
| 14 namespace web { |
| 15 |
| 16 NavigationItem* GetCommittedItemWithUniqueID( |
| 17 NavigationManager* navigation_manager, |
| 18 int unique_id) { |
| 19 int index = GetCommittedItemIndexWithUniqueID(navigation_manager, unique_id); |
| 20 return index != -1 ? navigation_manager->GetItemAtIndex(index) : nullptr; |
| 21 } |
| 22 |
| 23 int GetCommittedItemIndexWithUniqueID(NavigationManager* navigation_manager, |
| 24 int unique_id) { |
| 25 for (int i = 0; i < navigation_manager->GetItemCount(); i++) { |
| 26 web::NavigationItem* item = navigation_manager->GetItemAtIndex(i); |
| 27 if (item->GetUniqueID() == unique_id) { |
| 28 return i; |
| 29 } |
| 30 } |
| 31 return -1; |
| 32 } |
| 33 |
| 34 } // namespace web |
OLD | NEW |