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

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

Issue 2014803002: Move DownloadControllerAndroid from content/ to chrome/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix failing tests/bugs Created 4 years, 6 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
Index: chrome/android/java/src/org/chromium/chrome/browser/download/DownloadController.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/DownloadController.java b/chrome/android/java/src/org/chromium/chrome/browser/download/DownloadController.java
similarity index 62%
rename from content/public/android/java/src/org/chromium/content/browser/DownloadController.java
rename to chrome/android/java/src/org/chromium/chrome/browser/download/DownloadController.java
index 86cc27d3afb9a099b23469f7e68ff648cf8077d4..375ede60f245fb715fd8a67242b0cb8899349f89 100644
--- a/content/public/android/java/src/org/chromium/content/browser/DownloadController.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/download/DownloadController.java
@@ -2,21 +2,18 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.chromium.content.browser;
+package org.chromium.chrome.browser.download;
import android.Manifest.permission;
-import android.content.pm.PackageManager;
import org.chromium.base.annotations.CalledByNative;
-import org.chromium.base.annotations.JNINamespace;
-import org.chromium.ui.base.WindowAndroid.PermissionCallback;
+import org.chromium.ui.base.WindowAndroid;
/**
* Java counterpart of android DownloadController.
*
* Its a singleton class instantiated by the C++ DownloadController.
*/
-@JNINamespace("content")
public class DownloadController {
private static final String LOGTAG = "DownloadController";
private static final DownloadController sInstance = new DownloadController();
@@ -62,60 +59,11 @@ public class DownloadController {
nativeInit();
}
- private static ContentViewDownloadDelegate downloadDelegateFromView(ContentViewCore view) {
- return view.getDownloadDelegate();
- }
-
public static void setDownloadNotificationService(DownloadNotificationService service) {
sDownloadNotificationService = service;
}
/**
- * Notifies the download delegate of a new GET download and passes all the information
- * needed to download the file.
- *
- * The download delegate is expected to handle the download.
- */
- @CalledByNative
- private void newHttpGetDownload(ContentViewCore view, String url,
- String userAgent, String contentDisposition, String mimeType,
- String cookie, String referer, boolean hasUserGesture,
- String filename, long contentLength, boolean mustDownload) {
- ContentViewDownloadDelegate downloadDelegate = downloadDelegateFromView(view);
-
- if (downloadDelegate == null) return;
- DownloadInfo downloadInfo = new DownloadInfo.Builder()
- .setUrl(url)
- .setUserAgent(userAgent)
- .setContentDisposition(contentDisposition)
- .setMimeType(mimeType)
- .setCookie(cookie)
- .setReferer(referer)
- .setHasUserGesture(hasUserGesture)
- .setFileName(filename)
- .setContentLength(contentLength)
- .setIsGETRequest(true)
- .build();
- downloadDelegate.requestHttpGetDownload(downloadInfo, mustDownload);
- }
-
- /**
- * Notifies the download delegate that a new download has started. This can
- * be either a POST download or a GET download with authentication.
- * @param view ContentViewCore associated with the download item.
- * @param filename File name of the downloaded file.
- * @param mimeType Mime of the downloaded item.
- */
- @CalledByNative
- private void onDownloadStarted(ContentViewCore view, String filename, String mimeType) {
- ContentViewDownloadDelegate downloadDelegate = downloadDelegateFromView(view);
-
- if (downloadDelegate != null) {
- downloadDelegate.onDownloadStarted(filename, mimeType);
- }
- }
-
- /**
* Notifies the download delegate that a download completed and passes along info about the
* download. This can be either a POST download or a GET download with authentication.
*/
@@ -203,51 +151,16 @@ public class DownloadController {
sDownloadNotificationService.onDownloadUpdated(downloadInfo);
}
- /**
- * Notifies the download delegate that a dangerous download started.
- */
- @CalledByNative
- private void onDangerousDownload(ContentViewCore view, String filename, String downloadGuid) {
- ContentViewDownloadDelegate downloadDelegate = downloadDelegateFromView(view);
- if (downloadDelegate != null) {
- downloadDelegate.onDangerousDownload(filename, downloadGuid);
- }
- }
/**
* Returns whether file access is allowed.
*
- * @param view The ContentViewCore to access file system.
+ * @param windowAndroid WindowAndroid to access file system.
* @return true if allowed, or false otherwise.
*/
@CalledByNative
- private boolean hasFileAccess(ContentViewCore view) {
- return view.getWindowAndroid().hasPermission(permission.WRITE_EXTERNAL_STORAGE);
- }
-
- /**
- * 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(final ContentViewCore view, final long callbackId) {
- ContentViewDownloadDelegate downloadDelegate = downloadDelegateFromView(view);
- if (downloadDelegate != null) {
- downloadDelegate.requestFileAccess(callbackId);
- } else {
- PermissionCallback permissionCallback = new PermissionCallback() {
- @Override
- public void onRequestPermissionsResult(String[] permissions, int[] grantResults) {
- onRequestFileAccessResult(callbackId, grantResults.length > 0
- && grantResults[0] == PackageManager.PERMISSION_GRANTED);
- }
- };
- view.getWindowAndroid().requestPermissions(
- new String[] {android.Manifest.permission.WRITE_EXTERNAL_STORAGE},
- permissionCallback);
- }
+ private boolean hasFileAccess(WindowAndroid windowAndroid) {
+ return windowAndroid.hasPermission(permission.WRITE_EXTERNAL_STORAGE);
}
/**

Powered by Google App Engine
This is Rietveld 408576698