Chromium Code Reviews| 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 082068a4daff3edd92c064299dd81658a62a06ed..b3cdec7dae43bf3d8ca05719fb4eae2a712ebb25 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 |
| @@ -6,6 +6,7 @@ package org.chromium.content.browser; |
| import android.content.ClipboardManager; |
| import android.content.Context; |
| +import android.content.Intent; |
| import android.content.res.Resources; |
| import android.graphics.Rect; |
| import android.view.ActionMode; |
| @@ -53,6 +54,16 @@ public class WebActionModeCallback implements ActionMode.Callback { |
| void share(); |
| /** |
| + * Perform a processText action (translating the text, for example). |
| + */ |
| + void processText(Intent intent); |
| + |
| + /** |
| + * Intialize the menu items for processing text, if there is any. |
| + */ |
| + void initializeTextProcessingMenu(Menu menu); |
|
Ted C
2015/09/17 20:34:57
To me, this function doesn't seem like it belongs
hush (inactive)
2015/09/17 21:30:52
Okay. I just moved the related logic from contentv
|
| + |
| + /** |
| * Perform a search action. |
| */ |
| void search(); |
| @@ -157,12 +168,15 @@ public class WebActionModeCallback implements ActionMode.Callback { |
| new MenuInflater(getContext()).inflate(R.menu.select_action_menu, menu); |
| } |
| + mActionHandler.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; |
| } |
| @@ -185,6 +199,7 @@ 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); |
| } |
| } |
| @@ -193,6 +208,7 @@ public class WebActionModeCallback implements ActionMode.Callback { |
| if (mIsDestroyed) return true; |
| int id = item.getItemId(); |
| + int groupId = item.getGroupId(); |
| if (id == R.id.select_action_menu_select_all) { |
| mActionHandler.selectAll(); |
| @@ -211,6 +227,9 @@ public class WebActionModeCallback implements ActionMode.Callback { |
| } else if (id == R.id.select_action_menu_web_search) { |
| mActionHandler.search(); |
| mode.finish(); |
| + } else if (groupId == R.id.select_action_menu_text_processing_menus) { |
| + mActionHandler.processText(item.getIntent()); |
| + mode.finish(); |
| } else { |
| return false; |
| } |