Add stdint.h include to fix WebKitTestRunner build.
[WebKit.git] / WebKit2 / UIProcess / API / C / WKPage.h
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 WKPage_h
27 #define WKPage_h
28
29 #include <WebKit2/WKBase.h>
30
31 #ifndef __cplusplus
32 #include <stdbool.h>
33 #endif
34
35 #include <stdint.h>
36
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40
41 // FrameLoad Client
42 typedef void (*WKPageDidStartProvisionalLoadForFrameCallback)(WKPageRef page, WKFrameRef frame, const void *clientInfo);
43 typedef void (*WKPageDidReceiveServerRedirectForProvisionalLoadForFrameCallback)(WKPageRef page, WKFrameRef frame, const void *clientInfo);
44 typedef void (*WKPageDidFailProvisionalLoadWithErrorForFrameCallback)(WKPageRef page, WKFrameRef frame, const void *clientInfo); // FIXME: Add WKErrorRef.
45 typedef void (*WKPageDidCommitLoadForFrameCallback)(WKPageRef page, WKFrameRef frame, const void *clientInfo);
46 typedef void (*WKPageDidFinishLoadForFrameCallback)(WKPageRef page, WKFrameRef frame, const void *clientInfo);
47 typedef void (*WKPageDidFailLoadWithErrorForFrameCallback)(WKPageRef page, WKFrameRef frame, const void *clientInfo); // FIXME: Add WKErrorRef.
48 typedef void (*WKPageDidReceiveTitleForFrameCallback)(WKPageRef page, WKStringRef title, WKFrameRef frame, const void *clientInfo);
49 typedef void (*WKPageDidFirstLayoutForFrame)(WKPageRef page, WKFrameRef frame, const void *clientInfo);
50 typedef void (*WKPageDidFirstVisuallyNonEmptyLayoutForFrame)(WKPageRef page, WKFrameRef frame, const void *clientInfo);
51
52 // Progress Client
53 typedef void (*WKPageDidStartProgressCallback)(WKPageRef page, const void *clientInfo);
54 typedef void (*WKPageDidChangeProgressCallback)(WKPageRef page, const void *clientInfo);
55 typedef void (*WKPageDidFinishProgressCallback)(WKPageRef page, const void *clientInfo);
56
57 // WebPageNamespace Client
58 // FIXME: These two methods should not be part of this client.
59 typedef void (*WKPageDidBecomeUnresponsiveCallback)(WKPageRef page, const void *clientInfo);
60 typedef void (*WKPageDidBecomeResponsiveCallback)(WKPageRef page, const void *clientInfo);
61
62 struct WKPageLoaderClient {
63     int                                                                 version;
64     const void *                                                        clientInfo;
65     WKPageDidStartProvisionalLoadForFrameCallback                       didStartProvisionalLoadForFrame;
66     WKPageDidReceiveServerRedirectForProvisionalLoadForFrameCallback    didReceiveServerRedirectForProvisionalLoadForFrame;
67     WKPageDidFailProvisionalLoadWithErrorForFrameCallback               didFailProvisionalLoadWithErrorForFrame;
68     WKPageDidCommitLoadForFrameCallback                                 didCommitLoadForFrame;
69     WKPageDidFinishLoadForFrameCallback                                 didFinishLoadForFrame;
70     WKPageDidFailLoadWithErrorForFrameCallback                          didFailLoadWithErrorForFrame;
71     WKPageDidReceiveTitleForFrameCallback                               didReceiveTitleForFrame;
72     WKPageDidFirstLayoutForFrame                                        didFirstLayoutForFrame;
73     WKPageDidFirstVisuallyNonEmptyLayoutForFrame                        didFirstVisuallyNonEmptyLayoutForFrame;
74
75     // FIXME: Move to progress client.
76     WKPageDidStartProgressCallback                                      didStartProgress;
77     WKPageDidChangeProgressCallback                                     didChangeProgress;
78     WKPageDidFinishProgressCallback                                     didFinishProgress;
79
80     // FIXME: These two methods should not be part of this client.
81     WKPageDidBecomeUnresponsiveCallback                                 didBecomeUnresponsive;
82     WKPageDidBecomeResponsiveCallback                                   didBecomeResponsive;
83 };
84 typedef struct WKPageLoaderClient WKPageLoaderClient;
85
86 // Policy Client.
87 typedef void (*WKPageDecidePolicyForNavigationActionCallback)(WKPageRef page, uint32_t navigationType, WKURLRef url, WKFrameRef frame, WKFramePolicyListenerRef listener, const void *clientInfo);
88 typedef void (*WKPageDecidePolicyForNewWindowActionCallback)(WKPageRef page, uint32_t navigationType, WKURLRef url, WKFrameRef frame, WKFramePolicyListenerRef listener, const void *clientInfo);
89 typedef void (*WKPageDecidePolicyForMIMETypeCallback)(WKPageRef page, WKStringRef MIMEType, WKURLRef url, WKFrameRef frame, WKFramePolicyListenerRef listener, const void *clientInfo);
90
91 struct WKPagePolicyClient {
92     int                                                                 version;
93     const void *                                                        clientInfo;
94     WKPageDecidePolicyForNavigationActionCallback                       decidePolicyForNavigationAction;
95     WKPageDecidePolicyForNewWindowActionCallback                        decidePolicyForNewWindowAction;
96     WKPageDecidePolicyForMIMETypeCallback                               decidePolicyForMIMEType;
97 };
98 typedef struct WKPagePolicyClient WKPagePolicyClient;
99
100 // UI Client
101 typedef WKPageRef (*WKPageCreateNewPageCallback)(WKPageRef page, const void *clientInfo);
102 typedef void (*WKPageShowPageCallback)(WKPageRef page, const void *clientInfo);
103 typedef void (*WKPageCloseCallback)(WKPageRef page, const void *clientInfo);
104 typedef void (*WKPageRunJavaScriptAlertCallback)(WKPageRef page, WKStringRef alertText, WKFrameRef frame, const void *clientInfo);
105
106 struct WKPageUIClient {
107     int                                                                 version;
108     const void *                                                        clientInfo;
109     WKPageCreateNewPageCallback                                         createNewPage;
110     WKPageShowPageCallback                                              showPage;
111     WKPageCloseCallback                                                 close;
112     WKPageRunJavaScriptAlertCallback                                    runJavaScriptAlert;
113 };
114 typedef struct WKPageUIClient WKPageUIClient;
115
116 // History Client
117 typedef void (*WKPageDidNavigateWithNavigationDataCallback)(WKPageRef page, WKNavigationDataRef navigationData, WKFrameRef frame, const void *clientInfo);
118 typedef void (*WKPageDidPerformClientRedirectCallback)(WKPageRef page, WKURLRef sourceURL, WKURLRef destinationURL, WKFrameRef frame, const void *clientInfo);
119 typedef void (*WKPageDidPerformServerRedirectCallback)(WKPageRef page, WKURLRef sourceURL, WKURLRef destinationURL, WKFrameRef frame, const void *clientInfo);
120 typedef void (*WKPageDidUpdateHistoryTitleCallback)(WKPageRef page, WKStringRef title, WKURLRef URL, WKFrameRef frame, const void *clientInfo);
121
122 struct WKPageHistoryClient {
123     int                                                                 version;
124     const void *                                                        clientInfo;
125     WKPageDidNavigateWithNavigationDataCallback                         didNavigateWithNavigationData;
126     WKPageDidPerformClientRedirectCallback                              didPerformClientRedirect;
127     WKPageDidPerformServerRedirectCallback                              didPerformServerRedirect;
128     WKPageDidUpdateHistoryTitleCallback                                 didUpdateHistoryTitle;
129 };
130 typedef struct WKPageHistoryClient WKPageHistoryClient;
131
132
133 WK_EXPORT WKPageNamespaceRef WKPageGetPageNamespace(WKPageRef page);
134
135 WK_EXPORT void WKPageLoadURL(WKPageRef page, WKURLRef url);
136 WK_EXPORT void WKPageStopLoading(WKPageRef page);
137 WK_EXPORT void WKPageReload(WKPageRef page);
138 WK_EXPORT void WKPageReloadFromOrigin(WKPageRef page);
139
140 WK_EXPORT bool WKPageTryClose(WKPageRef page);
141 WK_EXPORT void WKPageClose(WKPageRef page);
142 WK_EXPORT bool WKPageIsClosed(WKPageRef page);
143
144 WK_EXPORT void WKPageGoForward(WKPageRef page);
145 WK_EXPORT bool WKPageCanGoForward(WKPageRef page);
146 WK_EXPORT void WKPageGoBack(WKPageRef page);
147 WK_EXPORT bool WKPageCanGoBack(WKPageRef page);
148 WK_EXPORT WKBackForwardListRef WKPageGetBackForwardList(WKPageRef page);
149
150 WK_EXPORT WKStringRef WKPageGetTitle(WKPageRef page);
151
152 WK_EXPORT WKFrameRef WKPageGetMainFrame(WKPageRef page);
153 WK_EXPORT double WKPageGetEstimatedProgress(WKPageRef page);
154     
155 WK_EXPORT void WKPageTerminate(WKPageRef page);
156
157 WK_EXPORT void WKPageSetPageLoaderClient(WKPageRef page, WKPageLoaderClient * client);
158 WK_EXPORT void WKPageSetPagePolicyClient(WKPageRef page, WKPagePolicyClient * client);
159 WK_EXPORT void WKPageSetPageUIClient(WKPageRef page, WKPageUIClient * client);
160 WK_EXPORT void WKPageSetPageHistoryClient(WKPageRef page, WKPageHistoryClient * client);
161
162 typedef void (*WKPageRunJavaScriptFunction)(WKStringRef, void*);
163 typedef void (*WKPageRunJavaScriptDisposeFunction)(void*);
164 WK_EXPORT void WKPageRunJavaScriptInMainFrame(WKPageRef page, WKStringRef script, void *context, WKPageRunJavaScriptFunction function, WKPageRunJavaScriptDisposeFunction disposeFunction);
165 #ifdef __BLOCKS__
166 typedef void (^WKPageRunJavaScriptBlock)(WKStringRef);
167 WK_EXPORT void WKPageRunJavaScriptInMainFrame_b(WKPageRef page, WKStringRef script, WKPageRunJavaScriptBlock block);
168 #endif
169
170
171 WK_EXPORT WKPageRef WKPageRetain(WKPageRef page);
172 WK_EXPORT void WKPageRelease(WKPageRef page);
173
174 #ifdef __cplusplus
175 }
176 #endif
177
178 WK_DECLARE_RETAIN_RELEASE_OVERLOADS(WKPage)
179
180 #endif /* WKPage_h */