871746887617e40350141a9dc101537f2bce99d5
[WebKit-https.git] / Source / WebKit / UIProcess / API / C / WKPagePrivate.h
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 WKPagePrivate_h
27 #define WKPagePrivate_h
28
29 #include <WebKit/WKBase.h>
30 #include <WebKit/WKPage.h>
31
32 #include <unistd.h>
33
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37
38 typedef void (*WKPageRenderTreeExternalRepresentationFunction)(WKStringRef, WKErrorRef, void*);
39 WK_EXPORT void WKPageRenderTreeExternalRepresentation(WKPageRef page, void *context, WKPageRenderTreeExternalRepresentationFunction function);
40
41 enum {
42     kWKDebugFlashViewUpdates = 1 << 0,
43     kWKDebugFlashBackingStoreUpdates = 1 << 1
44 };
45 typedef unsigned WKPageDebugPaintFlags;
46
47 WK_EXPORT WKStringRef WKPageCopyStandardUserAgentWithApplicationName(WKStringRef);
48
49 enum {
50     kWKPaginationModeUnpaginated,
51     kWKPaginationModeLeftToRight,
52     kWKPaginationModeRightToLeft,
53     kWKPaginationModeTopToBottom,
54     kWKPaginationModeBottomToTop,
55 };
56 typedef uint32_t WKPaginationMode;
57
58 WK_EXPORT void WKPageSetPaginationMode(WKPageRef page, WKPaginationMode paginationMode);
59 WK_EXPORT WKPaginationMode WKPageGetPaginationMode(WKPageRef page);
60 WK_EXPORT void WKPageSetPaginationBehavesLikeColumns(WKPageRef page, bool behavesLikeColumns);
61 WK_EXPORT bool WKPageGetPaginationBehavesLikeColumns(WKPageRef page);
62 WK_EXPORT void WKPageSetPageLength(WKPageRef page, double pageLength);
63 WK_EXPORT double WKPageGetPageLength(WKPageRef page);
64 WK_EXPORT void WKPageSetGapBetweenPages(WKPageRef page, double gap);
65 WK_EXPORT double WKPageGetGapBetweenPages(WKPageRef page);
66 WK_EXPORT void WKPageSetPaginationLineGridEnabled(WKPageRef page, bool lineGridEnabled);
67 WK_EXPORT bool WKPageGetPaginationLineGridEnabled(WKPageRef page);
68
69 WK_EXPORT unsigned WKPageGetPageCount(WKPageRef page);
70
71 struct WKPrintInfo {
72     float pageSetupScaleFactor;
73     float availablePaperWidth;
74     float availablePaperHeight;
75 };
76 typedef struct WKPrintInfo WKPrintInfo;
77
78 typedef void (*WKPageComputePagesForPrintingFunction)(WKRect* pageRects, uint32_t pageCount, double resultPageScaleFactor, WKErrorRef error, void* functionContext);
79 WK_EXPORT void WKPageComputePagesForPrinting(WKPageRef page, WKFrameRef frame, WKPrintInfo, WKPageComputePagesForPrintingFunction, void* context);
80
81 typedef void (*WKPageDrawToPDFFunction)(WKDataRef data, WKErrorRef error, void* functionContext);
82 WK_EXPORT void WKPageBeginPrinting(WKPageRef page, WKFrameRef frame, WKPrintInfo printInfo);
83 WK_EXPORT void WKPageDrawPagesToPDF(WKPageRef page, WKFrameRef frame, WKPrintInfo printInfo, uint32_t first, uint32_t count, WKPageDrawToPDFFunction callback, void* context);
84 WK_EXPORT void WKPageEndPrinting(WKPageRef page);
85
86 WK_EXPORT bool WKPageGetIsControlledByAutomation(WKPageRef page);
87 WK_EXPORT void WKPageSetControlledByAutomation(WKPageRef page, bool controlled);
88
89 WK_EXPORT bool WKPageGetAllowsRemoteInspection(WKPageRef page);
90 WK_EXPORT void WKPageSetAllowsRemoteInspection(WKPageRef page, bool allow);
91
92 WK_EXPORT void WKPageSetMediaVolume(WKPageRef page, float volume);
93 WK_EXPORT void WKPageSetMayStartMediaWhenInWindow(WKPageRef page, bool mayStartMedia);
94
95 typedef void (*WKPageGetBytecodeProfileFunction)(WKStringRef, WKErrorRef, void*);
96 WK_EXPORT void WKPageGetBytecodeProfile(WKPageRef page, void* context, WKPageGetBytecodeProfileFunction function);
97
98 typedef void (*WKPageGetSamplingProfilerOutputFunction)(WKStringRef, WKErrorRef, void*);
99 WK_EXPORT void WKPageGetSamplingProfilerOutput(WKPageRef page, void* context, WKPageGetSamplingProfilerOutputFunction function);
100
101 typedef void (*WKPageIsWebProcessResponsiveFunction)(bool isWebProcessResponsive, void* context);
102 WK_EXPORT void WKPageIsWebProcessResponsive(WKPageRef page, void* context, WKPageIsWebProcessResponsiveFunction function);
103     
104 WK_EXPORT WKArrayRef WKPageCopyRelatedPages(WKPageRef page);
105
106 WK_EXPORT WKFrameRef WKPageLookUpFrameFromHandle(WKPageRef page, WKFrameHandleRef handle);
107
108 enum {
109     kWKScrollPinningBehaviorDoNotPin,
110     kWKScrollPinningBehaviorPinToTop,
111     kWKScrollPinningBehaviorPinToBottom
112 };
113 typedef uint32_t WKScrollPinningBehavior;
114
115 WK_EXPORT WKScrollPinningBehavior WKPageGetScrollPinningBehavior(WKPageRef page);
116 WK_EXPORT void WKPageSetScrollPinningBehavior(WKPageRef page, WKScrollPinningBehavior pinning);
117
118 WK_EXPORT bool WKPageGetAddsVisitedLinks(WKPageRef page);
119 WK_EXPORT void WKPageSetAddsVisitedLinks(WKPageRef page, bool visitedLinks);
120
121 WK_EXPORT bool WKPageIsPlayingAudio(WKPageRef page);
122
123 enum {
124     kWKMediaNoneMuted = 0,
125     kWKMediaAudioMuted = 1 << 0,
126     kWKMediaCaptureDevicesMuted = 1 << 1,
127 };
128 typedef uint32_t WKMediaMutedState;
129 WK_EXPORT void WKPageSetMuted(WKPageRef page, WKMediaMutedState muted);
130
131 WK_EXPORT void WKPageClearUserMediaState(WKPageRef page);
132 WK_EXPORT void WKPageSetMediaCaptureEnabled(WKPageRef page, bool enabled);
133 WK_EXPORT bool WKPageGetMediaCaptureEnabled(WKPageRef page);
134
135 WK_EXPORT void WKPageDidAllowPointerLock(WKPageRef page);
136 WK_EXPORT void WKPageDidDenyPointerLock(WKPageRef page);
137
138 enum {
139     kWKMediaIsNotPlaying = 0,
140     kWKMediaIsPlayingAudio = 1 << 0,
141     kWKMediaIsPlayingVideo = 1 << 1,
142     kWKMediaHasActiveAudioCaptureDevice = 1 << 2,
143     kWKMediaHasActiveVideoCaptureDevice = 1 << 3,
144     kWKMediaHasMutedAudioCaptureDevice = 1 << 4,
145     kWKMediaHasMutedVideoCaptureDevice = 1 << 5,
146 };
147 typedef uint32_t WKMediaState;
148
149
150 WK_EXPORT WKMediaState WKPageGetMediaState(WKPageRef page);
151
152 enum {
153     kWKMediaEventTypePlayPause,
154     kWKMediaEventTypeTrackNext,
155     kWKMediaEventTypeTrackPrevious
156 };
157 typedef uint32_t WKMediaEventType;
158
159 WK_EXPORT bool WKPageHasMediaSessionWithActiveMediaElements(WKPageRef page);
160 WK_EXPORT void WKPageHandleMediaEvent(WKPageRef page, WKMediaEventType event);
161
162 WK_EXPORT void WKPageLoadURLWithShouldOpenExternalURLsPolicy(WKPageRef page, WKURLRef url, bool shouldOpenExternalURLs);
163
164 typedef void (*WKPagePostPresentationUpdateFunction)(WKErrorRef, void*);
165 WK_EXPORT void WKPageCallAfterNextPresentationUpdate(WKPageRef page, void* context, WKPagePostPresentationUpdateFunction function);
166
167 WK_EXPORT bool WKPageGetResourceCachingDisabled(WKPageRef page);
168 WK_EXPORT void WKPageSetResourceCachingDisabled(WKPageRef page, bool disabled);
169
170 WK_EXPORT void WKPageRestoreFromSessionStateWithoutNavigation(WKPageRef page, WKTypeRef sessionState);
171
172 WK_EXPORT void WKPageSetIgnoresViewportScaleLimits(WKPageRef page, bool ignoresViewportScaleLimits);
173
174 WK_EXPORT pid_t WKPageGetProcessIdentifier(WKPageRef page);
175
176 #ifdef __cplusplus
177 }
178 #endif
179
180 #endif /* WKPagePrivate_h */