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..6e1fd30072306d649af9d8b5f1121d12fbd6b39e |
| --- /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" |
| + |
| +#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); |
| + // Skips navigation item if it is for a kind of HTTP Redirect. |
|
kkhorimoto
2017/03/17 01:18:01
"Skips" is a little misleading; I would expect a c
pkl (ping after 24h if needed)
2017/03/17 01:25:08
It's not just misleading...it's wrong. Thanks for
|
| + if ((item->GetTransitionType() & ui::PAGE_TRANSITION_IS_REDIRECT_MASK) == 0) |
| + break; |
| + --index; |
| + } |
| + return item; |
| +} |