summaryrefslogtreecommitdiffstats
path: root/android_webview/java
diff options
context:
space:
mode:
authorbenm <benm@chromium.org>2014-11-07 00:47:12 -0800
committerCommit bot <commit-bot@chromium.org>2014-11-07 08:47:35 +0000
commitde1d85133418eaffbf2cc429683e46fa1f9fc03a (patch)
tree5d626a40ea3b5cf85b324a469a4048d4586602c1 /android_webview/java
parentcec4e6d73017e475d7a5b8b5efdf4ede25f34f99 (diff)
downloadchromium_src-de1d85133418eaffbf2cc429683e46fa1f9fc03a.zip
chromium_src-de1d85133418eaffbf2cc429683e46fa1f9fc03a.tar.gz
chromium_src-de1d85133418eaffbf2cc429683e46fa1f9fc03a.tar.bz2
[Android WebView] Implement SmartClipProvider.
Makes AwContents implement the SmartClipProvider interface. For now, we implement in the same way that ContentView. AwContents may have an arbitrary container view, so this allows that container view to invoke the smart clip methods. Review URL: https://codereview.chromium.org/705933002 Cr-Commit-Position: refs/heads/master@{#303208}
Diffstat (limited to 'android_webview/java')
-rw-r--r--android_webview/java/src/org/chromium/android_webview/AwContents.java31
1 files changed, 28 insertions, 3 deletions
diff --git a/android_webview/java/src/org/chromium/android_webview/AwContents.java b/android_webview/java/src/org/chromium/android_webview/AwContents.java
index 37aad23..60b976e 100644
--- a/android_webview/java/src/org/chromium/android_webview/AwContents.java
+++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java
@@ -49,6 +49,7 @@ import org.chromium.content.browser.ContentSettings;
import org.chromium.content.browser.ContentViewClient;
import org.chromium.content.browser.ContentViewCore;
import org.chromium.content.browser.ContentViewStatics;
+import org.chromium.content.browser.SmartClipProvider;
import org.chromium.content.browser.WebContentsObserver;
import org.chromium.content.common.CleanupReference;
import org.chromium.content_public.browser.GestureStateListener;
@@ -81,7 +82,7 @@ import java.util.concurrent.Callable;
* continuous build & test in the open source SDK-based tree).
*/
@JNINamespace("android_webview")
-public class AwContents {
+public class AwContents implements SmartClipProvider {
private static final String TAG = "AwContents";
private static final String WEB_ARCHIVE_EXTENSION = ".mht";
@@ -2234,12 +2235,36 @@ public class AwContents {
return null;
}
+ @Override
public void extractSmartClipData(int x, int y, int width, int height) {
if (!isDestroyed()) mContentViewCore.extractSmartClipData(x, y, width, height);
}
- public void setSmartClipDataListener(ContentViewCore.SmartClipDataListener listener) {
- if (!isDestroyed()) mContentViewCore.setSmartClipDataListener(listener);
+ @Override
+ public void setSmartClipResultHandler(final Handler resultHandler) {
+ if (isDestroyed()) return;
+
+ if (resultHandler == null) {
+ mContentViewCore.setSmartClipDataListener(null);
+ return;
+ }
+ mContentViewCore.setSmartClipDataListener(new ContentViewCore.SmartClipDataListener() {
+ public void onSmartClipDataExtracted(String text, String html, Rect clipRect) {
+ Bundle bundle = new Bundle();
+ bundle.putString("url", mContentViewCore.getWebContents().getVisibleUrl());
+ bundle.putString("title", mContentViewCore.getWebContents().getTitle());
+ bundle.putParcelable("rect", clipRect);
+ bundle.putString("text", text);
+ bundle.putString("html", html);
+ try {
+ Message msg = Message.obtain(resultHandler, 0);
+ msg.setData(bundle);
+ msg.sendToTarget();
+ } catch (Exception e) {
+ Log.e(TAG, "Error calling handler for smart clip data: ", e);
+ }
+ }
+ });
}
// --------------------------------------------------------------------------------------------