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

Unified Diff: content/public/android/java/src/org/chromium/content/browser/DownloadController.java

Issue 1217223006: Prompt user for file access permission before download starts (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 5 years, 5 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 | « content/content_browser.gypi ('k') | content/public/browser/android/download_controller_android.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/android/java/src/org/chromium/content/browser/DownloadController.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/DownloadController.java b/content/public/android/java/src/org/chromium/content/browser/DownloadController.java
index 81bca73b004c478ddaf79ec1297031f73688a8e7..5634f6f97c148754408b5d69fce006e02f33c0d3 100644
--- a/content/public/android/java/src/org/chromium/content/browser/DownloadController.java
+++ b/content/public/android/java/src/org/chromium/content/browser/DownloadController.java
@@ -8,6 +8,7 @@ import android.content.Context;
import org.chromium.base.CalledByNative;
import org.chromium.base.JNINamespace;
+import org.chromium.ui.base.WindowAndroid.FileAccessCallback;
/**
* Java counterpart of android DownloadController.
@@ -162,6 +163,35 @@ public class DownloadController {
}
}
+ /**
+ * Returns whether file access is allowed.
+ *
+ * @param view The ContentViewCore to access file system.
+ * @return true if allowed, or false otherwise.
+ */
+ @CalledByNative
+ private boolean hasFileAccess(ContentViewCore view) {
+ return view.getWindowAndroid().hasFileAccess();
+ }
+
+ /**
+ * Called to prompt user with the file access permission.
+ *
+ * @param view The ContentViewCore to access file system.
+ * @param callbackId The native callback function pointer.
+ */
+ @CalledByNative
+ private void requestFileAccess(ContentViewCore view, final long callbackId) {
+ FileAccessCallback callback = new FileAccessCallback() {
+ @Override
+ public void onFileAccessResult(boolean granted) {
+ nativeOnRequestFileAccessResult(callbackId, granted);
+ }
+ };
+ view.getWindowAndroid().requestFileAccess(callback);
+ }
+
// native methods
private native void nativeInit();
+ private native void nativeOnRequestFileAccessResult(long callbackId, boolean granted);
}
« no previous file with comments | « content/content_browser.gypi ('k') | content/public/browser/android/download_controller_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698