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