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

Unified Diff: ios/chrome/browser/web/navigation_manager_util.mm

Issue 2756483006: Adds NavigationManager util functions to ios/chrome/browser/web/ (Closed)
Patch Set: changed #include to #import and minor renaming. Created 3 years, 9 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/chrome/browser/web/navigation_manager_util.mm
diff --git a/ios/chrome/browser/web/navigation_manager_util.mm b/ios/chrome/browser/web/navigation_manager_util.mm
new file mode 100644
index 0000000000000000000000000000000000000000..bd9a43362b0f40494dd26b220f36ae661e96bc7d
--- /dev/null
+++ b/ios/chrome/browser/web/navigation_manager_util.mm
@@ -0,0 +1,25 @@
+// 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.
+
+#import "ios/chrome/browser/web/navigation_manager_util.h"
+
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
+web::NavigationItem* GetLastNonRedirectedItem(
+ web::NavigationManager* nav_manager) {
+ if (!nav_manager->GetItemCount())
+ return nullptr;
+ int index = nav_manager->GetCurrentItemIndex();
+ web::NavigationItem* item = nullptr;
+ while (index >= 0) {
+ item = nav_manager->GetItemAtIndex(index);
+ // Returns the first non-Redirect item found.
+ if ((item->GetTransitionType() & ui::PAGE_TRANSITION_IS_REDIRECT_MASK) == 0)
+ break;
+ --index;
+ }
+ return item;
+}
« no previous file with comments | « ios/chrome/browser/web/navigation_manager_util.h ('k') | ios/chrome/browser/web/navigation_manager_util_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698