Add WKPageNavigationClient as C SPI around API::NavigationClient, and adopt in WKTR
[WebKit-https.git] / Source / WebKit2 / UIProcess / API / C / WKAPICast.h
1 /*
2  * Copyright (C) 2010, 2011 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 "FontSmoothingLevel.h"
32 #include "HTTPCookieAcceptPolicy.h"
33 #include "InjectedBundleHitTestResultMediaType.h"
34 #include "PluginModuleInfo.h"
35 #include "ProcessModel.h"
36 #include "ResourceCachesToClear.h"
37 #include "WKBundleHitTestResult.h"
38 #include "WKContext.h"
39 #include "WKCookieManager.h"
40 #include "WKCredentialTypes.h"
41 #include "WKPage.h"
42 #include "WKPreferencesRef.h"
43 #include "WKPreferencesRefPrivate.h"
44 #include "WKProtectionSpaceTypes.h"
45 #include "WKResourceCacheManager.h"
46 #include "WKSharedAPICast.h"
47 #include "WebGrammarDetail.h"
48 #include <WebCore/Credential.h>
49 #include <WebCore/FrameLoaderTypes.h>
50 #include <WebCore/ProtectionSpace.h>
51 #include <WebCore/Settings.h>
52
53 namespace API {
54 class FrameInfo;
55 class Navigation;
56 class NavigationAction;
57 class NavigationData;
58 class NavigationResponse;
59 class PageConfiguration;
60 class ProcessPoolConfiguration;
61 class SessionState;
62 class UserContentFilter;
63 class UserScript;
64 }
65
66 namespace WebKit {
67
68 class AuthenticationChallengeProxy;
69 class AuthenticationDecisionListener;
70 class DownloadProxy;
71 class GeolocationPermissionRequestProxy;
72 class NotificationPermissionRequest;
73 class UserMediaPermissionRequestProxy;
74 class WebApplicationCacheManagerProxy;
75 class WebBackForwardList;
76 class WebBackForwardListItem;
77 class WebBatteryManagerProxy;
78 class WebBatteryStatus;
79 class WebColorPickerResultListenerProxy;
80 class WebCookieManagerProxy;
81 class WebCredential;
82 class WebDatabaseManagerProxy;
83 class WebFormSubmissionListenerProxy;
84 class WebFramePolicyListenerProxy;
85 class WebFrameProxy;
86 class WebGeolocationManagerProxy;
87 class WebGeolocationPosition;
88 class WebGrammarDetail;
89 class WebHitTestResult;
90 class WebIconDatabase;
91 class WebInspectorProxy;
92 class WebKeyValueStorageManager;
93 class WebMediaCacheManagerProxy;
94 class WebNotification;
95 class WebNotificationManagerProxy;
96 class WebNotificationProvider;
97 class WebOpenPanelParameters;
98 class WebOpenPanelResultListenerProxy;
99 class WebOriginDataManagerProxy;
100 class WebPageGroup;
101 class WebPageProxy;
102 class WebPluginSiteDataManager;
103 class WebPreferences;
104 class WebProcessPool;
105 class WebProtectionSpace;
106 class WebRenderLayer;
107 class WebRenderObject;
108 class WebResourceCacheManagerProxy;
109 class WebTextChecker;
110 class WebUserContentControllerProxy;
111 class WebVibrationProxy;
112 class WebViewportAttributes;
113
114 WK_ADD_API_MAPPING(WKApplicationCacheManagerRef, WebApplicationCacheManagerProxy)
115 WK_ADD_API_MAPPING(WKAuthenticationChallengeRef, AuthenticationChallengeProxy)
116 WK_ADD_API_MAPPING(WKAuthenticationDecisionListenerRef, AuthenticationDecisionListener)
117 WK_ADD_API_MAPPING(WKBackForwardListItemRef, WebBackForwardListItem)
118 WK_ADD_API_MAPPING(WKBackForwardListRef, WebBackForwardList)
119 WK_ADD_API_MAPPING(WKBatteryManagerRef, WebBatteryManagerProxy)
120 WK_ADD_API_MAPPING(WKBatteryStatusRef, WebBatteryStatus)
121 WK_ADD_API_MAPPING(WKBundleHitTestResultMediaType, BundleHitTestResultMediaType)
122 WK_ADD_API_MAPPING(WKResourceCacheManagerRef, WebResourceCacheManagerProxy)
123 WK_ADD_API_MAPPING(WKColorPickerResultListenerRef, WebColorPickerResultListenerProxy)
124 WK_ADD_API_MAPPING(WKContextRef, WebProcessPool)
125 WK_ADD_API_MAPPING(WKContextConfigurationRef, API::ProcessPoolConfiguration)
126 WK_ADD_API_MAPPING(WKCookieManagerRef, WebCookieManagerProxy)
127 WK_ADD_API_MAPPING(WKCredentialRef, WebCredential)
128 WK_ADD_API_MAPPING(WKDatabaseManagerRef, WebDatabaseManagerProxy)
129 WK_ADD_API_MAPPING(WKDownloadRef, DownloadProxy)
130 WK_ADD_API_MAPPING(WKFormSubmissionListenerRef, WebFormSubmissionListenerProxy)
131 WK_ADD_API_MAPPING(WKFramePolicyListenerRef, WebFramePolicyListenerProxy)
132 WK_ADD_API_MAPPING(WKFrameInfoRef, API::FrameInfo)
133 WK_ADD_API_MAPPING(WKFrameRef, WebFrameProxy)
134 WK_ADD_API_MAPPING(WKGeolocationManagerRef, WebGeolocationManagerProxy)
135 WK_ADD_API_MAPPING(WKGeolocationPermissionRequestRef, GeolocationPermissionRequestProxy)
136 WK_ADD_API_MAPPING(WKGeolocationPositionRef, WebGeolocationPosition)
137 WK_ADD_API_MAPPING(WKGrammarDetailRef, WebGrammarDetail)
138 WK_ADD_API_MAPPING(WKHitTestResultRef, WebHitTestResult)
139 WK_ADD_API_MAPPING(WKIconDatabaseRef, WebIconDatabase)
140 WK_ADD_API_MAPPING(WKKeyValueStorageManagerRef, WebKeyValueStorageManager)
141 WK_ADD_API_MAPPING(WKMediaCacheManagerRef, WebMediaCacheManagerProxy)
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, WebOpenPanelParameters)
151 WK_ADD_API_MAPPING(WKOpenPanelResultListenerRef, WebOpenPanelResultListenerProxy)
152 WK_ADD_API_MAPPING(WKOriginDataManagerRef, WebOriginDataManagerProxy)
153 WK_ADD_API_MAPPING(WKPageGroupRef, WebPageGroup)
154 WK_ADD_API_MAPPING(WKPageConfigurationRef, API::PageConfiguration)
155 WK_ADD_API_MAPPING(WKPageRef, WebPageProxy)
156 WK_ADD_API_MAPPING(WKPluginSiteDataManagerRef, WebPluginSiteDataManager)
157 WK_ADD_API_MAPPING(WKPreferencesRef, WebPreferences)
158 WK_ADD_API_MAPPING(WKProtectionSpaceRef, WebProtectionSpace)
159 WK_ADD_API_MAPPING(WKRenderLayerRef, WebRenderLayer)
160 WK_ADD_API_MAPPING(WKRenderObjectRef, WebRenderObject)
161 WK_ADD_API_MAPPING(WKSessionStateRef, API::SessionState)
162 WK_ADD_API_MAPPING(WKTextCheckerRef, WebTextChecker)
163 WK_ADD_API_MAPPING(WKUserContentControllerRef, WebUserContentControllerProxy)
164 WK_ADD_API_MAPPING(WKUserContentFilterRef, API::UserContentFilter)
165 WK_ADD_API_MAPPING(WKUserMediaPermissionRequestRef, UserMediaPermissionRequestProxy)
166 WK_ADD_API_MAPPING(WKUserScriptRef, API::UserScript)
167 WK_ADD_API_MAPPING(WKVibrationRef, WebVibrationProxy)
168 WK_ADD_API_MAPPING(WKViewportAttributesRef, WebViewportAttributes)
169 WK_ADD_API_MAPPING(WKInspectorRef, WebInspectorProxy)
170
171 /* Enum conversions */
172
173 inline BundleHitTestResultMediaType toBundleHitTestResultMediaType(WKBundleHitTestResultMediaType wkMediaType)
174 {
175     switch (wkMediaType) {
176     case kWKBundleHitTestResultMediaTypeNone:
177         return BundleHitTestResultMediaTypeNone;
178     case kWKBundleHitTestResultMediaTypeAudio:
179         return BundleHitTestResultMediaTypeAudio;
180     case kWKBundleHitTestResultMediaTypeVideo:
181         return BundleHitTestResultMediaTypeVideo;
182     }
183     
184     ASSERT_NOT_REACHED();
185     return BundleHitTestResultMediaTypeNone;
186 }
187     
188 inline WKBundleHitTestResultMediaType toAPI(BundleHitTestResultMediaType mediaType)
189 {
190     switch (mediaType) {
191     case BundleHitTestResultMediaTypeNone:
192         return kWKBundleHitTestResultMediaTypeNone;
193     case BundleHitTestResultMediaTypeAudio:
194         return kWKBundleHitTestResultMediaTypeAudio;
195     case BundleHitTestResultMediaTypeVideo:
196         return kWKBundleHitTestResultMediaTypeVideo;
197     }
198     
199     ASSERT_NOT_REACHED();
200     return kWKBundleHitTestResultMediaTypeNone;
201 }
202
203 inline CacheModel toCacheModel(WKCacheModel wkCacheModel)
204 {
205     switch (wkCacheModel) {
206     case kWKCacheModelDocumentViewer:
207         return CacheModelDocumentViewer;
208     case kWKCacheModelDocumentBrowser:
209         return CacheModelDocumentBrowser;
210     case kWKCacheModelPrimaryWebBrowser:
211         return CacheModelPrimaryWebBrowser;
212     }
213
214     ASSERT_NOT_REACHED();
215     return CacheModelDocumentViewer;
216 }
217
218 inline WKCacheModel toAPI(CacheModel cacheModel)
219 {
220     switch (cacheModel) {
221     case CacheModelDocumentViewer:
222         return kWKCacheModelDocumentViewer;
223     case CacheModelDocumentBrowser:
224         return kWKCacheModelDocumentBrowser;
225     case CacheModelPrimaryWebBrowser:
226         return kWKCacheModelPrimaryWebBrowser;
227     }
228     
229     return kWKCacheModelDocumentViewer;
230 }
231
232 inline ProcessModel toProcessModel(WKProcessModel wkProcessModel)
233 {
234     switch (wkProcessModel) {
235     case kWKProcessModelSharedSecondaryProcess:
236         return ProcessModelSharedSecondaryProcess;
237     case kWKProcessModelMultipleSecondaryProcesses:
238         return ProcessModelMultipleSecondaryProcesses;
239     }
240
241     ASSERT_NOT_REACHED();
242     return ProcessModelSharedSecondaryProcess;
243 }
244
245 inline WKProcessModel toAPI(ProcessModel processModel)
246 {
247     switch (processModel) {
248     case ProcessModelSharedSecondaryProcess:
249         return kWKProcessModelSharedSecondaryProcess;
250     case ProcessModelMultipleSecondaryProcesses:
251         return kWKProcessModelMultipleSecondaryProcesses;
252     }
253     
254     return kWKProcessModelSharedSecondaryProcess;
255 }
256
257 inline FontSmoothingLevel toFontSmoothingLevel(WKFontSmoothingLevel wkLevel)
258 {
259     switch (wkLevel) {
260     case kWKFontSmoothingLevelNoSubpixelAntiAliasing:
261         return FontSmoothingLevelNoSubpixelAntiAliasing;
262     case kWKFontSmoothingLevelLight:
263         return FontSmoothingLevelLight;
264     case kWKFontSmoothingLevelMedium:
265         return FontSmoothingLevelMedium;
266     case kWKFontSmoothingLevelStrong:
267         return FontSmoothingLevelStrong;
268     }
269
270     ASSERT_NOT_REACHED();
271     return FontSmoothingLevelMedium;
272 }
273
274
275 inline WKFontSmoothingLevel toAPI(FontSmoothingLevel level)
276 {
277     switch (level) {
278     case FontSmoothingLevelNoSubpixelAntiAliasing:
279         return kWKFontSmoothingLevelNoSubpixelAntiAliasing;
280     case FontSmoothingLevelLight:
281         return kWKFontSmoothingLevelLight;
282     case FontSmoothingLevelMedium:
283         return kWKFontSmoothingLevelMedium;
284     case FontSmoothingLevelStrong:
285         return kWKFontSmoothingLevelStrong;
286     }
287
288     ASSERT_NOT_REACHED();
289     return kWKFontSmoothingLevelMedium;
290 }
291
292 inline WKEditableLinkBehavior toAPI(WebCore::EditableLinkBehavior behavior)
293 {
294     switch (behavior) {
295     case WebCore::EditableLinkDefaultBehavior:
296         return kWKEditableLinkBehaviorDefault;
297     case WebCore::EditableLinkAlwaysLive:
298         return kWKEditableLinkBehaviorAlwaysLive;
299     case WebCore::EditableLinkOnlyLiveWithShiftKey:
300         return kWKEditableLinkBehaviorOnlyLiveWithShiftKey;
301     case WebCore::EditableLinkLiveWhenNotFocused:
302         return kWKEditableLinkBehaviorLiveWhenNotFocused;
303     case WebCore::EditableLinkNeverLive:
304         return kWKEditableLinkBehaviorNeverLive;
305     }
306     
307     ASSERT_NOT_REACHED();
308     return kWKEditableLinkBehaviorNeverLive;
309 }
310
311 inline WebCore::EditableLinkBehavior toEditableLinkBehavior(WKEditableLinkBehavior wkBehavior)
312 {
313     switch (wkBehavior) {
314     case kWKEditableLinkBehaviorDefault:
315         return WebCore::EditableLinkDefaultBehavior;
316     case kWKEditableLinkBehaviorAlwaysLive:
317         return WebCore::EditableLinkAlwaysLive;
318     case kWKEditableLinkBehaviorOnlyLiveWithShiftKey:
319         return WebCore::EditableLinkOnlyLiveWithShiftKey;
320     case kWKEditableLinkBehaviorLiveWhenNotFocused:
321         return WebCore::EditableLinkLiveWhenNotFocused;
322     case kWKEditableLinkBehaviorNeverLive:
323         return WebCore::EditableLinkNeverLive;
324     }
325     
326     ASSERT_NOT_REACHED();
327     return WebCore::EditableLinkNeverLive;
328 }
329     
330 inline WKProtectionSpaceServerType toAPI(WebCore::ProtectionSpaceServerType type)
331 {
332     switch (type) {
333     case WebCore::ProtectionSpaceServerHTTP:
334         return kWKProtectionSpaceServerTypeHTTP;
335     case WebCore::ProtectionSpaceServerHTTPS:
336         return kWKProtectionSpaceServerTypeHTTPS;
337     case WebCore::ProtectionSpaceServerFTP:
338         return kWKProtectionSpaceServerTypeFTP;
339     case WebCore::ProtectionSpaceServerFTPS:
340         return kWKProtectionSpaceServerTypeFTPS;
341     case WebCore::ProtectionSpaceProxyHTTP:
342         return kWKProtectionSpaceProxyTypeHTTP;
343     case WebCore::ProtectionSpaceProxyHTTPS:
344         return kWKProtectionSpaceProxyTypeHTTPS;
345     case WebCore::ProtectionSpaceProxyFTP:
346         return kWKProtectionSpaceProxyTypeFTP;
347     case WebCore::ProtectionSpaceProxySOCKS:
348         return kWKProtectionSpaceProxyTypeSOCKS;
349     }
350     return kWKProtectionSpaceServerTypeHTTP;
351 }
352
353 inline WKProtectionSpaceAuthenticationScheme toAPI(WebCore::ProtectionSpaceAuthenticationScheme type)
354 {
355     switch (type) {
356     case WebCore::ProtectionSpaceAuthenticationSchemeDefault:
357         return kWKProtectionSpaceAuthenticationSchemeDefault;
358     case WebCore::ProtectionSpaceAuthenticationSchemeHTTPBasic:
359         return kWKProtectionSpaceAuthenticationSchemeHTTPBasic;
360     case WebCore::ProtectionSpaceAuthenticationSchemeHTTPDigest:
361         return kWKProtectionSpaceAuthenticationSchemeHTTPDigest;
362     case WebCore::ProtectionSpaceAuthenticationSchemeHTMLForm:
363         return kWKProtectionSpaceAuthenticationSchemeHTMLForm;
364     case WebCore::ProtectionSpaceAuthenticationSchemeNTLM:
365         return kWKProtectionSpaceAuthenticationSchemeNTLM;
366     case WebCore::ProtectionSpaceAuthenticationSchemeNegotiate:
367         return kWKProtectionSpaceAuthenticationSchemeNegotiate;
368     case WebCore::ProtectionSpaceAuthenticationSchemeClientCertificateRequested:
369         return kWKProtectionSpaceAuthenticationSchemeClientCertificateRequested;
370     case WebCore::ProtectionSpaceAuthenticationSchemeServerTrustEvaluationRequested:
371         return kWKProtectionSpaceAuthenticationSchemeServerTrustEvaluationRequested;
372     default:
373         return kWKProtectionSpaceAuthenticationSchemeUnknown;
374     }
375 }
376
377 inline WebCore::CredentialPersistence toCredentialPersistence(WKCredentialPersistence type)
378 {
379     switch (type) {
380     case kWKCredentialPersistenceNone:
381         return WebCore::CredentialPersistenceNone;
382     case kWKCredentialPersistenceForSession:
383         return WebCore::CredentialPersistenceForSession;
384     case kWKCredentialPersistencePermanent:
385         return WebCore::CredentialPersistencePermanent;
386     default:
387         return WebCore::CredentialPersistenceNone;
388     }
389 }
390
391 inline ResourceCachesToClear toResourceCachesToClear(WKResourceCachesToClear wkResourceCachesToClear)
392 {
393     switch (wkResourceCachesToClear) {
394     case WKResourceCachesToClearAll:
395         return AllResourceCaches;
396     case WKResourceCachesToClearInMemoryOnly:
397         return InMemoryResourceCachesOnly;
398     }
399
400     ASSERT_NOT_REACHED();
401     return AllResourceCaches;
402 }
403
404 inline HTTPCookieAcceptPolicy toHTTPCookieAcceptPolicy(WKHTTPCookieAcceptPolicy policy)
405 {
406     switch (policy) {
407     case kWKHTTPCookieAcceptPolicyAlways:
408         return HTTPCookieAcceptPolicyAlways;
409     case kWKHTTPCookieAcceptPolicyNever:
410         return HTTPCookieAcceptPolicyNever;
411     case kWKHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain:
412         return HTTPCookieAcceptPolicyOnlyFromMainDocumentDomain;
413     case kWKHTTPCookieAcceptPolicyExclusivelyFromMainDocumentDomain:
414         return HTTPCookieAcceptPolicyExclusivelyFromMainDocumentDomain;
415     }
416
417     ASSERT_NOT_REACHED();
418     return HTTPCookieAcceptPolicyAlways;
419 }
420
421 inline WKHTTPCookieAcceptPolicy toAPI(HTTPCookieAcceptPolicy policy)
422 {
423     switch (policy) {
424     case HTTPCookieAcceptPolicyAlways:
425         return kWKHTTPCookieAcceptPolicyAlways;
426     case HTTPCookieAcceptPolicyNever:
427         return kWKHTTPCookieAcceptPolicyNever;
428     case HTTPCookieAcceptPolicyOnlyFromMainDocumentDomain:
429         return kWKHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain;
430     case HTTPCookieAcceptPolicyExclusivelyFromMainDocumentDomain:
431         return kWKHTTPCookieAcceptPolicyExclusivelyFromMainDocumentDomain;
432     }
433
434     ASSERT_NOT_REACHED();
435     return kWKHTTPCookieAcceptPolicyAlways;
436 }
437
438 inline WebCore::SecurityOrigin::StorageBlockingPolicy toStorageBlockingPolicy(WKStorageBlockingPolicy policy)
439 {
440     switch (policy) {
441     case kWKAllowAllStorage:
442         return WebCore::SecurityOrigin::AllowAllStorage;
443     case kWKBlockThirdPartyStorage:
444         return WebCore::SecurityOrigin::BlockThirdPartyStorage;
445     case kWKBlockAllStorage:
446         return WebCore::SecurityOrigin::BlockAllStorage;
447     }
448
449     ASSERT_NOT_REACHED();
450     return WebCore::SecurityOrigin::AllowAllStorage;
451 }
452
453 inline WKStorageBlockingPolicy toAPI(WebCore::SecurityOrigin::StorageBlockingPolicy policy)
454 {
455     switch (policy) {
456     case WebCore::SecurityOrigin::AllowAllStorage:
457         return kWKAllowAllStorage;
458     case WebCore::SecurityOrigin::BlockThirdPartyStorage:
459         return kWKBlockThirdPartyStorage;
460     case WebCore::SecurityOrigin::BlockAllStorage:
461         return kWKBlockAllStorage;
462     }
463
464     ASSERT_NOT_REACHED();
465     return kWKAllowAllStorage;
466 }
467
468 inline WKPluginLoadPolicy toWKPluginLoadPolicy(PluginModuleLoadPolicy pluginModuleLoadPolicy)
469 {
470     switch (pluginModuleLoadPolicy) {
471     case PluginModuleLoadNormally:
472         return kWKPluginLoadPolicyLoadNormally;
473     case PluginModuleLoadUnsandboxed:
474         return kWKPluginLoadPolicyLoadUnsandboxed;
475     case PluginModuleBlocked:
476         return kWKPluginLoadPolicyBlocked;
477     }
478     
479     ASSERT_NOT_REACHED();
480     return kWKPluginLoadPolicyBlocked;
481 }
482
483 inline PluginModuleLoadPolicy toPluginModuleLoadPolicy(WKPluginLoadPolicy pluginLoadPolicy)
484 {
485     switch (pluginLoadPolicy) {
486     case kWKPluginLoadPolicyLoadNormally:
487         return PluginModuleLoadNormally;
488     case kWKPluginLoadPolicyBlocked:
489         return PluginModuleBlocked;
490     case kWKPluginLoadPolicyLoadUnsandboxed:
491         return PluginModuleLoadUnsandboxed;
492     }
493     
494     ASSERT_NOT_REACHED();
495     return PluginModuleBlocked;
496 }
497
498 inline WebCore::WebGLLoadPolicy toWebGLLoadPolicy(WKWebGLLoadPolicy webGLLoadPolicy)
499 {
500     switch (webGLLoadPolicy) {
501     case kWKWebGLLoadPolicyLoadNormally:
502         return WebCore::WebGLAllowCreation;
503     case kWKWebGLLoadPolicyBlocked:
504         return WebCore::WebGLBlockCreation;
505     case kWKWebGLLoadPolicyPending:
506         return WebCore::WebGLPendingCreation;
507     }
508     
509     ASSERT_NOT_REACHED();
510     return WebCore::WebGLAllowCreation;
511 }
512
513 inline WKWebGLLoadPolicy toAPI(WebCore::WebGLLoadPolicy webGLLoadPolicy)
514 {
515     switch (webGLLoadPolicy) {
516     case WebCore::WebGLAllowCreation:
517         return kWKWebGLLoadPolicyLoadNormally;
518     case WebCore::WebGLBlockCreation:
519         return kWKWebGLLoadPolicyBlocked;
520     case WebCore::WebGLPendingCreation:
521         return kWKWebGLLoadPolicyPending;
522     }
523
524     ASSERT_NOT_REACHED();
525     return kWKWebGLLoadPolicyLoadNormally;
526 }
527
528 inline ProxyingRefPtr<WebGrammarDetail> toAPI(const WebCore::GrammarDetail& grammarDetail)
529 {
530     return ProxyingRefPtr<WebGrammarDetail>(WebGrammarDetail::create(grammarDetail));
531 }
532
533 } // namespace WebKit
534
535 #if defined(BUILDING_GTK__)
536 #include "WKAPICastGtk.h"
537 #endif
538
539 #if USE(SOUP)
540 #include "WKAPICastSoup.h"
541 #endif
542
543 #if defined(BUILDING_EFL__)
544 #include "WKAPICastEfl.h"
545 #endif
546
547 #endif // WKAPICast_h