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

Unified Diff: android_webview/java/src/org/chromium/android_webview/AwContents.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: 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 9ebbb5b57ef8576cac1111b73192d98c93ad29ca..df5b6b386ea7eecfb1e6764fecc6136d0a01998e 100644
--- a/android_webview/java/src/org/chromium/android_webview/AwContents.java
+++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java
@@ -60,6 +60,7 @@ import org.chromium.base.annotations.SuppressFBWarnings;
import org.chromium.components.navigation_interception.InterceptNavigationDelegate;
import org.chromium.components.navigation_interception.NavigationParams;
import org.chromium.content.browser.AppWebMessagePort;
+import org.chromium.content.browser.ContentClassFactory;
boliu 2017/04/25 20:30:28 layer violation
import org.chromium.content.browser.ContentViewCore;
import org.chromium.content.browser.ContentViewStatics;
import org.chromium.content.browser.SmartClipProvider;
@@ -69,6 +70,7 @@ import org.chromium.content_public.browser.LoadUrlParams;
import org.chromium.content_public.browser.MessagePort;
import org.chromium.content_public.browser.NavigationController;
import org.chromium.content_public.browser.NavigationHistory;
+import org.chromium.content_public.browser.TextClassifierProvider;
import org.chromium.content_public.browser.WebContents;
import org.chromium.content_public.browser.navigation_controller.LoadURLType;
import org.chromium.content_public.browser.navigation_controller.UserAgentOverrideOption;
@@ -1037,6 +1039,12 @@ public class AwContents implements SmartClipProvider {
* ^^^^^^^^^ See the native class declaration for more details on relative object lifetimes.
*/
private void setNewAwContents(long newAwContentsPtr) {
+ TextClassifierProvider textClassifierProvider = (mWebContents != null)
+ ? mWebContents.getTextClassifierProvider()
+ : ContentClassFactory.get().createTextClassifierProvider(mContext);
boliu 2017/04/25 20:30:28 simplify the API, if it's null, then content will
+
+ assert textClassifierProvider != null;
+
if (mNativeAwContents != 0) {
destroyNatives();
mContentViewCore = null;
@@ -1054,6 +1062,7 @@ public class AwContents implements SmartClipProvider {
// WebContent's browser context.
WebContents webContents = nativeGetWebContents(mNativeAwContents);
+ webContents.setTextClassifierProvider(textClassifierProvider);
mWindowAndroid = getWindowAndroid(mContext);
mContentViewCore = new ContentViewCore(mContext, PRODUCT_VERSION);
@@ -2343,6 +2352,14 @@ public class AwContents implements SmartClipProvider {
return (mSettings.getDisabledActionModeMenuItems() & actionModeItem) != actionModeItem;
}
+ public void setTextClassifier(Object textClassifier) {
+ mWebContents.getTextClassifierProvider().setTextClassifier(textClassifier);
+ }
+
+ public Object getTextClassifier() {
+ return mWebContents.getTextClassifierProvider().getTextClassifier();
+ }
+
//--------------------------------------------------------------------------------------------
// View and ViewGroup method implementations
//--------------------------------------------------------------------------------------------

Powered by Google App Engine
This is Rietveld 408576698