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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/download/ChromeDownloadDelegate.java

Issue 2850223002: remove reliance on webcontents when requesting storage permission (Closed)
Patch Set: fix mock class Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/download/DownloadController.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/download/ChromeDownloadDelegate.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/download/ChromeDownloadDelegate.java b/chrome/android/java/src/org/chromium/chrome/browser/download/ChromeDownloadDelegate.java
index a9748f4468107fb22237c6a904bb20f18dd3a84d..a11f58d718a8acf16ff99a46f47e70603ce3fec9 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/download/ChromeDownloadDelegate.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/download/ChromeDownloadDelegate.java
@@ -8,23 +8,18 @@ import android.Manifest.permission;
import android.app.Activity;
import android.app.DownloadManager;
import android.content.Context;
-import android.content.DialogInterface;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Environment;
import android.os.Handler;
-import android.support.v7.app.AlertDialog;
import android.text.TextUtils;
-import android.view.View;
import android.webkit.MimeTypeMap;
import android.webkit.URLUtil;
-import android.widget.TextView;
import org.chromium.base.Log;
import org.chromium.base.ThreadUtils;
import org.chromium.base.annotations.CalledByNative;
-import org.chromium.chrome.R;
import org.chromium.chrome.browser.ChromeActivity;
import org.chromium.chrome.browser.UrlConstants;
import org.chromium.chrome.browser.tab.EmptyTabObserver;
@@ -135,64 +130,6 @@ public class ChromeDownloadDelegate {
return downloadInfo.getUrl();
}
- @CalledByNative
- private void requestFileAccess(final long callbackId) {
- if (mTab == null || mTab.getWindowAndroid() == null) {
- // TODO(tedchoc): Show toast (only when activity is alive).
- DownloadController.getInstance().onRequestFileAccessResult(callbackId, false);
- return;
- }
- final String storagePermission = android.Manifest.permission.WRITE_EXTERNAL_STORAGE;
- final Activity activity = mTab.getWindowAndroid().getActivity().get();
-
- if (activity == null) {
- DownloadController.getInstance().onRequestFileAccessResult(callbackId, false);
- } else if (mTab.getWindowAndroid().canRequestPermission(storagePermission)) {
- View view = activity.getLayoutInflater().inflate(
- R.layout.update_permissions_dialog, null);
- TextView dialogText = (TextView) view.findViewById(R.id.text);
- dialogText.setText(R.string.missing_storage_permission_download_education_text);
-
- final PermissionCallback permissionCallback = new PermissionCallback() {
- @Override
- public void onRequestPermissionsResult(String[] permissions, int[] grantResults) {
- DownloadController.getInstance().onRequestFileAccessResult(callbackId,
- grantResults.length > 0
- && grantResults[0] == PackageManager.PERMISSION_GRANTED);
- }
- };
-
- AlertDialog.Builder builder =
- new AlertDialog.Builder(activity, R.style.AlertDialogTheme)
- .setView(view)
- .setPositiveButton(R.string.infobar_update_permissions_button_text,
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int id) {
- if (mTab == null) {
- dialog.cancel();
- return;
- }
- mTab.getWindowAndroid().requestPermissions(
- new String[] {storagePermission}, permissionCallback);
- }
- })
- .setOnCancelListener(new DialogInterface.OnCancelListener() {
- @Override
- public void onCancel(DialogInterface dialog) {
- DownloadController.getInstance().onRequestFileAccessResult(
- callbackId, false);
- }
- });
- builder.create().show();
- } else if (!mTab.getWindowAndroid().isPermissionRevokedByPolicy(storagePermission)) {
- nativeLaunchPermissionUpdateInfoBar(mTab, storagePermission, callbackId);
- } else {
- // TODO(tedchoc): Show toast.
- DownloadController.getInstance().onRequestFileAccessResult(callbackId, false);
- }
- }
-
/**
* Return the full path of the download directory.
*
@@ -497,6 +434,4 @@ public class ChromeDownloadDelegate {
private static native String nativeGetDownloadWarningText(String filename);
private static native void nativeLaunchDuplicateDownloadInfoBar(ChromeDownloadDelegate delegate,
Tab tab, DownloadInfo downloadInfo, String filePath, boolean isIncognito);
- private static native void nativeLaunchPermissionUpdateInfoBar(
- Tab tab, String permission, long callbackId);
}
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/download/DownloadController.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698