2 * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
3 * Portions Copyright (c) 2010 Motorola Mobility, Inc. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
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.
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.
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"
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>
55 class ProcessPoolConfiguration;
61 class AuthenticationChallengeProxy;
62 class AuthenticationDecisionListener;
64 class GeolocationPermissionRequestProxy;
65 class NotificationPermissionRequest;
66 class UserMediaPermissionRequestProxy;
67 class WebApplicationCacheManagerProxy;
68 class WebBackForwardList;
69 class WebBackForwardListItem;
70 class WebBatteryManagerProxy;
71 class WebBatteryStatus;
72 class WebResourceCacheManagerProxy;
73 class WebColorPickerResultListenerProxy;
74 class WebCookieManagerProxy;
76 class WebDatabaseManagerProxy;
77 class WebFormSubmissionListenerProxy;
78 class WebFramePolicyListenerProxy;
80 class WebGeolocationManagerProxy;
81 class WebGeolocationPosition;
82 class WebGrammarDetail;
83 class WebHitTestResult;
84 class WebIconDatabase;
85 class WebInspectorProxy;
86 class WebKeyValueStorageManager;
87 class WebMediaCacheManagerProxy;
88 class WebNotification;
89 class WebNotificationProvider;
90 class WebNotificationManagerProxy;
91 class WebOpenPanelParameters;
92 class WebOpenPanelResultListenerProxy;
93 class WebOriginDataManagerProxy;
96 class WebPluginSiteDataManager;
99 class WebProtectionSpace;
100 class WebRenderLayer;
101 class WebRenderObject;
102 class WebTextChecker;
103 class WebVibrationProxy;
104 class WebViewportAttributes;
106 WK_ADD_API_MAPPING(WKApplicationCacheManagerRef, WebApplicationCacheManagerProxy)
107 WK_ADD_API_MAPPING(WKAuthenticationChallengeRef, AuthenticationChallengeProxy)
108 WK_ADD_API_MAPPING(WKAuthenticationDecisionListenerRef, AuthenticationDecisionListener)
109 WK_ADD_API_MAPPING(WKBackForwardListItemRef, WebBackForwardListItem)
110 WK_ADD_API_MAPPING(WKBackForwardListRef, WebBackForwardList)
111 WK_ADD_API_MAPPING(WKBatteryManagerRef, WebBatteryManagerProxy)
112 WK_ADD_API_MAPPING(WKBatteryStatusRef, WebBatteryStatus)
113 WK_ADD_API_MAPPING(WKBundleHitTestResultMediaType, BundleHitTestResultMediaType)
114 WK_ADD_API_MAPPING(WKResourceCacheManagerRef, WebResourceCacheManagerProxy)
115 WK_ADD_API_MAPPING(WKColorPickerResultListenerRef, WebColorPickerResultListenerProxy)
116 WK_ADD_API_MAPPING(WKContextRef, WebProcessPool)
117 WK_ADD_API_MAPPING(WKContextConfigurationRef, API::ProcessPoolConfiguration)
118 WK_ADD_API_MAPPING(WKCookieManagerRef, WebCookieManagerProxy)
119 WK_ADD_API_MAPPING(WKCredentialRef, WebCredential)
120 WK_ADD_API_MAPPING(WKDatabaseManagerRef, WebDatabaseManagerProxy)
121 WK_ADD_API_MAPPING(WKDownloadRef, DownloadProxy)
122 WK_ADD_API_MAPPING(WKFormSubmissionListenerRef, WebFormSubmissionListenerProxy)
123 WK_ADD_API_MAPPING(WKFramePolicyListenerRef, WebFramePolicyListenerProxy)
124 WK_ADD_API_MAPPING(WKFrameRef, WebFrameProxy)
125 WK_ADD_API_MAPPING(WKGeolocationManagerRef, WebGeolocationManagerProxy)
126 WK_ADD_API_MAPPING(WKGeolocationPermissionRequestRef, GeolocationPermissionRequestProxy)
127 WK_ADD_API_MAPPING(WKGeolocationPositionRef, WebGeolocationPosition)
128 WK_ADD_API_MAPPING(WKGrammarDetailRef, WebGrammarDetail)
129 WK_ADD_API_MAPPING(WKHitTestResultRef, WebHitTestResult)
130 WK_ADD_API_MAPPING(WKIconDatabaseRef, WebIconDatabase)
131 WK_ADD_API_MAPPING(WKKeyValueStorageManagerRef, WebKeyValueStorageManager)
132 WK_ADD_API_MAPPING(WKMediaCacheManagerRef, WebMediaCacheManagerProxy)
133 WK_ADD_API_MAPPING(WKNavigationDataRef, API::NavigationData)
134 WK_ADD_API_MAPPING(WKNotificationManagerRef, WebNotificationManagerProxy)
135 WK_ADD_API_MAPPING(WKNotificationPermissionRequestRef, NotificationPermissionRequest)
136 WK_ADD_API_MAPPING(WKNotificationProviderRef, WebNotificationProvider)
137 WK_ADD_API_MAPPING(WKNotificationRef, WebNotification)
138 WK_ADD_API_MAPPING(WKOpenPanelParametersRef, WebOpenPanelParameters)
139 WK_ADD_API_MAPPING(WKOpenPanelResultListenerRef, WebOpenPanelResultListenerProxy)
140 WK_ADD_API_MAPPING(WKOriginDataManagerRef, WebOriginDataManagerProxy)
141 WK_ADD_API_MAPPING(WKPageGroupRef, WebPageGroup)
142 WK_ADD_API_MAPPING(WKPageRef, WebPageProxy)
143 WK_ADD_API_MAPPING(WKPluginSiteDataManagerRef, WebPluginSiteDataManager)
144 WK_ADD_API_MAPPING(WKPreferencesRef, WebPreferences)
145 WK_ADD_API_MAPPING(WKProtectionSpaceRef, WebProtectionSpace)
146 WK_ADD_API_MAPPING(WKRenderLayerRef, WebRenderLayer)
147 WK_ADD_API_MAPPING(WKRenderObjectRef, WebRenderObject)
148 WK_ADD_API_MAPPING(WKSessionStateRef, API::SessionState)
149 WK_ADD_API_MAPPING(WKTextCheckerRef, WebTextChecker)
150 WK_ADD_API_MAPPING(WKUserMediaPermissionRequestRef, UserMediaPermissionRequestProxy)
151 WK_ADD_API_MAPPING(WKVibrationRef, WebVibrationProxy)
152 WK_ADD_API_MAPPING(WKViewportAttributesRef, WebViewportAttributes)
153 WK_ADD_API_MAPPING(WKInspectorRef, WebInspectorProxy)
155 /* Enum conversions */
157 inline BundleHitTestResultMediaType toBundleHitTestResultMediaType(WKBundleHitTestResultMediaType wkMediaType)
159 switch (wkMediaType) {
160 case kWKBundleHitTestResultMediaTypeNone:
161 return BundleHitTestResultMediaTypeNone;
162 case kWKBundleHitTestResultMediaTypeAudio:
163 return BundleHitTestResultMediaTypeAudio;
164 case kWKBundleHitTestResultMediaTypeVideo:
165 return BundleHitTestResultMediaTypeVideo;
168 ASSERT_NOT_REACHED();
169 return BundleHitTestResultMediaTypeNone;
172 inline WKBundleHitTestResultMediaType toAPI(BundleHitTestResultMediaType mediaType)
175 case BundleHitTestResultMediaTypeNone:
176 return kWKBundleHitTestResultMediaTypeNone;
177 case BundleHitTestResultMediaTypeAudio:
178 return kWKBundleHitTestResultMediaTypeAudio;
179 case BundleHitTestResultMediaTypeVideo:
180 return kWKBundleHitTestResultMediaTypeVideo;
183 ASSERT_NOT_REACHED();
184 return kWKBundleHitTestResultMediaTypeNone;
187 inline CacheModel toCacheModel(WKCacheModel wkCacheModel)
189 switch (wkCacheModel) {
190 case kWKCacheModelDocumentViewer:
191 return CacheModelDocumentViewer;
192 case kWKCacheModelDocumentBrowser:
193 return CacheModelDocumentBrowser;
194 case kWKCacheModelPrimaryWebBrowser:
195 return CacheModelPrimaryWebBrowser;
198 ASSERT_NOT_REACHED();
199 return CacheModelDocumentViewer;
202 inline WKCacheModel toAPI(CacheModel cacheModel)
204 switch (cacheModel) {
205 case CacheModelDocumentViewer:
206 return kWKCacheModelDocumentViewer;
207 case CacheModelDocumentBrowser:
208 return kWKCacheModelDocumentBrowser;
209 case CacheModelPrimaryWebBrowser:
210 return kWKCacheModelPrimaryWebBrowser;
213 return kWKCacheModelDocumentViewer;
216 inline ProcessModel toProcessModel(WKProcessModel wkProcessModel)
218 switch (wkProcessModel) {
219 case kWKProcessModelSharedSecondaryProcess:
220 return ProcessModelSharedSecondaryProcess;
221 case kWKProcessModelMultipleSecondaryProcesses:
222 return ProcessModelMultipleSecondaryProcesses;
225 ASSERT_NOT_REACHED();
226 return ProcessModelSharedSecondaryProcess;
229 inline WKProcessModel toAPI(ProcessModel processModel)
231 switch (processModel) {
232 case ProcessModelSharedSecondaryProcess:
233 return kWKProcessModelSharedSecondaryProcess;
234 case ProcessModelMultipleSecondaryProcesses:
235 return kWKProcessModelMultipleSecondaryProcesses;
238 return kWKProcessModelSharedSecondaryProcess;
241 inline FontSmoothingLevel toFontSmoothingLevel(WKFontSmoothingLevel wkLevel)
244 case kWKFontSmoothingLevelNoSubpixelAntiAliasing:
245 return FontSmoothingLevelNoSubpixelAntiAliasing;
246 case kWKFontSmoothingLevelLight:
247 return FontSmoothingLevelLight;
248 case kWKFontSmoothingLevelMedium:
249 return FontSmoothingLevelMedium;
250 case kWKFontSmoothingLevelStrong:
251 return FontSmoothingLevelStrong;
254 ASSERT_NOT_REACHED();
255 return FontSmoothingLevelMedium;
259 inline WKFontSmoothingLevel toAPI(FontSmoothingLevel level)
262 case FontSmoothingLevelNoSubpixelAntiAliasing:
263 return kWKFontSmoothingLevelNoSubpixelAntiAliasing;
264 case FontSmoothingLevelLight:
265 return kWKFontSmoothingLevelLight;
266 case FontSmoothingLevelMedium:
267 return kWKFontSmoothingLevelMedium;
268 case FontSmoothingLevelStrong:
269 return kWKFontSmoothingLevelStrong;
272 ASSERT_NOT_REACHED();
273 return kWKFontSmoothingLevelMedium;
276 inline WKEditableLinkBehavior toAPI(WebCore::EditableLinkBehavior behavior)
279 case WebCore::EditableLinkDefaultBehavior:
280 return kWKEditableLinkBehaviorDefault;
281 case WebCore::EditableLinkAlwaysLive:
282 return kWKEditableLinkBehaviorAlwaysLive;
283 case WebCore::EditableLinkOnlyLiveWithShiftKey:
284 return kWKEditableLinkBehaviorOnlyLiveWithShiftKey;
285 case WebCore::EditableLinkLiveWhenNotFocused:
286 return kWKEditableLinkBehaviorLiveWhenNotFocused;
287 case WebCore::EditableLinkNeverLive:
288 return kWKEditableLinkBehaviorNeverLive;
291 ASSERT_NOT_REACHED();
292 return kWKEditableLinkBehaviorNeverLive;
295 inline WebCore::EditableLinkBehavior toEditableLinkBehavior(WKEditableLinkBehavior wkBehavior)
297 switch (wkBehavior) {
298 case kWKEditableLinkBehaviorDefault:
299 return WebCore::EditableLinkDefaultBehavior;
300 case kWKEditableLinkBehaviorAlwaysLive:
301 return WebCore::EditableLinkAlwaysLive;
302 case kWKEditableLinkBehaviorOnlyLiveWithShiftKey:
303 return WebCore::EditableLinkOnlyLiveWithShiftKey;
304 case kWKEditableLinkBehaviorLiveWhenNotFocused:
305 return WebCore::EditableLinkLiveWhenNotFocused;
306 case kWKEditableLinkBehaviorNeverLive:
307 return WebCore::EditableLinkNeverLive;
310 ASSERT_NOT_REACHED();
311 return WebCore::EditableLinkNeverLive;
314 inline WKProtectionSpaceServerType toAPI(WebCore::ProtectionSpaceServerType type)
317 case WebCore::ProtectionSpaceServerHTTP:
318 return kWKProtectionSpaceServerTypeHTTP;
319 case WebCore::ProtectionSpaceServerHTTPS:
320 return kWKProtectionSpaceServerTypeHTTPS;
321 case WebCore::ProtectionSpaceServerFTP:
322 return kWKProtectionSpaceServerTypeFTP;
323 case WebCore::ProtectionSpaceServerFTPS:
324 return kWKProtectionSpaceServerTypeFTPS;
325 case WebCore::ProtectionSpaceProxyHTTP:
326 return kWKProtectionSpaceProxyTypeHTTP;
327 case WebCore::ProtectionSpaceProxyHTTPS:
328 return kWKProtectionSpaceProxyTypeHTTPS;
329 case WebCore::ProtectionSpaceProxyFTP:
330 return kWKProtectionSpaceProxyTypeFTP;
331 case WebCore::ProtectionSpaceProxySOCKS:
332 return kWKProtectionSpaceProxyTypeSOCKS;
334 return kWKProtectionSpaceServerTypeHTTP;
337 inline WKProtectionSpaceAuthenticationScheme toAPI(WebCore::ProtectionSpaceAuthenticationScheme type)
340 case WebCore::ProtectionSpaceAuthenticationSchemeDefault:
341 return kWKProtectionSpaceAuthenticationSchemeDefault;
342 case WebCore::ProtectionSpaceAuthenticationSchemeHTTPBasic:
343 return kWKProtectionSpaceAuthenticationSchemeHTTPBasic;
344 case WebCore::ProtectionSpaceAuthenticationSchemeHTTPDigest:
345 return kWKProtectionSpaceAuthenticationSchemeHTTPDigest;
346 case WebCore::ProtectionSpaceAuthenticationSchemeHTMLForm:
347 return kWKProtectionSpaceAuthenticationSchemeHTMLForm;
348 case WebCore::ProtectionSpaceAuthenticationSchemeNTLM:
349 return kWKProtectionSpaceAuthenticationSchemeNTLM;
350 case WebCore::ProtectionSpaceAuthenticationSchemeNegotiate:
351 return kWKProtectionSpaceAuthenticationSchemeNegotiate;
352 case WebCore::ProtectionSpaceAuthenticationSchemeClientCertificateRequested:
353 return kWKProtectionSpaceAuthenticationSchemeClientCertificateRequested;
354 case WebCore::ProtectionSpaceAuthenticationSchemeServerTrustEvaluationRequested:
355 return kWKProtectionSpaceAuthenticationSchemeServerTrustEvaluationRequested;
357 return kWKProtectionSpaceAuthenticationSchemeUnknown;
361 inline WebCore::CredentialPersistence toCredentialPersistence(WKCredentialPersistence type)
364 case kWKCredentialPersistenceNone:
365 return WebCore::CredentialPersistenceNone;
366 case kWKCredentialPersistenceForSession:
367 return WebCore::CredentialPersistenceForSession;
368 case kWKCredentialPersistencePermanent:
369 return WebCore::CredentialPersistencePermanent;
371 return WebCore::CredentialPersistenceNone;
375 inline ResourceCachesToClear toResourceCachesToClear(WKResourceCachesToClear wkResourceCachesToClear)
377 switch (wkResourceCachesToClear) {
378 case WKResourceCachesToClearAll:
379 return AllResourceCaches;
380 case WKResourceCachesToClearInMemoryOnly:
381 return InMemoryResourceCachesOnly;
384 ASSERT_NOT_REACHED();
385 return AllResourceCaches;
388 inline HTTPCookieAcceptPolicy toHTTPCookieAcceptPolicy(WKHTTPCookieAcceptPolicy policy)
391 case kWKHTTPCookieAcceptPolicyAlways:
392 return HTTPCookieAcceptPolicyAlways;
393 case kWKHTTPCookieAcceptPolicyNever:
394 return HTTPCookieAcceptPolicyNever;
395 case kWKHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain:
396 return HTTPCookieAcceptPolicyOnlyFromMainDocumentDomain;
397 case kWKHTTPCookieAcceptPolicyExclusivelyFromMainDocumentDomain:
398 return HTTPCookieAcceptPolicyExclusivelyFromMainDocumentDomain;
401 ASSERT_NOT_REACHED();
402 return HTTPCookieAcceptPolicyAlways;
405 inline WKHTTPCookieAcceptPolicy toAPI(HTTPCookieAcceptPolicy policy)
408 case HTTPCookieAcceptPolicyAlways:
409 return kWKHTTPCookieAcceptPolicyAlways;
410 case HTTPCookieAcceptPolicyNever:
411 return kWKHTTPCookieAcceptPolicyNever;
412 case HTTPCookieAcceptPolicyOnlyFromMainDocumentDomain:
413 return kWKHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain;
414 case HTTPCookieAcceptPolicyExclusivelyFromMainDocumentDomain:
415 return kWKHTTPCookieAcceptPolicyExclusivelyFromMainDocumentDomain;
418 ASSERT_NOT_REACHED();
419 return kWKHTTPCookieAcceptPolicyAlways;
422 inline WebCore::SecurityOrigin::StorageBlockingPolicy toStorageBlockingPolicy(WKStorageBlockingPolicy policy)
425 case kWKAllowAllStorage:
426 return WebCore::SecurityOrigin::AllowAllStorage;
427 case kWKBlockThirdPartyStorage:
428 return WebCore::SecurityOrigin::BlockThirdPartyStorage;
429 case kWKBlockAllStorage:
430 return WebCore::SecurityOrigin::BlockAllStorage;
433 ASSERT_NOT_REACHED();
434 return WebCore::SecurityOrigin::AllowAllStorage;
437 inline WKStorageBlockingPolicy toAPI(WebCore::SecurityOrigin::StorageBlockingPolicy policy)
440 case WebCore::SecurityOrigin::AllowAllStorage:
441 return kWKAllowAllStorage;
442 case WebCore::SecurityOrigin::BlockThirdPartyStorage:
443 return kWKBlockThirdPartyStorage;
444 case WebCore::SecurityOrigin::BlockAllStorage:
445 return kWKBlockAllStorage;
448 ASSERT_NOT_REACHED();
449 return kWKAllowAllStorage;
452 inline WKPluginLoadPolicy toWKPluginLoadPolicy(PluginModuleLoadPolicy pluginModuleLoadPolicy)
454 switch (pluginModuleLoadPolicy) {
455 case PluginModuleLoadNormally:
456 return kWKPluginLoadPolicyLoadNormally;
457 case PluginModuleLoadUnsandboxed:
458 return kWKPluginLoadPolicyLoadUnsandboxed;
459 case PluginModuleBlocked:
460 return kWKPluginLoadPolicyBlocked;
463 ASSERT_NOT_REACHED();
464 return kWKPluginLoadPolicyBlocked;
467 inline PluginModuleLoadPolicy toPluginModuleLoadPolicy(WKPluginLoadPolicy pluginLoadPolicy)
469 switch (pluginLoadPolicy) {
470 case kWKPluginLoadPolicyLoadNormally:
471 return PluginModuleLoadNormally;
472 case kWKPluginLoadPolicyBlocked:
473 return PluginModuleBlocked;
474 case kWKPluginLoadPolicyLoadUnsandboxed:
475 return PluginModuleLoadUnsandboxed;
478 ASSERT_NOT_REACHED();
479 return PluginModuleBlocked;
482 inline WebCore::WebGLLoadPolicy toWebGLLoadPolicy(WKWebGLLoadPolicy webGLLoadPolicy)
484 switch (webGLLoadPolicy) {
485 case kWKWebGLLoadPolicyLoadNormally:
486 return WebCore::WebGLAllowCreation;
487 case kWKWebGLLoadPolicyBlocked:
488 return WebCore::WebGLBlockCreation;
489 case kWKWebGLLoadPolicyPending:
490 return WebCore::WebGLPendingCreation;
493 ASSERT_NOT_REACHED();
494 return WebCore::WebGLAllowCreation;
497 inline WKWebGLLoadPolicy toAPI(WebCore::WebGLLoadPolicy webGLLoadPolicy)
499 switch (webGLLoadPolicy) {
500 case WebCore::WebGLAllowCreation:
501 return kWKWebGLLoadPolicyLoadNormally;
502 case WebCore::WebGLBlockCreation:
503 return kWKWebGLLoadPolicyBlocked;
504 case WebCore::WebGLPendingCreation:
505 return kWKWebGLLoadPolicyPending;
508 ASSERT_NOT_REACHED();
509 return kWKWebGLLoadPolicyLoadNormally;
512 inline ProxyingRefPtr<WebGrammarDetail> toAPI(const WebCore::GrammarDetail& grammarDetail)
514 return ProxyingRefPtr<WebGrammarDetail>(WebGrammarDetail::create(grammarDetail));
517 } // namespace WebKit
519 #if defined(BUILDING_GTK__)
520 #include "WKAPICastGtk.h"
524 #include "WKAPICastSoup.h"
527 #if defined(BUILDING_EFL__)
528 #include "WKAPICastEfl.h"
531 #endif // WKAPICast_h