| 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 public void run() { | 108 public void run() { |
| 109 if (mNativeContextMenuHelper == 0) return; | 109 if (mNativeContextMenuHelper == 0) return; |
| 110 nativeOnContextMenuClosed(mNativeContextMenuHelper); | 110 nativeOnContextMenuClosed(mNativeContextMenuHelper); |
| 111 } | 111 } |
| 112 }; | 112 }; |
| 113 | 113 |
| 114 if (ChromeFeatureList.isEnabled(ChromeFeatureList.CUSTOM_CONTEXT_MENU))
{ | 114 if (ChromeFeatureList.isEnabled(ChromeFeatureList.CUSTOM_CONTEXT_MENU))
{ |
| 115 List<Pair<Integer, List<ContextMenuItem>>> items = | 115 List<Pair<Integer, List<ContextMenuItem>>> items = |
| 116 mPopulator.buildContextMenu(null, mActivity, mCurrentContext
MenuParams); | 116 mPopulator.buildContextMenu(null, mActivity, mCurrentContext
MenuParams); |
| 117 | 117 |
| 118 final ContextMenuUi menuUi = new TabularContextMenuUi(new Runnable()
{ | 118 final TabularContextMenuUi menuUi = new TabularContextMenuUi(new Run
nable() { |
| 119 @Override | 119 @Override |
| 120 public void run() { | 120 public void run() { |
| 121 shareImageDirectly(ShareHelper.getLastShareComponentName()); | 121 shareImageDirectly(ShareHelper.getLastShareComponentName()); |
| 122 } | 122 } |
| 123 }); | 123 }); |
| 124 menuUi.setRenderCoordinates(contentViewCore.getRenderCoordinates()); |
| 124 menuUi.displayMenu(mActivity, mCurrentContextMenuParams, items, mCal
lback, mOnMenuShown, | 125 menuUi.displayMenu(mActivity, mCurrentContextMenuParams, items, mCal
lback, mOnMenuShown, |
| 125 mOnMenuClosed); | 126 mOnMenuClosed); |
| 126 if (mCurrentContextMenuParams.isImage()) { | 127 if (mCurrentContextMenuParams.isImage()) { |
| 127 getThumbnail(new Callback<Bitmap>() { | 128 getThumbnail(new Callback<Bitmap>() { |
| 128 @Override | 129 @Override |
| 129 public void onResult(Bitmap result) { | 130 public void onResult(Bitmap result) { |
| 130 ((TabularContextMenuUi) menuUi).onImageThumbnailRetrieve
d(result); | 131 menuUi.onImageThumbnailRetrieved(result); |
| 131 } | 132 } |
| 132 }); | 133 }); |
| 133 } | 134 } |
| 134 return; | 135 return; |
| 135 } | 136 } |
| 136 | 137 |
| 137 // The Platform Context Menu requires the listener within this hepler si
nce this helper and | 138 // The Platform Context Menu requires the listener within this helper si
nce this helper and |
| 138 // provides context menu for us to show. | 139 // provides context menu for us to show. |
| 139 view.setOnCreateContextMenuListener(this); | 140 view.setOnCreateContextMenuListener(this); |
| 140 if (view.showContextMenu()) { | 141 if (view.showContextMenu()) { |
| 141 mOnMenuShown.run(); | 142 mOnMenuShown.run(); |
| 142 windowAndroid.addContextMenuCloseListener(new OnCloseContextMenuList
ener() { | 143 windowAndroid.addContextMenuCloseListener(new OnCloseContextMenuList
ener() { |
| 143 @Override | 144 @Override |
| 144 public void onContextMenuClosed() { | 145 public void onContextMenuClosed() { |
| 145 mOnMenuClosed.run(); | 146 mOnMenuClosed.run(); |
| 146 windowAndroid.removeContextMenuCloseListener(this); | 147 windowAndroid.removeContextMenuCloseListener(this); |
| 147 } | 148 } |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 } | 233 } |
| 233 | 234 |
| 234 private native WebContents nativeGetJavaWebContents(long nativeContextMenuHe
lper); | 235 private native WebContents nativeGetJavaWebContents(long nativeContextMenuHe
lper); |
| 235 private native void nativeOnStartDownload( | 236 private native void nativeOnStartDownload( |
| 236 long nativeContextMenuHelper, boolean isLink, boolean isDataReductio
nProxyEnabled); | 237 long nativeContextMenuHelper, boolean isLink, boolean isDataReductio
nProxyEnabled); |
| 237 private native void nativeSearchForImage(long nativeContextMenuHelper); | 238 private native void nativeSearchForImage(long nativeContextMenuHelper); |
| 238 private native void nativeRetrieveImage( | 239 private native void nativeRetrieveImage( |
| 239 long nativeContextMenuHelper, Callback<byte[]> callback, int maxSize
Px); | 240 long nativeContextMenuHelper, Callback<byte[]> callback, int maxSize
Px); |
| 240 private native void nativeOnContextMenuClosed(long nativeContextMenuHelper); | 241 private native void nativeOnContextMenuClosed(long nativeContextMenuHelper); |
| 241 } | 242 } |
| OLD | NEW |