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 <WebKit2/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
65// Database Manager Client
66typedef void (*WKDatabaseManagerDidModifyOriginCallback)(WKDatabaseManagerRef databaseManager, WKSecurityOriginRef origin, const void *clientInfo);
67typedef void (*WKDatabaseManagerDidModifyDatabaseCallback)(WKDatabaseManagerRef databaseManager, WKSecurityOriginRef origin, WKStringRef databaseIdentifier, const void *clientInfo);
68
69struct WKDatabaseManagerClient {
70    int                                                                 version;
71    const void *                                                        clientInfo;
72    WKDatabaseManagerDidModifyOriginCallback                            didModifyOrigin;
73    WKDatabaseManagerDidModifyDatabaseCallback                          didModifyDatabase;
74};
75typedef struct WKDatabaseManagerClient WKDatabaseManagerClient;
76
77
78WK_EXPORT WKTypeID WKDatabaseManagerGetTypeID();
79
80WK_EXPORT void WKDatabaseManagerSetClient(WKDatabaseManagerRef databaseManager, const WKDatabaseManagerClient* client);
81
82typedef void (*WKDatabaseManagerGetDatabasesByOriginFunction)(WKArrayRef, WKErrorRef, void*);
83WK_EXPORT void WKDatabaseManagerGetDatabasesByOrigin(WKDatabaseManagerRef databaseManager, void* context, WKDatabaseManagerGetDatabasesByOriginFunction function);
84#ifdef __BLOCKS__
85typedef void (^WKDatabaseManagerGetDatabasesByOriginBlock)(WKArrayRef, WKErrorRef);
86WK_EXPORT void WKDatabaseManagerGetDatabasesByOrigin_b(WKDatabaseManagerRef databaseManager, WKDatabaseManagerGetDatabasesByOriginBlock block);
87#endif
88
89typedef void (*WKDatabaseManagerGetDatabaseOriginsFunction)(WKArrayRef, WKErrorRef, void*);
90WK_EXPORT void WKDatabaseManagerGetDatabaseOrigins(WKDatabaseManagerRef contextRef, void* context, WKDatabaseManagerGetDatabaseOriginsFunction function);
91#ifdef __BLOCKS__
92typedef void (^WKDatabaseManagerGetDatabaseOriginsBlock)(WKArrayRef, WKErrorRef);
93WK_EXPORT void WKDatabaseManagerGetDatabaseOrigins_b(WKDatabaseManagerRef databaseManager, WKDatabaseManagerGetDatabaseOriginsBlock block);
94#endif
95
96WK_EXPORT void WKDatabaseManagerDeleteDatabasesWithNameForOrigin(WKDatabaseManagerRef databaseManager, WKStringRef databaseName, WKSecurityOriginRef origin);
97WK_EXPORT void WKDatabaseManagerDeleteDatabasesForOrigin(WKDatabaseManagerRef databaseManager, WKSecurityOriginRef origin);
98WK_EXPORT void WKDatabaseManagerDeleteAllDatabases(WKDatabaseManagerRef databaseManager);
99
100WK_EXPORT void WKDatabaseManagerSetQuotaForOrigin(WKDatabaseManagerRef databaseManager, WKSecurityOriginRef origin, uint64_t quota);
101
102#ifdef __cplusplus
103}
104#endif
105
106#endif // WKDatabaseManager_h
107