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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/contextmenu/ContextMenuHelper.java

Issue 2747453002: Split context menu display and population/handling (Closed)
Patch Set: Created 3 years, 9 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: chrome/android/java/src/org/chromium/chrome/browser/contextmenu/ContextMenuHelper.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/contextmenu/ContextMenuHelper.java b/chrome/android/java/src/org/chromium/chrome/browser/contextmenu/ContextMenuHelper.java
index 529b678e4d6d6f3afb955caabd95fd7a5392c1c5..69f59b97366d93e1678190f8d985856c8c9dc92e 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/contextmenu/ContextMenuHelper.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/contextmenu/ContextMenuHelper.java
@@ -5,6 +5,7 @@
package org.chromium.chrome.browser.contextmenu;
import android.app.Activity;
+import android.util.Pair;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.MenuItem;
@@ -21,6 +22,8 @@ import org.chromium.content_public.browser.WebContents;
import org.chromium.ui.base.WindowAndroid;
import org.chromium.ui.base.WindowAndroid.OnCloseContextMenuListener;
+import java.util.List;
+
/**
* A helper class that handles generating context menus for {@link ContentViewCore}s.
*/
@@ -29,6 +32,7 @@ public class ContextMenuHelper implements OnCreateContextMenuListener, OnMenuIte
private ContextMenuPopulator mPopulator;
private ContextMenuParams mCurrentContextMenuParams;
+ private Activity mActivity;
JJ 2017/03/10 18:01:16 If you're wondering why we get activity instead of
private ContextMenuHelper(long nativeContextMenuHelper) {
mNativeContextMenuHelper = nativeContextMenuHelper;
@@ -71,6 +75,7 @@ public class ContextMenuHelper implements OnCreateContextMenuListener, OnMenuIte
}
mCurrentContextMenuParams = params;
+ mActivity = windowAndroid.getActivity().get();
Ted C 2017/03/11 00:31:14 if the activity is null, we should return as well
JJ 2017/03/13 20:24:28 Done.
view.setOnCreateContextMenuListener(this);
Ted C 2017/03/11 00:31:14 Can this move into the ui code? This is specific
JJ 2017/03/13 20:24:28 In a previous iteration of this (before it was upl
Ted C 2017/03/13 21:55:19 Seems ok to do in a follow up.
JJ 2017/03/13 23:39:32 Thanks thanks.
if (view.showContextMenu()) {
@@ -128,11 +133,18 @@ public class ContextMenuHelper implements OnCreateContextMenuListener, OnMenuIte
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
assert mPopulator != null;
- mPopulator.buildContextMenu(menu, v.getContext(), mCurrentContextMenuParams);
-
- for (int i = 0; i < menu.size(); i++) {
- menu.getItem(i).setOnMenuItemClickListener(this);
- }
+ List<Pair<Integer, List<ContextMenuItems>>> items =
+ mPopulator.buildContextMenu(menu, v.getContext(), mCurrentContextMenuParams);
+ ContextMenuUi menuUi =
+ new SimpleContextMenuUi(menu, new ContextMenuUi.OnMenuClickedListener() {
Ted C 2017/03/11 00:31:14 Take a look at Callback.java in base instead of ad
JJ 2017/03/13 20:24:28 Is that what the youngins are into these days? I n
+ @Override
+ public void onItemClicked(int menuId) {
+ mPopulator.onItemSelected(
+ ContextMenuHelper.this, mCurrentContextMenuParams, menuId);
+ }
+ });
+
+ menuUi.displayMenu(mActivity, mCurrentContextMenuParams, items);
Ted C 2017/03/11 00:31:14 Also if both UIs are going to need the click liste
JJ 2017/03/13 20:24:29 Done.
}
@Override

Powered by Google App Engine
This is Rietveld 408576698