| Index: chrome/android/java/src/org/chromium/chrome/browser/ntp/ContextMenuManager.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/ContextMenuManager.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/ContextMenuManager.java
|
| index 79910e5857edb491729a8f3a898764bae5f45968..8a290a96734fb3906a81f876440ee482fa62f0f8 100644
|
| --- a/chrome/android/java/src/org/chromium/chrome/browser/ntp/ContextMenuManager.java
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/ContextMenuManager.java
|
| @@ -17,7 +17,6 @@ import org.chromium.chrome.R;
|
| import org.chromium.chrome.browser.ntp.NewTabPageView.NewTabPageManager;
|
| import org.chromium.chrome.browser.ntp.snippets.SnippetsConfig;
|
| import org.chromium.chrome.browser.offlinepages.OfflinePageBridge;
|
| -import org.chromium.chrome.browser.tab.Tab;
|
| import org.chromium.ui.base.WindowAndroid.OnCloseContextMenuListener;
|
| import org.chromium.ui.mojom.WindowOpenDisposition;
|
|
|
| @@ -43,9 +42,10 @@ public class ContextMenuManager implements OnCloseContextMenuListener {
|
| public static final int ID_SAVE_FOR_OFFLINE = 3;
|
| public static final int ID_REMOVE = 4;
|
|
|
| + private final Activity mActivity;
|
| private final NewTabPageManager mManager;
|
| - private final Tab mTab;
|
| private final TouchDisableableView mOuterView;
|
| + private boolean mContextMenuOpen;
|
|
|
| /** Defines callback to configure the context menu and respond to user interaction. */
|
| public interface Delegate {
|
| @@ -65,10 +65,10 @@ public class ContextMenuManager implements OnCloseContextMenuListener {
|
| /** Interface for a view that can be set to stop responding to touches. */
|
| public interface TouchDisableableView { void setTouchEnabled(boolean enabled); }
|
|
|
| - public ContextMenuManager(
|
| - NewTabPageManager newTabPageManager, Tab tab, TouchDisableableView outerView) {
|
| + public ContextMenuManager(Activity activity, NewTabPageManager newTabPageManager,
|
| + TouchDisableableView outerView) {
|
| + mActivity = activity;
|
| mManager = newTabPageManager;
|
| - mTab = tab;
|
| mOuterView = outerView;
|
| }
|
|
|
| @@ -111,22 +111,19 @@ public class ContextMenuManager implements OnCloseContextMenuListener {
|
| // or swiping to dismiss an item (eg. https://crbug.com/638854, https://crbug.com/638555,
|
| // https://crbug.com/636296)
|
| mOuterView.setTouchEnabled(false);
|
| -
|
| - mTab.getWindowAndroid().addContextMenuCloseListener(this);
|
| + mContextMenuOpen = true;
|
| }
|
|
|
| @Override
|
| public void onContextMenuClosed() {
|
| + if (!mContextMenuOpen) return;
|
| mOuterView.setTouchEnabled(true);
|
| - mTab.getWindowAndroid().removeContextMenuCloseListener(this);
|
| + mContextMenuOpen = false;
|
| }
|
|
|
| /** Closes the context menu, if open. */
|
| public void closeContextMenu() {
|
| - Activity activity = mTab.getWindowAndroid().getActivity().get();
|
| - if (activity == null) return;
|
| -
|
| - activity.closeContextMenu();
|
| + mActivity.closeContextMenu();
|
| }
|
|
|
| private boolean shouldShowItem(@ContextMenuItemId int itemId, Delegate delegate) {
|
|
|