Add WKPageLoadData and WKPageLoadDataWithUserData SPI to support loading arbitrary...
[WebKit-https.git] / Source / WebKit2 / UIProcess / API / C / WKPage.h
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 WKPage_h
27 #define WKPage_h
28
29 #include <WebKit2/WKBase.h>
30 #include <WebKit2/WKError.h>
31 #include <WebKit2/WKEvent.h>
32 #include <WebKit2/WKFindOptions.h>
33 #include <WebKit2/WKGeometry.h>
34 #include <WebKit2/WKNativeEvent.h>
35 #include <WebKit2/WKPageLoadTypes.h>
36 #include <WebKit2/WKPageVisibilityTypes.h>
37
38 #ifndef __cplusplus
39 #include <stdbool.h>
40 #endif
41
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45
46 enum {
47     kWKFocusDirectionBackward = 0,
48     kWKFocusDirectionForward = 1
49 };
50 typedef uint32_t WKFocusDirection;
51
52 enum {
53     kWKPluginLoadPolicyLoadNormally = 0,
54     kWKPluginLoadPolicyBlocked,
55     kWKPluginLoadPolicyInactive,
56 };
57 typedef uint32_t WKPluginLoadPolicy;
58
59 typedef void (*WKPageCallback)(WKPageRef page, const void* clientInfo);
60
61 // FrameLoad Client
62 typedef void (*WKPageDidStartProvisionalLoadForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
63 typedef void (*WKPageDidReceiveServerRedirectForProvisionalLoadForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
64 typedef void (*WKPageDidFailProvisionalLoadWithErrorForFrameCallback)(WKPageRef page, WKFrameRef frame, WKErrorRef error, WKTypeRef userData, const void *clientInfo);
65 typedef void (*WKPageDidCommitLoadForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
66 typedef void (*WKPageDidFinishDocumentLoadForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
67 typedef void (*WKPageDidFinishLoadForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
68 typedef void (*WKPageDidFailLoadWithErrorForFrameCallback)(WKPageRef page, WKFrameRef frame, WKErrorRef error, WKTypeRef userData, const void *clientInfo);
69 typedef void (*WKPageDidSameDocumentNavigationForFrameCallback)(WKPageRef page, WKFrameRef frame, WKSameDocumentNavigationType type, WKTypeRef userData, const void *clientInfo);
70 typedef void (*WKPageDidReceiveTitleForFrameCallback)(WKPageRef page, WKStringRef title, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
71 typedef void (*WKPageDidFirstLayoutForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
72 typedef void (*WKPageDidFirstVisuallyNonEmptyLayoutForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
73 typedef void (*WKPageDidRemoveFrameFromHierarchyCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
74 typedef void (*WKPageDidDisplayInsecureContentForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
75 typedef void (*WKPageDidRunInsecureContentForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
76 typedef void (*WKPageDidDetectXSSForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
77 typedef bool (*WKPageCanAuthenticateAgainstProtectionSpaceInFrameCallback)(WKPageRef page, WKFrameRef frame, WKProtectionSpaceRef protectionSpace, const void *clientInfo);
78 typedef void (*WKPageDidReceiveAuthenticationChallengeInFrameCallback)(WKPageRef page, WKFrameRef frame, WKAuthenticationChallengeRef authenticationChallenge, const void *clientInfo);
79 typedef void (*WKPageDidChangeBackForwardListCallback)(WKPageRef page, WKBackForwardListItemRef addedItem, WKArrayRef removedItems, const void *clientInfo);
80 typedef bool (*WKPageShouldGoToBackForwardListItemCallback)(WKPageRef page, WKBackForwardListItemRef item, const void *clientInfo);
81 typedef void (*WKPageDidNewFirstVisuallyNonEmptyLayoutCallback)(WKPageRef page, WKTypeRef userData, const void *clientInfo);
82 typedef void (*WKPageWillGoToBackForwardListItemCallback)(WKPageRef page, WKBackForwardListItemRef item, WKTypeRef userData, const void *clientInfo);
83 typedef void (*WKPageDidLayoutCallback)(WKPageRef page, WKLayoutMilestones milestones, WKTypeRef userData, const void *clientInfo);
84 typedef WKPluginLoadPolicy (*WKPagePluginLoadPolicyCallback)(WKPageRef page, WKPluginLoadPolicy currentPluginLoadPolicy, WKDictionaryRef pluginInfoDictionary, const void* clientInfo);
85 typedef void (*WKPagePluginDidFailCallback)(WKPageRef page, WKErrorCode errorCode, WKDictionaryRef pluginInfoDictionary, const void* clientInfo);
86
87 // Deprecated
88 typedef void (*WKPageDidFailToInitializePluginCallback_deprecatedForUseWithV0)(WKPageRef page, WKStringRef mimeType, const void* clientInfo);
89 typedef void (*WKPagePluginDidFailCallback_deprecatedForUseWithV1)(WKPageRef page, WKErrorCode errorCode, WKStringRef mimeType, WKStringRef pluginIdentifier, WKStringRef pluginVersion, const void* clientInfo);
90
91 struct WKPageLoaderClient {
92     int                                                                 version;
93     const void *                                                        clientInfo;
94     WKPageDidStartProvisionalLoadForFrameCallback                       didStartProvisionalLoadForFrame;
95     WKPageDidReceiveServerRedirectForProvisionalLoadForFrameCallback    didReceiveServerRedirectForProvisionalLoadForFrame;
96     WKPageDidFailProvisionalLoadWithErrorForFrameCallback               didFailProvisionalLoadWithErrorForFrame;
97     WKPageDidCommitLoadForFrameCallback                                 didCommitLoadForFrame;
98     WKPageDidFinishDocumentLoadForFrameCallback                         didFinishDocumentLoadForFrame;
99     WKPageDidFinishLoadForFrameCallback                                 didFinishLoadForFrame;
100     WKPageDidFailLoadWithErrorForFrameCallback                          didFailLoadWithErrorForFrame;
101     WKPageDidSameDocumentNavigationForFrameCallback                     didSameDocumentNavigationForFrame;
102     WKPageDidReceiveTitleForFrameCallback                               didReceiveTitleForFrame;
103     WKPageDidFirstLayoutForFrameCallback                                didFirstLayoutForFrame;
104     WKPageDidFirstVisuallyNonEmptyLayoutForFrameCallback                didFirstVisuallyNonEmptyLayoutForFrame;
105     WKPageDidRemoveFrameFromHierarchyCallback                           didRemoveFrameFromHierarchy;
106     WKPageDidDisplayInsecureContentForFrameCallback                     didDisplayInsecureContentForFrame;
107     WKPageDidRunInsecureContentForFrameCallback                         didRunInsecureContentForFrame;
108     WKPageCanAuthenticateAgainstProtectionSpaceInFrameCallback          canAuthenticateAgainstProtectionSpaceInFrame;
109     WKPageDidReceiveAuthenticationChallengeInFrameCallback              didReceiveAuthenticationChallengeInFrame;
110
111     // FIXME: Move to progress client.
112     WKPageCallback                                                      didStartProgress;
113     WKPageCallback                                                      didChangeProgress;
114     WKPageCallback                                                      didFinishProgress;
115
116     // FIXME: These three functions should not be part of this client.
117     WKPageCallback                                                      processDidBecomeUnresponsive;
118     WKPageCallback                                                      processDidBecomeResponsive;
119     WKPageCallback                                                      processDidCrash;
120     WKPageDidChangeBackForwardListCallback                              didChangeBackForwardList;
121     WKPageShouldGoToBackForwardListItemCallback                         shouldGoToBackForwardListItem;
122     WKPageDidFailToInitializePluginCallback_deprecatedForUseWithV0      didFailToInitializePlugin_deprecatedForUseWithV0;
123
124     // Version 1
125     WKPageDidDetectXSSForFrameCallback                                  didDetectXSSForFrame;
126
127     // FIXME: didNewFirstVisuallyNonEmptyLayout should be removed. We should consider removing didFirstVisuallyNonEmptyLayoutForFrame
128     // as well. Their functionality is replaced by didLayout.
129     WKPageDidNewFirstVisuallyNonEmptyLayoutCallback                     didNewFirstVisuallyNonEmptyLayout;
130
131     WKPageWillGoToBackForwardListItemCallback                           willGoToBackForwardListItem;
132
133     WKPageCallback                                                      interactionOccurredWhileProcessUnresponsive;
134     WKPagePluginDidFailCallback_deprecatedForUseWithV1                  pluginDidFail_deprecatedForUseWithV1;
135
136     // Version 2
137     void                                                                (*didReceiveIntentForFrame_unavailable)(void);
138     void                                                                (*registerIntentServiceForFrame_unavailable)(void);
139
140     WKPageDidLayoutCallback                                             didLayout;
141     WKPagePluginLoadPolicyCallback                                      pluginLoadPolicy;
142     WKPagePluginDidFailCallback                                         pluginDidFail;
143 };
144 typedef struct WKPageLoaderClient WKPageLoaderClient;
145
146 enum { kWKPageLoaderClientCurrentVersion = 2 };
147
148 // Policy Client.
149 typedef void (*WKPageDecidePolicyForNavigationActionCallback)(WKPageRef page, WKFrameRef frame, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRequestRef request, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo);
150 typedef void (*WKPageDecidePolicyForNewWindowActionCallback)(WKPageRef page, WKFrameRef frame, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRequestRef request, WKStringRef frameName, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo);
151 typedef void (*WKPageDecidePolicyForResponseCallback)(WKPageRef page, WKFrameRef frame, WKURLResponseRef response, WKURLRequestRef request, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo);
152 typedef void (*WKPageUnableToImplementPolicyCallback)(WKPageRef page, WKFrameRef frame, WKErrorRef error, WKTypeRef userData, const void* clientInfo);
153
154 struct WKPagePolicyClient {
155     int                                                                 version;
156     const void *                                                        clientInfo;
157     WKPageDecidePolicyForNavigationActionCallback                       decidePolicyForNavigationAction;
158     WKPageDecidePolicyForNewWindowActionCallback                        decidePolicyForNewWindowAction;
159     WKPageDecidePolicyForResponseCallback                               decidePolicyForResponse;
160     WKPageUnableToImplementPolicyCallback                               unableToImplementPolicy;
161 };
162 typedef struct WKPagePolicyClient WKPagePolicyClient;
163
164 enum { kWKPagePolicyClientCurrentVersion = 0 };
165
166 // Form Client.
167 typedef void (*WKPageWillSubmitFormCallback)(WKPageRef page, WKFrameRef frame, WKFrameRef sourceFrame, WKDictionaryRef values, WKTypeRef userData, WKFormSubmissionListenerRef listener, const void* clientInfo);
168
169 struct WKPageFormClient {
170     int                                                                 version;
171     const void *                                                        clientInfo;
172     WKPageWillSubmitFormCallback                                        willSubmitForm;
173 };
174 typedef struct WKPageFormClient WKPageFormClient;
175
176 enum { kWKPageFormClientCurrentVersion = 0 };
177
178 enum {
179     kWKPluginUnavailabilityReasonPluginMissing,
180     kWKPluginUnavailabilityReasonPluginCrashed,
181     kWKPluginUnavailabilityReasonInsecurePluginVersion
182 };
183 typedef uint32_t WKPluginUnavailabilityReason;
184
185 // UI Client
186 typedef WKPageRef (*WKPageCreateNewPageCallback)(WKPageRef page, WKURLRequestRef urlRequest, WKDictionaryRef features, WKEventModifiers modifiers, WKEventMouseButton mouseButton, const void *clientInfo);
187 typedef void (*WKPageRunJavaScriptAlertCallback)(WKPageRef page, WKStringRef alertText, WKFrameRef frame, const void *clientInfo);
188 typedef bool (*WKPageRunJavaScriptConfirmCallback)(WKPageRef page, WKStringRef message, WKFrameRef frame, const void *clientInfo);
189 typedef WKStringRef (*WKPageRunJavaScriptPromptCallback)(WKPageRef page, WKStringRef message, WKStringRef defaultValue, WKFrameRef frame, const void *clientInfo);
190 typedef void (*WKPageTakeFocusCallback)(WKPageRef page, WKFocusDirection direction, const void *clientInfo);
191 typedef void (*WKPageFocusCallback)(WKPageRef page, const void *clientInfo);
192 typedef void (*WKPageUnfocusCallback)(WKPageRef page, const void *clientInfo);
193 typedef void (*WKPageSetStatusTextCallback)(WKPageRef page, WKStringRef text, const void *clientInfo);
194 typedef void (*WKPageMouseDidMoveOverElementCallback)(WKPageRef page, WKHitTestResultRef hitTestResult, WKEventModifiers modifiers, WKTypeRef userData, const void *clientInfo);
195 typedef void (*WKPageDidNotHandleKeyEventCallback)(WKPageRef page, WKNativeEventPtr event, const void *clientInfo);
196 typedef void (*WKPageDidNotHandleWheelEventCallback)(WKPageRef page, WKNativeEventPtr event, const void *clientInfo);
197 typedef bool (*WKPageGetToolbarsAreVisibleCallback)(WKPageRef page, const void *clientInfo);
198 typedef void (*WKPageSetToolbarsAreVisibleCallback)(WKPageRef page, bool toolbarsVisible, const void *clientInfo);
199 typedef bool (*WKPageGetMenuBarIsVisibleCallback)(WKPageRef page, const void *clientInfo);
200 typedef void (*WKPageSetMenuBarIsVisibleCallback)(WKPageRef page, bool menuBarVisible, const void *clientInfo);
201 typedef bool (*WKPageGetStatusBarIsVisibleCallback)(WKPageRef page, const void *clientInfo);
202 typedef void (*WKPageSetStatusBarIsVisibleCallback)(WKPageRef page, bool statusBarVisible, const void *clientInfo);
203 typedef bool (*WKPageGetIsResizableCallback)(WKPageRef page, const void *clientInfo);
204 typedef void (*WKPageSetIsResizableCallback)(WKPageRef page, bool resizable, const void *clientInfo);
205 typedef WKRect (*WKPageGetWindowFrameCallback)(WKPageRef page, const void *clientInfo);
206 typedef void (*WKPageSetWindowFrameCallback)(WKPageRef page, WKRect frame, const void *clientInfo);
207 typedef bool (*WKPageRunBeforeUnloadConfirmPanelCallback)(WKPageRef page, WKStringRef message, WKFrameRef frame, const void *clientInfo);
208 typedef unsigned long long (*WKPageExceededDatabaseQuotaCallback)(WKPageRef page, WKFrameRef frame, WKSecurityOriginRef origin, WKStringRef databaseName, WKStringRef displayName, unsigned long long currentQuota, unsigned long long currentOriginUsage, unsigned long long currentDatabaseUsage, unsigned long long expectedUsage, const void *clientInfo);
209 typedef void (*WKPageRunOpenPanelCallback)(WKPageRef page, WKFrameRef frame, WKOpenPanelParametersRef parameters, WKOpenPanelResultListenerRef listener, const void *clientInfo);
210 typedef void (*WKPageDecidePolicyForGeolocationPermissionRequestCallback)(WKPageRef page, WKFrameRef frame, WKSecurityOriginRef origin, WKGeolocationPermissionRequestRef permissionRequest, const void* clientInfo);
211 typedef float (*WKPageHeaderHeightCallback)(WKPageRef page, WKFrameRef frame, const void* clientInfo);
212 typedef float (*WKPageFooterHeightCallback)(WKPageRef page, WKFrameRef frame, const void* clientInfo);
213 typedef void (*WKPageDrawHeaderCallback)(WKPageRef page, WKFrameRef frame, WKRect rect, const void* clientInfo);
214 typedef void (*WKPageDrawFooterCallback)(WKPageRef page, WKFrameRef frame, WKRect rect, const void* clientInfo);
215 typedef void (*WKPagePrintFrameCallback)(WKPageRef page, WKFrameRef frame, const void* clientInfo);
216 typedef void (*WKPageSaveDataToFileInDownloadsFolderCallback)(WKPageRef page, WKStringRef suggestedFilename, WKStringRef mimeType, WKURLRef originatingURL, WKDataRef data, const void* clientInfo);
217 typedef bool (*WKPageShouldInterruptJavaScriptCallback)(WKPageRef page, const void *clientInfo);
218 typedef void (*WKPageDecidePolicyForNotificationPermissionRequestCallback)(WKPageRef page, WKSecurityOriginRef origin, WKNotificationPermissionRequestRef permissionRequest, const void *clientInfo);
219 typedef void (*WKPageShowColorPickerCallback)(WKPageRef page, WKStringRef initialColor, WKColorPickerResultListenerRef listener, const void* clientInfo);
220 typedef void (*WKPageHideColorPickerCallback)(WKPageRef page, const void* clientInfo);
221 typedef void (*WKPageUnavailablePluginButtonClickedCallback)(WKPageRef page, WKPluginUnavailabilityReason pluginUnavailabilityReason, WKDictionaryRef pluginInfoDictionary, const void* clientInfo);
222
223 // Deprecated    
224 typedef WKPageRef (*WKPageCreateNewPageCallback_deprecatedForUseWithV0)(WKPageRef page, WKDictionaryRef features, WKEventModifiers modifiers, WKEventMouseButton mouseButton, const void *clientInfo);
225 typedef void      (*WKPageMouseDidMoveOverElementCallback_deprecatedForUseWithV0)(WKPageRef page, WKEventModifiers modifiers, WKTypeRef userData, const void *clientInfo);
226 typedef void (*WKPageMissingPluginButtonClickedCallback_deprecatedForUseWithV0)(WKPageRef page, WKStringRef mimeType, WKStringRef url, WKStringRef pluginsPageURL, const void* clientInfo);
227 typedef void (*WKPageUnavailablePluginButtonClickedCallback_deprecatedForUseWithV1)(WKPageRef page, WKPluginUnavailabilityReason pluginUnavailabilityReason, WKStringRef mimeType, WKStringRef url, WKStringRef pluginsPageURL, const void* clientInfo);
228
229 struct WKPageUIClient {
230     int                                                                 version;
231     const void *                                                        clientInfo;
232
233     // Version 0
234     WKPageCreateNewPageCallback_deprecatedForUseWithV0                  createNewPage_deprecatedForUseWithV0;
235     WKPageCallback                                                      showPage;
236     WKPageCallback                                                      close;
237     WKPageTakeFocusCallback                                             takeFocus;
238     WKPageFocusCallback                                                 focus;
239     WKPageUnfocusCallback                                               unfocus;
240     WKPageRunJavaScriptAlertCallback                                    runJavaScriptAlert;
241     WKPageRunJavaScriptConfirmCallback                                  runJavaScriptConfirm;
242     WKPageRunJavaScriptPromptCallback                                   runJavaScriptPrompt;
243     WKPageSetStatusTextCallback                                         setStatusText;
244     WKPageMouseDidMoveOverElementCallback_deprecatedForUseWithV0        mouseDidMoveOverElement_deprecatedForUseWithV0;
245     WKPageMissingPluginButtonClickedCallback_deprecatedForUseWithV0     missingPluginButtonClicked_deprecatedForUseWithV0;
246     WKPageDidNotHandleKeyEventCallback                                  didNotHandleKeyEvent;
247     WKPageDidNotHandleWheelEventCallback                                didNotHandleWheelEvent;
248     WKPageGetToolbarsAreVisibleCallback                                 toolbarsAreVisible;
249     WKPageSetToolbarsAreVisibleCallback                                 setToolbarsAreVisible;
250     WKPageGetMenuBarIsVisibleCallback                                   menuBarIsVisible;
251     WKPageSetMenuBarIsVisibleCallback                                   setMenuBarIsVisible;
252     WKPageGetStatusBarIsVisibleCallback                                 statusBarIsVisible;
253     WKPageSetStatusBarIsVisibleCallback                                 setStatusBarIsVisible;
254     WKPageGetIsResizableCallback                                        isResizable;
255     WKPageSetIsResizableCallback                                        setIsResizable;
256     WKPageGetWindowFrameCallback                                        getWindowFrame;
257     WKPageSetWindowFrameCallback                                        setWindowFrame;
258     WKPageRunBeforeUnloadConfirmPanelCallback                           runBeforeUnloadConfirmPanel;
259     WKPageCallback                                                      didDraw;
260     WKPageCallback                                                      pageDidScroll;
261     WKPageExceededDatabaseQuotaCallback                                 exceededDatabaseQuota;
262     WKPageRunOpenPanelCallback                                          runOpenPanel;
263     WKPageDecidePolicyForGeolocationPermissionRequestCallback           decidePolicyForGeolocationPermissionRequest;
264     WKPageHeaderHeightCallback                                          headerHeight;
265     WKPageFooterHeightCallback                                          footerHeight;
266     WKPageDrawHeaderCallback                                            drawHeader;
267     WKPageDrawFooterCallback                                            drawFooter;
268     WKPagePrintFrameCallback                                            printFrame;
269     WKPageCallback                                                      runModal;
270     void*                                                               unused1; // Used to be didCompleteRubberBandForMainFrame
271     WKPageSaveDataToFileInDownloadsFolderCallback                       saveDataToFileInDownloadsFolder;
272     WKPageShouldInterruptJavaScriptCallback                             shouldInterruptJavaScript;    
273
274     // Version 1
275     WKPageCreateNewPageCallback                                         createNewPage;
276     WKPageMouseDidMoveOverElementCallback                               mouseDidMoveOverElement;
277     WKPageDecidePolicyForNotificationPermissionRequestCallback          decidePolicyForNotificationPermissionRequest;
278     WKPageUnavailablePluginButtonClickedCallback_deprecatedForUseWithV1 unavailablePluginButtonClicked_deprecatedForUseWithV1;
279
280     // Version 2
281     WKPageShowColorPickerCallback                                       showColorPicker;
282     WKPageHideColorPickerCallback                                       hideColorPicker;
283     WKPageUnavailablePluginButtonClickedCallback                        unavailablePluginButtonClicked;
284 };
285 typedef struct WKPageUIClient WKPageUIClient;
286
287 enum { kWKPageUIClientCurrentVersion = 2 };
288
289 // Find client.
290 typedef void (*WKPageDidFindStringCallback)(WKPageRef page, WKStringRef string, unsigned matchCount, const void* clientInfo);
291 typedef void (*WKPageDidFailToFindStringCallback)(WKPageRef page, WKStringRef string, const void* clientInfo);
292 typedef void (*WKPageDidCountStringMatchesCallback)(WKPageRef page, WKStringRef string, unsigned matchCount, const void* clientInfo);
293
294 struct WKPageFindClient {
295     int                                                                 version;
296     const void *                                                        clientInfo;
297     WKPageDidFindStringCallback                                         didFindString;
298     WKPageDidFailToFindStringCallback                                   didFailToFindString;
299     WKPageDidCountStringMatchesCallback                                 didCountStringMatches;
300 };
301 typedef struct WKPageFindClient WKPageFindClient;
302
303 enum { kWKPageFindClientCurrentVersion = 0 };
304
305 enum {
306     kWKMoreThanMaximumMatchCount = -1
307 };
308
309 // Find match client.
310 typedef void (*WKPageDidFindStringMatchesCallback)(WKPageRef page, WKStringRef string, WKArrayRef matches, int firstIndex, const void* clientInfo);
311 typedef void (*WKPageDidGetImageForMatchResultCallback)(WKPageRef page, WKImageRef image, uint32_t index, const void* clientInfo);
312
313 struct WKPageFindMatchesClient {
314     int                                                                 version;
315     const void *                                                        clientInfo;
316     WKPageDidFindStringMatchesCallback                                  didFindStringMatches;
317     WKPageDidGetImageForMatchResultCallback                             didGetImageForMatchResult;
318 };
319 typedef struct WKPageFindMatchesClient WKPageFindMatchesClient;
320
321 enum { kWKPageFindMatchesClientCurrentVersion = 0 };
322
323 // ContextMenu client
324 typedef void (*WKPageGetContextMenuFromProposedContextMenuCallback)(WKPageRef page, WKArrayRef proposedMenu, WKArrayRef* newMenu, WKHitTestResultRef hitTestResult, WKTypeRef userData, const void* clientInfo);
325 typedef void (*WKPageCustomContextMenuItemSelectedCallback)(WKPageRef page, WKContextMenuItemRef contextMenuItem, const void* clientInfo);
326 typedef void (*WKPageContextMenuDismissedCallback)(WKPageRef page, const void* clientInfo);
327 typedef void (*WKPageShowContextMenuCallback)(WKPageRef page, WKPoint menuLocation, WKArrayRef menuItems, const void* clientInfo);
328 typedef void (*WKPageHideContextMenuCallback)(WKPageRef page, const void* clientInfo);
329
330 // Deprecated
331 typedef void (*WKPageGetContextMenuFromProposedContextMenuCallback_deprecatedForUseWithV0)(WKPageRef page, WKArrayRef proposedMenu, WKArrayRef* newMenu, WKTypeRef userData, const void* clientInfo);
332 struct WKPageContextMenuClient {
333     int                                                                          version;
334     const void *                                                                 clientInfo;
335
336     // Version 0
337     WKPageGetContextMenuFromProposedContextMenuCallback_deprecatedForUseWithV0   getContextMenuFromProposedMenu_deprecatedForUseWithV0;
338     WKPageCustomContextMenuItemSelectedCallback                                  customContextMenuItemSelected;
339
340     // Version 1
341     WKPageContextMenuDismissedCallback                                           contextMenuDismissed;
342
343     // Version 2
344     WKPageGetContextMenuFromProposedContextMenuCallback                          getContextMenuFromProposedMenu;
345
346     // Version 3
347     WKPageShowContextMenuCallback                                                showContextMenu;
348     WKPageHideContextMenuCallback                                                hideContextMenu;
349 };
350 typedef struct WKPageContextMenuClient WKPageContextMenuClient;
351
352 enum { kWKPageContextMenuClientCurrentVersion = 3 };
353
354 WK_EXPORT WKTypeID WKPageGetTypeID();
355
356 WK_EXPORT WKContextRef WKPageGetContext(WKPageRef page);
357 WK_EXPORT WKPageGroupRef WKPageGetPageGroup(WKPageRef page);
358
359 // URL Requests
360 WK_EXPORT void WKPageLoadURL(WKPageRef page, WKURLRef url);
361 WK_EXPORT void WKPageLoadURLWithUserData(WKPageRef page, WKURLRef url, WKTypeRef userData);
362 WK_EXPORT void WKPageLoadURLRequest(WKPageRef page, WKURLRequestRef urlRequest);
363 WK_EXPORT void WKPageLoadURLRequestWithUserData(WKPageRef page, WKURLRequestRef urlRequest, WKTypeRef userData);
364 WK_EXPORT void WKPageLoadFile(WKPageRef page, WKURLRef fileURL, WKURLRef resourceDirectoryURL);
365 WK_EXPORT void WKPageLoadFileWithUserData(WKPageRef page, WKURLRef fileURL, WKURLRef resourceDirectoryURL, WKTypeRef userData);
366
367 // Data Requests
368 WK_EXPORT void WKPageLoadData(WKPageRef page, WKDataRef data, WKStringRef MIMEType, WKStringRef encoding, WKURLRef baseURL);
369 WK_EXPORT void WKPageLoadDataWithUserData(WKPageRef page, WKDataRef data, WKStringRef MIMEType, WKStringRef encoding, WKURLRef baseURL, WKTypeRef userData);
370 WK_EXPORT void WKPageLoadHTMLString(WKPageRef page, WKStringRef htmlString, WKURLRef baseURL);
371 WK_EXPORT void WKPageLoadHTMLStringWithUserData(WKPageRef page, WKStringRef htmlString, WKURLRef baseURL, WKTypeRef userData);
372 WK_EXPORT void WKPageLoadAlternateHTMLString(WKPageRef page, WKStringRef htmlString, WKURLRef baseURL, WKURLRef unreachableURL);
373 WK_EXPORT void WKPageLoadAlternateHTMLStringWithUserData(WKPageRef page, WKStringRef htmlString, WKURLRef baseURL, WKURLRef unreachableURL, WKTypeRef userData);
374 WK_EXPORT void WKPageLoadPlainTextString(WKPageRef page, WKStringRef plainTextString);
375 WK_EXPORT void WKPageLoadPlainTextStringWithUserData(WKPageRef page, WKStringRef plainTextString, WKTypeRef userData);
376 WK_EXPORT void WKPageLoadWebArchiveData(WKPageRef page, WKDataRef webArchiveData);
377 WK_EXPORT void WKPageLoadWebArchiveDataWithUserData(WKPageRef page, WKDataRef webArchiveData, WKTypeRef userData);
378
379 WK_EXPORT void WKPageStopLoading(WKPageRef page);
380 WK_EXPORT void WKPageReload(WKPageRef page);
381 WK_EXPORT void WKPageReloadFromOrigin(WKPageRef page);
382
383 WK_EXPORT bool WKPageTryClose(WKPageRef page);
384 WK_EXPORT void WKPageClose(WKPageRef page);
385 WK_EXPORT bool WKPageIsClosed(WKPageRef page);
386
387 WK_EXPORT void WKPageGoForward(WKPageRef page);
388 WK_EXPORT bool WKPageCanGoForward(WKPageRef page);
389 WK_EXPORT void WKPageGoBack(WKPageRef page);
390 WK_EXPORT bool WKPageCanGoBack(WKPageRef page);
391 WK_EXPORT void WKPageGoToBackForwardListItem(WKPageRef page, WKBackForwardListItemRef item);
392 WK_EXPORT void WKPageTryRestoreScrollPosition(WKPageRef page);
393 WK_EXPORT WKBackForwardListRef WKPageGetBackForwardList(WKPageRef page);
394 WK_EXPORT bool WKPageWillHandleHorizontalScrollEvents(WKPageRef page);
395     
396 WK_EXPORT WKStringRef WKPageCopyTitle(WKPageRef page);
397
398 WK_EXPORT WKURLRef WKPageCopyPendingAPIRequestURL(WKPageRef page);
399
400 WK_EXPORT WKURLRef WKPageCopyActiveURL(WKPageRef page);
401 WK_EXPORT WKURLRef WKPageCopyProvisionalURL(WKPageRef page);
402 WK_EXPORT WKURLRef WKPageCopyCommittedURL(WKPageRef page);
403
404 WK_EXPORT WKFrameRef WKPageGetMainFrame(WKPageRef page);
405 WK_EXPORT WKFrameRef WKPageGetFocusedFrame(WKPageRef page); // The focused frame may be inactive.
406 WK_EXPORT WKFrameRef WKPageGetFrameSetLargestFrame(WKPageRef page);
407 WK_EXPORT double WKPageGetEstimatedProgress(WKPageRef page);
408
409 WK_EXPORT uint64_t WKPageGetRenderTreeSize(WKPageRef page);
410
411 WK_EXPORT void WKPageSetMemoryCacheClientCallsEnabled(WKPageRef page, bool memoryCacheClientCallsEnabled);
412
413 WK_EXPORT WKInspectorRef WKPageGetInspector(WKPageRef page);
414
415 WK_EXPORT WKVibrationRef WKPageGetVibration(WKPageRef page);
416
417 WK_EXPORT WKStringRef WKPageCopyUserAgent(WKPageRef page);
418
419 WK_EXPORT WKStringRef WKPageCopyApplicationNameForUserAgent(WKPageRef page);
420 WK_EXPORT void WKPageSetApplicationNameForUserAgent(WKPageRef page, WKStringRef applicationName);
421
422 WK_EXPORT WKStringRef WKPageCopyCustomUserAgent(WKPageRef page);
423 WK_EXPORT void WKPageSetCustomUserAgent(WKPageRef page, WKStringRef userAgent);
424
425 WK_EXPORT bool WKPageSupportsTextEncoding(WKPageRef page);
426 WK_EXPORT WKStringRef WKPageCopyCustomTextEncodingName(WKPageRef page);
427 WK_EXPORT void WKPageSetCustomTextEncodingName(WKPageRef page, WKStringRef encodingName);
428
429 WK_EXPORT void WKPageTerminate(WKPageRef page);
430
431 WK_EXPORT WKStringRef WKPageGetSessionHistoryURLValueType(void);
432 WK_EXPORT WKStringRef WKPageGetSessionBackForwardListItemValueType(void);
433
434 typedef bool (*WKPageSessionStateFilterCallback)(WKPageRef page, WKStringRef valueType, WKTypeRef value, void* context);
435 WK_EXPORT WKDataRef WKPageCopySessionState(WKPageRef page, void* context, WKPageSessionStateFilterCallback urlAllowedCallback);
436 WK_EXPORT void WKPageRestoreFromSessionState(WKPageRef page, WKDataRef sessionStateData);
437
438 WK_EXPORT double WKPageGetBackingScaleFactor(WKPageRef page);
439 WK_EXPORT void WKPageSetCustomBackingScaleFactor(WKPageRef page, double customScaleFactor);
440
441 WK_EXPORT bool WKPageSupportsTextZoom(WKPageRef page);
442 WK_EXPORT double WKPageGetTextZoomFactor(WKPageRef page);
443 WK_EXPORT void WKPageSetTextZoomFactor(WKPageRef page, double zoomFactor);
444 WK_EXPORT double WKPageGetPageZoomFactor(WKPageRef page);
445 WK_EXPORT void WKPageSetPageZoomFactor(WKPageRef page, double zoomFactor);
446 WK_EXPORT void WKPageSetPageAndTextZoomFactors(WKPageRef page, double pageZoomFactor, double textZoomFactor);
447
448 WK_EXPORT void WKPageSetScaleFactor(WKPageRef page, double scale, WKPoint origin);
449 WK_EXPORT double WKPageGetScaleFactor(WKPageRef page);
450
451 WK_EXPORT void WKPageSetUseFixedLayout(WKPageRef page, bool fixed);
452 WK_EXPORT void WKPageSetFixedLayoutSize(WKPageRef page, WKSize size);
453 WK_EXPORT bool WKPageUseFixedLayout(WKPageRef page);
454 WK_EXPORT WKSize WKPageFixedLayoutSize(WKPageRef page);
455
456 WK_EXPORT void WKPageListenForLayoutMilestones(WKPageRef page, WKLayoutMilestones milestones);
457
458 WK_EXPORT void WKPageSetVisibilityState(WKPageRef page, WKPageVisibilityState state, bool isInitialState);
459
460 WK_EXPORT bool WKPageHasHorizontalScrollbar(WKPageRef page);
461 WK_EXPORT bool WKPageHasVerticalScrollbar(WKPageRef page);
462
463 WK_EXPORT void WKPageSetSuppressScrollbarAnimations(WKPageRef page, bool suppressAnimations);
464 WK_EXPORT bool WKPageAreScrollbarAnimationsSuppressed(WKPageRef page);
465
466 WK_EXPORT bool WKPageIsPinnedToLeftSide(WKPageRef page);
467 WK_EXPORT bool WKPageIsPinnedToRightSide(WKPageRef page);
468 WK_EXPORT bool WKPageIsPinnedToTopSide(WKPageRef page);
469 WK_EXPORT bool WKPageIsPinnedToBottomSide(WKPageRef page);
470
471 WK_EXPORT bool WKPageRubberBandsAtBottom(WKPageRef);
472 WK_EXPORT void WKPageSetRubberBandsAtBottom(WKPageRef, bool rubberBandsAtBottom);
473 WK_EXPORT bool WKPageRubberBandsAtTop(WKPageRef);
474 WK_EXPORT void WKPageSetRubberBandsAtTop(WKPageRef, bool rubberBandsAtTop);
475
476 WK_EXPORT bool WKPageCanDelete(WKPageRef page);
477 WK_EXPORT bool WKPageHasSelectedRange(WKPageRef page);
478 WK_EXPORT bool WKPageIsContentEditable(WKPageRef page);
479
480 WK_EXPORT void WKPageSetMaintainsInactiveSelection(WKPageRef page, bool maintainsInactiveSelection);
481 WK_EXPORT void WKPageCenterSelectionInVisibleArea(WKPageRef page);
482     
483 WK_EXPORT void WKPageFindString(WKPageRef page, WKStringRef string, WKFindOptions findOptions, unsigned maxMatchCount);
484 WK_EXPORT void WKPageHideFindUI(WKPageRef page);
485 WK_EXPORT void WKPageCountStringMatches(WKPageRef page, WKStringRef string, WKFindOptions findOptions, unsigned maxMatchCount);
486 WK_EXPORT void WKPageFindStringMatches(WKPageRef page, WKStringRef string, WKFindOptions findOptions, unsigned maxMatchCount);
487 WK_EXPORT void WKPageGetImageForFindMatch(WKPageRef page, int32_t matchIndex);
488 WK_EXPORT void WKPageSelectFindMatch(WKPageRef page, int32_t matchIndex);
489
490 WK_EXPORT void WKPageSetPageContextMenuClient(WKPageRef page, const WKPageContextMenuClient* client);
491 WK_EXPORT void WKPageSetPageFindClient(WKPageRef page, const WKPageFindClient* client);
492 WK_EXPORT void WKPageSetPageFindMatchesClient(WKPageRef page, const WKPageFindMatchesClient* client);
493 WK_EXPORT void WKPageSetPageFormClient(WKPageRef page, const WKPageFormClient* client);
494 WK_EXPORT void WKPageSetPageLoaderClient(WKPageRef page, const WKPageLoaderClient* client);
495 WK_EXPORT void WKPageSetPagePolicyClient(WKPageRef page, const WKPagePolicyClient* client);
496 WK_EXPORT void WKPageSetPageUIClient(WKPageRef page, const WKPageUIClient* client);
497
498 typedef void (*WKPageRunJavaScriptFunction)(WKSerializedScriptValueRef, WKErrorRef, void*);
499 WK_EXPORT void WKPageRunJavaScriptInMainFrame(WKPageRef page, WKStringRef script, void* context, WKPageRunJavaScriptFunction function);
500 #ifdef __BLOCKS__
501 typedef void (^WKPageRunJavaScriptBlock)(WKSerializedScriptValueRef, WKErrorRef);
502 WK_EXPORT void WKPageRunJavaScriptInMainFrame_b(WKPageRef page, WKStringRef script, WKPageRunJavaScriptBlock block);
503 #endif
504
505 typedef void (*WKPageGetSourceForFrameFunction)(WKStringRef, WKErrorRef, void*);
506 WK_EXPORT void WKPageGetSourceForFrame(WKPageRef page, WKFrameRef frame, void* context, WKPageGetSourceForFrameFunction function);
507 #ifdef __BLOCKS__
508 typedef void (^WKPageGetSourceForFrameBlock)(WKStringRef, WKErrorRef);
509 WK_EXPORT void WKPageGetSourceForFrame_b(WKPageRef page, WKFrameRef frame, WKPageGetSourceForFrameBlock block);
510 #endif
511
512 typedef void (*WKPageGetContentsAsStringFunction)(WKStringRef, WKErrorRef, void*);
513 WK_EXPORT void WKPageGetContentsAsString(WKPageRef page, void* context, WKPageGetContentsAsStringFunction function);
514 #ifdef __BLOCKS__
515 typedef void (^WKPageGetContentsAsStringBlock)(WKStringRef, WKErrorRef);
516 WK_EXPORT void WKPageGetContentsAsString_b(WKPageRef page, WKPageGetContentsAsStringBlock block);
517 #endif
518
519 typedef void (*WKPageGetContentsAsMHTMLDataFunction)(WKDataRef, WKErrorRef, void*);
520 WK_EXPORT void WKPageGetContentsAsMHTMLData(WKPageRef page, bool useBinaryEncoding, void* context, WKPageGetContentsAsMHTMLDataFunction function);
521
522 typedef void (*WKPageGetSelectionAsWebArchiveDataFunction)(WKDataRef, WKErrorRef, void*);
523 WK_EXPORT void WKPageGetSelectionAsWebArchiveData(WKPageRef page, void* context, WKPageGetSelectionAsWebArchiveDataFunction function);
524
525 typedef void (*WKPageForceRepaintFunction)(WKErrorRef, void*);
526 WK_EXPORT void WKPageForceRepaint(WKPageRef page, void* context, WKPageForceRepaintFunction function);
527
528 /*
529     Some of the more common command name strings include the following, although any WebCore EditorCommand string is supported:
530     
531     "Cut"
532     "Copy"
533     "Paste"
534     "SelectAll"
535     "Undo"
536     "Redo"
537 */
538
539 // state represents the state of the command in a menu (on is 1, off is 0, and mixed is -1), typically used to add a checkmark next to the menu item.
540 typedef void (*WKPageValidateCommandCallback)(WKStringRef command, bool isEnabled, int32_t state, WKErrorRef, void* context);
541 WK_EXPORT void WKPageValidateCommand(WKPageRef page, WKStringRef command, void* context, WKPageValidateCommandCallback callback);
542 WK_EXPORT void WKPageExecuteCommand(WKPageRef page, WKStringRef command);
543
544 WK_EXPORT void WKPagePostMessageToInjectedBundle(WKPageRef page, WKStringRef messageName, WKTypeRef messageBody);
545
546 WK_EXPORT void WKPageSelectContextMenuItem(WKPageRef page, WKContextMenuItemRef item);
547
548
549
550 /* DEPRECATED -  Please use constants from WKPluginInformation instead. */
551
552 /* Value type: WKStringRef */
553 WK_EXPORT WKStringRef WKPageGetPluginInformationBundleIdentifierKey();
554
555 /* Value type: WKStringRef */
556 WK_EXPORT WKStringRef WKPageGetPluginInformationBundleVersionKey();
557
558 /* Value type: WKStringRef */
559 WK_EXPORT WKStringRef WKPageGetPluginInformationDisplayNameKey();
560
561 /* Value type: WKURLRef */
562 WK_EXPORT WKStringRef WKPageGetPluginInformationFrameURLKey();
563
564 /* Value type: WKStringRef */
565 WK_EXPORT WKStringRef WKPageGetPluginInformationMIMETypeKey();
566
567 /* Value type: WKURLRef */
568 WK_EXPORT WKStringRef WKPageGetPluginInformationPageURLKey();
569
570 /* Value type: WKURLRef */
571 WK_EXPORT WKStringRef WKPageGetPluginInformationPluginspageAttributeURLKey();
572
573 /* Value type: WKURLRef */
574 WK_EXPORT WKStringRef WKPageGetPluginInformationPluginURLKey();
575
576 #ifdef __cplusplus
577 }
578 #endif
579
580 #endif /* WKPage_h */