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 WKBundlePage_h
27#define WKBundlePage_h
28
29#include <JavaScriptCore/JavaScript.h>
30#include <WebKit2/WKBase.h>
31#include <WebKit2/WKEvent.h>
32#include <WebKit2/WKFindOptions.h>
33#include <WebKit2/WKImage.h>
34#include <WebKit2/WKPageLoadTypes.h>
35
36#ifndef __cplusplus
37#include <stdbool.h>
38#endif
39
40#include <stdint.h>
41
42#ifdef __cplusplus
43extern "C" {
44#endif
45
46enum {
47    kWKInsertActionTyped = 0,
48    kWKInsertActionPasted = 1,
49    kWKInsertActionDropped = 2
50};
51typedef uint32_t WKInsertActionType;
52
53enum {
54    kWKAffinityUpstream,
55    kWKAffinityDownstream
56};
57typedef uint32_t WKAffinityType;
58
59enum {
60    WKInputFieldActionTypeMoveUp,
61    WKInputFieldActionTypeMoveDown,
62    WKInputFieldActionTypeCancel,
63    WKInputFieldActionTypeInsertTab,
64    WKInputFieldActionTypeInsertBacktab,
65    WKInputFieldActionTypeInsertNewline,
66    WKInputFieldActionTypeInsertDelete
67};
68typedef uint32_t WKInputFieldActionType;
69
70enum {
71    WKFullScreenNoKeyboard,
72    WKFullScreenKeyboard,
73};
74typedef uint32_t WKFullScreenKeyboardRequestType;
75
76enum {
77    WKScrollDirectionLeft,
78    WKScrollDirectionRight
79};
80typedef uint32_t WKScrollDirection;
81
82// Loader Client
83typedef void (*WKBundlePageDidStartProvisionalLoadForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo);
84typedef void (*WKBundlePageDidReceiveServerRedirectForProvisionalLoadForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo);
85typedef void (*WKBundlePageDidFailProvisionalLoadWithErrorForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKErrorRef error, WKTypeRef* userData, const void *clientInfo);
86typedef void (*WKBundlePageDidCommitLoadForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo);
87typedef void (*WKBundlePageDidDocumentFinishLoadForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo);
88typedef void (*WKBundlePageDidFinishLoadForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo);
89typedef void (*WKBundlePageDidFinishDocumentLoadForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo);
90typedef void (*WKBundlePageDidFinishProgressCallback)(WKBundlePageRef page, const void *clientInfo);
91typedef void (*WKBundlePageDidFailLoadWithErrorForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKErrorRef error, WKTypeRef* userData, const void *clientInfo);
92typedef void (*WKBundlePageDidSameDocumentNavigationForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKSameDocumentNavigationType type, WKTypeRef* userData, const void *clientInfo);
93typedef void (*WKBundlePageDidReceiveTitleForFrameCallback)(WKBundlePageRef page, WKStringRef title, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo);
94typedef void (*WKBundlePageDidRemoveFrameFromHierarchyCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo);
95typedef void (*WKBundlePageDidDisplayInsecureContentForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo);
96typedef void (*WKBundlePageDidRunInsecureContentForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo);
97typedef void (*WKBundlePageDidDetectXSSForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo);
98typedef void (*WKBundlePageDidFirstLayoutForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo);
99typedef void (*WKBundlePageDidFirstVisuallyNonEmptyLayoutForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo);
100typedef void (*WKBundlePageDidNewFirstVisuallyNonEmptyLayoutCallback)(WKBundlePageRef page, WKTypeRef* userData, const void *clientInfo);
101typedef void (*WKBundlePageDidLayoutForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, const void* clientInfo);
102typedef void (*WKBundlePageDidClearWindowObjectForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKBundleScriptWorldRef world, const void *clientInfo);
103typedef void (*WKBundlePageDidCancelClientRedirectForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, const void *clientInfo);
104typedef void (*WKBundlePageWillPerformClientRedirectForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKURLRef url, double delay, double date, const void *clientInfo);
105typedef void (*WKBundlePageDidHandleOnloadEventsForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, const void *clientInfo);
106typedef bool (*WKBundlePageShouldGoToBackForwardListItemCallback)(WKBundlePageRef page, WKBundleBackForwardListItemRef item, WKTypeRef* userData, const void *clientInfo);
107typedef void (*WKBundlePageGlobalObjectIsAvailableForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef, WKBundleScriptWorldRef, const void* clientInfo);
108typedef void (*WKBundlePageWillDisconnectDOMWindowExtensionFromGlobalObjectCallback)(WKBundlePageRef page, WKBundleDOMWindowExtensionRef, const void* clientInfo);
109typedef void (*WKBundlePageDidReconnectDOMWindowExtensionToGlobalObjectCallback)(WKBundlePageRef page, WKBundleDOMWindowExtensionRef, const void* clientInfo);
110typedef void (*WKBundlePageWillDestroyGlobalObjectForDOMWindowExtensionCallback)(WKBundlePageRef page, WKBundleDOMWindowExtensionRef, const void* clientInfo);
111typedef bool (*WKBundlePageShouldForceUniversalAccessFromLocalURLCallback)(WKBundlePageRef, WKStringRef url, const void* clientInfo);
112typedef void (*WKBundlePageDidLayoutCallback)(WKBundlePageRef page, WKLayoutMilestones milestones, WKTypeRef* userData, const void *clientInfo);
113typedef void (*WKBundlePageFeaturesUsedInPageCallback)(WKBundlePageRef page, WKArrayRef featureStrings, const void *clientInfo);
114typedef void (*WKBundlePageWillLoadURLRequestCallback)(WKBundlePageRef page, WKURLRequestRef request, WKTypeRef userData, const void *clientInfo);
115typedef void (*WKBundlePageWillLoadDataRequestCallback)(WKBundlePageRef page, WKURLRequestRef request, WKDataRef data, WKStringRef MIMEType, WKStringRef encodingName, WKURLRef unreachableURL, WKTypeRef userData, const void *clientInfo);
116
117struct WKBundlePageLoaderClient {
118    int                                                                     version;
119    const void *                                                            clientInfo;
120
121    // Version 0.
122    WKBundlePageDidStartProvisionalLoadForFrameCallback                     didStartProvisionalLoadForFrame;
123    WKBundlePageDidReceiveServerRedirectForProvisionalLoadForFrameCallback  didReceiveServerRedirectForProvisionalLoadForFrame;
124    WKBundlePageDidFailProvisionalLoadWithErrorForFrameCallback             didFailProvisionalLoadWithErrorForFrame;
125    WKBundlePageDidCommitLoadForFrameCallback                               didCommitLoadForFrame;
126    WKBundlePageDidFinishDocumentLoadForFrameCallback                       didFinishDocumentLoadForFrame;
127    WKBundlePageDidFinishLoadForFrameCallback                               didFinishLoadForFrame;
128    WKBundlePageDidFailLoadWithErrorForFrameCallback                        didFailLoadWithErrorForFrame;
129    WKBundlePageDidSameDocumentNavigationForFrameCallback                   didSameDocumentNavigationForFrame;
130    WKBundlePageDidReceiveTitleForFrameCallback                             didReceiveTitleForFrame;
131    WKBundlePageDidFirstLayoutForFrameCallback                              didFirstLayoutForFrame;
132    WKBundlePageDidFirstVisuallyNonEmptyLayoutForFrameCallback              didFirstVisuallyNonEmptyLayoutForFrame;
133    WKBundlePageDidRemoveFrameFromHierarchyCallback                         didRemoveFrameFromHierarchy;
134    WKBundlePageDidDisplayInsecureContentForFrameCallback                   didDisplayInsecureContentForFrame;
135    WKBundlePageDidRunInsecureContentForFrameCallback                       didRunInsecureContentForFrame;
136    WKBundlePageDidClearWindowObjectForFrameCallback                        didClearWindowObjectForFrame;
137    WKBundlePageDidCancelClientRedirectForFrameCallback                     didCancelClientRedirectForFrame;
138    WKBundlePageWillPerformClientRedirectForFrameCallback                   willPerformClientRedirectForFrame;
139    WKBundlePageDidHandleOnloadEventsForFrameCallback                       didHandleOnloadEventsForFrame;
140
141    // Version 1.
142    WKBundlePageDidLayoutForFrameCallback                                   didLayoutForFrame;
143    WKBundlePageDidNewFirstVisuallyNonEmptyLayoutCallback                   didNewFirstVisuallyNonEmptyLayout;
144    WKBundlePageDidDetectXSSForFrameCallback                                didDetectXSSForFrame;
145    WKBundlePageShouldGoToBackForwardListItemCallback                       shouldGoToBackForwardListItem;
146    WKBundlePageGlobalObjectIsAvailableForFrameCallback                     globalObjectIsAvailableForFrame;
147    WKBundlePageWillDisconnectDOMWindowExtensionFromGlobalObjectCallback    willDisconnectDOMWindowExtensionFromGlobalObject;
148    WKBundlePageDidReconnectDOMWindowExtensionToGlobalObjectCallback        didReconnectDOMWindowExtensionToGlobalObject;
149    WKBundlePageWillDestroyGlobalObjectForDOMWindowExtensionCallback        willDestroyGlobalObjectForDOMWindowExtension;
150
151    // Version 2
152    WKBundlePageDidFinishProgressCallback                                   didFinishProgress;
153    WKBundlePageShouldForceUniversalAccessFromLocalURLCallback              shouldForceUniversalAccessFromLocalURL;
154
155    // Version 3
156    void *                                                                  didReceiveIntentForFrame_unavailable;
157    void *                                                                  registerIntentServiceForFrame_unavailable;
158
159    // Version 4
160    WKBundlePageDidLayoutCallback                                           didLayout;
161
162    // Version 5
163    WKBundlePageFeaturesUsedInPageCallback                                  featuresUsedInPage;
164
165    // Version 6
166    WKBundlePageWillLoadURLRequestCallback                                  willLoadURLRequest;
167    WKBundlePageWillLoadDataRequestCallback                                 willLoadDataRequest;
168};
169typedef struct WKBundlePageLoaderClient WKBundlePageLoaderClient;
170
171enum { kWKBundlePageLoaderClientCurrentVersion = 6 };
172
173enum {
174    WKBundlePagePolicyActionPassThrough,
175    WKBundlePagePolicyActionUse
176};
177typedef uint32_t WKBundlePagePolicyAction;
178
179// Policy Client
180typedef WKBundlePagePolicyAction (*WKBundlePageDecidePolicyForNavigationActionCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKBundleNavigationActionRef navigationAction, WKURLRequestRef request, WKTypeRef* userData, const void* clientInfo);
181typedef WKBundlePagePolicyAction (*WKBundlePageDecidePolicyForNewWindowActionCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKBundleNavigationActionRef navigationAction, WKURLRequestRef request, WKStringRef frameName, WKTypeRef* userData, const void* clientInfo);
182typedef WKBundlePagePolicyAction (*WKBundlePageDecidePolicyForResponseCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKURLResponseRef response, WKURLRequestRef request, WKTypeRef* userData, const void* clientInfo);
183typedef void (*WKBundlePageUnableToImplementPolicyCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKErrorRef error, WKTypeRef* userData, const void* clientInfo);
184
185struct WKBundlePagePolicyClient {
186    int                                                                 version;
187    const void *                                                        clientInfo;
188    WKBundlePageDecidePolicyForNavigationActionCallback                 decidePolicyForNavigationAction;
189    WKBundlePageDecidePolicyForNewWindowActionCallback                  decidePolicyForNewWindowAction;
190    WKBundlePageDecidePolicyForResponseCallback                         decidePolicyForResponse;
191    WKBundlePageUnableToImplementPolicyCallback                         unableToImplementPolicy;
192};
193typedef struct WKBundlePagePolicyClient WKBundlePagePolicyClient;
194
195enum { kWKBundlePagePolicyClientCurrentVersion = 0 };
196
197// Resource Load Client
198typedef void (*WKBundlePageDidInitiateLoadForResourceCallback)(WKBundlePageRef, WKBundleFrameRef, uint64_t resourceIdentifier, WKURLRequestRef, bool pageIsProvisionallyLoading, const void* clientInfo);
199typedef WKURLRequestRef (*WKBundlePageWillSendRequestForFrameCallback)(WKBundlePageRef, WKBundleFrameRef, uint64_t resourceIdentifier, WKURLRequestRef, WKURLResponseRef redirectResponse, const void *clientInfo);
200typedef void (*WKBundlePageDidReceiveResponseForResourceCallback)(WKBundlePageRef, WKBundleFrameRef, uint64_t resourceIdentifier, WKURLResponseRef, const void* clientInfo);
201typedef void (*WKBundlePageDidReceiveContentLengthForResourceCallback)(WKBundlePageRef, WKBundleFrameRef, uint64_t resourceIdentifier, uint64_t contentLength, const void* clientInfo);
202typedef void (*WKBundlePageDidFinishLoadForResourceCallback)(WKBundlePageRef, WKBundleFrameRef, uint64_t resourceIdentifier, const void* clientInfo);
203typedef void (*WKBundlePageDidFailLoadForResourceCallback)(WKBundlePageRef, WKBundleFrameRef, uint64_t resourceIdentifier, WKErrorRef, const void* clientInfo);
204typedef bool (*WKBundlePageShouldCacheResponseCallback)(WKBundlePageRef, WKBundleFrameRef, uint64_t resourceIdentifier, const void* clientInfo);
205typedef bool (*WKBundlePageShouldUseCredentialStorageCallback)(WKBundlePageRef, WKBundleFrameRef, uint64_t resourceIdentifier, const void* clientInfo);
206
207struct WKBundlePageResourceLoadClient {
208    int                                                                 version;
209    const void *                                                        clientInfo;
210
211    // Version 0.
212    WKBundlePageDidInitiateLoadForResourceCallback                      didInitiateLoadForResource;
213
214    // willSendRequestForFrame is supposed to return a retained reference to the URL request.
215    WKBundlePageWillSendRequestForFrameCallback                         willSendRequestForFrame;
216
217    WKBundlePageDidReceiveResponseForResourceCallback                   didReceiveResponseForResource;
218    WKBundlePageDidReceiveContentLengthForResourceCallback              didReceiveContentLengthForResource;
219    WKBundlePageDidFinishLoadForResourceCallback                        didFinishLoadForResource;
220    WKBundlePageDidFailLoadForResourceCallback                          didFailLoadForResource;
221
222    // Version 1.
223    WKBundlePageShouldCacheResponseCallback                             shouldCacheResponse;
224    WKBundlePageShouldUseCredentialStorageCallback                      shouldUseCredentialStorage;
225};
226typedef struct WKBundlePageResourceLoadClient WKBundlePageResourceLoadClient;
227
228enum { kWKBundlePageResourceLoadClientCurrentVersion = 1 };
229
230enum {
231    WKBundlePageUIElementVisibilityUnknown,
232    WKBundlePageUIElementVisible,
233    WKBundlePageUIElementHidden
234};
235typedef uint32_t WKBundlePageUIElementVisibility;
236
237enum {
238    WKBundlePageLabelSizeSmall,
239    WKBundlePageLabelSizeLarge,
240};
241typedef uint32_t WKBundlePageLabelSize;
242
243// UI Client
244typedef void (*WKBundlePageWillAddMessageToConsoleCallback)(WKBundlePageRef page, WKStringRef message, uint32_t lineNumber, const void *clientInfo);
245typedef void (*WKBundlePageWillSetStatusbarTextCallback)(WKBundlePageRef page, WKStringRef statusbarText, const void *clientInfo);
246typedef void (*WKBundlePageWillRunJavaScriptAlertCallback)(WKBundlePageRef page, WKStringRef alertText, WKBundleFrameRef frame, const void *clientInfo);
247typedef void (*WKBundlePageWillRunJavaScriptConfirmCallback)(WKBundlePageRef page, WKStringRef message, WKBundleFrameRef frame, const void *clientInfo);
248typedef void (*WKBundlePageWillRunJavaScriptPromptCallback)(WKBundlePageRef page, WKStringRef message, WKStringRef defaultValue, WKBundleFrameRef frame, const void *clientInfo);
249typedef void (*WKBundlePageMouseDidMoveOverElementCallback)(WKBundlePageRef page, WKBundleHitTestResultRef hitTestResult, WKEventModifiers modifiers, WKTypeRef* userData, const void *clientInfo);
250typedef void (*WKBundlePageDidScrollCallback)(WKBundlePageRef page, const void *clientInfo);
251typedef void (*WKBundlePagePaintCustomOverhangAreaCallback)(WKBundlePageRef page, WKGraphicsContextRef graphicsContext, WKRect horizontalOverhang, WKRect verticalOverhang, WKRect dirtyRect, const void* clientInfo);
252typedef WKStringRef (*WKBundlePageGenerateFileForUploadCallback)(WKBundlePageRef page, WKStringRef originalFilePath, const void* clientInfo);
253typedef bool (*WKBundlePageShouldRubberBandInDirectionCallback)(WKBundlePageRef page, WKScrollDirection scrollDirection, const void* clientInfo);
254typedef WKBundlePageUIElementVisibility (*WKBundlePageStatusBarIsVisibleCallback)(WKBundlePageRef page, const void *clientInfo);
255typedef WKBundlePageUIElementVisibility (*WKBundlePageMenuBarIsVisibleCallback)(WKBundlePageRef page, const void *clientInfo);
256typedef WKBundlePageUIElementVisibility (*WKBundlePageToolbarsAreVisibleCallback)(WKBundlePageRef page, const void *clientInfo);
257typedef void (*WKBundlePageReachedAppCacheOriginQuotaCallback)(WKBundlePageRef page, WKSecurityOriginRef origin, int64_t totalBytesNeeded, const void *clientInfo);
258typedef uint64_t (*WKBundlePageExceededDatabaseQuotaCallback)(WKBundlePageRef page, WKSecurityOriginRef origin, WKStringRef databaseName, WKStringRef databaseDisplayName, uint64_t currentQuotaBytes, uint64_t currentOriginUsageBytes, uint64_t currentDatabaseUsageBytes, uint64_t expectedUsageBytes, const void *clientInfo);
259typedef WKStringRef (*WKBundlePagePlugInCreateStartLabelTitleCallback)(WKStringRef mimeType, const void *clientInfo);
260typedef WKStringRef (*WKBundlePagePlugInCreateStartLabelSubtitleCallback)(WKStringRef mimeType, const void *clientInfo);
261typedef WKStringRef (*WKBundlePagePlugInCreateExtraStyleSheetCallback)(const void *clientInfo);
262typedef WKStringRef (*WKBundlePagePlugInCreateExtraScriptCallback)(const void *clientInfo);
263
264struct WKBundlePageUIClient {
265    int                                                                 version;
266    const void *                                                        clientInfo;
267    WKBundlePageWillAddMessageToConsoleCallback                         willAddMessageToConsole;
268    WKBundlePageWillSetStatusbarTextCallback                            willSetStatusbarText;
269    WKBundlePageWillRunJavaScriptAlertCallback                          willRunJavaScriptAlert;
270    WKBundlePageWillRunJavaScriptConfirmCallback                        willRunJavaScriptConfirm;
271    WKBundlePageWillRunJavaScriptPromptCallback                         willRunJavaScriptPrompt;
272    WKBundlePageMouseDidMoveOverElementCallback                         mouseDidMoveOverElement;
273    WKBundlePageDidScrollCallback                                       pageDidScroll;
274    WKBundlePagePaintCustomOverhangAreaCallback                         paintCustomOverhangArea;
275    WKBundlePageGenerateFileForUploadCallback                           shouldGenerateFileForUpload;
276    WKBundlePageGenerateFileForUploadCallback                           generateFileForUpload;
277    WKBundlePageShouldRubberBandInDirectionCallback                     shouldRubberBandInDirection;
278    WKBundlePageStatusBarIsVisibleCallback                              statusBarIsVisible;
279    WKBundlePageMenuBarIsVisibleCallback                                menuBarIsVisible;
280    WKBundlePageToolbarsAreVisibleCallback                              toolbarsAreVisible;
281
282    // Version 1.
283    WKBundlePageReachedAppCacheOriginQuotaCallback                      didReachApplicationCacheOriginQuota;
284
285    // Version 2.
286    WKBundlePageExceededDatabaseQuotaCallback                           didExceedDatabaseQuota;
287    WKBundlePagePlugInCreateStartLabelTitleCallback                     createPlugInStartLabelTitle;
288    WKBundlePagePlugInCreateStartLabelSubtitleCallback                  createPlugInStartLabelSubtitle;
289    WKBundlePagePlugInCreateExtraStyleSheetCallback                     createPlugInExtraStyleSheet;
290    WKBundlePagePlugInCreateExtraScriptCallback                         createPlugInExtraScript;
291};
292typedef struct WKBundlePageUIClient WKBundlePageUIClient;
293
294enum { kWKBundlePageUIClientCurrentVersion = 2 };
295
296// Editor client
297typedef bool (*WKBundlePageShouldBeginEditingCallback)(WKBundlePageRef page, WKBundleRangeHandleRef range, const void* clientInfo);
298typedef bool (*WKBundlePageShouldEndEditingCallback)(WKBundlePageRef page, WKBundleRangeHandleRef range, const void* clientInfo);
299typedef bool (*WKBundlePageShouldInsertNodeCallback)(WKBundlePageRef page, WKBundleNodeHandleRef node, WKBundleRangeHandleRef rangeToReplace, WKInsertActionType action, const void* clientInfo);
300typedef bool (*WKBundlePageShouldInsertTextCallback)(WKBundlePageRef page, WKStringRef string, WKBundleRangeHandleRef rangeToReplace, WKInsertActionType action, const void* clientInfo);
301typedef bool (*WKBundlePageShouldDeleteRangeCallback)(WKBundlePageRef page, WKBundleRangeHandleRef range, const void* clientInfo);
302typedef bool (*WKBundlePageShouldChangeSelectedRange)(WKBundlePageRef page, WKBundleRangeHandleRef fromRange, WKBundleRangeHandleRef toRange, WKAffinityType affinity, bool stillSelecting, const void* clientInfo);
303typedef bool (*WKBundlePageShouldApplyStyle)(WKBundlePageRef page, WKBundleCSSStyleDeclarationRef style, WKBundleRangeHandleRef range, const void* clientInfo);
304typedef void (*WKBundlePageEditingNotification)(WKBundlePageRef page, WKStringRef notificationName, const void* clientInfo);
305typedef void (*WKBundlePageWillWriteToPasteboard)(WKBundlePageRef page, WKBundleRangeHandleRef range,  const void* clientInfo);
306typedef void (*WKBundlePageGetPasteboardDataForRange)(WKBundlePageRef page, WKBundleRangeHandleRef range, WKArrayRef* pasteboardTypes, WKArrayRef* pasteboardData, const void* clientInfo);
307typedef void (*WKBundlePageDidWriteToPasteboard)(WKBundlePageRef page, const void* clientInfo);
308
309struct WKBundlePageEditorClient {
310    int                                                                 version;
311    const void *                                                        clientInfo;
312    WKBundlePageShouldBeginEditingCallback                              shouldBeginEditing;
313    WKBundlePageShouldEndEditingCallback                                shouldEndEditing;
314    WKBundlePageShouldInsertNodeCallback                                shouldInsertNode;
315    WKBundlePageShouldInsertTextCallback                                shouldInsertText;
316    WKBundlePageShouldDeleteRangeCallback                               shouldDeleteRange;
317    WKBundlePageShouldChangeSelectedRange                               shouldChangeSelectedRange;
318    WKBundlePageShouldApplyStyle                                        shouldApplyStyle;
319    WKBundlePageEditingNotification                                     didBeginEditing;
320    WKBundlePageEditingNotification                                     didEndEditing;
321    WKBundlePageEditingNotification                                     didChange;
322    WKBundlePageEditingNotification                                     didChangeSelection;
323    // Version 1.
324    WKBundlePageWillWriteToPasteboard                                   willWriteToPasteboard;
325    WKBundlePageGetPasteboardDataForRange                               getPasteboardDataForRange;
326    WKBundlePageDidWriteToPasteboard                                    didWriteToPasteboard;
327};
328typedef struct WKBundlePageEditorClient WKBundlePageEditorClient;
329
330enum { kWKBundlePageEditorClientCurrentVersion = 1 };
331
332// Form client
333typedef void (*WKBundlePageTextFieldDidBeginEditingCallback)(WKBundlePageRef page, WKBundleNodeHandleRef htmlInputElementHandle, WKBundleFrameRef frame, const void* clientInfo);
334typedef void (*WKBundlePageTextFieldDidEndEditingCallback)(WKBundlePageRef page, WKBundleNodeHandleRef htmlInputElementHandle, WKBundleFrameRef frame, const void* clientInfo);
335typedef void (*WKBundlePageTextDidChangeInTextFieldCallback)(WKBundlePageRef page, WKBundleNodeHandleRef htmlInputElementHandle, WKBundleFrameRef frame, const void* clientInfo);
336typedef void (*WKBundlePageTextDidChangeInTextAreaCallback)(WKBundlePageRef page, WKBundleNodeHandleRef htmlTextAreaElementHandle, WKBundleFrameRef frame, const void* clientInfo);
337typedef bool (*WKBundlePageShouldPerformActionInTextFieldCallback)(WKBundlePageRef page, WKBundleNodeHandleRef htmlInputElementHandle, WKInputFieldActionType actionType, WKBundleFrameRef frame, const void* clientInfo);
338typedef void (*WKBundlePageWillSubmitFormCallback)(WKBundlePageRef page, WKBundleNodeHandleRef htmlFormElementHandle, WKBundleFrameRef frame, WKBundleFrameRef sourceFrame, WKDictionaryRef values, WKTypeRef* userData, const void* clientInfo);
339typedef void (*WKBundlePageWillSendSubmitEventCallback)(WKBundlePageRef page, WKBundleNodeHandleRef htmlFormElementHandle, WKBundleFrameRef frame, WKBundleFrameRef sourceFrame, WKDictionaryRef values, const void* clientInfo);
340typedef void (*WKBundlePageDidFocusTextFieldCallback)(WKBundlePageRef page, WKBundleNodeHandleRef htmlInputElementHandle, WKBundleFrameRef frame, const void* clientInfo);
341typedef bool (*WKBundlePageShouldNotifyOnFormChangesCallback)(WKBundlePageRef page, const void* clientInfo);
342typedef void (*WKBundlePageDidAssociateFormControlsCallback)(WKBundlePageRef page, WKArrayRef elementHandles, const void* clientInfo);
343
344struct WKBundlePageFormClient {
345    int                                                                 version;
346    const void *                                                        clientInfo;
347
348    // Version 0.
349    WKBundlePageTextFieldDidBeginEditingCallback                        textFieldDidBeginEditing;
350    WKBundlePageTextFieldDidEndEditingCallback                          textFieldDidEndEditing;
351    WKBundlePageTextDidChangeInTextFieldCallback                        textDidChangeInTextField;
352    WKBundlePageTextDidChangeInTextAreaCallback                         textDidChangeInTextArea;
353    WKBundlePageShouldPerformActionInTextFieldCallback                  shouldPerformActionInTextField;
354    WKBundlePageWillSubmitFormCallback                                  willSubmitForm;
355
356    // Version 1.
357    WKBundlePageWillSendSubmitEventCallback                             willSendSubmitEvent;
358
359    // version 2.
360    WKBundlePageDidFocusTextFieldCallback                               didFocusTextField;
361    WKBundlePageShouldNotifyOnFormChangesCallback                       shouldNotifyOnFormChanges;
362    WKBundlePageDidAssociateFormControlsCallback                        didAssociateFormControls;
363};
364typedef struct WKBundlePageFormClient WKBundlePageFormClient;
365
366enum { kWKBundlePageFormClientCurrentVersion = 2 };
367
368// ContextMenu client
369typedef void (*WKBundlePageGetContextMenuFromDefaultContextMenuCallback)(WKBundlePageRef page, WKBundleHitTestResultRef hitTestResult, WKArrayRef defaultMenu, WKArrayRef* newMenu, WKTypeRef* userData, const void* clientInfo);
370
371struct WKBundlePageContextMenuClient {
372    int                                                                 version;
373    const void *                                                        clientInfo;
374    WKBundlePageGetContextMenuFromDefaultContextMenuCallback            getContextMenuFromDefaultMenu;
375};
376typedef struct WKBundlePageContextMenuClient WKBundlePageContextMenuClient;
377
378enum { kWKBundlePageContextMenuClientCurrentVersion = 0 };
379
380// Full Screen client
381typedef bool (*WKBundlePageSupportsFullScreen)(WKBundlePageRef page, WKFullScreenKeyboardRequestType requestType);
382typedef void (*WKBundlePageEnterFullScreenForElement)(WKBundlePageRef page, WKBundleNodeHandleRef element);
383typedef void (*WKBundlePageExitFullScreenForElement)(WKBundlePageRef page, WKBundleNodeHandleRef element);
384typedef void (*WKBundlePageBeganEnterFullScreen)(WKBundlePageRef page, WKRect initialFrame, WKRect finalFrame);
385typedef void (*WKBundlePageBeganExitFullScreen)(WKBundlePageRef page, WKRect initialFrame, WKRect finalFrame);
386typedef void (*WKBundlePageCloseFullScreen)(WKBundlePageRef page);
387
388struct WKBundlePageFullScreenClient {
389    int                                                                 version;
390    const void *                                                        clientInfo;
391
392    // Version 0:
393    WKBundlePageSupportsFullScreen                                      supportsFullScreen;
394    WKBundlePageEnterFullScreenForElement                               enterFullScreenForElement;
395    WKBundlePageExitFullScreenForElement                                exitFullScreenForElement;
396
397    // Version 1:
398    WKBundlePageBeganEnterFullScreen                                    beganEnterFullScreen;
399    WKBundlePageBeganExitFullScreen                                     beganExitFullScreen;
400    WKBundlePageCloseFullScreen                                         closeFullScreen;
401};
402typedef struct WKBundlePageFullScreenClient WKBundlePageFullScreenClient;
403
404enum { kWKBundlePageFullScreenClientCurrentVersion = 1 };
405
406// MessageTrace client
407typedef void (*WKBundlePageDiagnosticLoggingCallback)(WKBundlePageRef page, WKStringRef message, WKStringRef description, WKStringRef success, const void* clientInfo);
408
409struct WKBundlePageDiagnosticLoggingClient {
410    int                                                                 version;
411    const void *                                                        clientInfo;
412    WKBundlePageDiagnosticLoggingCallback                               logDiagnosticMessage;
413};
414typedef struct WKBundlePageDiagnosticLoggingClient WKBundlePageDiagnosticLoggingClient;
415
416enum { kWKBundlePageDiagnosticLoggingClientCurrentVersion = 0 };
417
418WK_EXPORT void WKBundlePageWillEnterFullScreen(WKBundlePageRef page);
419WK_EXPORT void WKBundlePageDidEnterFullScreen(WKBundlePageRef page);
420WK_EXPORT void WKBundlePageWillExitFullScreen(WKBundlePageRef page);
421WK_EXPORT void WKBundlePageDidExitFullScreen(WKBundlePageRef page);
422
423WK_EXPORT WKTypeID WKBundlePageGetTypeID();
424
425WK_EXPORT void WKBundlePageSetContextMenuClient(WKBundlePageRef page, WKBundlePageContextMenuClient* client);
426WK_EXPORT void WKBundlePageSetEditorClient(WKBundlePageRef page, WKBundlePageEditorClient* client);
427WK_EXPORT void WKBundlePageSetFormClient(WKBundlePageRef page, WKBundlePageFormClient* client);
428WK_EXPORT void WKBundlePageSetPageLoaderClient(WKBundlePageRef page, WKBundlePageLoaderClient* client);
429WK_EXPORT void WKBundlePageSetResourceLoadClient(WKBundlePageRef page, WKBundlePageResourceLoadClient* client);
430WK_EXPORT void WKBundlePageSetPolicyClient(WKBundlePageRef page, WKBundlePagePolicyClient* client);
431WK_EXPORT void WKBundlePageSetUIClient(WKBundlePageRef page, WKBundlePageUIClient* client);
432WK_EXPORT void WKBundlePageSetFullScreenClient(WKBundlePageRef page, WKBundlePageFullScreenClient* client);
433WK_EXPORT void WKBundlePageSetDiagnosticLoggingClient(WKBundlePageRef page, WKBundlePageDiagnosticLoggingClient* client);
434
435WK_EXPORT WKBundlePageGroupRef WKBundlePageGetPageGroup(WKBundlePageRef page);
436WK_EXPORT WKBundleFrameRef WKBundlePageGetMainFrame(WKBundlePageRef page);
437
438WK_EXPORT WKBundleBackForwardListRef WKBundlePageGetBackForwardList(WKBundlePageRef page);
439
440WK_EXPORT void WKBundlePageSetUnderlayPage(WKBundlePageRef page, WKBundlePageRef pageUnderlay);
441
442WK_EXPORT void WKBundlePageInstallPageOverlay(WKBundlePageRef page, WKBundlePageOverlayRef pageOverlay);
443WK_EXPORT void WKBundlePageUninstallPageOverlay(WKBundlePageRef page, WKBundlePageOverlayRef pageOverlay);
444
445WK_EXPORT void WKBundlePageInstallPageOverlayWithAnimation(WKBundlePageRef page, WKBundlePageOverlayRef pageOverlay);
446WK_EXPORT void WKBundlePageUninstallPageOverlayWithAnimation(WKBundlePageRef page, WKBundlePageOverlayRef pageOverlay);
447
448WK_EXPORT void WKBundlePageSetTopOverhangImage(WKBundlePageRef page, WKImageRef image);
449WK_EXPORT void WKBundlePageSetBottomOverhangImage(WKBundlePageRef page, WKImageRef image);
450
451WK_EXPORT void WKBundlePageSetHeaderBanner(WKBundlePageRef page, WKBundlePageBannerRef banner);
452WK_EXPORT void WKBundlePageSetFooterBanner(WKBundlePageRef page, WKBundlePageBannerRef banner);
453
454WK_EXPORT bool WKBundlePageHasLocalDataForURL(WKBundlePageRef page, WKURLRef url);
455WK_EXPORT bool WKBundlePageCanHandleRequest(WKURLRequestRef request);
456
457WK_EXPORT bool WKBundlePageFindString(WKBundlePageRef page, WKStringRef target, WKFindOptions findOptions);
458
459WK_EXPORT WKImageRef WKBundlePageCreateSnapshotWithOptions(WKBundlePageRef page, WKRect rect, WKSnapshotOptions options);
460
461// We should deprecate these functions in favor of just using WKBundlePageCreateSnapshotWithOptions.
462WK_EXPORT WKImageRef WKBundlePageCreateSnapshotInViewCoordinates(WKBundlePageRef page, WKRect rect, WKImageOptions options);
463WK_EXPORT WKImageRef WKBundlePageCreateSnapshotInDocumentCoordinates(WKBundlePageRef page, WKRect rect, WKImageOptions options);
464
465// We should keep this function since it allows passing a scale factor, but we should re-name it to
466// WKBundlePageCreateScaledSnapshotWithOptions.
467WK_EXPORT WKImageRef WKBundlePageCreateScaledSnapshotInDocumentCoordinates(WKBundlePageRef page, WKRect rect, double scaleFactor, WKImageOptions options);
468
469WK_EXPORT double WKBundlePageGetBackingScaleFactor(WKBundlePageRef page);
470
471WK_EXPORT void WKBundlePageListenForLayoutMilestones(WKBundlePageRef page, WKLayoutMilestones milestones);
472
473WK_EXPORT WKBundleInspectorRef WKBundlePageGetInspector(WKBundlePageRef page);
474
475#ifdef __cplusplus
476}
477#endif
478
479#endif /* WKBundlePage_h */
480