Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(212)

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/contextmenu/ContextMenuHelper.java

Issue 2775373002: Add a Share Icon to Tabular Context Menu (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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.graphics.Bitmap; 9 import android.graphics.Bitmap;
9 import android.graphics.BitmapFactory; 10 import android.graphics.BitmapFactory;
10 import android.util.Pair; 11 import android.util.Pair;
11 import android.view.ContextMenu; 12 import android.view.ContextMenu;
12 import android.view.ContextMenu.ContextMenuInfo; 13 import android.view.ContextMenu.ContextMenuInfo;
13 import android.view.View; 14 import android.view.View;
14 import android.view.View.OnCreateContextMenuListener; 15 import android.view.View.OnCreateContextMenuListener;
15 16
16 import org.chromium.base.Callback; 17 import org.chromium.base.Callback;
17 import org.chromium.base.VisibleForTesting; 18 import org.chromium.base.VisibleForTesting;
(...skipping 14 matching lines...) Expand all
32 public class ContextMenuHelper implements OnCreateContextMenuListener { 33 public class ContextMenuHelper implements OnCreateContextMenuListener {
33 private long mNativeContextMenuHelper; 34 private long mNativeContextMenuHelper;
34 35
35 private ContextMenuPopulator mPopulator; 36 private ContextMenuPopulator mPopulator;
36 private ContextMenuParams mCurrentContextMenuParams; 37 private ContextMenuParams mCurrentContextMenuParams;
37 private Activity mActivity; 38 private Activity mActivity;
38 private Callback<Integer> mCallback; 39 private Callback<Integer> mCallback;
39 private Runnable mOnMenuShown; 40 private Runnable mOnMenuShown;
40 private Runnable mOnMenuClosed; 41 private Runnable mOnMenuClosed;
41 private OnThumbnailReceivedListener mOnThumbnailReceivedListener; 42 private OnThumbnailReceivedListener mOnThumbnailReceivedListener;
43 private ComponentName mComponentName;
42 44
43 interface OnThumbnailReceivedListener { 45 interface OnThumbnailReceivedListener {
44 void onThumbnailReceived(Bitmap bitmap); 46 void onThumbnailReceived(Bitmap bitmap);
45 } 47 }
46 48
47 private ContextMenuHelper(long nativeContextMenuHelper) { 49 private ContextMenuHelper(long nativeContextMenuHelper) {
48 mNativeContextMenuHelper = nativeContextMenuHelper; 50 mNativeContextMenuHelper = nativeContextMenuHelper;
49 } 51 }
50 52
51 @CalledByNative 53 @CalledByNative
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 if (mNativeContextMenuHelper == 0) return; 162 if (mNativeContextMenuHelper == 0) return;
161 nativeShareImage(mNativeContextMenuHelper); 163 nativeShareImage(mNativeContextMenuHelper);
162 } 164 }
163 165
164 @CalledByNative 166 @CalledByNative
165 private void onShareImageReceived( 167 private void onShareImageReceived(
166 WindowAndroid windowAndroid, byte[] jpegImageData) { 168 WindowAndroid windowAndroid, byte[] jpegImageData) {
167 Activity activity = windowAndroid.getActivity().get(); 169 Activity activity = windowAndroid.getActivity().get();
168 if (activity == null) return; 170 if (activity == null) return;
169 171
170 ShareHelper.shareImage(activity, jpegImageData); 172 ShareHelper.shareImage(activity, jpegImageData, mComponentName);
173 // Reset the component name so it can share otherwise.
Theresa 2017/03/27 21:17:43 This comment isn't very clear.
JJ 2017/03/27 23:23:09 Done.
174 mComponentName = null;
175 }
176
177 public void shareImageDirectly(ComponentName name) {
Theresa 2017/03/27 21:17:43 nit: this needs a JavaDoc.
JJ 2017/03/27 23:23:09 Done.
178 mComponentName = name;
179 shareImage();
171 } 180 }
172 181
173 public void getThumbnail() { 182 public void getThumbnail() {
174 if (mNativeContextMenuHelper == 0) return; 183 if (mNativeContextMenuHelper == 0) return;
175 nativeRetrieveHeaderThumbnail(mNativeContextMenuHelper); 184 nativeRetrieveHeaderThumbnail(mNativeContextMenuHelper);
176 } 185 }
177 186
178 @CalledByNative 187 @CalledByNative
179 private void onHeaderThumbnailReceived(WindowAndroid windowAndroid, byte[] j pegImageData) { 188 private void onHeaderThumbnailReceived(WindowAndroid windowAndroid, byte[] j pegImageData) {
180 Bitmap bitmap = BitmapFactory.decodeByteArray(jpegImageData, 0, jpegImag eData.length); 189 Bitmap bitmap = BitmapFactory.decodeByteArray(jpegImageData, 0, jpegImag eData.length);
(...skipping 23 matching lines...) Expand all
204 return mPopulator; 213 return mPopulator;
205 } 214 }
206 215
207 private native void nativeOnStartDownload( 216 private native void nativeOnStartDownload(
208 long nativeContextMenuHelper, boolean isLink, boolean isDataReductio nProxyEnabled); 217 long nativeContextMenuHelper, boolean isLink, boolean isDataReductio nProxyEnabled);
209 private native void nativeSearchForImage(long nativeContextMenuHelper); 218 private native void nativeSearchForImage(long nativeContextMenuHelper);
210 private native void nativeShareImage(long nativeContextMenuHelper); 219 private native void nativeShareImage(long nativeContextMenuHelper);
211 private native void nativeOnContextMenuClosed(long nativeContextMenuHelper); 220 private native void nativeOnContextMenuClosed(long nativeContextMenuHelper);
212 private native void nativeRetrieveHeaderThumbnail(long nativeContextMenuHelp er); 221 private native void nativeRetrieveHeaderThumbnail(long nativeContextMenuHelp er);
213 } 222 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698