Move DownloadListener handling out to webview layer
Simplifies the content/ layer by not having to know about the webkit.DownloadListener interface. BUG= Review URL: https://chromiumcodereview.appspot.com/11139003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@161727 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
content/public/android/java/src/org/chromium/content/browser
@ -19,7 +19,6 @@ import android.view.accessibility.AccessibilityEvent;
|
||||
import android.view.accessibility.AccessibilityNodeInfo;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.view.inputmethod.InputConnection;
|
||||
import android.webkit.DownloadListener;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -706,31 +705,11 @@ public class ContentView extends FrameLayout implements ContentViewCore.Internal
|
||||
return mContentViewCore.isMultiTouchZoomSupported();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the listener to be used when content can not be handled by the
|
||||
* rendering engine, and should be downloaded instead. This will replace the
|
||||
* current listener.
|
||||
* @param listener An implementation of DownloadListener.
|
||||
*/
|
||||
// TODO(nileshagrawal): decide if setDownloadDelegate will be public API. If so,
|
||||
// this method should be deprecated and the javadoc should make reference to the
|
||||
// fact that a ContentViewDownloadDelegate will be used in preference to a
|
||||
// DownloadListener.
|
||||
public void setDownloadListener(DownloadListener listener) {
|
||||
mContentViewCore.setDownloadListener(listener);
|
||||
}
|
||||
|
||||
// Called by DownloadController.
|
||||
DownloadListener downloadListener() {
|
||||
return mContentViewCore.downloadListener();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the delegate to be used when content can not be handled by
|
||||
* the rendering engine, and should be downloaded instead. This will replace
|
||||
* the current delegate or existing DownloadListner.
|
||||
* Embedders should prefer this over the legacy DownloadListener.
|
||||
* @param listener An implementation of ContentViewDownloadDelegate.
|
||||
* the current delegate.
|
||||
* @param delegate An implementation of ContentViewDownloadDelegate.
|
||||
*/
|
||||
public void setDownloadDelegate(ContentViewDownloadDelegate delegate) {
|
||||
mContentViewCore.setDownloadDelegate(delegate);
|
||||
|
@ -33,7 +33,6 @@ import android.view.accessibility.AccessibilityNodeInfo;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.view.inputmethod.InputConnection;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.webkit.DownloadListener;
|
||||
|
||||
import org.chromium.base.CalledByNative;
|
||||
import org.chromium.base.JNINamespace;
|
||||
@ -213,11 +212,7 @@ public class ContentViewCore implements MotionEventDelegate {
|
||||
// private ActionMode mActionMode;
|
||||
private boolean mActionBarVisible; // Remove this when mActionMode is upstreamed.
|
||||
|
||||
// The legacy webview DownloadListener.
|
||||
private DownloadListener mDownloadListener;
|
||||
// ContentViewDownloadDelegate adds support for authenticated downloads
|
||||
// and POST downloads. Embedders should prefer ContentViewDownloadDelegate
|
||||
// over DownloadListener.
|
||||
// Delegate that will handle GET downloads, and be notified of completion of POST downloads.
|
||||
private ContentViewDownloadDelegate mDownloadDelegate;
|
||||
|
||||
// Whether a physical keyboard is connected.
|
||||
@ -1399,31 +1394,11 @@ public class ContentViewCore implements MotionEventDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the listener to be used when content can not be handled by the
|
||||
* rendering engine, and should be downloaded instead. This will replace the
|
||||
* current listener.
|
||||
* @param listener An implementation of DownloadListener.
|
||||
*/
|
||||
// TODO(nileshagrawal): decide if setDownloadDelegate will be public API. If so,
|
||||
// this method should be deprecated and the javadoc should make reference to the
|
||||
// fact that a ContentViewDownloadDelegate will be used in preference to a
|
||||
// DownloadListener.
|
||||
public void setDownloadListener(DownloadListener listener) {
|
||||
mDownloadListener = listener;
|
||||
}
|
||||
|
||||
// Called by DownloadController.
|
||||
DownloadListener downloadListener() {
|
||||
return mDownloadListener;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the delegate to be used when content can not be handled by
|
||||
* the rendering engine, and should be downloaded instead. This will replace
|
||||
* the current delegate or existing DownloadListner.
|
||||
* Embedders should prefer this over the legacy DownloadListener.
|
||||
* @param listener An implementation of ContentViewDownloadDelegate.
|
||||
* the current delegate, if any.
|
||||
* @param delegate An implementation of ContentViewDownloadDelegate.
|
||||
*/
|
||||
public void setDownloadDelegate(ContentViewDownloadDelegate delegate) {
|
||||
mDownloadDelegate = delegate;
|
||||
|
@ -5,7 +5,6 @@
|
||||
package org.chromium.content.browser;
|
||||
|
||||
import android.content.Context;
|
||||
import android.webkit.DownloadListener;
|
||||
|
||||
import org.chromium.base.CalledByNative;
|
||||
import org.chromium.base.JNINamespace;
|
||||
@ -33,10 +32,6 @@ class DownloadController {
|
||||
nativeInit();
|
||||
}
|
||||
|
||||
private static DownloadListener listenerFromView(ContentViewCore view) {
|
||||
return view.downloadListener();
|
||||
}
|
||||
|
||||
private static ContentViewDownloadDelegate downloadDelegateFromView(ContentViewCore view) {
|
||||
return view.getDownloadDelegate();
|
||||
}
|
||||
@ -46,10 +41,10 @@ class DownloadController {
|
||||
}
|
||||
|
||||
/**
|
||||
* Notifies the DownloadListener of a new GET download and passes all the information
|
||||
* Notifies the download delegate of a new GET download and passes all the information
|
||||
* needed to download the file.
|
||||
*
|
||||
* The DownloadListener is expected to handle the download.
|
||||
* The download delegate is expected to handle the download.
|
||||
*/
|
||||
@CalledByNative
|
||||
public void newHttpGetDownload(ContentViewCore view, String url,
|
||||
@ -60,17 +55,11 @@ class DownloadController {
|
||||
if (downloadDelagate != null) {
|
||||
downloadDelagate.requestHttpGetDownload(url, userAgent, contentDisposition,
|
||||
mimetype, cookie, referer, contentLength);
|
||||
return;
|
||||
}
|
||||
|
||||
DownloadListener listener = listenerFromView(view);
|
||||
if (listener != null) {
|
||||
listener.onDownloadStart(url, userAgent, contentDisposition, mimetype, contentLength);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notifies the DownloadListener that a new POST download has started.
|
||||
* Notifies the download delegate that a new POST download has started.
|
||||
*/
|
||||
@CalledByNative
|
||||
public void onHttpPostDownloadStarted(ContentViewCore view) {
|
||||
@ -82,7 +71,7 @@ class DownloadController {
|
||||
}
|
||||
|
||||
/**
|
||||
* Notifies the DownloadListener that a POST download completed and passes along info about the
|
||||
* Notifies the download delegate that a POST download completed and passes along info about the
|
||||
* download.
|
||||
*/
|
||||
@CalledByNative
|
||||
|
Reference in New Issue
Block a user