Commit 330518ad authored by Sophey Dong's avatar Sophey Dong Committed by Commit Bot

[SharingHub] Change Screenshot shares to set FileUri.

Also removes URL from the screenshot share so they will share properly as image-only shares, and removes the distinction between screenshot and regular shares.

Bug: 1123862
Change-Id: Icc763397da04eed96e5d63e09e0a42170fa195c1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2393008
Commit-Queue: Sophey Dong <sophey@chromium.org>
Reviewed-by: default avatarKyle Milka <kmilka@chromium.org>
Reviewed-by: default avatarTanya Gupta <tgupta@chromium.org>
Cr-Commit-Position: refs/heads/master@{#806388}
parent c6a39f99
...@@ -18,6 +18,9 @@ import org.chromium.components.browser_ui.share.ShareParams; ...@@ -18,6 +18,9 @@ import org.chromium.components.browser_ui.share.ShareParams;
import org.chromium.ui.base.WindowAndroid; import org.chromium.ui.base.WindowAndroid;
import org.chromium.ui.modelutil.PropertyModel; import org.chromium.ui.modelutil.PropertyModel;
import java.util.ArrayList;
import java.util.Collections;
/** /**
* ScreenshotShareSheetMediator is in charge of calculating and setting values for * ScreenshotShareSheetMediator is in charge of calculating and setting values for
* ScreenshotShareSheetViewProperties. * ScreenshotShareSheetViewProperties.
...@@ -86,20 +89,19 @@ class ScreenshotShareSheetMediator { ...@@ -86,20 +89,19 @@ class ScreenshotShareSheetMediator {
Bitmap bitmap = mModel.get(ScreenshotShareSheetViewProperties.SCREENSHOT_BITMAP); Bitmap bitmap = mModel.get(ScreenshotShareSheetViewProperties.SCREENSHOT_BITMAP);
WindowAndroid window = mTab.getWindowAndroid(); WindowAndroid window = mTab.getWindowAndroid();
// TODO(1124799): Change title to screenshot title.
String title = mTab.getTitle(); String title = mTab.getTitle();
String visibleUrl = mTab.getUrlString();
Callback<Uri> callback = (bitmapUri) -> { Callback<Uri> callback = (bitmapUri) -> {
ShareParams params = new ShareParams.Builder(window, title, visibleUrl) ShareParams params =
.setScreenshotUri(bitmapUri) new ShareParams.Builder(window, title, /*url=*/"")
.setFileUris(new ArrayList<>(Collections.singletonList(bitmapUri)))
.setFileContentType(
window.getApplicationContext().getContentResolver().getType(
bitmapUri))
.build(); .build();
ChromeShareExtras chromeShareExtras = new ChromeShareExtras.Builder()
.setSaveLastUsed(false)
.setShareDirectly(false)
.setIsUrlOfVisiblePage(false)
.build();
mChromeOptionShareCallback.showThirdPartyShareSheet( mChromeOptionShareCallback.showThirdPartyShareSheet(
params, chromeShareExtras, System.currentTimeMillis()); params, new ChromeShareExtras.Builder().build(), System.currentTimeMillis());
}; };
generateTemporaryUriFromBitmap(mContext, title, bitmap, callback); generateTemporaryUriFromBitmap(mContext, title, bitmap, callback);
......
...@@ -203,12 +203,8 @@ public class ShareSheetPropertyModelBuilder { ...@@ -203,12 +203,8 @@ public class ShareSheetPropertyModelBuilder {
} }
mBottomSheetController.hideContent(bottomSheet, true); mBottomSheetController.hideContent(bottomSheet, true);
// Fire intent through ShareHelper. // Fire intent through ShareHelper.
if (params.getScreenshotUri() != null) {
ShareHelper.shareImage(window, component, params.getScreenshotUri());
} else {
ShareHelper.shareDirectly(params, component); ShareHelper.shareDirectly(params, component);
} }
}
/** /**
* Returns a list of compatible {@link ResolveInfo}s for the set of {@link ContentType}s. * Returns a list of compatible {@link ResolveInfo}s for the set of {@link ContentType}s.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment