OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ios/chrome/browser/native_app_launcher/native_app_navigation_util.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 #include "ios/web/public/navigation_item.h" |
| 9 #include "ios/web/public/navigation_manager.h" |
| 10 #import "ios/web/public/web_state/web_state.h" |
| 11 |
| 12 namespace native_app_launcher { |
| 13 |
| 14 bool IsLinkNavigation(web::WebState* web_state) { |
| 15 web::NavigationManager* navigationManager = web_state->GetNavigationManager(); |
| 16 DCHECK(navigationManager); |
| 17 int index = navigationManager->GetCurrentItemIndex(); |
| 18 // Walks backward on the navigation items list looking for the first item |
| 19 // that is not the result of a redirect. Check if user arrived at that |
| 20 // via link click or a suggestion on the UI. |
| 21 while (index >= 0) { |
| 22 web::NavigationItem* item = navigationManager->GetItemAtIndex(index); |
| 23 DCHECK(item); |
| 24 ui::PageTransition currentTransition = item->GetTransitionType(); |
| 25 // Checks non-redirect entries for transitions that are either links or |
| 26 // bookmarks. |
| 27 if ((currentTransition & ui::PAGE_TRANSITION_IS_REDIRECT_MASK) == 0) { |
| 28 return PageTransitionCoreTypeIs(currentTransition, |
| 29 ui::PAGE_TRANSITION_LINK) || |
| 30 PageTransitionCoreTypeIs(currentTransition, |
| 31 ui::PAGE_TRANSITION_AUTO_BOOKMARK); |
| 32 } |
| 33 --index; |
| 34 } |
| 35 return false; |
| 36 } |
| 37 |
| 38 } // namespace native_app_launcher |
OLD | NEW |