| 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.app.Activity; | 7 import android.app.Activity; |
| 8 import android.view.ContextMenu; | 8 import android.view.ContextMenu; |
| 9 import android.view.ContextMenu.ContextMenuInfo; | 9 import android.view.ContextMenu.ContextMenuInfo; |
| 10 import android.view.MenuItem; | 10 import android.view.MenuItem; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 private void setPopulator(ContextMenuPopulator populator) { | 51 private void setPopulator(ContextMenuPopulator populator) { |
| 52 mPopulator = populator; | 52 mPopulator = populator; |
| 53 } | 53 } |
| 54 | 54 |
| 55 /** | 55 /** |
| 56 * Starts showing a context menu for {@code view} based on {@code params}. | 56 * Starts showing a context menu for {@code view} based on {@code params}. |
| 57 * @param contentViewCore The {@link ContentViewCore} to show the menu to. | 57 * @param contentViewCore The {@link ContentViewCore} to show the menu to. |
| 58 * @param params The {@link ContextMenuParams} that indicate what m
enu items to show. | 58 * @param params The {@link ContextMenuParams} that indicate what m
enu items to show. |
| 59 */ | 59 */ |
| 60 @CalledByNative | 60 @CalledByNative |
| 61 private boolean showContextMenu(ContentViewCore contentViewCore, ContextMenu
Params params) { | 61 private void showContextMenu(ContentViewCore contentViewCore, ContextMenuPar
ams params) { |
| 62 final View view = contentViewCore.getContainerView(); | 62 final View view = contentViewCore.getContainerView(); |
| 63 | 63 |
| 64 if (view == null | 64 if (view == null |
| 65 || view.getVisibility() != View.VISIBLE | 65 || view.getVisibility() != View.VISIBLE |
| 66 || view.getParent() == null) { | 66 || view.getParent() == null) { |
| 67 return false; | 67 return; |
| 68 } | 68 } |
| 69 | 69 |
| 70 mCurrentContextMenuParams = params; | 70 mCurrentContextMenuParams = params; |
| 71 | 71 |
| 72 view.setOnCreateContextMenuListener(this); | 72 view.setOnCreateContextMenuListener(this); |
| 73 if (view.showContextMenu()) { | 73 if (view.showContextMenu()) { |
| 74 WebContents webContents = contentViewCore.getWebContents(); | 74 WebContents webContents = contentViewCore.getWebContents(); |
| 75 RecordHistogram.recordBooleanHistogram( | 75 RecordHistogram.recordBooleanHistogram( |
| 76 "ContextMenu.Shown", webContents != null); | 76 "ContextMenu.Shown", webContents != null); |
| 77 if (webContents != null) webContents.onContextMenuOpened(); | |
| 78 return true; | |
| 79 } | 77 } |
| 80 return false; | |
| 81 } | 78 } |
| 82 | 79 |
| 83 /** | 80 /** |
| 84 * Starts a download based on the current {@link ContextMenuParams}. | 81 * Starts a download based on the current {@link ContextMenuParams}. |
| 85 * @param isLink Whether or not the download target is a link. | 82 * @param isLink Whether or not the download target is a link. |
| 86 */ | 83 */ |
| 87 public void startContextMenuDownload(boolean isLink, boolean isDataReduction
ProxyEnabled) { | 84 public void startContextMenuDownload(boolean isLink, boolean isDataReduction
ProxyEnabled) { |
| 88 if (mNativeContextMenuHelper != 0) { | 85 if (mNativeContextMenuHelper != 0) { |
| 89 nativeOnStartDownload(mNativeContextMenuHelper, isLink, isDataReduct
ionProxyEnabled); | 86 nativeOnStartDownload(mNativeContextMenuHelper, isLink, isDataReduct
ionProxyEnabled); |
| 90 } | 87 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 @VisibleForTesting | 133 @VisibleForTesting |
| 137 public ContextMenuPopulator getPopulator() { | 134 public ContextMenuPopulator getPopulator() { |
| 138 return mPopulator; | 135 return mPopulator; |
| 139 } | 136 } |
| 140 | 137 |
| 141 private native void nativeOnStartDownload( | 138 private native void nativeOnStartDownload( |
| 142 long nativeContextMenuHelper, boolean isLink, boolean isDataReductio
nProxyEnabled); | 139 long nativeContextMenuHelper, boolean isLink, boolean isDataReductio
nProxyEnabled); |
| 143 private native void nativeSearchForImage(long nativeContextMenuHelper); | 140 private native void nativeSearchForImage(long nativeContextMenuHelper); |
| 144 private native void nativeShareImage(long nativeContextMenuHelper); | 141 private native void nativeShareImage(long nativeContextMenuHelper); |
| 145 } | 142 } |
| OLD | NEW |