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

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

Issue 1349563003: Implement Android M text process action in ActionMode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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 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;
}

Powered by Google App Engine
This is Rietveld 408576698