| 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.content.ComponentName; | 8 import android.content.ComponentName; |
| 9 import android.graphics.Bitmap; | 9 import android.graphics.Bitmap; |
| 10 import android.graphics.BitmapFactory; | 10 import android.graphics.BitmapFactory; |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 }; | 113 }; |
| 114 | 114 |
| 115 if (ChromeFeatureList.isEnabled(ChromeFeatureList.CUSTOM_CONTEXT_MENU))
{ | 115 if (ChromeFeatureList.isEnabled(ChromeFeatureList.CUSTOM_CONTEXT_MENU))
{ |
| 116 List<Pair<Integer, List<ContextMenuItem>>> items = | 116 List<Pair<Integer, List<ContextMenuItem>>> items = |
| 117 mPopulator.buildContextMenu(null, mActivity, mCurrentContext
MenuParams); | 117 mPopulator.buildContextMenu(null, mActivity, mCurrentContext
MenuParams); |
| 118 if (items.isEmpty()) { | 118 if (items.isEmpty()) { |
| 119 ThreadUtils.postOnUiThread(mOnMenuClosed); | 119 ThreadUtils.postOnUiThread(mOnMenuClosed); |
| 120 return; | 120 return; |
| 121 } | 121 } |
| 122 | 122 |
| 123 final ContextMenuUi menuUi = new TabularContextMenuUi(new Runnable()
{ | 123 final TabularContextMenuUi menuUi = new TabularContextMenuUi(new Run
nable() { |
| 124 @Override | 124 @Override |
| 125 public void run() { | 125 public void run() { |
| 126 shareImageDirectly(ShareHelper.getLastShareComponentName()); | 126 shareImageDirectly(ShareHelper.getLastShareComponentName()); |
| 127 } | 127 } |
| 128 }); | 128 }); |
| 129 menuUi.setRenderCoordinates(contentViewCore.getRenderCoordinates()); |
| 129 menuUi.displayMenu(mActivity, mCurrentContextMenuParams, items, mCal
lback, mOnMenuShown, | 130 menuUi.displayMenu(mActivity, mCurrentContextMenuParams, items, mCal
lback, mOnMenuShown, |
| 130 mOnMenuClosed); | 131 mOnMenuClosed); |
| 131 if (mCurrentContextMenuParams.isImage()) { | 132 if (mCurrentContextMenuParams.isImage()) { |
| 132 getThumbnail(new Callback<Bitmap>() { | 133 getThumbnail(new Callback<Bitmap>() { |
| 133 @Override | 134 @Override |
| 134 public void onResult(Bitmap result) { | 135 public void onResult(Bitmap result) { |
| 135 ((TabularContextMenuUi) menuUi).onImageThumbnailRetrieve
d(result); | 136 menuUi.onImageThumbnailRetrieved(result); |
| 136 } | 137 } |
| 137 }); | 138 }); |
| 138 } | 139 } |
| 139 return; | 140 return; |
| 140 } | 141 } |
| 141 | 142 |
| 142 // The Platform Context Menu requires the listener within this hepler si
nce this helper and | 143 // The Platform Context Menu requires the listener within this helper si
nce this helper and |
| 143 // provides context menu for us to show. | 144 // provides context menu for us to show. |
| 144 view.setOnCreateContextMenuListener(this); | 145 view.setOnCreateContextMenuListener(this); |
| 145 if (view.showContextMenu()) { | 146 if (view.showContextMenu()) { |
| 146 mOnMenuShown.run(); | 147 mOnMenuShown.run(); |
| 147 windowAndroid.addContextMenuCloseListener(new OnCloseContextMenuList
ener() { | 148 windowAndroid.addContextMenuCloseListener(new OnCloseContextMenuList
ener() { |
| 148 @Override | 149 @Override |
| 149 public void onContextMenuClosed() { | 150 public void onContextMenuClosed() { |
| 150 mOnMenuClosed.run(); | 151 mOnMenuClosed.run(); |
| 151 windowAndroid.removeContextMenuCloseListener(this); | 152 windowAndroid.removeContextMenuCloseListener(this); |
| 152 } | 153 } |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 } | 242 } |
| 242 | 243 |
| 243 private native WebContents nativeGetJavaWebContents(long nativeContextMenuHe
lper); | 244 private native WebContents nativeGetJavaWebContents(long nativeContextMenuHe
lper); |
| 244 private native void nativeOnStartDownload( | 245 private native void nativeOnStartDownload( |
| 245 long nativeContextMenuHelper, boolean isLink, boolean isDataReductio
nProxyEnabled); | 246 long nativeContextMenuHelper, boolean isLink, boolean isDataReductio
nProxyEnabled); |
| 246 private native void nativeSearchForImage(long nativeContextMenuHelper); | 247 private native void nativeSearchForImage(long nativeContextMenuHelper); |
| 247 private native void nativeRetrieveImage( | 248 private native void nativeRetrieveImage( |
| 248 long nativeContextMenuHelper, Callback<byte[]> callback, int maxSize
Px); | 249 long nativeContextMenuHelper, Callback<byte[]> callback, int maxSize
Px); |
| 249 private native void nativeOnContextMenuClosed(long nativeContextMenuHelper); | 250 private native void nativeOnContextMenuClosed(long nativeContextMenuHelper); |
| 250 } | 251 } |
| OLD | NEW |