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

Unified Diff: ios/web/navigation/navigation_manager_util.mm

Issue 2875153003: Added web::GetCommittedItemWithUniqueID function. (Closed)
Patch Set: Added GetCommittedItemIndexWithUniqueID Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: ios/web/navigation/navigation_manager_util.mm
diff --git a/ios/web/navigation/navigation_manager_util.mm b/ios/web/navigation/navigation_manager_util.mm
new file mode 100644
index 0000000000000000000000000000000000000000..296aa2999403610410013021484c6c6e23f72376
--- /dev/null
+++ b/ios/web/navigation/navigation_manager_util.mm
@@ -0,0 +1,34 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ios/web/navigation/navigation_manager_util.h"
+
+#import "ios/web/public/navigation_item.h"
+#import "ios/web/public/navigation_manager.h"
+
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
+namespace web {
+
+NavigationItem* GetCommittedItemWithUniqueID(
+ NavigationManager* navigation_manager,
+ int unique_id) {
+ int index = GetCommittedItemIndexWithUniqueID(navigation_manager, unique_id);
+ return index != -1 ? navigation_manager->GetItemAtIndex(index) : nullptr;
+}
+
+int GetCommittedItemIndexWithUniqueID(NavigationManager* navigation_manager,
+ int unique_id) {
+ for (int i = 0; i < navigation_manager->GetItemCount(); i++) {
+ web::NavigationItem* item = navigation_manager->GetItemAtIndex(i);
+ if (item->GetUniqueID() == unique_id) {
+ return i;
+ }
+ }
+ return -1;
+}
+
+} // namespace web
« 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