Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ios/chrome/browser/native_app_launcher/native_app_navigation_util.h" | 5 #include "ios/chrome/browser/native_app_launcher/native_app_navigation_util.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "ios/web/public/navigation_item.h" | 8 #include "ios/web/public/navigation_item.h" |
| 9 #include "ios/web/public/navigation_manager.h" | 9 #include "ios/web/public/navigation_manager.h" |
| 10 #import "ios/web/public/web_state/web_state.h" | 10 #import "ios/web/public/web_state/web_state.h" |
| 11 | 11 |
| 12 #if !defined(__has_feature) || !__has_feature(objc_arc) | |
| 13 #error "This file requires ARC support." | |
| 14 #endif | |
| 15 | |
| 16 #if !defined(__has_feature) || !__has_feature(objc_arc) | |
|
pkl (ping after 24h if needed)
2017/02/01 00:46:11
twice?
noyau (Ping after 24h)
2017/02/01 11:24:09
Done. And we'll fix the script.
| |
| 17 #error "This file requires ARC support." | |
| 18 #endif | |
| 19 | |
| 12 namespace native_app_launcher { | 20 namespace native_app_launcher { |
| 13 | 21 |
| 14 bool IsLinkNavigation(web::WebState* web_state) { | 22 bool IsLinkNavigation(web::WebState* web_state) { |
| 15 web::NavigationManager* navigationManager = web_state->GetNavigationManager(); | 23 web::NavigationManager* navigationManager = web_state->GetNavigationManager(); |
| 16 DCHECK(navigationManager); | 24 DCHECK(navigationManager); |
| 17 int index = navigationManager->GetCurrentItemIndex(); | 25 int index = navigationManager->GetCurrentItemIndex(); |
| 18 // Walks backward on the navigation items list looking for the first item | 26 // 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 | 27 // that is not the result of a redirect. Check if user arrived at that |
| 20 // via link click or a suggestion on the UI. | 28 // via link click or a suggestion on the UI. |
| 21 while (index >= 0) { | 29 while (index >= 0) { |
| 22 web::NavigationItem* item = navigationManager->GetItemAtIndex(index); | 30 web::NavigationItem* item = navigationManager->GetItemAtIndex(index); |
| 23 DCHECK(item); | 31 DCHECK(item); |
| 24 ui::PageTransition currentTransition = item->GetTransitionType(); | 32 ui::PageTransition currentTransition = item->GetTransitionType(); |
| 25 // Checks non-redirect entries for transitions that are either links or | 33 // Checks non-redirect entries for transitions that are either links or |
| 26 // bookmarks. | 34 // bookmarks. |
| 27 if ((currentTransition & ui::PAGE_TRANSITION_IS_REDIRECT_MASK) == 0) { | 35 if ((currentTransition & ui::PAGE_TRANSITION_IS_REDIRECT_MASK) == 0) { |
| 28 return PageTransitionCoreTypeIs(currentTransition, | 36 return PageTransitionCoreTypeIs(currentTransition, |
| 29 ui::PAGE_TRANSITION_LINK) || | 37 ui::PAGE_TRANSITION_LINK) || |
| 30 PageTransitionCoreTypeIs(currentTransition, | 38 PageTransitionCoreTypeIs(currentTransition, |
| 31 ui::PAGE_TRANSITION_AUTO_BOOKMARK); | 39 ui::PAGE_TRANSITION_AUTO_BOOKMARK); |
| 32 } | 40 } |
| 33 --index; | 41 --index; |
| 34 } | 42 } |
| 35 return false; | 43 return false; |
| 36 } | 44 } |
| 37 | 45 |
| 38 } // namespace native_app_launcher | 46 } // namespace native_app_launcher |
| OLD | NEW |