Index: chrome/android/java/src/org/chromium/chrome/browser/share/ShareHelper.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/share/ShareHelper.java b/chrome/android/java/src/org/chromium/chrome/browser/share/ShareHelper.java |
index 79ef3a334bb661d51960348702b5927b4ee1a11c..57d11a63d40ff95ef346112b7ed9685e4e33ad04 100644 |
--- a/chrome/android/java/src/org/chromium/chrome/browser/share/ShareHelper.java |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/share/ShareHelper.java |
@@ -363,15 +363,19 @@ public class ShareHelper { |
if (ApplicationStatus.getStateForApplication() |
!= ApplicationState.HAS_DESTROYED_ACTIVITIES) { |
Uri imageUri = ApiCompatibilityUtils.getUriForImageCaptureFile(saveFile); |
- |
+ Intent shareIntent = getShareImageIntent(imageUri); |
if (name == null) { |
- Intent chooserIntent = Intent.createChooser(getShareImageIntent(imageUri), |
- activity.getString(R.string.share_link_chooser_title)); |
- fireIntent(activity, chooserIntent); |
+ if (TargetChosenReceiver.isSupported()) { |
+ TargetChosenReceiver.sendChooserIntent( |
+ true, activity, shareIntent, null); |
+ } else { |
+ Intent chooserIntent = Intent.createChooser(shareIntent, |
+ activity.getString(R.string.share_link_chooser_title)); |
+ fireIntent(activity, chooserIntent); |
+ } |
} else { |
- Intent imageIntent = getShareImageIntent(imageUri); |
- imageIntent.setComponent(name); |
- fireIntent(activity, imageIntent); |
+ shareIntent.setComponent(name); |
+ fireIntent(activity, shareIntent); |
} |
} |
} |
@@ -548,7 +552,8 @@ public class ShareHelper { |
* @param item The menu item that is used for direct share |
*/ |
public static void configureDirectShareMenuItem(Activity activity, MenuItem item) { |
- Pair<Drawable, CharSequence> directShare = getShareableIconAndName(activity); |
+ Intent shareIntent = getShareIntent(activity, "", "", "", null, null); |
+ Pair<Drawable, CharSequence> directShare = getShareableIconAndName(activity, shareIntent); |
Drawable directShareIcon = directShare.first; |
CharSequence directShareTitle = directShare.second; |
@@ -562,19 +567,20 @@ public class ShareHelper { |
/** |
* Get the icon and name of the most recently shared app within chrome. |
* @param activity Activity that is used to access the package manager. |
+ * @param shareIntent Intent used to get list of apps support sharing. |
* @return The Image and the String of the recently shared Icon. |
*/ |
- public static Pair<Drawable, CharSequence> getShareableIconAndName(Activity activity) { |
+ public static Pair<Drawable, CharSequence> getShareableIconAndName( |
+ Activity activity, Intent shareIntent) { |
Drawable directShareIcon = null; |
CharSequence directShareTitle = null; |
final ComponentName component = getLastShareComponentName(); |
boolean isComponentValid = false; |
if (component != null) { |
- Intent intent = getShareIntent(activity, "", "", "", null, null); |
- intent.setPackage(component.getPackageName()); |
+ shareIntent.setPackage(component.getPackageName()); |
PackageManager manager = activity.getPackageManager(); |
- List<ResolveInfo> resolveInfoList = manager.queryIntentActivities(intent, 0); |
+ List<ResolveInfo> resolveInfoList = manager.queryIntentActivities(shareIntent, 0); |
for (ResolveInfo info : resolveInfoList) { |
ActivityInfo ai = info.activityInfo; |
if (component.equals(new ComponentName(ai.applicationInfo.packageName, ai.name))) { |
@@ -677,7 +683,12 @@ public class ShareHelper { |
return intent; |
} |
- private static Intent getShareImageIntent(Uri imageUri) { |
+ /** |
+ * Creates an Intent to share an image. |
+ * @param imageUri The Uri of the image. |
+ * @return The Intent used to share the image. |
+ */ |
+ public static Intent getShareImageIntent(Uri imageUri) { |
Intent intent = new Intent(Intent.ACTION_SEND); |
intent.addFlags(ApiCompatibilityUtils.getActivityNewDocumentFlag()); |
intent.setType("image/jpeg"); |