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 PageConfiguration;
56 class ProcessPoolConfiguration;
63 class AuthenticationChallengeProxy;
64 class AuthenticationDecisionListener;
66 class GeolocationPermissionRequestProxy;
67 class NotificationPermissionRequest;
68 class UserMediaPermissionRequestProxy;
69 class WebApplicationCacheManagerProxy;
70 class WebBackForwardList;
71 class WebBackForwardListItem;
72 class WebBatteryManagerProxy;
73 class WebBatteryStatus;
74 class WebColorPickerResultListenerProxy;
75 class WebCookieManagerProxy;
77 class WebDatabaseManagerProxy;
78 class WebFormSubmissionListenerProxy;
79 class WebFramePolicyListenerProxy;
81 class WebGeolocationManagerProxy;
82 class WebGeolocationPosition;
83 class WebGrammarDetail;
84 class WebHitTestResult;
85 class WebIconDatabase;
86 class WebInspectorProxy;
87 class WebKeyValueStorageManager;
88 class WebMediaCacheManagerProxy;
89 class WebNotification;
90 class WebNotificationManagerProxy;
91 class WebNotificationProvider;
92 class WebOpenPanelParameters;
93 class WebOpenPanelResultListenerProxy;
94 class WebOriginDataManagerProxy;
97 class WebPluginSiteDataManager;
100 class WebProtectionSpace;
101 class WebRenderLayer;
102 class WebRenderObject;
103 class WebResourceCacheManagerProxy;
104 class WebTextChecker;
105 class WebUserContentControllerProxy;
106 class WebVibrationProxy;
107 class WebViewportAttributes;
109 WK_ADD_API_MAPPING(WKApplicationCacheManagerRef, WebApplicationCacheManagerProxy)
110 WK_ADD_API_MAPPING(WKAuthenticationChallengeRef, AuthenticationChallengeProxy)
111 WK_ADD_API_MAPPING(WKAuthenticationDecisionListenerRef, AuthenticationDecisionListener)
112 WK_ADD_API_MAPPING(WKBackForwardListItemRef, WebBackForwardListItem)
113 WK_ADD_API_MAPPING(WKBackForwardListRef, WebBackForwardList)
114 WK_ADD_API_MAPPING(WKBatteryManagerRef, WebBatteryManagerProxy)
115 WK_ADD_API_MAPPING(WKBatteryStatusRef, WebBatteryStatus)
116 WK_ADD_API_MAPPING(WKBundleHitTestResultMediaType, BundleHitTestResultMediaType)
117 WK_ADD_API_MAPPING(WKResourceCacheManagerRef, WebResourceCacheManagerProxy)
118 WK_ADD_API_MAPPING(WKColorPickerResultListenerRef, WebColorPickerResultListenerProxy)
119 WK_ADD_API_MAPPING(WKContextRef, WebProcessPool)
120 WK_ADD_API_MAPPING(WKContextConfigurationRef, API::ProcessPoolConfiguration)
121 WK_ADD_API_MAPPING(WKCookieManagerRef, WebCookieManagerProxy)
122 WK_ADD_API_MAPPING(WKCredentialRef, WebCredential)
123 WK_ADD_API_MAPPING(WKDatabaseManagerRef, WebDatabaseManagerProxy)
124 WK_ADD_API_MAPPING(WKDownloadRef, DownloadProxy)
125 WK_ADD_API_MAPPING(WKFormSubmissionListenerRef, WebFormSubmissionListenerProxy)
126 WK_ADD_API_MAPPING(WKFramePolicyListenerRef, WebFramePolicyListenerProxy)
127 WK_ADD_API_MAPPING(WKFrameRef, WebFrameProxy)
128 WK_ADD_API_MAPPING(WKGeolocationManagerRef, WebGeolocationManagerProxy)
129 WK_ADD_API_MAPPING(WKGeolocationPermissionRequestRef, GeolocationPermissionRequestProxy)
130 WK_ADD_API_MAPPING(WKGeolocationPositionRef, WebGeolocationPosition)
131 WK_ADD_API_MAPPING(WKGrammarDetailRef, WebGrammarDetail)
132 WK_ADD_API_MAPPING(WKHitTestResultRef, WebHitTestResult)
133 WK_ADD_API_MAPPING(WKIconDatabaseRef, WebIconDatabase)
134 WK_ADD_API_MAPPING(WKKeyValueStorageManagerRef, WebKeyValueStorageManager)
135 WK_ADD_API_MAPPING(WKMediaCacheManagerRef, WebMediaCacheManagerProxy)
136 WK_ADD_API_MAPPING(WKNavigationDataRef, API::NavigationData)
137 WK_ADD_API_MAPPING(WKNotificationManagerRef, WebNotificationManagerProxy)
138 WK_ADD_API_MAPPING(WKNotificationPermissionRequestRef, NotificationPermissionRequest)
139 WK_ADD_API_MAPPING(WKNotificationProviderRef, WebNotificationProvider)
140 WK_ADD_API_MAPPING(WKNotificationRef, WebNotification)
141 WK_ADD_API_MAPPING(WKOpenPanelParametersRef, WebOpenPanelParameters)
142 WK_ADD_API_MAPPING(WKOpenPanelResultListenerRef, WebOpenPanelResultListenerProxy)
143 WK_ADD_API_MAPPING(WKOriginDataManagerRef, WebOriginDataManagerProxy)
144 WK_ADD_API_MAPPING(WKPageGroupRef, WebPageGroup)
145 WK_ADD_API_MAPPING(WKPageConfigurationRef, API::PageConfiguration)
146 WK_ADD_API_MAPPING(WKPageRef, WebPageProxy)
147 WK_ADD_API_MAPPING(WKPluginSiteDataManagerRef, WebPluginSiteDataManager)
148 WK_ADD_API_MAPPING(WKPreferencesRef, WebPreferences)
149 WK_ADD_API_MAPPING(WKProtectionSpaceRef, WebProtectionSpace)
150 WK_ADD_API_MAPPING(WKRenderLayerRef, WebRenderLayer)
151 WK_ADD_API_MAPPING(WKRenderObjectRef, WebRenderObject)
152 WK_ADD_API_MAPPING(WKSessionStateRef, API::SessionState)
153 WK_ADD_API_MAPPING(WKTextCheckerRef, WebTextChecker)
154 WK_ADD_API_MAPPING(WKUserContentControllerRef, WebUserContentControllerProxy)
155 WK_ADD_API_MAPPING(WKUserMediaPermissionRequestRef, UserMediaPermissionRequestProxy)
156 WK_ADD_API_MAPPING(WKUserScriptRef, API::UserScript)
157 WK_ADD_API_MAPPING(WKVibrationRef, WebVibrationProxy)
158 WK_ADD_API_MAPPING(WKViewportAttributesRef, WebViewportAttributes)
159 WK_ADD_API_MAPPING(WKInspectorRef, WebInspectorProxy)
161 /* Enum conversions */
163 inline BundleHitTestResultMediaType toBundleHitTestResultMediaType(WKBundleHitTestResultMediaType wkMediaType)
165 switch (wkMediaType) {
166 case kWKBundleHitTestResultMediaTypeNone:
167 return BundleHitTestResultMediaTypeNone;
168 case kWKBundleHitTestResultMediaTypeAudio:
169 return BundleHitTestResultMediaTypeAudio;
170 case kWKBundleHitTestResultMediaTypeVideo:
171 return BundleHitTestResultMediaTypeVideo;
174 ASSERT_NOT_REACHED();
175 return BundleHitTestResultMediaTypeNone;
178 inline WKBundleHitTestResultMediaType toAPI(BundleHitTestResultMediaType mediaType)
181 case BundleHitTestResultMediaTypeNone:
182 return kWKBundleHitTestResultMediaTypeNone;
183 case BundleHitTestResultMediaTypeAudio:
184 return kWKBundleHitTestResultMediaTypeAudio;
185 case BundleHitTestResultMediaTypeVideo:
186 return kWKBundleHitTestResultMediaTypeVideo;
189 ASSERT_NOT_REACHED();
190 return kWKBundleHitTestResultMediaTypeNone;
193 inline CacheModel toCacheModel(WKCacheModel wkCacheModel)
195 switch (wkCacheModel) {
196 case kWKCacheModelDocumentViewer:
197 return CacheModelDocumentViewer;
198 case kWKCacheModelDocumentBrowser:
199 return CacheModelDocumentBrowser;
200 case kWKCacheModelPrimaryWebBrowser:
201 return CacheModelPrimaryWebBrowser;
204 ASSERT_NOT_REACHED();
205 return CacheModelDocumentViewer;
208 inline WKCacheModel toAPI(CacheModel cacheModel)
210 switch (cacheModel) {
211 case CacheModelDocumentViewer:
212 return kWKCacheModelDocumentViewer;
213 case CacheModelDocumentBrowser:
214 return kWKCacheModelDocumentBrowser;
215 case CacheModelPrimaryWebBrowser:
216 return kWKCacheModelPrimaryWebBrowser;
219 return kWKCacheModelDocumentViewer;
222 inline ProcessModel toProcessModel(WKProcessModel wkProcessModel)
224 switch (wkProcessModel) {
225 case kWKProcessModelSharedSecondaryProcess:
226 return ProcessModelSharedSecondaryProcess;
227 case kWKProcessModelMultipleSecondaryProcesses:
228 return ProcessModelMultipleSecondaryProcesses;
231 ASSERT_NOT_REACHED();
232 return ProcessModelSharedSecondaryProcess;
235 inline WKProcessModel toAPI(ProcessModel processModel)
237 switch (processModel) {
238 case ProcessModelSharedSecondaryProcess:
239 return kWKProcessModelSharedSecondaryProcess;
240 case ProcessModelMultipleSecondaryProcesses:
241 return kWKProcessModelMultipleSecondaryProcesses;
244 return kWKProcessModelSharedSecondaryProcess;
247 inline FontSmoothingLevel toFontSmoothingLevel(WKFontSmoothingLevel wkLevel)
250 case kWKFontSmoothingLevelNoSubpixelAntiAliasing:
251 return FontSmoothingLevelNoSubpixelAntiAliasing;
252 case kWKFontSmoothingLevelLight:
253 return FontSmoothingLevelLight;
254 case kWKFontSmoothingLevelMedium:
255 return FontSmoothingLevelMedium;
256 case kWKFontSmoothingLevelStrong:
257 return FontSmoothingLevelStrong;
260 ASSERT_NOT_REACHED();
261 return FontSmoothingLevelMedium;
265 inline WKFontSmoothingLevel toAPI(FontSmoothingLevel level)
268 case FontSmoothingLevelNoSubpixelAntiAliasing:
269 return kWKFontSmoothingLevelNoSubpixelAntiAliasing;
270 case FontSmoothingLevelLight:
271 return kWKFontSmoothingLevelLight;
272 case FontSmoothingLevelMedium:
273 return kWKFontSmoothingLevelMedium;
274 case FontSmoothingLevelStrong:
275 return kWKFontSmoothingLevelStrong;
278 ASSERT_NOT_REACHED();
279 return kWKFontSmoothingLevelMedium;
282 inline WKEditableLinkBehavior toAPI(WebCore::EditableLinkBehavior behavior)
285 case WebCore::EditableLinkDefaultBehavior:
286 return kWKEditableLinkBehaviorDefault;
287 case WebCore::EditableLinkAlwaysLive:
288 return kWKEditableLinkBehaviorAlwaysLive;
289 case WebCore::EditableLinkOnlyLiveWithShiftKey:
290 return kWKEditableLinkBehaviorOnlyLiveWithShiftKey;
291 case WebCore::EditableLinkLiveWhenNotFocused:
292 return kWKEditableLinkBehaviorLiveWhenNotFocused;
293 case WebCore::EditableLinkNeverLive:
294 return kWKEditableLinkBehaviorNeverLive;
297 ASSERT_NOT_REACHED();
298 return kWKEditableLinkBehaviorNeverLive;
301 inline WebCore::EditableLinkBehavior toEditableLinkBehavior(WKEditableLinkBehavior wkBehavior)
303 switch (wkBehavior) {
304 case kWKEditableLinkBehaviorDefault:
305 return WebCore::EditableLinkDefaultBehavior;
306 case kWKEditableLinkBehaviorAlwaysLive:
307 return WebCore::EditableLinkAlwaysLive;
308 case kWKEditableLinkBehaviorOnlyLiveWithShiftKey:
309 return WebCore::EditableLinkOnlyLiveWithShiftKey;
310 case kWKEditableLinkBehaviorLiveWhenNotFocused:
311 return WebCore::EditableLinkLiveWhenNotFocused;
312 case kWKEditableLinkBehaviorNeverLive:
313 return WebCore::EditableLinkNeverLive;
316 ASSERT_NOT_REACHED();
317 return WebCore::EditableLinkNeverLive;
320 inline WKProtectionSpaceServerType toAPI(WebCore::ProtectionSpaceServerType type)
323 case WebCore::ProtectionSpaceServerHTTP:
324 return kWKProtectionSpaceServerTypeHTTP;
325 case WebCore::ProtectionSpaceServerHTTPS:
326 return kWKProtectionSpaceServerTypeHTTPS;
327 case WebCore::ProtectionSpaceServerFTP:
328 return kWKProtectionSpaceServerTypeFTP;
329 case WebCore::ProtectionSpaceServerFTPS:
330 return kWKProtectionSpaceServerTypeFTPS;
331 case WebCore::ProtectionSpaceProxyHTTP:
332 return kWKProtectionSpaceProxyTypeHTTP;
333 case WebCore::ProtectionSpaceProxyHTTPS:
334 return kWKProtectionSpaceProxyTypeHTTPS;
335 case WebCore::ProtectionSpaceProxyFTP:
336 return kWKProtectionSpaceProxyTypeFTP;
337 case WebCore::ProtectionSpaceProxySOCKS:
338 return kWKProtectionSpaceProxyTypeSOCKS;
340 return kWKProtectionSpaceServerTypeHTTP;
343 inline WKProtectionSpaceAuthenticationScheme toAPI(WebCore::ProtectionSpaceAuthenticationScheme type)
346 case WebCore::ProtectionSpaceAuthenticationSchemeDefault:
347 return kWKProtectionSpaceAuthenticationSchemeDefault;
348 case WebCore::ProtectionSpaceAuthenticationSchemeHTTPBasic:
349 return kWKProtectionSpaceAuthenticationSchemeHTTPBasic;
350 case WebCore::ProtectionSpaceAuthenticationSchemeHTTPDigest:
351 return kWKProtectionSpaceAuthenticationSchemeHTTPDigest;
352 case WebCore::ProtectionSpaceAuthenticationSchemeHTMLForm:
353 return kWKProtectionSpaceAuthenticationSchemeHTMLForm;
354 case WebCore::ProtectionSpaceAuthenticationSchemeNTLM:
355 return kWKProtectionSpaceAuthenticationSchemeNTLM;
356 case WebCore::ProtectionSpaceAuthenticationSchemeNegotiate:
357 return kWKProtectionSpaceAuthenticationSchemeNegotiate;
358 case WebCore::ProtectionSpaceAuthenticationSchemeClientCertificateRequested:
359 return kWKProtectionSpaceAuthenticationSchemeClientCertificateRequested;
360 case WebCore::ProtectionSpaceAuthenticationSchemeServerTrustEvaluationRequested:
361 return kWKProtectionSpaceAuthenticationSchemeServerTrustEvaluationRequested;
363 return kWKProtectionSpaceAuthenticationSchemeUnknown;
367 inline WebCore::CredentialPersistence toCredentialPersistence(WKCredentialPersistence type)
370 case kWKCredentialPersistenceNone:
371 return WebCore::CredentialPersistenceNone;
372 case kWKCredentialPersistenceForSession:
373 return WebCore::CredentialPersistenceForSession;
374 case kWKCredentialPersistencePermanent:
375 return WebCore::CredentialPersistencePermanent;
377 return WebCore::CredentialPersistenceNone;
381 inline ResourceCachesToClear toResourceCachesToClear(WKResourceCachesToClear wkResourceCachesToClear)
383 switch (wkResourceCachesToClear) {
384 case WKResourceCachesToClearAll:
385 return AllResourceCaches;
386 case WKResourceCachesToClearInMemoryOnly:
387 return InMemoryResourceCachesOnly;
390 ASSERT_NOT_REACHED();
391 return AllResourceCaches;
394 inline HTTPCookieAcceptPolicy toHTTPCookieAcceptPolicy(WKHTTPCookieAcceptPolicy policy)
397 case kWKHTTPCookieAcceptPolicyAlways:
398 return HTTPCookieAcceptPolicyAlways;
399 case kWKHTTPCookieAcceptPolicyNever:
400 return HTTPCookieAcceptPolicyNever;
401 case kWKHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain:
402 return HTTPCookieAcceptPolicyOnlyFromMainDocumentDomain;
403 case kWKHTTPCookieAcceptPolicyExclusivelyFromMainDocumentDomain:
404 return HTTPCookieAcceptPolicyExclusivelyFromMainDocumentDomain;
407 ASSERT_NOT_REACHED();
408 return HTTPCookieAcceptPolicyAlways;
411 inline WKHTTPCookieAcceptPolicy toAPI(HTTPCookieAcceptPolicy policy)
414 case HTTPCookieAcceptPolicyAlways:
415 return kWKHTTPCookieAcceptPolicyAlways;
416 case HTTPCookieAcceptPolicyNever:
417 return kWKHTTPCookieAcceptPolicyNever;
418 case HTTPCookieAcceptPolicyOnlyFromMainDocumentDomain:
419 return kWKHTTPCookieAcceptPolicyOnlyFromMainDocumentDomain;
420 case HTTPCookieAcceptPolicyExclusivelyFromMainDocumentDomain:
421 return kWKHTTPCookieAcceptPolicyExclusivelyFromMainDocumentDomain;
424 ASSERT_NOT_REACHED();
425 return kWKHTTPCookieAcceptPolicyAlways;
428 inline WebCore::SecurityOrigin::StorageBlockingPolicy toStorageBlockingPolicy(WKStorageBlockingPolicy policy)
431 case kWKAllowAllStorage:
432 return WebCore::SecurityOrigin::AllowAllStorage;
433 case kWKBlockThirdPartyStorage:
434 return WebCore::SecurityOrigin::BlockThirdPartyStorage;
435 case kWKBlockAllStorage:
436 return WebCore::SecurityOrigin::BlockAllStorage;
439 ASSERT_NOT_REACHED();
440 return WebCore::SecurityOrigin::AllowAllStorage;
443 inline WKStorageBlockingPolicy toAPI(WebCore::SecurityOrigin::StorageBlockingPolicy policy)
446 case WebCore::SecurityOrigin::AllowAllStorage:
447 return kWKAllowAllStorage;
448 case WebCore::SecurityOrigin::BlockThirdPartyStorage:
449 return kWKBlockThirdPartyStorage;
450 case WebCore::SecurityOrigin::BlockAllStorage:
451 return kWKBlockAllStorage;
454 ASSERT_NOT_REACHED();
455 return kWKAllowAllStorage;
458 inline WKPluginLoadPolicy toWKPluginLoadPolicy(PluginModuleLoadPolicy pluginModuleLoadPolicy)
460 switch (pluginModuleLoadPolicy) {
461 case PluginModuleLoadNormally:
462 return kWKPluginLoadPolicyLoadNormally;
463 case PluginModuleLoadUnsandboxed:
464 return kWKPluginLoadPolicyLoadUnsandboxed;
465 case PluginModuleBlocked:
466 return kWKPluginLoadPolicyBlocked;
469 ASSERT_NOT_REACHED();
470 return kWKPluginLoadPolicyBlocked;
473 inline PluginModuleLoadPolicy toPluginModuleLoadPolicy(WKPluginLoadPolicy pluginLoadPolicy)
475 switch (pluginLoadPolicy) {
476 case kWKPluginLoadPolicyLoadNormally:
477 return PluginModuleLoadNormally;
478 case kWKPluginLoadPolicyBlocked:
479 return PluginModuleBlocked;
480 case kWKPluginLoadPolicyLoadUnsandboxed:
481 return PluginModuleLoadUnsandboxed;
484 ASSERT_NOT_REACHED();
485 return PluginModuleBlocked;
488 inline WebCore::WebGLLoadPolicy toWebGLLoadPolicy(WKWebGLLoadPolicy webGLLoadPolicy)
490 switch (webGLLoadPolicy) {
491 case kWKWebGLLoadPolicyLoadNormally:
492 return WebCore::WebGLAllowCreation;
493 case kWKWebGLLoadPolicyBlocked:
494 return WebCore::WebGLBlockCreation;
495 case kWKWebGLLoadPolicyPending:
496 return WebCore::WebGLPendingCreation;
499 ASSERT_NOT_REACHED();
500 return WebCore::WebGLAllowCreation;
503 inline WKWebGLLoadPolicy toAPI(WebCore::WebGLLoadPolicy webGLLoadPolicy)
505 switch (webGLLoadPolicy) {
506 case WebCore::WebGLAllowCreation:
507 return kWKWebGLLoadPolicyLoadNormally;
508 case WebCore::WebGLBlockCreation:
509 return kWKWebGLLoadPolicyBlocked;
510 case WebCore::WebGLPendingCreation:
511 return kWKWebGLLoadPolicyPending;
514 ASSERT_NOT_REACHED();
515 return kWKWebGLLoadPolicyLoadNormally;
518 inline ProxyingRefPtr<WebGrammarDetail> toAPI(const WebCore::GrammarDetail& grammarDetail)
520 return ProxyingRefPtr<WebGrammarDetail>(WebGrammarDetail::create(grammarDetail));
523 } // namespace WebKit
525 #if defined(BUILDING_GTK__)
526 #include "WKAPICastGtk.h"
530 #include "WKAPICastSoup.h"
533 #if defined(BUILDING_EFL__)
534 #include "WKAPICastEfl.h"
537 #endif // WKAPICast_h