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

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

Issue 2756483006: Adds NavigationManager util functions to ios/chrome/browser/web/ (Closed)
Patch Set: added dependencies to BUILD.gn 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..76e54049e9aba75c3fd680abee0e5833fdc21da5
--- /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.
+
+#include "ios/chrome/browser/web/navigation_manager_util.h"
Eugene But (OOO till 7-30) 2017/03/17 14:32:04 s/include/import
pkl (ping after 24h if needed) 2017/03/17 20:23:53 Done.
+
+#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;
+}

Powered by Google App Engine
This is Rietveld 408576698