Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Unified Diff: ios/chrome/browser/native_app_launcher/native_app_navigation_util.mm

Issue 2650563002: Pass WebState to NativeAppNavigationController (Closed)
Patch Set: fixed import vs. include Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ios/chrome/browser/native_app_launcher/native_app_navigation_util.mm
diff --git a/ios/chrome/browser/native_app_launcher/native_app_navigation_util.mm b/ios/chrome/browser/native_app_launcher/native_app_navigation_util.mm
new file mode 100644
index 0000000000000000000000000000000000000000..7a6c34e73252c18af0890885407f52eaa80708d0
--- /dev/null
+++ b/ios/chrome/browser/native_app_launcher/native_app_navigation_util.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_util.h"
+
+#include "base/logging.h"
+#include "ios/web/public/navigation_item.h"
+#include "ios/web/public/navigation_manager.h"
+#import "ios/web/public/web_state/web_state.h"
+
+namespace native_app_launcher {
+
+bool IsLinkNavigation(web::WebState* web_state) {
+ web::NavigationManager* navigationManager = web_state->GetNavigationManager();
+ DCHECK(navigationManager);
+ int index = navigationManager->GetCurrentItemIndex();
+ // Walks backward on the navigation items list looking for the first item
+ // that is not the result of a redirect. Check if user arrived at that
+ // via link click or a suggestion on the UI.
+ 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

Powered by Google App Engine
This is Rietveld 408576698