From fc3f4ee8a0fb2c50ad77f4c9ceae5590a021f3e4 Mon Sep 17 00:00:00 2001 From: Selim Gurun Date: Tue, 20 Aug 2013 07:04:20 -0700 Subject: Added the callback signal. Bug:10190508 Change-Id: I52b327e0724938e1de7ce7550d26563364ff1589 --- core/java/android/webkit/WebView.java | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) (limited to 'core/java/android/webkit/WebView.java') diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index 03bde70..1b57d50 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -28,6 +28,7 @@ import android.graphics.drawable.Drawable; import android.net.http.SslCertificate; import android.os.Build; import android.os.Bundle; +import android.os.CancellationSignal; import android.os.Looper; import android.os.Message; import android.os.StrictMode; @@ -1043,24 +1044,26 @@ public class WebView extends AbsoluteLayout * @param width The page width. Should be larger than 0. * @param height The page height. Should be larger than 0. * @param resultCallback A callback to be invoked when the PDF content is exported. - * A true indicates success, and a false failure. - * - * TODO: explain method parameters, margins, consider making the callback - * return more meaningful information, explain any threading concerns, HW - * draw limitations, and make it public. - * TODO: at the moment we are asking app to provide paper size information (width - * and height). This is likely not ideal (I think need margin info too). - * Another approach would be using PrintAttributes. This is to be clarified later. - * - * TODO: explain this webview will not draw during export (onDraw will clear to - * background color) so recommend taking it offscreen, or putting in a layer with an - * overlaid progress UI / spinner. + * A true indicates success, and a false failure. Cannot be null. + * @param cancellationSignal Signal for cancelling the PDF conversion request. Must not + * be null. + * + * The PDF conversion is done asynchronously and the PDF output is written to the provided + * outputstream. The caller should not close the outputstream until the resultCallback is + * called, indicating PDF conversion is complete. Webview cannot be drawn during the pdf + * export so the application is recommended to take it offscreen, or putting in a layer + * with an overlaid progress UI / spinner. + * + * If the caller cancels the task using the cancellationSignal, the cancellation will be + * acked using the resultCallback signal. + * + * TODO(sgurun) margins, explain the units, make it public. * @hide */ public void exportToPdf(OutputStream out, int width, int height, - ValueCallback resultCallback) { + ValueCallback resultCallback, CancellationSignal cancellationSignal) { checkThread(); - mProvider.exportToPdf(out, width, height, resultCallback); + mProvider.exportToPdf(out, width, height, resultCallback, cancellationSignal); } /** -- cgit v1.1