Chromium Code Reviews| 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 615b7c8fb67885ad79fd377688ec0a8c45c7933d..b27d00e090bd5382f8232c2c855096cdcb678d0d 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 |
| @@ -15,6 +15,7 @@ import org.chromium.base.Callback; |
| import org.chromium.base.VisibleForTesting; |
| import org.chromium.base.annotations.CalledByNative; |
| import org.chromium.base.metrics.RecordHistogram; |
| +import org.chromium.chrome.browser.ChromeFeatureList; |
| import org.chromium.chrome.browser.share.ShareHelper; |
| import org.chromium.content.browser.ContentViewCore; |
| import org.chromium.content_public.browser.WebContents; |
| @@ -32,6 +33,7 @@ public class ContextMenuHelper implements OnCreateContextMenuListener { |
| private ContextMenuPopulator mPopulator; |
| private ContextMenuParams mCurrentContextMenuParams; |
| private Activity mActivity; |
| + private Callback<Integer> mCallback; |
| private ContextMenuHelper(long nativeContextMenuHelper) { |
| mNativeContextMenuHelper = nativeContextMenuHelper; |
| @@ -70,12 +72,29 @@ public class ContextMenuHelper implements OnCreateContextMenuListener { |
| final WindowAndroid windowAndroid = contentViewCore.getWindowAndroid(); |
| if (view == null || view.getVisibility() != View.VISIBLE || view.getParent() == null |
| - || windowAndroid == null || windowAndroid.getActivity().get() == null) { |
| + || windowAndroid == null || windowAndroid.getActivity().get() == null |
| + || mPopulator == null) { |
| return; |
| } |
| mCurrentContextMenuParams = params; |
| mActivity = windowAndroid.getActivity().get(); |
| + mCallback = new Callback<Integer>() { |
| + @Override |
| + public void onResult(Integer result) { |
| + mPopulator.onItemSelected( |
| + ContextMenuHelper.this, mCurrentContextMenuParams, result); |
| + } |
| + }; |
| + |
| + if (ChromeFeatureList.isEnabled(ChromeFeatureList.CUSTOM_CONTEXT_MENU)) { |
| + List<Pair<Integer, List<ContextMenuItem>>> items = |
|
Ted C
2017/03/24 04:32:53
I would pull this out and stash it in a local var
JJ
2017/03/25 01:40:25
So I really really wanted to do this. When separat
|
| + mPopulator.buildContextMenu(null, mActivity, mCurrentContextMenuParams); |
| + |
| + ContextMenuUi menuUi = new TabularContextMenuUi(); |
| + menuUi.displayMenu(mActivity, mCurrentContextMenuParams, items, mCallback); |
| + return; |
| + } |
| view.setOnCreateContextMenuListener(this); |
| if (view.showContextMenu()) { |
| @@ -132,18 +151,10 @@ public class ContextMenuHelper implements OnCreateContextMenuListener { |
| @Override |
| public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { |
| - assert mPopulator != null; |
| - |
| List<Pair<Integer, List<ContextMenuItem>>> items = |
| mPopulator.buildContextMenu(menu, v.getContext(), mCurrentContextMenuParams); |
| ContextMenuUi menuUi = new PlatformContextMenuUi(menu); |
| - menuUi.displayMenu(mActivity, mCurrentContextMenuParams, items, new Callback<Integer>() { |
| - @Override |
| - public void onResult(Integer result) { |
| - mPopulator.onItemSelected( |
| - ContextMenuHelper.this, mCurrentContextMenuParams, result); |
| - } |
| - }); |
| + menuUi.displayMenu(mActivity, mCurrentContextMenuParams, items, mCallback); |
| } |
| /** |