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