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

Unified Diff: android_webview/java/src/org/chromium/android_webview/AwContents.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: 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 ab356ff21ca2bf69c585cbdd21e2cd605082d0f6..75e1f125ec43f0f6a73d6ba0df4a559b08613a1e 100644
--- a/android_webview/java/src/org/chromium/android_webview/AwContents.java
+++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java
@@ -100,6 +100,8 @@ public class AwContents implements SmartClipProvider,
private static final int WARN = 1;
private static final String WEB_ARCHIVE_EXTENSION = ".mht";
+ // The request code should be unique per WebView/AwContents object.
+ private static final int PROCESS_TEXT_REQUEST_CODE = 100;
// Used to avoid enabling zooming in / out if resulting zooming will
// produce little visible difference.
@@ -2210,7 +2212,7 @@ public class AwContents implements SmartClipProvider,
* be thrown by Android framework if startActivityForResult is called with
* a non-Activity context.
*/
- public void startActivityForResult(Intent intent, int requestCode) {
+ void startActivityForResult(Intent intent, int requestCode) {
// Even in fullscreen mode, startActivityForResult will still use the
// initial internal access delegate because it has access to
// the hidden API View#startActivityForResult.
@@ -2218,9 +2220,19 @@ public class AwContents implements SmartClipProvider,
.super_startActivityForResult(intent, requestCode);
}
+ void startProcessTextIntent(Intent intent) {
+ if (ContentViewCore.activityFromContext(mContext) == null) {
+ mContext.startActivity(intent);
+ return;
+ }
+
+ startActivityForResult(intent, PROCESS_TEXT_REQUEST_CODE);
+ }
+
public void onActivityResult(int requestCode, int resultCode, Intent data) {
- // TODO(hush): Forward the activity result to content view core and
- // replace the text with translated text.
+ if (requestCode == PROCESS_TEXT_REQUEST_CODE) {
+ mContentViewCore.onReceivedProcessTextResult(resultCode, data);
+ }
boliu 2015/10/22 00:22:05 maybe log the else block as an error?
hush (inactive) 2015/10/22 19:27:37 Done.
}
/**

Powered by Google App Engine
This is Rietveld 408576698