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/WKEvent.h>
31#include <WebKit2/WKFindOptions.h>
32#include <WebKit2/WKGeometry.h>
33#include <WebKit2/WKNativeEvent.h>
34#include <WebKit2/WKPageLoadTypes.h>
35
36#ifndef __cplusplus
37#include <stdbool.h>
38#endif
39
40#ifdef __cplusplus
41extern "C" {
42#endif
43
44enum {
45    kWKFocusDirectionBackward = 0,
46    kWKFocusDirectionForward = 1
47};
48typedef uint32_t WKFocusDirection;
49
50typedef void (*WKPageCallback)(WKPageRef page, const void* clientInfo);
51
52// FrameLoad Client
53typedef void (*WKPageDidStartProvisionalLoadForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
54typedef void (*WKPageDidReceiveServerRedirectForProvisionalLoadForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
55typedef void (*WKPageDidFailProvisionalLoadWithErrorForFrameCallback)(WKPageRef page, WKFrameRef frame, WKErrorRef error, WKTypeRef userData, const void *clientInfo);
56typedef void (*WKPageDidCommitLoadForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
57typedef void (*WKPageDidFinishDocumentLoadForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
58typedef void (*WKPageDidFinishLoadForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
59typedef void (*WKPageDidFailLoadWithErrorForFrameCallback)(WKPageRef page, WKFrameRef frame, WKErrorRef error, WKTypeRef userData, const void *clientInfo);
60typedef void (*WKPageDidSameDocumentNavigationForFrameCallback)(WKPageRef page, WKFrameRef frame, WKSameDocumentNavigationType type, WKTypeRef userData, const void *clientInfo);
61typedef void (*WKPageDidReceiveTitleForFrameCallback)(WKPageRef page, WKStringRef title, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
62typedef void (*WKPageDidFirstLayoutForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
63typedef void (*WKPageDidFirstVisuallyNonEmptyLayoutForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
64typedef void (*WKPageDidRemoveFrameFromHierarchyCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
65typedef void (*WKPageDidDisplayInsecureContentForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
66typedef void (*WKPageDidRunInsecureContentForFrameCallback)(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
67typedef bool (*WKPageCanAuthenticateAgainstProtectionSpaceInFrameCallback)(WKPageRef page, WKFrameRef frame, WKProtectionSpaceRef protectionSpace, const void *clientInfo);
68typedef void (*WKPageDidReceiveAuthenticationChallengeInFrameCallback)(WKPageRef page, WKFrameRef frame, WKAuthenticationChallengeRef authenticationChallenge, const void *clientInfo);
69typedef void (*WKPageDidChangeBackForwardListCallback)(WKPageRef page, WKBackForwardListItemRef addedItem, WKArrayRef removedItems, const void *clientInfo);
70typedef bool (*WKPageShouldGoToBackForwardListItemCallback)(WKPageRef page, WKBackForwardListItemRef item, const void *clientInfo);
71
72struct WKPageLoaderClient {
73    int                                                                 version;
74    const void *                                                        clientInfo;
75    WKPageDidStartProvisionalLoadForFrameCallback                       didStartProvisionalLoadForFrame;
76    WKPageDidReceiveServerRedirectForProvisionalLoadForFrameCallback    didReceiveServerRedirectForProvisionalLoadForFrame;
77    WKPageDidFailProvisionalLoadWithErrorForFrameCallback               didFailProvisionalLoadWithErrorForFrame;
78    WKPageDidCommitLoadForFrameCallback                                 didCommitLoadForFrame;
79    WKPageDidFinishDocumentLoadForFrameCallback                         didFinishDocumentLoadForFrame;
80    WKPageDidFinishLoadForFrameCallback                                 didFinishLoadForFrame;
81    WKPageDidFailLoadWithErrorForFrameCallback                          didFailLoadWithErrorForFrame;
82    WKPageDidSameDocumentNavigationForFrameCallback                     didSameDocumentNavigationForFrame;
83    WKPageDidReceiveTitleForFrameCallback                               didReceiveTitleForFrame;
84    WKPageDidFirstLayoutForFrameCallback                                didFirstLayoutForFrame;
85    WKPageDidFirstVisuallyNonEmptyLayoutForFrameCallback                didFirstVisuallyNonEmptyLayoutForFrame;
86    WKPageDidRemoveFrameFromHierarchyCallback                           didRemoveFrameFromHierarchy;
87    WKPageDidDisplayInsecureContentForFrameCallback                     didDisplayInsecureContentForFrame;
88    WKPageDidRunInsecureContentForFrameCallback                         didRunInsecureContentForFrame;
89    WKPageCanAuthenticateAgainstProtectionSpaceInFrameCallback          canAuthenticateAgainstProtectionSpaceInFrame;
90    WKPageDidReceiveAuthenticationChallengeInFrameCallback              didReceiveAuthenticationChallengeInFrame;
91
92    // FIXME: Move to progress client.
93    WKPageCallback                                                      didStartProgress;
94    WKPageCallback                                                      didChangeProgress;
95    WKPageCallback                                                      didFinishProgress;
96
97    // FIXME: These three functions should not be part of this client.
98    WKPageCallback                                                      processDidBecomeUnresponsive;
99    WKPageCallback                                                      processDidBecomeResponsive;
100    WKPageCallback                                                      processDidCrash;
101
102    WKPageDidChangeBackForwardListCallback                              didChangeBackForwardList;
103    WKPageShouldGoToBackForwardListItemCallback                         shouldGoToBackForwardListItem;
104};
105typedef struct WKPageLoaderClient WKPageLoaderClient;
106
107// Policy Client.
108typedef void (*WKPageDecidePolicyForNavigationActionCallback)(WKPageRef page, WKFrameRef frame, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRequestRef request, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo);
109typedef void (*WKPageDecidePolicyForNewWindowActionCallback)(WKPageRef page, WKFrameRef frame, WKFrameNavigationType navigationType, WKEventModifiers modifiers, WKEventMouseButton mouseButton, WKURLRequestRef request, WKStringRef frameName, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo);
110typedef void (*WKPageDecidePolicyForResponseCallback)(WKPageRef page, WKFrameRef frame, WKURLResponseRef response, WKURLRequestRef request, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo);
111typedef void (*WKPageUnableToImplementPolicyCallback)(WKPageRef page, WKFrameRef frame, WKErrorRef error, WKTypeRef userData, const void* clientInfo);
112
113struct WKPagePolicyClient {
114    int                                                                 version;
115    const void *                                                        clientInfo;
116    WKPageDecidePolicyForNavigationActionCallback                       decidePolicyForNavigationAction;
117    WKPageDecidePolicyForNewWindowActionCallback                        decidePolicyForNewWindowAction;
118    WKPageDecidePolicyForResponseCallback                               decidePolicyForResponse;
119    WKPageUnableToImplementPolicyCallback                               unableToImplementPolicy;
120};
121typedef struct WKPagePolicyClient WKPagePolicyClient;
122
123// Form Client.
124typedef void (*WKPageWillSubmitFormCallback)(WKPageRef page, WKFrameRef frame, WKFrameRef sourceFrame, WKDictionaryRef values, WKTypeRef userData, WKFormSubmissionListenerRef listener, const void* clientInfo);
125
126struct WKPageFormClient {
127    int                                                                 version;
128    const void *                                                        clientInfo;
129    WKPageWillSubmitFormCallback                                        willSubmitForm;
130};
131typedef struct WKPageFormClient WKPageFormClient;
132
133// Resource Load Client.
134typedef void (*WKPageDidInitiateLoadForResourceCallback)(WKPageRef page, WKFrameRef frame, uint64_t resourceIdentifier, WKURLRequestRef request, bool pageIsProvisionallyLoading, const void* clientInfo);
135typedef void (*WKPageDidSendRequestForResourceCallback)(WKPageRef page, WKFrameRef frame, uint64_t resourceIdentifier, WKURLRequestRef request, WKURLResponseRef redirectResponse, const void* clientInfo);
136typedef void (*WKPageDidReceiveResponseForResourceCallback)(WKPageRef page, WKFrameRef frame, uint64_t resourceIdentifier, WKURLResponseRef response, const void* clientInfo);
137typedef void (*WKPageDidReceiveContentLengthForResourceCallback)(WKPageRef page, WKFrameRef frame, uint64_t resourceIdentifier, uint64_t contentLength, const void* clientInfo);
138typedef void (*WKPageDidFinishLoadForResourceCallback)(WKPageRef page, WKFrameRef frame, uint64_t resourceIdentifier, const void* clientInfo);
139typedef void (*WKPageDidFailLoadForResourceCallback)(WKPageRef page, WKFrameRef frame, uint64_t resourceIdentifier, WKErrorRef error, const void* clientInfo);
140
141struct WKPageResourceLoadClient {
142    int                                                                 version;
143    const void *                                                        clientInfo;
144    WKPageDidInitiateLoadForResourceCallback                            didInitiateLoadForResource;
145    WKPageDidSendRequestForResourceCallback                             didSendRequestForResource;
146    WKPageDidReceiveResponseForResourceCallback                         didReceiveResponseForResource;
147    WKPageDidReceiveContentLengthForResourceCallback                    didReceiveContentLengthForResource;
148    WKPageDidFinishLoadForResourceCallback                              didFinishLoadForResource;
149    WKPageDidFailLoadForResourceCallback                                didFailLoadForResource;
150};
151typedef struct WKPageResourceLoadClient WKPageResourceLoadClient;
152
153// UI Client
154typedef WKPageRef (*WKPageCreateNewPageCallback)(WKPageRef page, WKDictionaryRef features, WKEventModifiers modifiers, WKEventMouseButton mouseButton, const void *clientInfo);
155typedef void (*WKPageRunJavaScriptAlertCallback)(WKPageRef page, WKStringRef alertText, WKFrameRef frame, const void *clientInfo);
156typedef bool (*WKPageRunJavaScriptConfirmCallback)(WKPageRef page, WKStringRef message, WKFrameRef frame, const void *clientInfo);
157typedef WKStringRef (*WKPageRunJavaScriptPromptCallback)(WKPageRef page, WKStringRef message, WKStringRef defaultValue, WKFrameRef frame, const void *clientInfo);
158typedef void (*WKPageTakeFocusCallback)(WKPageRef page, WKFocusDirection direction, const void *clientInfo);
159typedef void (*WKPageFocusCallback)(WKPageRef page, const void *clientInfo);
160typedef void (*WKPageUnfocusCallback)(WKPageRef page, const void *clientInfo);
161typedef void (*WKPageSetStatusTextCallback)(WKPageRef page, WKStringRef text, const void *clientInfo);
162typedef void (*WKPageMouseDidMoveOverElementCallback)(WKPageRef page, WKEventModifiers modifiers, WKTypeRef userData, const void *clientInfo);
163typedef void (*WKPageMissingPluginButtonClickedCallback)(WKPageRef page, WKStringRef mimeType, WKStringRef url, WKStringRef pluginsPageURL, const void* clientInfo);
164typedef void (*WKPageDidNotHandleKeyEventCallback)(WKPageRef page, WKNativeEventPtr event, const void *clientInfo);
165typedef bool (*WKPageGetToolbarsAreVisibleCallback)(WKPageRef page, const void *clientInfo);
166typedef void (*WKPageSetToolbarsAreVisibleCallback)(WKPageRef page, bool toolbarsVisible, const void *clientInfo);
167typedef bool (*WKPageGetMenuBarIsVisibleCallback)(WKPageRef page, const void *clientInfo);
168typedef void (*WKPageSetMenuBarIsVisibleCallback)(WKPageRef page, bool menuBarVisible, const void *clientInfo);
169typedef bool (*WKPageGetStatusBarIsVisibleCallback)(WKPageRef page, const void *clientInfo);
170typedef void (*WKPageSetStatusBarIsVisibleCallback)(WKPageRef page, bool statusBarVisible, const void *clientInfo);
171typedef bool (*WKPageGetIsResizableCallback)(WKPageRef page, const void *clientInfo);
172typedef void (*WKPageSetIsResizableCallback)(WKPageRef page, bool resizable, const void *clientInfo);
173typedef WKRect (*WKPageGetWindowFrameCallback)(WKPageRef page, const void *clientInfo);
174typedef void (*WKPageSetWindowFrameCallback)(WKPageRef page, WKRect frame, const void *clientInfo);
175typedef bool (*WKPageRunBeforeUnloadConfirmPanelCallback)(WKPageRef page, WKStringRef message, WKFrameRef frame, const void *clientInfo);
176typedef unsigned long long (*WKPageExceededDatabaseQuotaCallback)(WKPageRef page, WKFrameRef frame, WKSecurityOriginRef origin, WKStringRef databaseName, WKStringRef displayName, unsigned long long currentQuota, unsigned long long currentUsage, unsigned long long expectedUsage, const void *clientInfo);
177typedef void (*WKPageRunOpenPanelCallback)(WKPageRef page, WKFrameRef frame, WKOpenPanelParametersRef parameters, WKOpenPanelResultListenerRef listener, const void *clientInfo);
178typedef void (*WKPageDecidePolicyForGeolocationPermissionRequestCallback)(WKPageRef page, WKFrameRef frame, WKSecurityOriginRef origin, WKGeolocationPermissionRequestRef permissionRequest, const void* clientInfo);
179typedef float (*WKPageHeaderHeightCallback)(WKPageRef page, WKFrameRef frame, const void* clientInfo);
180typedef float (*WKPageFooterHeightCallback)(WKPageRef page, WKFrameRef frame, const void* clientInfo);
181typedef void (*WKPageDrawHeaderCallback)(WKPageRef page, WKFrameRef frame, WKRect rect, const void* clientInfo);
182typedef void (*WKPageDrawFooterCallback)(WKPageRef page, WKFrameRef frame, WKRect rect, const void* clientInfo);
183typedef void (*WKPagePrintFrameCallback)(WKPageRef page, WKFrameRef frame, const void* clientInfo);
184typedef void (*WKPageDidCompleteRubberBandForMainFrameCallback)(WKPageRef page, WKSize initialOverhang, const void* clientInfo);
185typedef void (*WKPageSaveDataToFileInDownloadsFolderCallback)(WKPageRef page, WKStringRef suggestedFilename, WKStringRef mimeType, WKURLRef originatingURL, WKDataRef data, const void* clientInfo);
186
187struct WKPageUIClient {
188    int                                                                 version;
189    const void *                                                        clientInfo;
190    WKPageCreateNewPageCallback                                         createNewPage;
191    WKPageCallback                                                      showPage;
192    WKPageCallback                                                      close;
193    WKPageTakeFocusCallback                                             takeFocus;
194    WKPageFocusCallback                                                 focus;
195    WKPageUnfocusCallback                                               unfocus;
196    WKPageRunJavaScriptAlertCallback                                    runJavaScriptAlert;
197    WKPageRunJavaScriptConfirmCallback                                  runJavaScriptConfirm;
198    WKPageRunJavaScriptPromptCallback                                   runJavaScriptPrompt;
199    WKPageSetStatusTextCallback                                         setStatusText;
200    WKPageMouseDidMoveOverElementCallback                               mouseDidMoveOverElement;
201    WKPageMissingPluginButtonClickedCallback                            missingPluginButtonClicked;
202    WKPageDidNotHandleKeyEventCallback                                  didNotHandleKeyEvent;
203    WKPageGetToolbarsAreVisibleCallback                                 toolbarsAreVisible;
204    WKPageSetToolbarsAreVisibleCallback                                 setToolbarsAreVisible;
205    WKPageGetMenuBarIsVisibleCallback                                   menuBarIsVisible;
206    WKPageSetMenuBarIsVisibleCallback                                   setMenuBarIsVisible;
207    WKPageGetStatusBarIsVisibleCallback                                 statusBarIsVisible;
208    WKPageSetStatusBarIsVisibleCallback                                 setStatusBarIsVisible;
209    WKPageGetIsResizableCallback                                        isResizable;
210    WKPageSetIsResizableCallback                                        setIsResizable;
211    WKPageGetWindowFrameCallback                                        getWindowFrame;
212    WKPageSetWindowFrameCallback                                        setWindowFrame;
213    WKPageRunBeforeUnloadConfirmPanelCallback                           runBeforeUnloadConfirmPanel;
214    WKPageCallback                                                      didDraw;
215    WKPageCallback                                                      pageDidScroll;
216    WKPageExceededDatabaseQuotaCallback                                 exceededDatabaseQuota;
217    WKPageRunOpenPanelCallback                                          runOpenPanel;
218    WKPageDecidePolicyForGeolocationPermissionRequestCallback           decidePolicyForGeolocationPermissionRequest;
219    WKPageHeaderHeightCallback                                          headerHeight;
220    WKPageFooterHeightCallback                                          footerHeight;
221    WKPageDrawHeaderCallback                                            drawHeader;
222    WKPageDrawFooterCallback                                            drawFooter;
223    WKPagePrintFrameCallback                                            printFrame;
224    WKPageCallback                                                      runModal;
225    WKPageDidCompleteRubberBandForMainFrameCallback                     didCompleteRubberBandForMainFrame;
226    WKPageSaveDataToFileInDownloadsFolderCallback                       saveDataToFileInDownloadsFolder;
227};
228typedef struct WKPageUIClient WKPageUIClient;
229
230// Find client.
231typedef void (*WKPageDidFindStringCallback)(WKPageRef page, WKStringRef string, unsigned matchCount, const void* clientInfo);
232typedef void (*WKPageDidFailToFindStringCallback)(WKPageRef page, WKStringRef string, const void* clientInfo);
233typedef void (*WKPageDidCountStringMatchesCallback)(WKPageRef page, WKStringRef string, unsigned matchCount, const void* clientInfo);
234
235struct WKPageFindClient {
236    int                                                                 version;
237    const void *                                                        clientInfo;
238    WKPageDidFindStringCallback                                         didFindString;
239    WKPageDidFailToFindStringCallback                                   didFailToFindString;
240    WKPageDidCountStringMatchesCallback                                 didCountStringMatches;
241};
242typedef struct WKPageFindClient WKPageFindClient;
243
244enum {
245    kWKMoreThanMaximumMatchCount = -1
246};
247
248// ContextMenu client
249typedef void (*WKPageGetContextMenuFromProposedContextMenuCallback)(WKPageRef page, WKArrayRef proposedMenu, WKArrayRef* newMenu, WKTypeRef userData, const void* clientInfo);
250typedef void (*WKPageCustomContextMenuItemSelectedCallback)(WKPageRef page, WKContextMenuItemRef contextMenuItem, const void* clientInfo);
251
252struct WKPageContextMenuClient {
253    int                                                                 version;
254    const void *                                                        clientInfo;
255    WKPageGetContextMenuFromProposedContextMenuCallback                 getContextMenuFromProposedMenu;
256    WKPageCustomContextMenuItemSelectedCallback                         customContextMenuItemSelected;
257};
258typedef struct WKPageContextMenuClient WKPageContextMenuClient;
259
260WK_EXPORT WKTypeID WKPageGetTypeID();
261
262WK_EXPORT WKContextRef WKPageGetContext(WKPageRef page);
263WK_EXPORT WKPageGroupRef WKPageGetPageGroup(WKPageRef page);
264
265WK_EXPORT void WKPageLoadURL(WKPageRef page, WKURLRef url);
266WK_EXPORT void WKPageLoadURLRequest(WKPageRef page, WKURLRequestRef urlRequest);
267WK_EXPORT void WKPageLoadHTMLString(WKPageRef page, WKStringRef htmlString, WKURLRef baseURL);
268WK_EXPORT void WKPageLoadAlternateHTMLString(WKPageRef page, WKStringRef htmlString, WKURLRef baseURL, WKURLRef unreachableURL);
269WK_EXPORT void WKPageLoadPlainTextString(WKPageRef page, WKStringRef plainTextString);
270
271WK_EXPORT void WKPageStopLoading(WKPageRef page);
272WK_EXPORT void WKPageReload(WKPageRef page);
273WK_EXPORT void WKPageReloadFromOrigin(WKPageRef page);
274
275WK_EXPORT bool WKPageTryClose(WKPageRef page);
276WK_EXPORT void WKPageClose(WKPageRef page);
277WK_EXPORT bool WKPageIsClosed(WKPageRef page);
278
279WK_EXPORT void WKPageGoForward(WKPageRef page);
280WK_EXPORT bool WKPageCanGoForward(WKPageRef page);
281WK_EXPORT void WKPageGoBack(WKPageRef page);
282WK_EXPORT bool WKPageCanGoBack(WKPageRef page);
283WK_EXPORT void WKPageGoToBackForwardListItem(WKPageRef page, WKBackForwardListItemRef item);
284WK_EXPORT WKBackForwardListRef WKPageGetBackForwardList(WKPageRef page);
285
286WK_EXPORT WKStringRef WKPageCopyTitle(WKPageRef page);
287
288WK_EXPORT WKURLRef WKPageCopyPendingAPIRequestURL(WKPageRef page);
289
290WK_EXPORT WKFrameRef WKPageGetMainFrame(WKPageRef page);
291WK_EXPORT WKFrameRef WKPageGetFocusedFrame(WKPageRef page); // The focused frame may be inactive.
292WK_EXPORT WKFrameRef WKPageGetFrameSetLargestFrame(WKPageRef page);
293WK_EXPORT double WKPageGetEstimatedProgress(WKPageRef page);
294
295WK_EXPORT void WKPageSetMemoryCacheClientCallsEnabled(WKPageRef page, bool memoryCacheClientCallsEnabled);
296
297#if defined(ENABLE_INSPECTOR) && ENABLE_INSPECTOR
298WK_EXPORT WKInspectorRef WKPageGetInspector(WKPageRef page);
299#endif
300
301WK_EXPORT WKStringRef WKPageCopyUserAgent(WKPageRef page);
302
303WK_EXPORT WKStringRef WKPageCopyApplicationNameForUserAgent(WKPageRef page);
304WK_EXPORT void WKPageSetApplicationNameForUserAgent(WKPageRef page, WKStringRef applicationName);
305
306WK_EXPORT WKStringRef WKPageCopyCustomUserAgent(WKPageRef page);
307WK_EXPORT void WKPageSetCustomUserAgent(WKPageRef page, WKStringRef userAgent);
308
309WK_EXPORT bool WKPageSupportsTextEncoding(WKPageRef page);
310WK_EXPORT WKStringRef WKPageCopyCustomTextEncodingName(WKPageRef page);
311WK_EXPORT void WKPageSetCustomTextEncodingName(WKPageRef page, WKStringRef encodingName);
312
313WK_EXPORT void WKPageTerminate(WKPageRef page);
314
315WK_EXPORT WKStringRef WKPageGetSessionHistoryURLValueType(void);
316
317typedef bool (*WKPageSessionStateFilterCallback)(WKPageRef page, WKStringRef valueType, WKTypeRef value, void* context);
318WK_EXPORT WKDataRef WKPageCopySessionState(WKPageRef page, void* context, WKPageSessionStateFilterCallback urlAllowedCallback);
319WK_EXPORT void WKPageRestoreFromSessionState(WKPageRef page, WKDataRef sessionStateData);
320
321WK_EXPORT bool WKPageSupportsTextZoom(WKPageRef page);
322WK_EXPORT double WKPageGetTextZoomFactor(WKPageRef page);
323WK_EXPORT void WKPageSetTextZoomFactor(WKPageRef page, double zoomFactor);
324WK_EXPORT double WKPageGetPageZoomFactor(WKPageRef page);
325WK_EXPORT void WKPageSetPageZoomFactor(WKPageRef page, double zoomFactor);
326WK_EXPORT void WKPageSetPageAndTextZoomFactors(WKPageRef page, double pageZoomFactor, double textZoomFactor);
327
328WK_EXPORT void WKPageSetScaleFactor(WKPageRef page, double scale, WKPoint origin);
329WK_EXPORT double WKPageGetScaleFactor(WKPageRef page);
330
331WK_EXPORT void WKPageSetUseFixedLayout(WKPageRef page, bool fixed);
332WK_EXPORT void WKPageSetFixedLayoutSize(WKPageRef page, WKSize size);
333WK_EXPORT bool WKPageUseFixedLayout(WKPageRef page);
334WK_EXPORT WKSize WKPageFixedLayoutSize(WKPageRef page);
335
336WK_EXPORT bool WKPageHasHorizontalScrollbar(WKPageRef page);
337WK_EXPORT bool WKPageHasVerticalScrollbar(WKPageRef page);
338
339WK_EXPORT bool WKPageIsPinnedToLeftSide(WKPageRef page);
340WK_EXPORT bool WKPageIsPinnedToRightSide(WKPageRef page);
341
342WK_EXPORT bool WKPageCanDelete(WKPageRef page);
343WK_EXPORT bool WKPageHasSelectedRange(WKPageRef page);
344WK_EXPORT bool WKPageIsContentEditable(WKPageRef page);
345
346WK_EXPORT void WKPageFindString(WKPageRef page, WKStringRef string, WKFindOptions findOptions, unsigned maxMatchCount);
347WK_EXPORT void WKPageHideFindUI(WKPageRef page);
348WK_EXPORT void WKPageCountStringMatches(WKPageRef page, WKStringRef string, WKFindOptions findOptions, unsigned maxMatchCount);
349
350WK_EXPORT void WKPageSetPageContextMenuClient(WKPageRef page, const WKPageContextMenuClient* client);
351WK_EXPORT void WKPageSetPageFindClient(WKPageRef page, const WKPageFindClient* client);
352WK_EXPORT void WKPageSetPageFormClient(WKPageRef page, const WKPageFormClient* client);
353WK_EXPORT void WKPageSetPageLoaderClient(WKPageRef page, const WKPageLoaderClient* client);
354WK_EXPORT void WKPageSetPagePolicyClient(WKPageRef page, const WKPagePolicyClient* client);
355WK_EXPORT void WKPageSetPageResourceLoadClient(WKPageRef page, const WKPageResourceLoadClient* client);
356WK_EXPORT void WKPageSetPageUIClient(WKPageRef page, const WKPageUIClient* client);
357
358typedef void (*WKPageRunJavaScriptFunction)(WKSerializedScriptValueRef, WKErrorRef, void*);
359WK_EXPORT void WKPageRunJavaScriptInMainFrame(WKPageRef page, WKStringRef script, void* context, WKPageRunJavaScriptFunction function);
360#ifdef __BLOCKS__
361typedef void (^WKPageRunJavaScriptBlock)(WKSerializedScriptValueRef, WKErrorRef);
362WK_EXPORT void WKPageRunJavaScriptInMainFrame_b(WKPageRef page, WKStringRef script, WKPageRunJavaScriptBlock block);
363#endif
364
365typedef void (*WKPageGetSourceForFrameFunction)(WKStringRef, WKErrorRef, void*);
366WK_EXPORT void WKPageGetSourceForFrame(WKPageRef page, WKFrameRef frame, void* context, WKPageGetSourceForFrameFunction function);
367#ifdef __BLOCKS__
368typedef void (^WKPageGetSourceForFrameBlock)(WKStringRef, WKErrorRef);
369WK_EXPORT void WKPageGetSourceForFrame_b(WKPageRef page, WKFrameRef frame, WKPageGetSourceForFrameBlock block);
370#endif
371
372typedef void (*WKPageGetContentsAsStringFunction)(WKStringRef, WKErrorRef, void*);
373WK_EXPORT void WKPageGetContentsAsString(WKPageRef page, void* context, WKPageGetContentsAsStringFunction function);
374#ifdef __BLOCKS__
375typedef void (^WKPageGetContentsAsStringBlock)(WKStringRef, WKErrorRef);
376WK_EXPORT void WKPageGetContentsAsString_b(WKPageRef page, WKPageGetContentsAsStringBlock block);
377#endif
378
379typedef void (*WKPageForceRepaintFunction)(WKErrorRef, void*);
380WK_EXPORT void WKPageForceRepaint(WKPageRef page, void* context, WKPageForceRepaintFunction function);
381
382/*
383    Some of the more common command name strings include the following, although any WebCore EditorCommand string is supported:
384
385    "Cut"
386    "Copy"
387    "Paste"
388    "SelectAll"
389    "Undo"
390    "Redo"
391*/
392
393// 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.
394typedef void (*WKPageValidateCommandCallback)(WKStringRef command, bool isEnabled, int32_t state, WKErrorRef, void* context);
395WK_EXPORT void WKPageValidateCommand(WKPageRef page, WKStringRef command, void* context, WKPageValidateCommandCallback callback);
396WK_EXPORT void WKPageExecuteCommand(WKPageRef page, WKStringRef command);
397
398#ifdef __cplusplus
399}
400#endif
401
402#endif /* WKPage_h */
403