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

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

Issue 1409443002: Make Chrome and WebView replace the selected text with the processed text. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address Bo's comments Created 5 years, 2 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/ContentViewCore.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
index 69d11cf978e8029adf93e805b3e2ad632d3cddc1..935ba9bbb7968b56c6d62d1475940b13de62df0a 100644
--- a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
+++ b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
@@ -9,6 +9,7 @@ import android.annotation.TargetApi;
import android.app.Activity;
import android.app.SearchManager;
import android.content.ClipboardManager;
+import android.content.ContentResolver;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.Intent;
@@ -102,10 +103,8 @@ import java.util.Map.Entry;
* being tied to the view system.
*/
@JNINamespace("content")
-public class ContentViewCore implements
- AccessibilityStateChangeListener, ScreenOrientationObserver,
- SystemCaptioningBridge.SystemCaptioningBridgeListener {
-
+public class ContentViewCore implements AccessibilityStateChangeListener, ScreenOrientationObserver,
+ SystemCaptioningBridge.SystemCaptioningBridgeListener {
private static final String TAG = "cr.ContentViewCore";
// Used to avoid enabling zooming in / out if resulting zooming will
@@ -2091,7 +2090,19 @@ public class ContentViewCore implements
intent.putExtra(Intent.EXTRA_PROCESS_TEXT, query);
try {
- getContext().startActivity(intent);
+ if (getContentViewClient().doesPerformProcessText()) {
+ getContentViewClient().startProcessTextIntent(intent);
+ } else {
+ getWindowAndroid().showIntent(
+ intent, new WindowAndroid.IntentCallback() {
+ @Override
+ public void onIntentCompleted(WindowAndroid window,
+ int resultCode, ContentResolver contentResolver,
+ Intent data) {
+ onReceivedProcessTextResult(resultCode, data);
+ }
+ }, null);
+ }
} catch (android.content.ActivityNotFoundException ex) {
// If no app handles it, do nothing.
}
@@ -3044,6 +3055,16 @@ public class ContentViewCore implements
settings.getTextTrackTextShadow(), settings.getTextTrackTextSize());
}
+ public void onReceivedProcessTextResult(int resultCode, Intent data) {
jdduke (slow) 2015/10/22 00:43:56 Javadoc, definitely need some description here of
hush (inactive) 2015/10/22 19:27:37 Done.
+ if (mActionMode == null) return;
jdduke (slow) 2015/10/22 00:43:56 Can you do a sanity check that this works OK with
hush (inactive) 2015/10/22 19:27:37 Yeah.. I just found that it does not always work o
+ if (resultCode == Activity.RESULT_OK && data != null) {
+ CharSequence result = data.getCharSequenceExtra(Intent.EXTRA_PROCESS_TEXT);
+ if (result != null && isSelectionEditable()) {
+ mWebContents.replace(result.toString());
+ }
+ }
+ }
+
/**
* Returns true if accessibility is on and touch exploration is enabled.
*/

Powered by Google App Engine
This is Rietveld 408576698