Functions with no parameters in WebKit/Shared/API/c and WebKit/UIProcess/API/C are
[WebKit-https.git] / Source / WebKit / 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 <WebKit/WKBase.h>
30 #include <WebKit/WKDeprecated.h>
31 #include <WebKit/WKErrorRef.h>
32 #include <WebKit/WKEvent.h>
33 #include <WebKit/WKFindOptions.h>
34 #include <WebKit/WKGeometry.h>
35 #include <WebKit/WKNativeEvent.h>
36 #include <WebKit/WKPageContextMenuClient.h>
37 #include <WebKit/WKPageDiagnosticLoggingClient.h>
38 #include <WebKit/WKPageFindClient.h>
39 #include <WebKit/WKPageFindMatchesClient.h>
40 #include <WebKit/WKPageFormClient.h>
41 #include <WebKit/WKPageInjectedBundleClient.h>
42 #include <WebKit/WKPageLoadTypes.h>
43 #include <WebKit/WKPageLoaderClient.h>
44 #include <WebKit/WKPageNavigationClient.h>
45 #include <WebKit/WKPagePolicyClient.h>
46 #include <WebKit/WKPageStateClient.h>
47 #include <WebKit/WKPageUIClient.h>
48 #include <WebKit/WKPageVisibilityTypes.h>
49
50 #ifndef __cplusplus
51 #include <stdbool.h>
52 #endif
53
54 #ifdef __cplusplus
55 extern "C" {
56 #endif
57
58 WK_EXPORT WKTypeID WKPageGetTypeID(void);
59
60 WK_EXPORT WKContextRef WKPageGetContext(WKPageRef page);
61 WK_EXPORT WKPageGroupRef WKPageGetPageGroup(WKPageRef page);
62
63 WK_EXPORT WKPageConfigurationRef WKPageCopyPageConfiguration(WKPageRef page);
64
65 // URL Requests
66 WK_EXPORT void WKPageLoadURL(WKPageRef page, WKURLRef url);
67 WK_EXPORT void WKPageLoadURLWithUserData(WKPageRef page, WKURLRef url, WKTypeRef userData);
68 WK_EXPORT void WKPageLoadURLRequest(WKPageRef page, WKURLRequestRef urlRequest);
69 WK_EXPORT void WKPageLoadURLRequestWithUserData(WKPageRef page, WKURLRequestRef urlRequest, WKTypeRef userData);
70 WK_EXPORT void WKPageLoadFile(WKPageRef page, WKURLRef fileURL, WKURLRef resourceDirectoryURL);
71 WK_EXPORT void WKPageLoadFileWithUserData(WKPageRef page, WKURLRef fileURL, WKURLRef resourceDirectoryURL, WKTypeRef userData);
72
73 // Data Requests
74 WK_EXPORT void WKPageLoadData(WKPageRef page, WKDataRef data, WKStringRef MIMEType, WKStringRef encoding, WKURLRef baseURL);
75 WK_EXPORT void WKPageLoadDataWithUserData(WKPageRef page, WKDataRef data, WKStringRef MIMEType, WKStringRef encoding, WKURLRef baseURL, WKTypeRef userData);
76 WK_EXPORT void WKPageLoadHTMLString(WKPageRef page, WKStringRef htmlString, WKURLRef baseURL);
77 WK_EXPORT void WKPageLoadHTMLStringWithUserData(WKPageRef page, WKStringRef htmlString, WKURLRef baseURL, WKTypeRef userData);
78 WK_EXPORT void WKPageLoadAlternateHTMLString(WKPageRef page, WKStringRef htmlString, WKURLRef baseURL, WKURLRef unreachableURL);
79 WK_EXPORT void WKPageLoadAlternateHTMLStringWithUserData(WKPageRef page, WKStringRef htmlString, WKURLRef baseURL, WKURLRef unreachableURL, WKTypeRef userData);
80 WK_EXPORT void WKPageLoadPlainTextString(WKPageRef page, WKStringRef plainTextString);
81 WK_EXPORT void WKPageLoadPlainTextStringWithUserData(WKPageRef page, WKStringRef plainTextString, WKTypeRef userData);
82 WK_EXPORT void WKPageLoadWebArchiveData(WKPageRef page, WKDataRef webArchiveData);
83 WK_EXPORT void WKPageLoadWebArchiveDataWithUserData(WKPageRef page, WKDataRef webArchiveData, WKTypeRef userData);
84
85 WK_EXPORT void WKPageStopLoading(WKPageRef page);
86 WK_EXPORT void WKPageReload(WKPageRef page);
87 WK_EXPORT void WKPageReloadWithoutContentBlockers(WKPageRef page);
88 WK_EXPORT void WKPageReloadFromOrigin(WKPageRef page);
89 WK_EXPORT void WKPageReloadExpiredOnly(WKPageRef page);
90
91 WK_EXPORT bool WKPageTryClose(WKPageRef page);
92 WK_EXPORT void WKPageClose(WKPageRef page);
93 WK_EXPORT bool WKPageIsClosed(WKPageRef page);
94
95 WK_EXPORT void WKPageGoForward(WKPageRef page);
96 WK_EXPORT bool WKPageCanGoForward(WKPageRef page);
97 WK_EXPORT void WKPageGoBack(WKPageRef page);
98 WK_EXPORT bool WKPageCanGoBack(WKPageRef page);
99 WK_EXPORT void WKPageGoToBackForwardListItem(WKPageRef page, WKBackForwardListItemRef item);
100 WK_EXPORT void WKPageTryRestoreScrollPosition(WKPageRef page);
101 WK_EXPORT WKBackForwardListRef WKPageGetBackForwardList(WKPageRef page);
102 WK_EXPORT bool WKPageWillHandleHorizontalScrollEvents(WKPageRef page);
103
104 WK_EXPORT void WKPageUpdateWebsitePolicies(WKPageRef, WKWebsitePoliciesRef);
105
106 WK_EXPORT WKStringRef WKPageCopyTitle(WKPageRef page);
107
108 WK_EXPORT WKURLRef WKPageCopyPendingAPIRequestURL(WKPageRef page);
109
110 WK_EXPORT WKURLRef WKPageCopyActiveURL(WKPageRef page);
111 WK_EXPORT WKURLRef WKPageCopyProvisionalURL(WKPageRef page);
112 WK_EXPORT WKURLRef WKPageCopyCommittedURL(WKPageRef page);
113
114 WK_EXPORT WKFrameRef WKPageGetMainFrame(WKPageRef page);
115 WK_EXPORT WKFrameRef WKPageGetFocusedFrame(WKPageRef page); // The focused frame may be inactive.
116 WK_EXPORT WKFrameRef WKPageGetFrameSetLargestFrame(WKPageRef page);
117 WK_EXPORT double WKPageGetEstimatedProgress(WKPageRef page);
118
119 WK_EXPORT uint64_t WKPageGetRenderTreeSize(WKPageRef page);
120
121 WK_EXPORT WKInspectorRef WKPageGetInspector(WKPageRef page);
122
123 WK_EXPORT WKStringRef WKPageCopyUserAgent(WKPageRef page);
124
125 WK_EXPORT WKStringRef WKPageCopyApplicationNameForUserAgent(WKPageRef page);
126 WK_EXPORT void WKPageSetApplicationNameForUserAgent(WKPageRef page, WKStringRef applicationName);
127
128 WK_EXPORT WKStringRef WKPageCopyCustomUserAgent(WKPageRef page);
129 WK_EXPORT void WKPageSetCustomUserAgent(WKPageRef page, WKStringRef userAgent);
130
131 WK_EXPORT void WKPageSetUserContentExtensionsEnabled(WKPageRef, bool);
132     
133 WK_EXPORT bool WKPageSupportsTextEncoding(WKPageRef page);
134 WK_EXPORT WKStringRef WKPageCopyCustomTextEncodingName(WKPageRef page);
135 WK_EXPORT void WKPageSetCustomTextEncodingName(WKPageRef page, WKStringRef encodingName);
136
137 WK_EXPORT void WKPageTerminate(WKPageRef page);
138
139 WK_EXPORT WKStringRef WKPageGetSessionHistoryURLValueType(void);
140 WK_EXPORT WKStringRef WKPageGetSessionBackForwardListItemValueType(void);
141
142 typedef bool (*WKPageSessionStateFilterCallback)(WKPageRef page, WKStringRef valueType, WKTypeRef value, void* context);
143
144 // FIXME: This should return a WKSessionStateRef object, not a WKTypeRef.
145 // It currently returns a WKTypeRef for backwards compatibility with Safari.
146 WK_EXPORT WKTypeRef WKPageCopySessionState(WKPageRef page, void* context, WKPageSessionStateFilterCallback urlAllowedCallback);
147
148 // FIXME: This should take a WKSessionStateRef object, not a WKTypeRef.
149 // It currently takes a WKTypeRef for backwards compatibility with Safari.
150 WK_EXPORT void WKPageRestoreFromSessionState(WKPageRef page, WKTypeRef sessionState);
151
152 WK_EXPORT double WKPageGetBackingScaleFactor(WKPageRef page);
153 WK_EXPORT void WKPageSetCustomBackingScaleFactor(WKPageRef page, double customScaleFactor);
154 WK_EXPORT void WKPageClearWheelEventTestTrigger(WKPageRef page);
155
156 WK_EXPORT bool WKPageSupportsTextZoom(WKPageRef page);
157 WK_EXPORT double WKPageGetTextZoomFactor(WKPageRef page);
158 WK_EXPORT void WKPageSetTextZoomFactor(WKPageRef page, double zoomFactor);
159 WK_EXPORT double WKPageGetPageZoomFactor(WKPageRef page);
160 WK_EXPORT void WKPageSetPageZoomFactor(WKPageRef page, double zoomFactor);
161 WK_EXPORT void WKPageSetPageAndTextZoomFactors(WKPageRef page, double pageZoomFactor, double textZoomFactor);
162
163 WK_EXPORT void WKPageSetScaleFactor(WKPageRef page, double scale, WKPoint origin);
164 WK_EXPORT double WKPageGetScaleFactor(WKPageRef page);
165
166 WK_EXPORT void WKPageSetUseFixedLayout(WKPageRef page, bool fixed);
167 WK_EXPORT void WKPageSetFixedLayoutSize(WKPageRef page, WKSize size);
168 WK_EXPORT bool WKPageUseFixedLayout(WKPageRef page);
169 WK_EXPORT WKSize WKPageFixedLayoutSize(WKPageRef page);
170
171 WK_EXPORT void WKPageListenForLayoutMilestones(WKPageRef page, WKLayoutMilestones milestones);
172
173 WK_EXPORT bool WKPageHasHorizontalScrollbar(WKPageRef page);
174 WK_EXPORT bool WKPageHasVerticalScrollbar(WKPageRef page);
175
176 WK_EXPORT void WKPageSetSuppressScrollbarAnimations(WKPageRef page, bool suppressAnimations);
177 WK_EXPORT bool WKPageAreScrollbarAnimationsSuppressed(WKPageRef page);
178
179 WK_EXPORT bool WKPageIsPinnedToLeftSide(WKPageRef page);
180 WK_EXPORT bool WKPageIsPinnedToRightSide(WKPageRef page);
181 WK_EXPORT bool WKPageIsPinnedToTopSide(WKPageRef page);
182 WK_EXPORT bool WKPageIsPinnedToBottomSide(WKPageRef page);
183     
184 // This API is poorly named. Even when these values are set to false, rubber-banding will
185 // still be allowed to occur at the end of a momentum scroll. These values are used along
186 // with pin state to determine if wheel events should be handled in the web process or if
187 // they should be passed up to the client.
188 WK_EXPORT bool WKPageRubberBandsAtLeft(WKPageRef);
189 WK_EXPORT void WKPageSetRubberBandsAtLeft(WKPageRef, bool rubberBandsAtLeft);
190 WK_EXPORT bool WKPageRubberBandsAtRight(WKPageRef);
191 WK_EXPORT void WKPageSetRubberBandsAtRight(WKPageRef, bool rubberBandsAtRight);
192 WK_EXPORT bool WKPageRubberBandsAtTop(WKPageRef);
193 WK_EXPORT void WKPageSetRubberBandsAtTop(WKPageRef, bool rubberBandsAtTop);
194 WK_EXPORT bool WKPageRubberBandsAtBottom(WKPageRef);
195 WK_EXPORT void WKPageSetRubberBandsAtBottom(WKPageRef, bool rubberBandsAtBottom);
196     
197 // Rubber-banding is enabled by default.
198 WK_EXPORT bool WKPageVerticalRubberBandingIsEnabled(WKPageRef);
199 WK_EXPORT void WKPageSetEnableVerticalRubberBanding(WKPageRef, bool enableVerticalRubberBanding);
200 WK_EXPORT bool WKPageHorizontalRubberBandingIsEnabled(WKPageRef);
201 WK_EXPORT void WKPageSetEnableHorizontalRubberBanding(WKPageRef, bool enableHorizontalRubberBanding);
202     
203 WK_EXPORT void WKPageSetBackgroundExtendsBeyondPage(WKPageRef, bool backgroundExtendsBeyondPage);
204 WK_EXPORT bool WKPageBackgroundExtendsBeyondPage(WKPageRef);
205
206 WK_EXPORT bool WKPageCanDelete(WKPageRef page);
207 WK_EXPORT bool WKPageHasSelectedRange(WKPageRef page);
208 WK_EXPORT bool WKPageIsContentEditable(WKPageRef page);
209
210 WK_EXPORT void WKPageSetMaintainsInactiveSelection(WKPageRef page, bool maintainsInactiveSelection);
211 WK_EXPORT void WKPageCenterSelectionInVisibleArea(WKPageRef page);
212     
213 WK_EXPORT void WKPageFindString(WKPageRef page, WKStringRef string, WKFindOptions findOptions, unsigned maxMatchCount);
214 WK_EXPORT void WKPageHideFindUI(WKPageRef page);
215 WK_EXPORT void WKPageCountStringMatches(WKPageRef page, WKStringRef string, WKFindOptions findOptions, unsigned maxMatchCount);
216 WK_EXPORT void WKPageFindStringMatches(WKPageRef page, WKStringRef string, WKFindOptions findOptions, unsigned maxMatchCount);
217 WK_EXPORT void WKPageGetImageForFindMatch(WKPageRef page, int32_t matchIndex);
218 WK_EXPORT void WKPageSelectFindMatch(WKPageRef page, int32_t matchIndex);
219
220 WK_EXPORT void WKPageSetPageContextMenuClient(WKPageRef page, const WKPageContextMenuClientBase* client);
221 WK_EXPORT void WKPageSetPageDiagnosticLoggingClient(WKPageRef page, const WKPageDiagnosticLoggingClientBase* client);
222 WK_EXPORT void WKPageSetPageFindClient(WKPageRef page, const WKPageFindClientBase* client);
223 WK_EXPORT void WKPageSetPageFindMatchesClient(WKPageRef page, const WKPageFindMatchesClientBase* client);
224 WK_EXPORT void WKPageSetPageFormClient(WKPageRef page, const WKPageFormClientBase* client);
225 WK_EXPORT void WKPageSetPageUIClient(WKPageRef page, const WKPageUIClientBase* client);
226 WK_EXPORT void WKPageSetPageInjectedBundleClient(WKPageRef page, const WKPageInjectedBundleClientBase* client);
227
228 // A client can implement either a navigation client or loader and policy clients, but never both.
229 WK_EXPORT void WKPageSetPageLoaderClient(WKPageRef page, const WKPageLoaderClientBase* client) WK_C_API_DEPRECATED_WITH_REPLACEMENT(WKPageSetPageNavigationClient, macos(10.14.4));
230 WK_EXPORT void WKPageSetPagePolicyClient(WKPageRef page, const WKPagePolicyClientBase* client) WK_C_API_DEPRECATED_WITH_REPLACEMENT(WKPageSetPageNavigationClient, macos(10.14.4));
231 WK_EXPORT void WKPageSetPageNavigationClient(WKPageRef page, const WKPageNavigationClientBase* client);
232
233 WK_EXPORT void WKPageSetPageStateClient(WKPageRef page, WKPageStateClientBase* client);
234
235 typedef void (*WKPageRunJavaScriptFunction)(WKSerializedScriptValueRef, WKErrorRef, void*);
236 WK_EXPORT void WKPageRunJavaScriptInMainFrame(WKPageRef page, WKStringRef script, void* context, WKPageRunJavaScriptFunction function);
237 #ifdef __BLOCKS__
238 typedef void (^WKPageRunJavaScriptBlock)(WKSerializedScriptValueRef, WKErrorRef);
239 WK_EXPORT void WKPageRunJavaScriptInMainFrame_b(WKPageRef page, WKStringRef script, WKPageRunJavaScriptBlock block);
240 #endif
241
242 typedef void (*WKPageGetSourceForFrameFunction)(WKStringRef, WKErrorRef, void*);
243 WK_EXPORT void WKPageGetSourceForFrame(WKPageRef page, WKFrameRef frame, void* context, WKPageGetSourceForFrameFunction function);
244
245 typedef void (*WKPageGetContentsAsStringFunction)(WKStringRef, WKErrorRef, void*);
246 WK_EXPORT void WKPageGetContentsAsString(WKPageRef page, void* context, WKPageGetContentsAsStringFunction function);
247
248 typedef void (*WKPageGetContentsAsMHTMLDataFunction)(WKDataRef, WKErrorRef, void*);
249 WK_EXPORT void WKPageGetContentsAsMHTMLData(WKPageRef page, void* context, WKPageGetContentsAsMHTMLDataFunction function);
250
251 typedef void (*WKPageGetSelectionAsWebArchiveDataFunction)(WKDataRef, WKErrorRef, void*);
252 WK_EXPORT void WKPageGetSelectionAsWebArchiveData(WKPageRef page, void* context, WKPageGetSelectionAsWebArchiveDataFunction function);
253
254 typedef void (*WKPageForceRepaintFunction)(WKErrorRef, void*);
255 WK_EXPORT void WKPageForceRepaint(WKPageRef page, void* context, WKPageForceRepaintFunction function);
256
257 /*
258     Some of the more common command name strings include the following, although any WebCore EditorCommand string is supported:
259     
260     "Cut"
261     "Copy"
262     "Paste"
263     "SelectAll"
264     "Undo"
265     "Redo"
266 */
267
268 // 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.
269 typedef void (*WKPageValidateCommandCallback)(WKStringRef command, bool isEnabled, int32_t state, WKErrorRef, void* context);
270 WK_EXPORT void WKPageValidateCommand(WKPageRef page, WKStringRef command, void* context, WKPageValidateCommandCallback callback);
271 WK_EXPORT void WKPageExecuteCommand(WKPageRef page, WKStringRef command);
272
273 WK_EXPORT void WKPagePostMessageToInjectedBundle(WKPageRef page, WKStringRef messageName, WKTypeRef messageBody);
274
275 WK_EXPORT void WKPageSelectContextMenuItem(WKPageRef page, WKContextMenuItemRef item);
276
277 #ifdef __cplusplus
278 }
279 #endif
280
281 #endif /* WKPage_h */