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

Unified Diff: content/public/android/java/src/org/chromium/content/browser/ContextSelectionClient.java

Issue 2835323003: [SmartText selection] Implement TextClassifier getter and setter
Patch Set: Created 3 years, 8 months 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
Index: content/public/android/java/src/org/chromium/content/browser/ContextSelectionClient.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/ContextSelectionClient.java b/content/public/android/java/src/org/chromium/content/browser/ContextSelectionClient.java
index 6a8bcea1be127d6450024cd13c9400a3b5a49a39..b898a48debe26d7ba8dc3d12a47349eb83bed1e0 100644
--- a/content/public/android/java/src/org/chromium/content/browser/ContextSelectionClient.java
+++ b/content/public/android/java/src/org/chromium/content/browser/ContextSelectionClient.java
@@ -7,10 +7,11 @@ package org.chromium.content.browser;
import android.support.annotation.IntDef;
import android.text.TextUtils;
+import org.chromium.base.Log;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace;
+import org.chromium.content_public.browser.TextClassifierProvider;
import org.chromium.content_public.browser.WebContents;
-import org.chromium.ui.base.WindowAndroid;
import org.chromium.ui.touch_selection.SelectionEventType;
import java.lang.annotation.Retention;
@@ -39,6 +40,8 @@ public class ContextSelectionClient implements SelectionClient {
// Used for surrounding text request.
private static final int NUM_EXTRA_CHARS = 100;
+ private static final String TAG = "ContextSelClient"; // 20 characters limit
+
private long mNativeContextSelectionClient;
private ContextSelectionProvider mProvider;
private ContextSelectionProvider.ResultCallback mCallback;
@@ -47,10 +50,15 @@ public class ContextSelectionClient implements SelectionClient {
* Creates the ContextSelectionClient. Returns null in case ContextSelectionProvider
* does not exist in the system.
*/
- public static ContextSelectionClient create(ContextSelectionProvider.ResultCallback callback,
- WindowAndroid windowAndroid, WebContents webContents) {
+ public static ContextSelectionClient create(
+ ContextSelectionProvider.ResultCallback callback, WebContents webContents) {
+ TextClassifierProvider tc_provider = webContents.getTextClassifierProvider();
boliu 2017/04/25 20:30:28 camelCase
+ if (tc_provider == null) {
+ Log.e(TAG, "Cannot create object: no TextClassifierProvider");
boliu 2017/04/25 20:30:28 assert, don't log
+ return null;
+ }
ContextSelectionProvider provider =
- ContentClassFactory.get().createContextSelectionProvider(callback, windowAndroid);
+ ContentClassFactory.get().createContextSelectionProvider(callback, tc_provider);
// ContextSelectionProvider might not exist.
if (provider == null) return null;

Powered by Google App Engine
This is Rietveld 408576698