Home | History | Annotate | Download | only in C
      1 /*
      2  * Copyright (C) 2010, 2011 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 WKContext_h
     27 #define WKContext_h
     28 
     29 #include <WebKit2/WKBase.h>
     30 
     31 #ifdef __cplusplus
     32 extern "C" {
     33 #endif
     34 
     35 enum {
     36     kWKCacheModelDocumentViewer = 0,
     37     kWKCacheModelDocumentBrowser = 1,
     38     kWKCacheModelPrimaryWebBrowser = 2
     39 };
     40 typedef uint32_t WKCacheModel;
     41 
     42 // Injected Bundle Client
     43 typedef void (*WKContextDidReceiveMessageFromInjectedBundleCallback)(WKContextRef page, WKStringRef messageName, WKTypeRef messageBody, const void *clientInfo);
     44 typedef void (*WKContextDidReceiveSynchronousMessageFromInjectedBundleCallback)(WKContextRef page, WKStringRef messageName, WKTypeRef messageBody, WKTypeRef* returnData, const void *clientInfo);
     45 
     46 struct WKContextInjectedBundleClient {
     47     int                                                                 version;
     48     const void *                                                        clientInfo;
     49     WKContextDidReceiveMessageFromInjectedBundleCallback                didReceiveMessageFromInjectedBundle;
     50     WKContextDidReceiveSynchronousMessageFromInjectedBundleCallback     didReceiveSynchronousMessageFromInjectedBundle;
     51 };
     52 typedef struct WKContextInjectedBundleClient WKContextInjectedBundleClient;
     53 
     54 // History Client
     55 typedef void (*WKContextDidNavigateWithNavigationDataCallback)(WKContextRef context, WKPageRef page, WKNavigationDataRef navigationData, WKFrameRef frame, const void *clientInfo);
     56 typedef void (*WKContextDidPerformClientRedirectCallback)(WKContextRef context, WKPageRef page, WKURLRef sourceURL, WKURLRef destinationURL, WKFrameRef frame, const void *clientInfo);
     57 typedef void (*WKContextDidPerformServerRedirectCallback)(WKContextRef context, WKPageRef page, WKURLRef sourceURL, WKURLRef destinationURL, WKFrameRef frame, const void *clientInfo);
     58 typedef void (*WKContextDidUpdateHistoryTitleCallback)(WKContextRef context, WKPageRef page, WKStringRef title, WKURLRef URL, WKFrameRef frame, const void *clientInfo);
     59 typedef void (*WKContextPopulateVisitedLinksCallback)(WKContextRef context, const void *clientInfo);
     60 
     61 struct WKContextHistoryClient {
     62     int                                                                 version;
     63     const void *                                                        clientInfo;
     64     WKContextDidNavigateWithNavigationDataCallback                      didNavigateWithNavigationData;
     65     WKContextDidPerformClientRedirectCallback                           didPerformClientRedirect;
     66     WKContextDidPerformServerRedirectCallback                           didPerformServerRedirect;
     67     WKContextDidUpdateHistoryTitleCallback                              didUpdateHistoryTitle;
     68     WKContextPopulateVisitedLinksCallback                               populateVisitedLinks;
     69 };
     70 typedef struct WKContextHistoryClient WKContextHistoryClient;
     71 
     72 // Download Client
     73 typedef void (*WKContextDownloadDidStartCallback)(WKContextRef context, WKDownloadRef download, const void *clientInfo);
     74 typedef void (*WKContextDownloadDidReceiveAuthenticationChallengeCallback)(WKContextRef context, WKDownloadRef download, WKAuthenticationChallengeRef authenticationChallenge, const void *clientInfo);
     75 typedef void (*WKContextDownloadDidReceiveResponseCallback)(WKContextRef context, WKDownloadRef download, WKURLResponseRef response, const void *clientInfo);
     76 typedef void (*WKContextDownloadDidReceiveDataCallback)(WKContextRef context, WKDownloadRef download, uint64_t length, const void *clientInfo);
     77 typedef bool (*WKContextDownloadShouldDecodeSourceDataOfMIMETypeCallback)(WKContextRef context, WKDownloadRef download, WKStringRef mimeType, const void *clientInfo);
     78 typedef WKStringRef (*WKContextDownloadDecideDestinationWithSuggestedFilenameCallback)(WKContextRef context, WKDownloadRef download, WKStringRef filename, bool* allowOverwrite, const void *clientInfo);
     79 typedef void (*WKContextDownloadDidCreateDestinationCallback)(WKContextRef context, WKDownloadRef download, WKStringRef path, const void *clientInfo);
     80 typedef void (*WKContextDownloadDidFinishCallback)(WKContextRef context, WKDownloadRef download, const void *clientInfo);
     81 typedef void (*WKContextDownloadDidFailCallback)(WKContextRef context, WKDownloadRef download, WKErrorRef error, const void *clientInfo);
     82 typedef void (*WKContextDownloadDidCancel)(WKContextRef context, WKDownloadRef download, const void *clientInfo);
     83 typedef void (*WKContextDownloadProcessDidCrashCallback)(WKContextRef context, WKDownloadRef download, const void *clientInfo);
     84 
     85 struct WKContextDownloadClient {
     86     int                                                                 version;
     87     const void *                                                        clientInfo;
     88     WKContextDownloadDidStartCallback                                   didStart;
     89     WKContextDownloadDidReceiveAuthenticationChallengeCallback          didReceiveAuthenticationChallenge;
     90     WKContextDownloadDidReceiveResponseCallback                         didReceiveResponse;
     91     WKContextDownloadDidReceiveDataCallback                             didReceiveData;
     92     WKContextDownloadShouldDecodeSourceDataOfMIMETypeCallback           shouldDecodeSourceDataOfMIMEType;
     93     WKContextDownloadDecideDestinationWithSuggestedFilenameCallback     decideDestinationWithSuggestedFilename;
     94     WKContextDownloadDidCreateDestinationCallback                       didCreateDestination;
     95     WKContextDownloadDidFinishCallback                                  didFinish;
     96     WKContextDownloadDidFailCallback                                    didFail;
     97     WKContextDownloadDidCancel                                          didCancel;
     98     WKContextDownloadProcessDidCrashCallback                            processDidCrash;
     99 };
    100 typedef struct WKContextDownloadClient WKContextDownloadClient;
    101 
    102 WK_EXPORT WKTypeID WKContextGetTypeID();
    103 
    104 WK_EXPORT WKContextRef WKContextCreate();
    105 WK_EXPORT WKContextRef WKContextCreateWithInjectedBundlePath(WKStringRef path);
    106 WK_EXPORT WKContextRef WKContextGetSharedProcessContext();
    107 
    108 WK_EXPORT void WKContextSetInjectedBundleClient(WKContextRef context, const WKContextInjectedBundleClient* client);
    109 WK_EXPORT void WKContextSetHistoryClient(WKContextRef context, const WKContextHistoryClient* client);
    110 WK_EXPORT void WKContextSetDownloadClient(WKContextRef context, const WKContextDownloadClient* client);
    111 
    112 WK_EXPORT WKDownloadRef WKContextDownloadURLRequest(WKContextRef context, const WKURLRequestRef request);
    113 
    114 WK_EXPORT void WKContextSetInitializationUserDataForInjectedBundle(WKContextRef context, WKTypeRef userData);
    115 WK_EXPORT void WKContextPostMessageToInjectedBundle(WKContextRef context, WKStringRef messageName, WKTypeRef messageBody);
    116 
    117 WK_EXPORT void WKContextAddVisitedLink(WKContextRef context, WKStringRef visitedURL);
    118 
    119 WK_EXPORT void WKContextSetCacheModel(WKContextRef context, WKCacheModel cacheModel);
    120 WK_EXPORT WKCacheModel WKContextGetCacheModel(WKContextRef context);
    121 
    122 WK_EXPORT void WKContextStartMemorySampler(WKContextRef context, WKDoubleRef interval);
    123 WK_EXPORT void WKContextStopMemorySampler(WKContextRef context);
    124 
    125 WK_EXPORT WKApplicationCacheManagerRef WKContextGetApplicationCacheManager(WKContextRef context);
    126 WK_EXPORT WKCookieManagerRef WKContextGetCookieManager(WKContextRef context);
    127 WK_EXPORT WKDatabaseManagerRef WKContextGetDatabaseManager(WKContextRef context);
    128 WK_EXPORT WKGeolocationManagerRef WKContextGetGeolocationManager(WKContextRef context);
    129 WK_EXPORT WKIconDatabaseRef WKContextGetIconDatabase(WKContextRef context);
    130 WK_EXPORT WKKeyValueStorageManagerRef WKContextGetKeyValueStorageManager(WKContextRef context);
    131 WK_EXPORT WKMediaCacheManagerRef WKContextGetMediaCacheManager(WKContextRef context);
    132 WK_EXPORT WKPluginSiteDataManagerRef WKContextGetPluginSiteDataManager(WKContextRef context);
    133 WK_EXPORT WKResourceCacheManagerRef WKContextGetResourceCacheManager(WKContextRef context);
    134 
    135 #ifdef __cplusplus
    136 }
    137 #endif
    138 
    139 #endif /* WKContext_h */
    140