Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Side by Side Diff: ios/web/navigation/navigation_manager_util.mm

Issue 2875153003: Added web::GetCommittedItemWithUniqueID function. (Closed)
Patch Set: Added GetCommittedItemIndexWithUniqueID Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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
OLDNEW
« no previous file with comments | « ios/web/navigation/navigation_manager_util.h ('k') | ios/web/navigation/navigation_manager_util_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698