Index: ios/chrome/browser/native_app_launcher/native_app_navigation_utils.mm |
diff --git a/ios/chrome/browser/native_app_launcher/native_app_navigation_utils.mm b/ios/chrome/browser/native_app_launcher/native_app_navigation_utils.mm |
new file mode 100644 |
index 0000000000000000000000000000000000000000..80af7ed6ac1b69a0811b3857dd4d41e06ff496cb |
--- /dev/null |
+++ b/ios/chrome/browser/native_app_launcher/native_app_navigation_utils.mm |
@@ -0,0 +1,38 @@ |
+// 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/native_app_launcher/native_app_navigation_utils.h" |
+ |
+#include "base/logging.h" |
+#import "ios/web/navigation/navigation_manager_impl.h" |
Eugene But (OOO till 7-30)
2017/01/26 01:04:38
do we need this include?
pkl (ping after 24h if needed)
2017/01/26 02:26:28
Not this one, but we do need ios/web/public/naviga
|
+#include "ios/web/public/navigation_item.h" |
+#include "ios/web/public/web_state/web_state.h" |
Eugene But (OOO till 7-30)
2017/01/26 01:04:38
s/include/import
pkl (ping after 24h if needed)
2017/01/26 02:26:28
web_state.h is all C++ code, so should be #include
Eugene But (OOO till 7-30)
2017/01/26 03:10:02
Line 26 is Objective-C code.
pkl (ping after 24h if needed)
2017/01/26 19:44:24
Done.
|
+ |
+namespace native_app_launcher { |
+ |
+bool IsLinkNavigation(web::WebState* webState) { |
Eugene But (OOO till 7-30)
2017/01/26 01:04:39
Please use C++ Style for variables
pkl (ping after 24h if needed)
2017/01/26 02:26:28
Done.
|
+ web::NavigationManager* navigationManager = webState->GetNavigationManager(); |
+ if (!navigationManager) |
+ return false; |
Eugene But (OOO till 7-30)
2017/01/26 01:04:38
Can this ever happen? I think NavigationManager li
pkl (ping after 24h if needed)
2017/01/26 02:26:28
web_state.h says "Can never return null". Cool! Tu
|
+ int index = navigationManager->GetCurrentItemIndex(); |
+ // Walks backward on the navigation items for the first item that is not a |
Eugene But (OOO till 7-30)
2017/01/26 01:04:38
nit: s/Walks/Walk
pkl (ping after 24h if needed)
2017/01/26 02:26:28
I recall that comments should be third-person sing
Eugene But (OOO till 7-30)
2017/01/26 03:10:02
I guess you referring to Style Guide: "Use descrip
pkl (ping after 24h if needed)
2017/01/26 19:44:24
Acknowledged.
|
+ // redirect. |
+ while (index >= 0) { |
+ web::NavigationItem* item = navigationManager->GetItemAtIndex(index); |
+ DCHECK(item); |
+ ui::PageTransition currentTransition = item->GetTransitionType(); |
+ // Checks non-redirect entries for transitions that are either links or |
+ // bookmarks. |
+ if ((currentTransition & ui::PAGE_TRANSITION_IS_REDIRECT_MASK) == 0) { |
+ return PageTransitionCoreTypeIs(currentTransition, |
+ ui::PAGE_TRANSITION_LINK) || |
+ PageTransitionCoreTypeIs(currentTransition, |
+ ui::PAGE_TRANSITION_AUTO_BOOKMARK); |
+ } |
+ --index; |
+ } |
+ return false; |
+} |
+ |
+} // namespace native_app_launcher |