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