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 fda2dde2e44a70f861edf9433745d4a84ba75af1..36f81a5ce8a3d773d43fa0333b16521762d4541f 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 |
@@ -6,6 +6,7 @@ package org.chromium.chrome.browser.ntp; |
import android.app.Activity; |
import android.support.annotation.IntDef; |
+import android.support.annotation.Nullable; |
import android.support.annotation.StringRes; |
import android.support.v13.view.ViewCompat; |
import android.view.ContextMenu; |
@@ -45,6 +46,7 @@ public class ContextMenuManager implements OnCloseContextMenuListener { |
public static final int ID_REMOVE = 4; |
private final NewTabPageManager mManager; |
+ @Nullable |
private final Tab mTab; |
private final TouchDisableableView mOuterView; |
@@ -67,7 +69,8 @@ public class ContextMenuManager implements OnCloseContextMenuListener { |
public interface TouchDisableableView { void setTouchEnabled(boolean enabled); } |
public ContextMenuManager( |
- NewTabPageManager newTabPageManager, Tab tab, TouchDisableableView outerView) { |
+ NewTabPageManager newTabPageManager, @Nullable Tab tab, |
+ TouchDisableableView outerView) { |
mManager = newTabPageManager; |
mTab = tab; |
mOuterView = outerView; |
@@ -111,9 +114,10 @@ public class ContextMenuManager implements OnCloseContextMenuListener { |
// prevent the user long pressing to get the context menu then on the same press scrolling |
// 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); |
+ if (mTab != null) { |
+ mOuterView.setTouchEnabled(false); |
+ mTab.getWindowAndroid().addContextMenuCloseListener(this); |
dgn
2017/01/04 12:19:43
Activity#onContextMenuClosed as a substitute maybe
Bernhard Bauer
2017/01/05 12:02:15
As discussed offline, changed ContextMenuManager s
|
+ } |
} |
@Override |
@@ -124,6 +128,8 @@ public class ContextMenuManager implements OnCloseContextMenuListener { |
/** Closes the context menu, if open. */ |
public void closeContextMenu() { |
dgn
2017/01/04 12:19:43
we also use this method to close the menu when cha
Bernhard Bauer
2017/01/05 12:02:15
Done.
|
+ if (mTab == null) return; |
+ |
Activity activity = mTab.getWindowAndroid().getActivity().get(); |
if (activity == null) return; |