Chromium Code Reviews| 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; |
| +} |