Commit 0810f2fa authored by jaekyun's avatar jaekyun Committed by Commit bot

Put the screenshot URI in clipData

Adding Intent.FLAG_GRANT_READ_URI_PERMISSION only worked on specifit URIs
(EXTRA_STREAM, or MULTIPLE_STREAM).

So the URI should be put in ClipData to give read access to an Intent
target.

BUG=480047

Review URL: https://codereview.chromium.org/1101743003

Cr-Commit-Position: refs/heads/master@{#326701}
parent f01e1802
...@@ -6,6 +6,7 @@ package org.chromium.chrome.browser.share; ...@@ -6,6 +6,7 @@ package org.chromium.chrome.browser.share;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.ClipData;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
...@@ -253,6 +254,10 @@ public class ShareHelper { ...@@ -253,6 +254,10 @@ public class ShareHelper {
intent.putExtra(Intent.EXTRA_TEXT, url); intent.putExtra(Intent.EXTRA_TEXT, url);
if (screenshotUri != null) { if (screenshotUri != null) {
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
// To give read access to an Intent target, we need to put |screenshotUri| in clipData
// because adding Intent.FLAG_GRANT_READ_URI_PERMISSION doesn't work for
// EXTRA_SHARE_SCREENSHOT_AS_STREAM.
intent.setClipData(ClipData.newRawUri("", screenshotUri));
intent.putExtra(EXTRA_SHARE_SCREENSHOT_AS_STREAM, screenshotUri); intent.putExtra(EXTRA_SHARE_SCREENSHOT_AS_STREAM, screenshotUri);
} }
return intent; return intent;
......
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