Skip to content

Commit

Permalink
Temporarily disable opening file:// on Android TM
Browse files Browse the repository at this point in the history
In Android TM for apps targeting API 33, READ_EXTERNAL_STORAGE is split
into specific permissions for READ_MEDIA_*. For now, skip requesting
READ_EXTERNAL_STORAGE when the user navigates to file:// URLs. Opening
the file:// will still fail, but the user won't first be prompted to
accept a permission that has no effect.

(cherry picked from commit 9501a42)

Bug: 1316672
Change-Id: I6fbcd6466f9ecda544712151bb3cdc2e04496897
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3587279
Reviewed-by: Ted Choc <tedchoc@chromium.org>
Commit-Queue: Theresa Sullivan <twellington@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#993351}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3594606
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/branch-heads/5005@{#35}
Cr-Branched-From: 5b4d945-refs/heads/main@{#992738}
  • Loading branch information
Theresa Sullivan authored and Chromium LUCI CQ committed Apr 19, 2022
1 parent 0e3612b commit 3630083
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.AlertDialog;

import org.chromium.base.BuildInfo;
import org.chromium.base.CommandLine;
import org.chromium.base.ContextUtils;
import org.chromium.base.IntentUtils;
Expand Down Expand Up @@ -2064,6 +2065,10 @@ protected GURL getLastCommittedUrl() {
*/
@VisibleForTesting
protected boolean shouldRequestFileAccess(GURL url) {
// TODO(https://crbug.com/1316672): Replace READ_EXTERNAL_STORAGE with READ_MEDIA_*
// permissions to restore capability to open file:// on Android T.
if (BuildInfo.isAtLeastT()) return false;

// If the tab is null, then do not attempt to prompt for access.
if (!mDelegate.hasValidTab()) return false;
assert url.getScheme().equals(UrlConstants.FILE_SCHEME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import org.chromium.base.ThreadUtils;
import org.chromium.base.test.BaseJUnit4ClassRunner;
import org.chromium.base.test.util.Batch;
import org.chromium.base.test.util.MaxAndroidSdkLevel;
import org.chromium.components.external_intents.ExternalNavigationDelegate.IntentToAutofillAllowingAppResult;
import org.chromium.components.external_intents.ExternalNavigationHandler.OverrideUrlLoadingAsyncActionType;
import org.chromium.components.external_intents.ExternalNavigationHandler.OverrideUrlLoadingResult;
Expand Down Expand Up @@ -1835,6 +1836,7 @@ public void testNavigationWithForwardBack() {
@Test
@SuppressLint("SdCardPath")
@SmallTest
@MaxAndroidSdkLevel(Build.VERSION_CODES.S)
public void testFileAccess() {
String fileUrl = "file:///sdcard/Downloads/test.html";

Expand Down

0 comments on commit 3630083

Please sign in to comment.