| 1 | /* |
| 2 | * Copyright (C) 2013 Apple Inc. All rights reserved. |
| 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions |
| 6 | * are met: |
| 7 | * 1. Redistributions of source code must retain the above copyright |
| 8 | * notice, this list of conditions and the following disclaimer. |
| 9 | * 2. Redistributions in binary form must reproduce the above copyright |
| 10 | * notice, this list of conditions and the following disclaimer in the |
| 11 | * documentation and/or other materials provided with the distribution. |
| 12 | * |
| 13 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' |
| 14 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
| 15 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS |
| 17 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 18 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 19 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 20 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 21 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 22 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
| 23 | * THE POSSIBILITY OF SUCH DAMAGE. |
| 24 | */ |
| 25 | |
| 26 | #ifndef WKContextDownloadClient_h |
| 27 | #define WKContextDownloadClient_h |
| 28 | |
| 29 | #include <WebKit/WKBase.h> |
| 30 | |
| 31 | typedef void (*WKContextDownloadDidStartCallback)(WKContextRef context, WKDownloadRef download, const void *clientInfo); |
| 32 | typedef void (*WKContextDownloadDidReceiveAuthenticationChallengeCallback)(WKContextRef context, WKDownloadRef download, WKAuthenticationChallengeRef authenticationChallenge, const void *clientInfo); |
| 33 | typedef void (*WKContextDownloadDidReceiveResponseCallback)(WKContextRef context, WKDownloadRef download, WKURLResponseRef response, const void *clientInfo); |
| 34 | typedef void (*WKContextDownloadDidReceiveDataCallback)(WKContextRef context, WKDownloadRef download, uint64_t length, const void *clientInfo); |
| 35 | typedef bool (*WKContextDownloadShouldDecodeSourceDataOfMIMETypeCallback)(WKContextRef context, WKDownloadRef download, WKStringRef mimeType, const void *clientInfo); |
| 36 | typedef WKStringRef (*WKContextDownloadDecideDestinationWithSuggestedFilenameCallback)(WKContextRef context, WKDownloadRef download, WKStringRef filename, bool* allowOverwrite, const void *clientInfo); |
| 37 | typedef void (*WKContextDownloadDidCreateDestinationCallback)(WKContextRef context, WKDownloadRef download, WKStringRef path, const void *clientInfo); |
| 38 | typedef void (*WKContextDownloadDidFinishCallback)(WKContextRef context, WKDownloadRef download, const void *clientInfo); |
| 39 | typedef void (*WKContextDownloadDidFailCallback)(WKContextRef context, WKDownloadRef download, WKErrorRef error, const void *clientInfo); |
| 40 | typedef void (*WKContextDownloadDidCancel)(WKContextRef context, WKDownloadRef download, const void *clientInfo); |
| 41 | typedef void (*WKContextDownloadProcessDidCrashCallback)(WKContextRef context, WKDownloadRef download, const void *clientInfo); |
| 42 | typedef void (*WKContextDownloadDidReceiveServerRedirect)(WKContextRef context, WKDownloadRef download, WKURLRef url, const void *clientInfo); |
| 43 | |
| 44 | typedef struct WKContextDownloadClientBase { |
| 45 | int version; |
| 46 | const void * clientInfo; |
| 47 | } WKContextDownloadClientBase; |
| 48 | |
| 49 | typedef struct WKContextDownloadClientV0 { |
| 50 | WKContextDownloadClientBase base; |
| 51 | |
| 52 | // Version 0. |
| 53 | WKContextDownloadDidStartCallback didStart; |
| 54 | WKContextDownloadDidReceiveAuthenticationChallengeCallback didReceiveAuthenticationChallenge; |
| 55 | WKContextDownloadDidReceiveResponseCallback didReceiveResponse; |
| 56 | WKContextDownloadDidReceiveDataCallback didReceiveData; |
| 57 | WKContextDownloadShouldDecodeSourceDataOfMIMETypeCallback shouldDecodeSourceDataOfMIMEType; |
| 58 | WKContextDownloadDecideDestinationWithSuggestedFilenameCallback decideDestinationWithSuggestedFilename; |
| 59 | WKContextDownloadDidCreateDestinationCallback didCreateDestination; |
| 60 | WKContextDownloadDidFinishCallback didFinish; |
| 61 | WKContextDownloadDidFailCallback didFail; |
| 62 | WKContextDownloadDidCancel didCancel; |
| 63 | WKContextDownloadProcessDidCrashCallback processDidCrash; |
| 64 | } WKContextDownloadClientV0; |
| 65 | |
| 66 | typedef struct WKContextDownloadClientV1 { |
| 67 | WKContextDownloadClientBase base; |
| 68 | |
| 69 | // Version 0. |
| 70 | WKContextDownloadDidStartCallback didStart; |
| 71 | WKContextDownloadDidReceiveAuthenticationChallengeCallback didReceiveAuthenticationChallenge; |
| 72 | WKContextDownloadDidReceiveResponseCallback didReceiveResponse; |
| 73 | WKContextDownloadDidReceiveDataCallback didReceiveData; |
| 74 | WKContextDownloadShouldDecodeSourceDataOfMIMETypeCallback shouldDecodeSourceDataOfMIMEType; |
| 75 | WKContextDownloadDecideDestinationWithSuggestedFilenameCallback decideDestinationWithSuggestedFilename; |
| 76 | WKContextDownloadDidCreateDestinationCallback didCreateDestination; |
| 77 | WKContextDownloadDidFinishCallback didFinish; |
| 78 | WKContextDownloadDidFailCallback didFail; |
| 79 | WKContextDownloadDidCancel didCancel; |
| 80 | WKContextDownloadProcessDidCrashCallback processDidCrash; |
| 81 | |
| 82 | // Version 1. |
| 83 | WKContextDownloadDidReceiveServerRedirect didReceiveServerRedirect; |
| 84 | } WKContextDownloadClientV1; |
| 85 | |
| 86 | #endif // WKContextDownloadClient_h |
| 87 | |