Chromium Code Reviews| Index: content/public/android/java/src/org/chromium/content/browser/webcontents/WebContentsImpl.java |
| 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 5150f32ab82bffca49276be51d3bdd3ef9b9b305..8c8f9824669455826d2f28f439960074f53b2ca4 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 |
| @@ -8,6 +8,8 @@ import android.annotation.SuppressLint; |
| import android.graphics.Bitmap; |
| import android.graphics.Rect; |
| import android.os.Bundle; |
| +import android.os.Handler; |
| +import android.os.Message; |
| import android.os.Parcel; |
| import android.os.ParcelUuid; |
| import android.os.Parcelable; |
| @@ -26,6 +28,7 @@ import org.chromium.content_public.browser.ImageDownloadCallback; |
| import org.chromium.content_public.browser.JavaScriptCallback; |
| import org.chromium.content_public.browser.MessagePortService; |
| import org.chromium.content_public.browser.NavigationController; |
| +import org.chromium.content_public.browser.SmartClipCallback; |
| import org.chromium.content_public.browser.WebContents; |
| import org.chromium.content_public.browser.WebContentsObserver; |
| import org.chromium.ui.OverscrollRefreshHandler; |
| @@ -99,6 +102,8 @@ import java.util.UUID; |
| // the same life time as native MediaSession. |
| private MediaSessionImpl mMediaSession; |
| + private SmartClipCallback mSmartClipCallback; |
| + |
| private WebContentsImpl( |
| long nativeWebContentsAndroid, NavigationController navigationController) { |
| mNativeWebContentsAndroid = nativeWebContentsAndroid; |
| @@ -367,6 +372,40 @@ import java.util.UUID; |
| } |
| @Override |
| + public void requestSmartClipExtract(int x, int y, int width, int height) { |
| + nativeRequestSmartClipExtract( |
|
boliu
2017/02/06 13:08:09
check mSmartClipCallback is not null?
aelias_OOO_until_Jul13
2017/02/07 20:48:13
Added an assertion.
|
| + mNativeWebContentsAndroid, mSmartClipCallback, x, y, width, height); |
| + } |
| + |
| + @Override |
| + public void setSmartClipResultHandler(final Handler smartClipHandler) { |
| + if (smartClipHandler == null) { |
| + mSmartClipCallback = null; |
| + return; |
| + } |
| + mSmartClipCallback = new SmartClipCallback() { |
| + @Override |
| + public void onSmartClipDataExtracted(String text, String html) { |
| + Bundle bundle = new Bundle(); |
| + bundle.putString("url", getVisibleUrl()); |
| + bundle.putString("title", getTitle()); |
| + bundle.putString("text", text); |
| + bundle.putString("html", html); |
| + |
| + Message msg = Message.obtain(smartClipHandler, 0); |
|
boliu
2017/02/06 13:08:09
old code had a try/catch block here
aelias_OOO_until_Jul13
2017/02/07 20:48:13
I removed it because it doesn't happen and fine to
|
| + msg.setData(bundle); |
| + msg.sendToTarget(); |
| + } |
| + }; |
| + } |
| + |
| + @CalledByNative |
| + private static void onSmartClipDataExtracted( |
| + String text, String html, SmartClipCallback callback) { |
| + callback.onSmartClipDataExtracted(text, html); |
| + } |
| + |
| + @Override |
| public void requestAccessibilitySnapshot(AccessibilitySnapshotCallback callback) { |
| nativeRequestAccessibilitySnapshot(mNativeWebContentsAndroid, callback); |
| } |
| @@ -545,6 +584,8 @@ import java.util.UUID; |
| private native boolean nativeHasAccessedInitialDocument( |
| long nativeWebContentsAndroid); |
| private native int nativeGetThemeColor(long nativeWebContentsAndroid); |
| + private native void nativeRequestSmartClipExtract(long nativeWebContentsAndroid, |
| + SmartClipCallback callback, int x, int y, int width, int height); |
| private native void nativeRequestAccessibilitySnapshot( |
| long nativeWebContentsAndroid, AccessibilitySnapshotCallback callback); |
| private native void nativeSetOverscrollRefreshHandler( |