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

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: moved comments around 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..9477fce2d168a7e815caf211b134d25093103529 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.
} else {
return false;
}
@@ -288,10 +288,9 @@ public class WebActionModeCallback implements ActionMode.Callback {
@TargetApi(Build.VERSION_CODES.M)
private Intent createProcessTextIntentForResolveInfo(ResolveInfo info) {
+ boolean isReadOnly = !mActionHandler.isSelectionEditable();
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