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

Unified Diff: android_webview/java/src/org/chromium/android_webview/AwContents.java

Issue 705933002: [Android WebView] Implement SmartClipProvider. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: android_webview/java/src/org/chromium/android_webview/AwContents.java
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 37aad23306bdd6098201359fecfe1dfce0f1b772..60b976ea868cdc190eeb8fcf0679514edf092a67 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 {
boliu 2014/11/07 01:12:23 drive-by suggestion: pull this out into a helper c
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);
+ }
+ }
+ });
}
// --------------------------------------------------------------------------------------------
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698