| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.browser.contextmenu; | 5 package org.chromium.chrome.browser.contextmenu; |
| 6 | 6 |
| 7 import android.view.ContextMenu; | 7 import android.view.ContextMenu; |
| 8 import android.view.ContextMenu.ContextMenuInfo; | 8 import android.view.ContextMenu.ContextMenuInfo; |
| 9 import android.view.HapticFeedbackConstants; | 9 import android.view.HapticFeedbackConstants; |
| 10 import android.view.Menu; | 10 import android.view.Menu; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 if (!shouldShowMenu(params) | 61 if (!shouldShowMenu(params) |
| 62 || view == null | 62 || view == null |
| 63 || view.getVisibility() != View.VISIBLE | 63 || view.getVisibility() != View.VISIBLE |
| 64 || view.getParent() == null) { | 64 || view.getParent() == null) { |
| 65 return; | 65 return; |
| 66 } | 66 } |
| 67 | 67 |
| 68 mCurrentContextMenuParams = params; | 68 mCurrentContextMenuParams = params; |
| 69 | 69 |
| 70 view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); | 70 view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); |
| 71 contentViewCore.setIgnoreRemainingTouchEvents(); | |
| 72 view.setOnCreateContextMenuListener(this); | 71 view.setOnCreateContextMenuListener(this); |
| 73 view.showContextMenu(); | 72 view.showContextMenu(); |
| 74 } | 73 } |
| 75 | 74 |
| 76 /** | 75 /** |
| 77 * Starts a download based on the current {@link ContextMenuParams}. | 76 * Starts a download based on the current {@link ContextMenuParams}. |
| 78 * @param isLink Whether or not the download target is a link. | 77 * @param isLink Whether or not the download target is a link. |
| 79 */ | 78 */ |
| 80 public void startContextMenuDownload(boolean isLink) { | 79 public void startContextMenuDownload(boolean isLink) { |
| 81 if (mNativeContextMenuHelper != 0) nativeOnStartDownload(mNativeContextM
enuHelper, isLink); | 80 if (mNativeContextMenuHelper != 0) nativeOnStartDownload(mNativeContextM
enuHelper, isLink); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 } | 120 } |
| 122 | 121 |
| 123 private boolean shouldShowMenu(ContextMenuParams params) { | 122 private boolean shouldShowMenu(ContextMenuParams params) { |
| 124 // Custom menus are handled by this class and do not require a ContextMe
nuPopulator. | 123 // Custom menus are handled by this class and do not require a ContextMe
nuPopulator. |
| 125 return params.isCustomMenu() || | 124 return params.isCustomMenu() || |
| 126 (mPopulator != null && mPopulator.shouldShowContextMenu(params))
; | 125 (mPopulator != null && mPopulator.shouldShowContextMenu(params))
; |
| 127 } | 126 } |
| 128 | 127 |
| 129 private native void nativeOnStartDownload(long nativeContextMenuHelper, bool
ean isLink); | 128 private native void nativeOnStartDownload(long nativeContextMenuHelper, bool
ean isLink); |
| 130 private native void nativeOnCustomItemSelected(long nativeContextMenuHelper,
int action); | 129 private native void nativeOnCustomItemSelected(long nativeContextMenuHelper,
int action); |
| 131 } | 130 } |
| OLD | NEW |