1/* 2 * Copyright (C) 2010 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 WKDatabaseManager_h 27#define WKDatabaseManager_h 28 29#include <WebKit/WKBase.h> 30 31#ifdef __cplusplus 32extern "C" { 33#endif 34 35/* Value type: WKSecurityOriginRef */ 36WK_EXPORT WKStringRef WKDatabaseManagerGetOriginKey(); 37 38/* Value type: WKUInt64Ref */ 39WK_EXPORT WKStringRef WKDatabaseManagerGetOriginQuotaKey(); 40 41/* Value type: WKUInt64Ref */ 42WK_EXPORT WKStringRef WKDatabaseManagerGetOriginUsageKey(); 43 44/* Value type: WKArrayRef (array of WKDictionaryRef's with keys that include: 45 - WKDatabaseManagerGetDatabaseNameKey() 46 - WKDatabaseManagerGetDatabaseDisplayNameKey() 47 - WKDatabaseManagerGetDatabaseExpectedUsageKey() 48 - WKDatabaseManagerGetDatabaseCurrentUsageKey() 49 */ 50WK_EXPORT WKStringRef WKDatabaseManagerGetDatabaseDetailsKey(); 51 52/* Value type: WKStringRef */ 53WK_EXPORT WKStringRef WKDatabaseManagerGetDatabaseDetailsNameKey(); 54 55/* Value type: WKStringRef */ 56WK_EXPORT WKStringRef WKDatabaseManagerGetDatabaseDetailsDisplayNameKey(); 57 58/* Value type: WKUInt64Ref */ 59WK_EXPORT WKStringRef WKDatabaseManagerGetDatabaseDetailsExpectedUsageKey(); 60 61/* Value type: WKUInt64Ref */ 62WK_EXPORT WKStringRef WKDatabaseManagerGetDatabaseDetailsCurrentUsageKey(); 63 64/* Value type: WKDoubleRef, seconds since January 1st, 1970 UTC */ 65WK_EXPORT WKStringRef WKDatabaseManagerGetDatabaseDetailsCreationTimeKey(); 66 67/* Value type: WKDoubleRef, seconds since January 1st, 1970 UTC */ 68WK_EXPORT WKStringRef WKDatabaseManagerGetDatabaseDetailsModificationTimeKey(); 69 70 71// Database Manager Client 72typedef void (*WKDatabaseManagerDidModifyOriginCallback)(WKDatabaseManagerRef databaseManager, WKSecurityOriginRef origin, const void *clientInfo); 73typedef void (*WKDatabaseManagerDidModifyDatabaseCallback)(WKDatabaseManagerRef databaseManager, WKSecurityOriginRef origin, WKStringRef databaseIdentifier, const void *clientInfo); 74 75typedef struct WKDatabaseManagerClientBase { 76 int version; 77 const void * clientInfo; 78} WKDatabaseManagerClientBase; 79 80typedef struct WKDatabaseManagerClientV0 { 81 WKDatabaseManagerClientBase base; 82 83 // Version 0. 84 WKDatabaseManagerDidModifyOriginCallback didModifyOrigin; 85 WKDatabaseManagerDidModifyDatabaseCallback didModifyDatabase; 86} WKDatabaseManagerClientV0; 87 88enum { kWKDatabaseManagerClientCurrentVersion WK_ENUM_DEPRECATED("Use an explicit version number instead") = 0 }; 89typedef struct WKDatabaseManagerClient { 90 int version; 91 const void * clientInfo; 92 93 // Version 0. 94 WKDatabaseManagerDidModifyOriginCallback didModifyOrigin; 95 WKDatabaseManagerDidModifyDatabaseCallback didModifyDatabase; 96} WKDatabaseManagerClient WK_DEPRECATED("Use an explicit versioned struct instead"); 97 98WK_EXPORT WKTypeID WKDatabaseManagerGetTypeID(); 99 100WK_EXPORT void WKDatabaseManagerSetClient(WKDatabaseManagerRef databaseManager, const WKDatabaseManagerClientBase* client); 101 102typedef void (*WKDatabaseManagerGetDatabasesByOriginFunction)(WKArrayRef, WKErrorRef, void*); 103WK_EXPORT void WKDatabaseManagerGetDatabasesByOrigin(WKDatabaseManagerRef databaseManager, void* context, WKDatabaseManagerGetDatabasesByOriginFunction function); 104 105typedef void (*WKDatabaseManagerGetDatabaseOriginsFunction)(WKArrayRef, WKErrorRef, void*); 106WK_EXPORT void WKDatabaseManagerGetDatabaseOrigins(WKDatabaseManagerRef contextRef, void* context, WKDatabaseManagerGetDatabaseOriginsFunction function); 107 108WK_EXPORT void WKDatabaseManagerDeleteDatabasesWithNameForOrigin(WKDatabaseManagerRef databaseManager, WKStringRef databaseName, WKSecurityOriginRef origin); 109WK_EXPORT void WKDatabaseManagerDeleteDatabasesForOrigin(WKDatabaseManagerRef databaseManager, WKSecurityOriginRef origin); 110WK_EXPORT void WKDatabaseManagerDeleteAllDatabases(WKDatabaseManagerRef databaseManager); 111 112WK_EXPORT void WKDatabaseManagerSetQuotaForOrigin(WKDatabaseManagerRef databaseManager, WKSecurityOriginRef origin, uint64_t quota); 113 114#ifdef __cplusplus 115} 116#endif 117 118#endif // WKDatabaseManager_h 119