5173755948dd415e27a5f73ea472fac8095beb19
[WebKit-https.git] / Source / WebKit / UIProcess / API / C / WKAPICast.h
1 /*
2  * Copyright (C) 2010-2017 Apple Inc. All rights reserved.
3  * Portions Copyright (c) 2010 Motorola Mobility, Inc.  All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
15  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
18  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
24  * THE POSSIBILITY OF SUCH DAMAGE.
25  */
26
27 #ifndef WKAPICast_h
28 #define WKAPICast_h
29
30 #include "CacheModel.h"
31 #include "HTTPCookieAcceptPolicy.h"
32 #include "InjectedBundleHitTestResultMediaType.h"
33 #include "PluginModuleInfo.h"
34 #include "ProcessTerminationReason.h"
35 #include "ResourceCachesToClear.h"
36 #include "WKBundleHitTestResult.h"
37 #include "WKContext.h"
38 #include "WKCookieManager.h"
39 #include "WKCredentialTypes.h"
40 #include "WKPage.h"
41 #include "WKPreferencesRef.h"
42 #include "WKPreferencesRefPrivate.h"
43 #include "WKProcessTerminationReason.h"
44 #include "WKProtectionSpaceTypes.h"
45 #include "WKResourceCacheManager.h"
46 #include "WKSharedAPICast.h"
47 #include <WebCore/Credential.h>
48 #include <WebCore/FrameLoaderTypes.h>
49 #include <WebCore/PluginData.h>
50 #include <WebCore/ProtectionSpace.h>
51 #include <WebCore/Settings.h>
52
53 namespace API {
54 class ContentRuleList;
55 class ContentRuleListStore;
56 class InternalDebugFeature;
57 class ExperimentalFeature;
58 class FrameHandle;
59 class FrameInfo;
60 class HitTestResult;
61 class MessageListener;
62 class Navigation;
63 class NavigationAction;
64 class NavigationData;
65 class NavigationResponse;
66 class OpenPanelParameters;
67 class PageConfiguration;
68 class ProcessPoolConfiguration;
69 class SessionState;
70 class UserScript;
71 class WebsiteDataStore;
72 class WebsitePolicies;
73 class WindowFeatures;
74 }
75
76 namespace WebKit {
77
78 class AuthenticationChallengeProxy;
79 class AuthenticationDecisionListener;
80 class DownloadProxy;
81 class GeolocationPermissionRequest;
82 class NotificationPermissionRequest;
83 class UserMediaPermissionCheckProxy;
84 class UserMediaPermissionRequestProxy;
85 class WebBackForwardList;
86 class WebBackForwardListItem;
87 class WebColorPickerResultListenerProxy;
88 class WebContextMenuListenerProxy;
89 class WebCookieManagerProxy;
90 class WebCredential;
91 class WebFormSubmissionListenerProxy;
92 class WebFramePolicyListenerProxy;
93 class WebFrameProxy;
94 class WebGeolocationManagerProxy;
95 class WebGeolocationPosition;
96 class WebIconDatabase;
97 class WebInspectorProxy;
98 class WebMediaSessionFocusManager;
99 class WebMediaSessionMetadata;
100 class WebNotification;
101 class WebNotificationManagerProxy;
102 class WebNotificationProvider;
103 class WebOpenPanelResultListenerProxy;
104 class WebPageGroup;
105 class WebPageProxy;
106 class WebPreferences;
107 class WebProcessPool;
108 class WebProtectionSpace;
109 class WebRenderLayer;
110 class WebRenderObject;
111 class WebResourceLoadStatisticsManager;
112 class WebTextChecker;
113 class WebUserContentControllerProxy;
114 class WebViewportAttributes;
115
116 WK_ADD_API_MAPPING(WKAuthenticationChallengeRef, AuthenticationChallengeProxy)
117 WK_ADD_API_MAPPING(WKAuthenticationDecisionListenerRef, AuthenticationDecisionListener)
118 WK_ADD_API_MAPPING(WKBackForwardListItemRef, WebBackForwardListItem)
119 WK_ADD_API_MAPPING(WKBackForwardListRef, WebBackForwardList)
120 WK_ADD_API_MAPPING(WKBundleHitTestResultMediaType, BundleHitTestResultMediaType)
121 WK_ADD_API_MAPPING(WKColorPickerResultListenerRef, WebColorPickerResultListenerProxy)
122 WK_ADD_API_MAPPING(WKContextRef, WebProcessPool)
123 WK_ADD_API_MAPPING(WKContextConfigurationRef, API::ProcessPoolConfiguration)
124 WK_ADD_API_MAPPING(WKContextMenuListenerRef, WebContextMenuListenerProxy)
125 WK_ADD_API_MAPPING(WKCookieManagerRef, WebCookieManagerProxy)
126 WK_ADD_API_MAPPING(WKCredentialRef, WebCredential)
127 WK_ADD_API_MAPPING(WKDownloadRef, DownloadProxy)
128 WK_ADD_API_MAPPING(WKFormSubmissionListenerRef, WebFormSubmissionListenerProxy)
129 WK_ADD_API_MAPPING(WKFramePolicyListenerRef, WebFramePolicyListenerProxy)
130 WK_ADD_API_MAPPING(WKFrameHandleRef, API::FrameHandle)
131 WK_ADD_API_MAPPING(WKFrameInfoRef, API::FrameInfo)
132 WK_ADD_API_MAPPING(WKFrameRef, WebFrameProxy)
133 WK_ADD_API_MAPPING(WKGeolocationManagerRef, WebGeolocationManagerProxy)
134 WK_ADD_API_MAPPING(WKGeolocationPermissionRequestRef, GeolocationPermissionRequest)
135 WK_ADD_API_MAPPING(WKGeolocationPositionRef, WebGeolocationPosition)
136 WK_ADD_API_MAPPING(WKHitTestResultRef, API::HitTestResult)
137 WK_ADD_API_MAPPING(WKIconDatabaseRef, WebIconDatabase)
138 WK_ADD_API_MAPPING(WKInspectorRef, WebInspectorProxy)
139 WK_ADD_API_MAPPING(WKMediaSessionFocusManagerRef, WebMediaSessionFocusManager)
140 WK_ADD_API_MAPPING(WKMediaSessionMetadataRef, WebMediaSessionMetadata)
141 WK_ADD_API_MAPPING(WKMessageListenerRef, API::MessageListener)
142 WK_ADD_API_MAPPING(WKNavigationActionRef, API::NavigationAction)
143 WK_ADD_API_MAPPING(WKNavigationDataRef, API::NavigationData)
144 WK_ADD_API_MAPPING(WKNavigationRef, API::Navigation)
145 WK_ADD_API_MAPPING(WKNavigationResponseRef, API::NavigationResponse)
146 WK_ADD_API_MAPPING(WKNotificationManagerRef, WebNotificationManagerProxy)
147 WK_ADD_API_MAPPING(WKNotificationPermissionRequestRef, NotificationPermissionRequest)
148 WK_ADD_API_MAPPING(WKNotificationProviderRef, WebNotificationProvider)
149 WK_ADD_API_MAPPING(WKNotificationRef, WebNotification)
150 WK_ADD_API_MAPPING(WKOpenPanelParametersRef, API::OpenPanelParameters)
151 WK_ADD_API_MAPPING(WKOpenPanelResultListenerRef, WebOpenPanelResultListenerProxy)
152 WK_ADD_API_MAPPING(WKPageGroupRef, WebPageGroup)
153 WK_ADD_API_MAPPING(WKPageConfigurationRef, API::PageConfiguration)
154 WK_ADD_API_MAPPING(WKPageRef, WebPageProxy)
155 WK_ADD_API_MAPPING(WKPreferencesRef, WebPreferences)
156 WK_ADD_API_MAPPING(WKProtectionSpaceRef, WebProtectionSpace)
157 WK_ADD_API_MAPPING(WKRenderLayerRef, WebRenderLayer)
158 WK_ADD_API_MAPPING(WKRenderObjectRef, WebRenderObject)
159 WK_ADD_API_MAPPING(WKResourceLoadStatisticsManagerRef, WebResourceLoadStatisticsManager)
160 WK_ADD_API_MAPPING(WKSessionStateRef, API::SessionState)
161 WK_ADD_API_MAPPING(WKTextCheckerRef, WebTextChecker)
162 WK_ADD_API_MAPPING(WKUserContentControllerRef, WebUserContentControllerProxy)
163 WK_ADD_API_MAPPING(WKUserContentExtensionStoreRef, API::ContentRuleListStore)
164 WK_ADD_API_MAPPING(WKUserContentFilterRef, API::ContentRuleList)
165 WK_ADD_API_MAPPING(WKUserMediaPermissionCheckRef, UserMediaPermissionCheckProxy)
166 WK_ADD_API_MAPPING(WKUserMediaPermissionRequestRef, UserMediaPermissionRequestProxy)
167 WK_ADD_API_MAPPING(WKUserScriptRef, API::UserScript)
168 WK_ADD_API_MAPPING(WKViewportAttributesRef, WebViewportAttributes)
169 WK_ADD_API_MAPPING(WKWebsiteDataStoreRef, API::WebsiteDataStore)
170 WK_ADD_API_MAPPING(WKWebsitePoliciesRef, API::WebsitePolicies)
171 WK_ADD_API_MAPPING(WKWindowFeaturesRef, API::WindowFeatures)
172
173 /* Enum conversions */
174
175 inline BundleHitTestResultMediaType toBundleHitTestResultMediaType(WKBundleHitTestResultMediaType wkMediaType)
176 {
177     switch (wkMediaType) {
178     case kWKBundleHitTestResultMediaTypeNone:
179         return BundleHitTestResultMediaTypeNone;
180     case kWKBundleHitTestResultMediaTypeAudio:
181         return BundleHitTestResultMediaTypeAudio;
182     case kWKBundleHitTestResultMediaTypeVideo:
183         return BundleHitTestResultMediaTypeVideo;
184     }
185     
186     ASSERT_NOT_REACHED();
187     return BundleHitTestResultMediaTypeNone;
188 }
189     
190 inline WKBundleHitTestResultMediaType toAPI(BundleHitTestResultMediaType mediaType)
191 {
192     switch (mediaType) {
193     case BundleHitTestResultMediaTypeNone:
194         return kWKBundleHitTestResultMediaTypeNone;
195     case BundleHitTestResultMediaTypeAudio:
196         return kWKBundleHitTestResultMediaTypeAudio;
197     case BundleHitTestResultMediaTypeVideo:
198         return kWKBundleHitTestResultMediaTypeVideo;
199     }
200     
201     ASSERT_NOT_REACHED();
202     return kWKBundleHitTestResultMediaTypeNone;
203 }
204
205 inline CacheModel toCacheModel(WKCacheModel wkCacheModel)
206 {
207     switch (wkCacheModel) {
208     case kWKCacheModelDocumentViewer:
209         return CacheModel::DocumentViewer;
210     case kWKCacheModelDocumentBrowser:
211         return CacheModel::DocumentBrowser;
212     case kWKCacheModelPrimaryWebBrowser:
213         return CacheModel::PrimaryWebBrowser;
214     }
215
216     ASSERT_NOT_REACHED();
217     return CacheModel::DocumentViewer;
218 }
219
220 inline WKCacheModel toAPI(CacheModel cacheModel)
221 {
222     switch (cacheModel) {
223     case CacheModel::DocumentViewer:
224         return kWKCacheModelDocumentViewer;
225     case CacheModel::DocumentBrowser:
226         return kWKCacheModelDocumentBrowser;
227     case CacheModel::PrimaryWebBrowser:
228         return kWKCacheModelPrimaryWebBrowser;
229     }
230     
231     return kWKCacheModelDocumentViewer;
232 }
233
234 inline WKProcessTerminationReason toAPI(ProcessTerminationReason reason)
235 {
236     switch (reason) {
237     case ProcessTerminationReason::ExceededMemoryLimit:
238         return kWKProcessTerminationReasonExceededMemoryLimit;
239     case ProcessTerminationReason::ExceededCPULimit:
240         return kWKProcessTerminationReasonExceededCPULimit;
241     case ProcessTerminationReason::NavigationSwap:
242         // We probably shouldn't bother coming up with a new C-API type for process-swapping.
243         // "Requested by client" seems like the best match for existing types.
244         FALLTHROUGH;
245     case ProcessTerminationReason::RequestedByClient:
246         return kWKProcessTerminationReasonRequestedByClient;
247     case ProcessTerminationReason::Crash:
248         return kWKProcessTerminationReasonCrash;
249     }
250
251     return kWKProcessTerminationReasonCrash;
252 }
253
254 inline WKEditableLinkBehavior toAPI(WebCore::EditableLinkBehavior behavior)
255 {
256     switch (behavior) {
257     case WebCore::EditableLinkDefaultBehavior:
258         return kWKEditableLinkBehaviorDefault;
259     case WebCore::EditableLinkAlwaysLive:
260         return kWKEditableLinkBehaviorAlwaysLive;
261     case WebCore::EditableLinkOnlyLiveWithShiftKey:
262         return kWKEditableLinkBehaviorOnlyLiveWithShiftKey;
263     case WebCore::EditableLinkLiveWhenNotFocused:
264         return kWKEditableLinkBehaviorLiveWhenNotFocused;
265     case WebCore::EditableLinkNeverLive:
266         return kWKEditableLinkBehaviorNeverLive;
267     }
268     
269     ASSERT_NOT_REACHED();
270     return kWKEditableLinkBehaviorNeverLive;
271 }
272
273 inline WebCore::EditableLinkBehavior toEditableLinkBehavior(WKEditableLinkBehavior wkBehavior)
274 {
275     switch (wkBehavior) {
276     case kWKEditableLinkBehaviorDefault:
277         return WebCore::EditableLinkDefaultBehavior;
278     case kWKEditableLinkBehaviorAlwaysLive:
279         return WebCore::EditableLinkAlwaysLive;
280     case kWKEditableLinkBehaviorOnlyLiveWithShiftKey:
281         return WebCore::EditableLinkOnlyLiveWithShiftKey;
282     case kWKEditableLinkBehaviorLiveWhenNotFocused:
283         return WebCore::EditableLinkLiveWhenNotFocused;
284     case kWKEditableLinkBehaviorNeverLive:
285         return WebCore::EditableLinkNeverLive;
286     }
287     
288     ASSERT_NOT_REACHED();
289     return WebCore::EditableLinkNeverLive;
290 }
291     
292 inline WKProtectionSpaceServerType toAPI(WebCore::ProtectionSpaceServerType type)
293 {
294     switch (type) {
295     case WebCore::ProtectionSpaceServerHTTP:
296         return kWKProtectionSpaceServerTypeHTTP;
297     case WebCore::ProtectionSpaceServerHTTPS:
298         return kWKProtectionSpaceServerTypeHTTPS;
299     case WebCore::ProtectionSpaceServerFTP:
300         return kWKProtectionSpaceServerTypeFTP;
301     case WebCore::ProtectionSpaceServerFTPS:
302         return kWKProtectionSpaceServerTypeFTPS;
303     case WebCore::ProtectionSpaceProxyHTTP:
304         return kWKProtectionSpaceProxyTypeHTTP;
305     case WebCore::ProtectionSpaceProxyHTTPS:
306         return kWKProtectionSpaceProxyTypeHTTPS;
307     case WebCore::ProtectionSpaceProxyFTP:
308         return kWKProtectionSpaceProxyTypeFTP;
309     case WebCore::ProtectionSpaceProxySOCKS:
310         return kWKProtectionSpaceProxyTypeSOCKS;
311     }
312     return kWKProtectionSpaceServerTypeHTTP;
313 }
314
315 inline WKProtectionSpaceAuthenticationScheme toAPI(WebCore::ProtectionSpaceAuthenticationScheme type)
316 {
317     switch (type) {
318     case WebCore::ProtectionSpaceAuthenticationSchemeDefault:
319         return kWKProtectionSpaceAuthenticationSchemeDefault;
320     case WebCore::ProtectionSpaceAuthenticationSchemeHTTPBasic:
321         return kWKProtectionSpaceAuthenticationSchemeHTTPBasic;
322     case WebCore::ProtectionSpaceAuthenticationSchemeHTTPDigest:
323         return kWKProtectionSpaceAuthenticationSchemeHTTPDigest;
324     case WebCore::ProtectionSpaceAuthenticationSchemeHTMLForm:
325         return kWKProtectionSpaceAuthenticationSchemeHTMLForm;
326     case WebCore::ProtectionSpaceAuthenticationSchemeNTLM:
327         return kWKProtectionSpaceAuthenticationSchemeNTLM;
328     case WebCore::ProtectionSpaceAuthenticationSchemeNegotiate:
329         return kWKProtectionSpaceAuthenticationSchemeNegotiate;
330     case WebCore::ProtectionSpaceAuthenticationSchemeClientCertificateRequested:
331         return kWKProtectionSpaceAuthenticationSchemeClientCertificateRequested;
332     case WebCore::ProtectionSpaceAuthenticationSchemeServerTrustEvaluationRequested:
333         return kWKProtectionSpaceAuthenticationSchemeServerTrustEvaluationRequested;
334     case WebCore::ProtectionSpaceAuthenticationSchemeOAuth:
335         return kWKProtectionSpaceAuthenticationSchemeOAuth;
336     default:
337         return kWKProtectionSpaceAuthenticationSchemeUnknown;
338     }
339 }
340
341 inline WebCore::CredentialPersistence toCredentialPersistence(WKCredentialPersistence type)
342 {
343     switch (type) {
344     case kWKCredentialPersistenceNone:
345         return WebCore::CredentialPersistenceNone;
346     case kWKCredentialPersistenceForSession:
347         return WebCore::CredentialPersistenceForSession;
348     case kWKCredentialPersistencePermanent:
349         return WebCore::CredentialPersistencePermanent;
350     default:
351         return WebCore::CredentialPersistenceNone;
352     }
353 }
354
355 inline ResourceCachesToClear toResourceCachesToClear(WKResourceCachesToClear wkResourceCachesToClear)
356 {
357     switch (wkResourceCachesToClear) {
358     case WKResourceCachesToClearAll:
359         return AllResourceCaches;
360     case WKResourceCachesToClearInMemoryOnly:
361         return InMemoryResourceCachesOnly;
362     }
363
364     ASSERT_NOT_REACHED();
365     return AllResourceCaches;
366 }
367
368 inline HTTPCookieAcceptPolicy toHTTPCookieAcceptPolicy(WKHTTPCookieAcceptPolicy policy)
369 {
370     switch (policy) {
371     case kWKHTTPCookieAcceptPolicyAlways:
372         return HTTPCookieAcceptPolicy::AlwaysAccept;
373     case kWKHTTPCookieAcceptPolicyNever:
374         return HTTPCookieAcceptPolicy::Never;
375     case kWKHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain:
376         return HTTPCookieAcceptPolicy::OnlyFromMainDocumentDomain;
377     case kWKHTTPCookieAcceptPolicyExclusivelyFromMainDocumentDomain:
378         return HTTPCookieAcceptPolicy::ExclusivelyFromMainDocumentDomain;
379     }
380
381     ASSERT_NOT_REACHED();
382     return HTTPCookieAcceptPolicy::AlwaysAccept;
383 }
384
385 inline WKHTTPCookieAcceptPolicy toAPI(HTTPCookieAcceptPolicy policy)
386 {
387     switch (policy) {
388     case HTTPCookieAcceptPolicy::AlwaysAccept:
389         return kWKHTTPCookieAcceptPolicyAlways;
390     case HTTPCookieAcceptPolicy::Never:
391         return kWKHTTPCookieAcceptPolicyNever;
392     case HTTPCookieAcceptPolicy::OnlyFromMainDocumentDomain:
393         return kWKHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain;
394     case HTTPCookieAcceptPolicy::ExclusivelyFromMainDocumentDomain:
395         return kWKHTTPCookieAcceptPolicyExclusivelyFromMainDocumentDomain;
396     }
397
398     ASSERT_NOT_REACHED();
399     return kWKHTTPCookieAcceptPolicyAlways;
400 }
401
402 inline WebCore::SecurityOrigin::StorageBlockingPolicy toStorageBlockingPolicy(WKStorageBlockingPolicy policy)
403 {
404     switch (policy) {
405     case kWKAllowAllStorage:
406         return WebCore::SecurityOrigin::AllowAllStorage;
407     case kWKBlockThirdPartyStorage:
408         return WebCore::SecurityOrigin::BlockThirdPartyStorage;
409     case kWKBlockAllStorage:
410         return WebCore::SecurityOrigin::BlockAllStorage;
411     }
412
413     ASSERT_NOT_REACHED();
414     return WebCore::SecurityOrigin::AllowAllStorage;
415 }
416
417 inline WKStorageBlockingPolicy toAPI(WebCore::SecurityOrigin::StorageBlockingPolicy policy)
418 {
419     switch (policy) {
420     case WebCore::SecurityOrigin::AllowAllStorage:
421         return kWKAllowAllStorage;
422     case WebCore::SecurityOrigin::BlockThirdPartyStorage:
423         return kWKBlockThirdPartyStorage;
424     case WebCore::SecurityOrigin::BlockAllStorage:
425         return kWKBlockAllStorage;
426     }
427
428     ASSERT_NOT_REACHED();
429     return kWKAllowAllStorage;
430 }
431
432 inline WKPluginLoadPolicy toWKPluginLoadPolicy(PluginModuleLoadPolicy pluginModuleLoadPolicy)
433 {
434     switch (pluginModuleLoadPolicy) {
435     case PluginModuleLoadNormally:
436         return kWKPluginLoadPolicyLoadNormally;
437     case PluginModuleLoadUnsandboxed:
438         return kWKPluginLoadPolicyLoadUnsandboxed;
439     case PluginModuleBlockedForSecurity:
440         return kWKPluginLoadPolicyBlocked;
441     case PluginModuleBlockedForCompatibility:
442         return kWKPluginLoadPolicyBlockedForCompatibility;
443     }
444     
445     ASSERT_NOT_REACHED();
446     return kWKPluginLoadPolicyBlocked;
447 }
448
449 inline WKPluginLoadClientPolicy toWKPluginLoadClientPolicy(WebCore::PluginLoadClientPolicy PluginLoadClientPolicy)
450 {
451     switch (PluginLoadClientPolicy) {
452     case WebCore::PluginLoadClientPolicyUndefined:
453         return kWKPluginLoadClientPolicyUndefined;
454     case WebCore::PluginLoadClientPolicyBlock:
455         return kWKPluginLoadClientPolicyBlock;
456     case WebCore::PluginLoadClientPolicyAsk:
457         return kWKPluginLoadClientPolicyAsk;
458     case WebCore::PluginLoadClientPolicyAllow:
459         return kWKPluginLoadClientPolicyAllow;
460     case WebCore::PluginLoadClientPolicyAllowAlways:
461         return kWKPluginLoadClientPolicyAllowAlways;
462     }
463
464     ASSERT_NOT_REACHED();
465     return kWKPluginLoadClientPolicyBlock;
466 }
467
468 inline PluginModuleLoadPolicy toPluginModuleLoadPolicy(WKPluginLoadPolicy pluginLoadPolicy)
469 {
470     switch (pluginLoadPolicy) {
471     case kWKPluginLoadPolicyLoadNormally:
472         return PluginModuleLoadNormally;
473     case kWKPluginLoadPolicyBlocked:
474         return PluginModuleBlockedForSecurity;
475     case kWKPluginLoadPolicyBlockedForCompatibility:
476         return PluginModuleBlockedForCompatibility;
477     case kWKPluginLoadPolicyLoadUnsandboxed:
478         return PluginModuleLoadUnsandboxed;
479     }
480     
481     ASSERT_NOT_REACHED();
482     return PluginModuleBlockedForSecurity;
483 }
484
485 inline WebCore::PluginLoadClientPolicy toPluginLoadClientPolicy(WKPluginLoadClientPolicy pluginLoadClientPolicy)
486 {
487     switch (pluginLoadClientPolicy) {
488     case kWKPluginLoadClientPolicyUndefined:
489         return WebCore::PluginLoadClientPolicyUndefined;
490     case kWKPluginLoadClientPolicyBlock:
491         return WebCore::PluginLoadClientPolicyBlock;
492     case kWKPluginLoadClientPolicyAsk:
493         return WebCore::PluginLoadClientPolicyAsk;
494     case kWKPluginLoadClientPolicyAllow:
495         return WebCore::PluginLoadClientPolicyAllow;
496     case kWKPluginLoadClientPolicyAllowAlways:
497         return WebCore::PluginLoadClientPolicyAllowAlways;
498     }
499
500     ASSERT_NOT_REACHED();
501     return WebCore::PluginLoadClientPolicyBlock;
502 }
503
504 inline WebCore::WebGLLoadPolicy toWebGLLoadPolicy(WKWebGLLoadPolicy webGLLoadPolicy)
505 {
506     switch (webGLLoadPolicy) {
507     case kWKWebGLLoadPolicyLoadNormally:
508         return WebCore::WebGLAllowCreation;
509     case kWKWebGLLoadPolicyBlocked:
510         return WebCore::WebGLBlockCreation;
511     case kWKWebGLLoadPolicyPending:
512         return WebCore::WebGLPendingCreation;
513     }
514     
515     ASSERT_NOT_REACHED();
516     return WebCore::WebGLAllowCreation;
517 }
518
519 inline WKWebGLLoadPolicy toAPI(WebCore::WebGLLoadPolicy webGLLoadPolicy)
520 {
521     switch (webGLLoadPolicy) {
522     case WebCore::WebGLAllowCreation:
523         return kWKWebGLLoadPolicyLoadNormally;
524     case WebCore::WebGLBlockCreation:
525         return kWKWebGLLoadPolicyBlocked;
526     case WebCore::WebGLPendingCreation:
527         return kWKWebGLLoadPolicyPending;
528     }
529
530     ASSERT_NOT_REACHED();
531     return kWKWebGLLoadPolicyLoadNormally;
532 }
533
534 } // namespace WebKit
535
536 #if defined(BUILDING_GTK__)
537 #include "WKAPICastGtk.h"
538 #endif
539
540 #if defined(BUILDING_WPE__)
541 #include "WKAPICastWPE.h"
542 #endif
543
544 #if defined(WIN32) || defined(_WIN32)
545 #include "WKAPICastWin.h"
546 #endif
547
548 #endif // WKAPICast_h