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

Unified Diff: content/public/android/java/src/org/chromium/content/browser/WebActionModeCallback.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/WebActionModeCallback.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/WebActionModeCallback.java b/content/public/android/java/src/org/chromium/content/browser/WebActionModeCallback.java
index d6eab6eabf815457741449e2831fabd057ac3bd1..d1bc3d27bd51f477ca3a4674389b6553ea79bb08 100644
--- a/content/public/android/java/src/org/chromium/content/browser/WebActionModeCallback.java
+++ b/content/public/android/java/src/org/chromium/content/browser/WebActionModeCallback.java
@@ -169,15 +169,12 @@ public class WebActionModeCallback implements ActionMode.Callback {
new MenuInflater(getContext()).inflate(R.menu.select_action_menu, menu);
}
- initializeTextProcessingMenu(menu);
-
if (mIsInsertion) {
menu.removeItem(R.id.select_action_menu_select_all);
menu.removeItem(R.id.select_action_menu_cut);
menu.removeItem(R.id.select_action_menu_copy);
menu.removeItem(R.id.select_action_menu_share);
menu.removeItem(R.id.select_action_menu_web_search);
- menu.removeGroup(R.id.select_action_menu_text_processing_menus);
return;
}
@@ -200,8 +197,10 @@ public class WebActionModeCallback implements ActionMode.Callback {
if (mIsPasswordType) {
menu.removeItem(R.id.select_action_menu_copy);
menu.removeItem(R.id.select_action_menu_cut);
- menu.removeGroup(R.id.select_action_menu_text_processing_menus);
+ return;
}
+
+ initializeTextProcessingMenu(menu);
}
@Override
@@ -230,7 +229,8 @@ public class WebActionModeCallback implements ActionMode.Callback {
mode.finish();
} else if (groupId == R.id.select_action_menu_text_processing_menus) {
mActionHandler.processText(item.getIntent());
- mode.finish();
+ // The ActionMode is not dismissed to match the behavior with
+ // TextView in Android M.
jdduke (slow) 2015/10/22 00:43:56 Hmm, will calling |Replace| both replace the text
jdduke (slow) 2015/10/22 00:45:57 That is to say, either way I think we're OK here.
hush (inactive) 2015/10/22 19:27:38 It is the latter case: we will switch to an insert
} else {
return false;
}
@@ -288,10 +288,12 @@ public class WebActionModeCallback implements ActionMode.Callback {
@TargetApi(Build.VERSION_CODES.M)
private Intent createProcessTextIntentForResolveInfo(ResolveInfo info) {
+ // on Android M, WebView is not able to replace the text with the processed text.
+ // So set the readonly flag for M.
+ boolean isReadOnly = !mActionHandler.isSelectionEditable()
+ || Build.VERSION.SDK_INT == Build.VERSION_CODES.M;
jdduke (slow) 2015/10/22 00:45:57 Wait, what? What about Chrome though?
hush (inactive) 2015/10/22 19:27:38 Sorry. My mistake here. Thanks for catching it! I
return createProcessTextIntent()
- // TODO(hush crbug.com/521027): should be !isSelectionEditable(),
- // when WebView supports replacing the text.
- .putExtra(Intent.EXTRA_PROCESS_TEXT_READONLY, true)
+ .putExtra(Intent.EXTRA_PROCESS_TEXT_READONLY, isReadOnly)
.setClassName(info.activityInfo.packageName, info.activityInfo.name);
}
}

Powered by Google App Engine
This is Rietveld 408576698