Chromium Code Reviews| Index: content/public/android/java/src/org/chromium/content_public/browser/NavigationHandle.java |
| diff --git a/content/public/android/java/src/org/chromium/content_public/browser/NavigationHandle.java b/content/public/android/java/src/org/chromium/content_public/browser/NavigationHandle.java |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b223f6aacaef625529676b67bd58efa862e77399 |
| --- /dev/null |
| +++ b/content/public/android/java/src/org/chromium/content_public/browser/NavigationHandle.java |
| @@ -0,0 +1,107 @@ |
| +// Copyright 2016 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. |
| + |
| +package org.chromium.content_public.browser; |
| + |
| +import org.chromium.base.annotations.CalledByNative; |
| +import org.chromium.base.annotations.JNINamespace; |
| +import org.chromium.ui.base.PageTransition; |
| + |
| +/** |
| + * Represents a bundle of information related to a single navigation. NavigationHandles are provided |
| + * to several WebContentsObserver methods to allow observers to track specific navigations. |
| + */ |
| +@JNINamespace("content") |
| +public class NavigationHandle { |
| + private final String mUrl; |
| + private final String mValidatedUrl; |
| + private final boolean mIsInMainFrame; |
| + private final boolean mIsSamePage; |
| + private final int mPageTransition; |
| + private final boolean mHasCommitted; |
| + private final boolean mIsErrorPage; |
| + |
| + @CalledByNative |
| + public static NavigationHandle createNavigationHandle(String url, String validatedUrl, |
| + boolean isInMainFrame, boolean isSamePage, int pageTransition, boolean hasCommitted, |
| + boolean isErrorPage) { |
| + return new NavigationHandle(url, validatedUrl, isInMainFrame, isSamePage, pageTransition, |
| + hasCommitted, isErrorPage); |
| + } |
| + |
| + /** |
| + * Default constructor. |
| + */ |
|
Maria
2016/12/27 19:31:10
nit: How about a comment about this being construc
|
| + public NavigationHandle(String url, String validatedUrl, boolean isInMainFrame, |
|
Maria
2016/12/27 19:31:10
I would make this private since nothing on the Jav
|
| + boolean isSamePage, int pageTransition, boolean hasCommitted, boolean isErrorPage) { |
| + this.mUrl = url; |
| + this.mValidatedUrl = validatedUrl; |
| + this.mIsInMainFrame = isInMainFrame; |
| + this.mIsSamePage = isSamePage; |
| + this.mPageTransition = pageTransition; |
| + this.mHasCommitted = hasCommitted; |
| + this.mIsErrorPage = isErrorPage; |
| + } |
| + |
| + /** |
| + * @return The URL the frame is navigating to. |
| + */ |
| + public String getURL() { |
| + return mUrl; |
| + } |
| + |
| + /** |
| + * @return The validated URL for the navigation. |
| + */ |
| + public String getValidatedURL() { |
| + return mValidatedUrl; |
| + } |
| + |
| + /** |
| + * @return Whether the navigation is happening in the main frame or in a subframe. |
| + */ |
| + public boolean isInMainFrame() { |
| + return mIsInMainFrame; |
| + } |
| + |
| + /** |
| + * Whether the navigation happened within the same page such as fragment navigations or |
| + * pushState/replaceState. |
| + * @return True if same page. |
| + */ |
| + public boolean isSamePage() { |
| + return mIsSamePage; |
| + } |
| + |
| + /** |
| + * @return Page Transition type associated. |
| + */ |
| + public int getPageTransition() { |
| + return mPageTransition; |
| + } |
| + |
| + /** |
| + * Whether the navigation has committed. |
| + * @return True for successful commits or error pages that replace the previous page. |
| + * False for errors that leave the user on the previous page. |
| + */ |
| + public boolean hasCommitted() { |
| + return mHasCommitted; |
| + } |
| + |
| + /** |
| + * Whether the navigation resulted in an error page. |
| + * @return True if the result is an error page. |
| + */ |
| + public boolean isErrorPage() { |
| + return mIsErrorPage; |
| + } |
| + |
| + /** |
| + * @return Whether or not the navigation is a reload. |
| + */ |
| + public boolean isReload() { |
| + return mPageTransition == PageTransition.RELOAD; |
| + } |
| +} |