From 7df471a6892305f56a3b441eccff1be0145a067c Mon Sep 17 00:00:00 2001 From: tedchoc Date: Thu, 30 Oct 2014 17:04:51 -0700 Subject: [PATCH] [Android] Expose WebContents IsLoading methods to java. BUG=428538 Review URL: https://codereview.chromium.org/690083005 Cr-Commit-Position: refs/heads/master@{#302195} --- content/browser/web_contents/web_contents_android.cc | 9 +++++++++ content/browser/web_contents/web_contents_android.h | 4 ++++ .../content/browser/webcontents/WebContentsImpl.java | 12 ++++++++++++ .../src/org/chromium/content_public/browser/WebContents.java | 11 +++++++++++ 4 files changed, 36 insertions(+) diff --git a/content/browser/web_contents/web_contents_android.cc b/content/browser/web_contents/web_contents_android.cc index 906ec99a0758..85490c178b8f 100644 --- a/content/browser/web_contents/web_contents_android.cc +++ b/content/browser/web_contents/web_contents_android.cc @@ -99,6 +99,15 @@ ScopedJavaLocalRef WebContentsAndroid::GetVisibleURL( env, web_contents_->GetVisibleURL().spec()); } +bool WebContentsAndroid::IsLoading(JNIEnv* env, jobject obj) const { + return web_contents_->IsLoading(); +} + +bool WebContentsAndroid::IsLoadingToDifferentDocument(JNIEnv* env, + jobject obj) const { + return web_contents_->IsLoadingToDifferentDocument(); +} + void WebContentsAndroid::Stop(JNIEnv* env, jobject obj) { web_contents_->Stop(); } diff --git a/content/browser/web_contents/web_contents_android.h b/content/browser/web_contents/web_contents_android.h index 6da02bb128b4..4b79231c0057 100644 --- a/content/browser/web_contents/web_contents_android.h +++ b/content/browser/web_contents/web_contents_android.h @@ -41,6 +41,10 @@ class CONTENT_EXPORT WebContentsAndroid jobject obj) const; base::android::ScopedJavaLocalRef GetVisibleURL(JNIEnv* env, jobject obj) const; + + bool IsLoading(JNIEnv* env, jobject obj) const; + bool IsLoadingToDifferentDocument(JNIEnv* env, jobject obj) const; + void Stop(JNIEnv* env, jobject obj); jint GetBackgroundColor(JNIEnv* env, jobject obj); base::android::ScopedJavaLocalRef GetURL(JNIEnv* env, jobject) const; diff --git a/content/public/android/java/src/org/chromium/content/browser/webcontents/WebContentsImpl.java b/content/public/android/java/src/org/chromium/content/browser/webcontents/WebContentsImpl.java index 311ca87b879d..db7875b35435 100644 --- a/content/public/android/java/src/org/chromium/content/browser/webcontents/WebContentsImpl.java +++ b/content/public/android/java/src/org/chromium/content/browser/webcontents/WebContentsImpl.java @@ -64,6 +64,16 @@ import org.chromium.content_public.browser.WebContents; } @Override + public boolean isLoading() { + return nativeIsLoading(mNativeWebContentsAndroid); + } + + @Override + public boolean isLoadingToDifferentDocument() { + return nativeIsLoadingToDifferentDocument(mNativeWebContentsAndroid); + } + + @Override public void stop() { nativeStop(mNativeWebContentsAndroid); } @@ -244,6 +254,8 @@ import org.chromium.content_public.browser.WebContents; private native String nativeGetTitle(long nativeWebContentsAndroid); private native String nativeGetVisibleURL(long nativeWebContentsAndroid); + private native boolean nativeIsLoading(long nativeWebContentsAndroid); + private native boolean nativeIsLoadingToDifferentDocument(long nativeWebContentsAndroid); private native void nativeStop(long nativeWebContentsAndroid); private native void nativeInsertCSS(long nativeWebContentsAndroid, String css); private native void nativeOnHide(long nativeWebContentsAndroid); diff --git a/content/public/android/java/src/org/chromium/content_public/browser/WebContents.java b/content/public/android/java/src/org/chromium/content_public/browser/WebContents.java index e3de2bdf5ec7..a519d09905b0 100644 --- a/content/public/android/java/src/org/chromium/content_public/browser/WebContents.java +++ b/content/public/android/java/src/org/chromium/content_public/browser/WebContents.java @@ -24,6 +24,17 @@ public interface WebContents { String getVisibleUrl(); /** + * @return Whether this WebContents is loading a resource. + */ + boolean isLoading(); + + /** + * @return Whether this WebContents is loading and and the load is to a different top-level + * document (rather than being a navigation within the same document). + */ + boolean isLoadingToDifferentDocument(); + + /** * Stop any pending navigation. */ void stop(); -- 2.11.4.GIT