Add support for reporting "display composited video frames" through the VideoPlayback...
[WebKit-https.git] / Source / WebKit / UIProcess / API / Cocoa / WKPreferences.mm
index 186a171..e00b3bf 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014-2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2014-2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 #if WK_API_ENABLED
 
 #import "APIArray.h"
+#import "PluginProcessManager.h"
 #import "WKNSArray.h"
 #import "WebPreferences.h"
-#import "_WKExperimentalFeature.h"
 #import "_WKExperimentalFeatureInternal.h"
+#import "_WKInternalDebugFeatureInternal.h"
 #import <WebCore/SecurityOrigin.h>
 #import <WebCore/Settings.h>
 #import <wtf/RetainPtr.h>
     [super dealloc];
 }
 
++ (BOOL)supportsSecureCoding
+{
+    return YES;
+}
+
 // FIXME: We currently only encode/decode API preferences. We should consider whether we should
 // encode/decode SPI preferences as well.
 
@@ -91,7 +97,7 @@
 
 - (id)copyWithZone:(NSZone *)zone
 {
-    return wrapper(_preferences->copy().leakRef());
+    return [wrapper(_preferences->copy()) retain];
 }
 
 - (CGFloat)minimumFontSize
     _preferences->setJavaScriptCanOpenWindowsAutomatically(javaScriptCanOpenWindowsAutomatically);
 }
 
+- (BOOL)_storageAccessPromptsEnabled
+{
+    return _preferences->storageAccessPromptsEnabled();
+}
+
+- (void)_setStorageAccessPromptsEnabled:(BOOL)enabled
+{
+    _preferences->setStorageAccessPromptsEnabled(enabled);
+}
+
 #pragma mark OS X-specific methods
 
 #if PLATFORM(MAC)
@@ -511,20 +527,48 @@ static _WKStorageBlockingPolicy toAPI(WebCore::SecurityOrigin::StorageBlockingPo
     _preferences->setFixedFontFamily(fixedPitchFontFamily);
 }
 
++ (NSArray<_WKInternalDebugFeature *> *)_internalDebugFeatures
+{
+    auto features = WebKit::WebPreferences::internalDebugFeatures();
+    return wrapper(API::Array::create(WTFMove(features)));
+}
+
+- (BOOL)_isEnabledForInternalDebugFeature:(_WKInternalDebugFeature *)feature
+{
+    return _preferences->isFeatureEnabled(*feature->_internalDebugFeature);
+}
+
+- (void)_setEnabled:(BOOL)value forInternalDebugFeature:(_WKInternalDebugFeature *)feature
+{
+    _preferences->setFeatureEnabled(*feature->_internalDebugFeature, value);
+}
+
 + (NSArray<_WKExperimentalFeature *> *)_experimentalFeatures
 {
     auto features = WebKit::WebPreferences::experimentalFeatures();
-    return [wrapper(API::Array::create(WTFMove(features)).leakRef()) autorelease];
+    return wrapper(API::Array::create(WTFMove(features)));
 }
 
+// FIXME: Remove this once Safari has adopted the new API.
 - (BOOL)_isEnabledForFeature:(_WKExperimentalFeature *)feature
 {
-    return _preferences->isEnabledForFeature(*feature->_experimentalFeature);
+    return [self _isEnabledForExperimentalFeature:feature];
 }
 
+// FIXME: Remove this once Safari has adopted the new API.
 - (void)_setEnabled:(BOOL)value forFeature:(_WKExperimentalFeature *)feature
 {
-    _preferences->setEnabledForFeature(value, *feature->_experimentalFeature);
+    [self _setEnabled:value forExperimentalFeature:feature];
+}
+
+- (BOOL)_isEnabledForExperimentalFeature:(_WKExperimentalFeature *)feature
+{
+    return _preferences->isFeatureEnabled(*feature->_experimentalFeature);
+}
+
+- (void)_setEnabled:(BOOL)value forExperimentalFeature:(_WKExperimentalFeature *)feature
+{
+    _preferences->setFeatureEnabled(*feature->_experimentalFeature, value);
 }
 
 - (BOOL)_applePayCapabilityDisclosureAllowed
@@ -655,12 +699,11 @@ static _WKStorageBlockingPolicy toAPI(WebCore::SecurityOrigin::StorageBlockingPo
 
 - (BOOL)_webRTCLegacyAPIEnabled
 {
-    return !_preferences->webRTCLegacyAPIDisabled();
+    return NO;
 }
 
 - (void)_setWebRTCLegacyAPIEnabled:(BOOL)enabled
 {
-    _preferences->setWebRTCLegacyAPIDisabled(!enabled);
 }
 
 - (void)_setJavaScriptCanAccessClipboard:(BOOL)javaScriptCanAccessClipboard
@@ -726,6 +769,56 @@ static WebCore::EditableLinkBehavior toEditableLinkBehavior(_WKEditableLinkBehav
     _preferences->setEditableLinkBehavior(toEditableLinkBehavior(editableLinkBehavior));
 }
 
+- (void)_setAVFoundationEnabled:(BOOL)enabled
+{
+    _preferences->setAVFoundationEnabled(enabled);
+}
+
+- (BOOL)_avFoundationEnabled
+{
+    return _preferences->isAVFoundationEnabled();
+}
+
+- (void)_setColorFilterEnabled:(BOOL)enabled
+{
+    _preferences->setColorFilterEnabled(enabled);
+}
+
+- (BOOL)_colorFilterEnabled
+{
+    return _preferences->colorFilterEnabled();
+}
+
+- (void)_setPunchOutWhiteBackgroundsInDarkMode:(BOOL)punches
+{
+    _preferences->setPunchOutWhiteBackgroundsInDarkMode(punches);
+}
+
+- (BOOL)_punchOutWhiteBackgroundsInDarkMode
+{
+    return _preferences->punchOutWhiteBackgroundsInDarkMode();
+}
+
+- (void)_setLowPowerVideoAudioBufferSizeEnabled:(BOOL)enabled
+{
+    _preferences->setLowPowerVideoAudioBufferSizeEnabled(enabled);
+}
+
+- (BOOL)_lowPowerVideoAudioBufferSizeEnabled
+{
+    return _preferences->lowPowerVideoAudioBufferSizeEnabled();
+}
+
+- (void)_setShouldIgnoreMetaViewport:(BOOL)ignoreMetaViewport
+{
+    return _preferences->setShouldIgnoreMetaViewport(ignoreMetaViewport);
+}
+
+- (BOOL)_shouldIgnoreMetaViewport
+{
+    return _preferences->shouldIgnoreMetaViewport();
+}
+
 #if PLATFORM(MAC)
 - (void)_setJavaEnabledForLocalFiles:(BOOL)enabled
 {
@@ -867,16 +960,6 @@ static WebCore::EditableLinkBehavior toEditableLinkBehavior(_WKEditableLinkBehav
     return _preferences->allowUniversalAccessFromFileURLs();
 }
 
-- (void)_setAVFoundationEnabled:(BOOL)enabled
-{
-    _preferences->setAVFoundationEnabled(enabled);
-}
-
-- (BOOL)_avFoundationEnabled
-{
-    return _preferences->isAVFoundationEnabled();
-}
-
 - (void)_setSuppressesIncrementalRendering:(BOOL)enabled
 {
     _preferences->setSuppressesIncrementalRendering(enabled);
@@ -907,6 +990,19 @@ static WebCore::EditableLinkBehavior toEditableLinkBehavior(_WKEditableLinkBehav
     return _preferences->artificialPluginInitializationDelayEnabled();
 }
 
+- (void)_setExperimentalPlugInSandboxProfilesEnabled:(BOOL)enabled
+{
+#if ENABLE(NETSCAPE_PLUGIN_API)
+    WebKit::PluginProcessManager::singleton().setExperimentalPlugInSandboxProfilesEnabled(enabled);
+#endif
+    _preferences->setExperimentalPlugInSandboxProfilesEnabled(enabled);
+}
+
+- (BOOL)_experimentalPlugInSandboxProfilesEnabled
+{
+    return _preferences->experimentalPlugInSandboxProfilesEnabled();
+}
+
 - (void)_setCookieEnabled:(BOOL)enabled
 {
     _preferences->setCookieEnabled(enabled);
@@ -927,16 +1023,6 @@ static WebCore::EditableLinkBehavior toEditableLinkBehavior(_WKEditableLinkBehav
     return _preferences->plugInSnapshottingEnabled();
 }
 
-- (void)_setQTKitEnabled:(BOOL)enabled
-{
-    _preferences->setQTKitEnabled(enabled);
-}
-
-- (BOOL)_qtKitEnabled
-{
-    return _preferences->isQTKitEnabled();
-}
-
 - (void)_setSubpixelCSSOMElementMetricsEnabled:(BOOL)enabled
 {
     _preferences->setSubpixelCSSOMElementMetricsEnabled(enabled);
@@ -967,14 +1053,14 @@ static WebCore::EditableLinkBehavior toEditableLinkBehavior(_WKEditableLinkBehav
     return _preferences->viewGestureDebuggingEnabled();
 }
 
-- (void)_setCSSAnimationTriggersEnabled:(BOOL)enabled
+- (void)_setWebAnimationsCSSIntegrationEnabled:(BOOL)enabled
 {
-    _preferences->setCSSAnimationTriggersEnabled(enabled);
+    _preferences->setWebAnimationsCSSIntegrationEnabled(enabled);
 }
 
-- (BOOL)_cssAnimationTriggersEnabled
+- (BOOL)_webAnimationsCSSIntegrationEnabled
 {
-    return _preferences->cssAnimationTriggersEnabled();
+    return _preferences->webAnimationsCSSIntegrationEnabled();
 }
 
 - (void)_setStandardFontFamily:(NSString *)family
@@ -1016,6 +1102,197 @@ static WebCore::EditableLinkBehavior toEditableLinkBehavior(_WKEditableLinkBehav
 {
     return _preferences->webGLEnabled();
 }
+
+- (void)_setAllowsInlineMediaPlayback:(BOOL)enabled
+{
+    _preferences->setAllowsInlineMediaPlayback(enabled);
+}
+
+- (BOOL)_allowsInlineMediaPlayback
+{
+    return _preferences->allowsInlineMediaPlayback();
+}
+
+- (void)_setApplePayEnabled:(BOOL)enabled
+{
+    _preferences->setApplePayEnabled(enabled);
+}
+
+- (BOOL)_applePayEnabled
+{
+    return _preferences->applePayEnabled();
+}
+
+- (void)_setDNSPrefetchingEnabled:(BOOL)enabled
+{
+    _preferences->setDNSPrefetchingEnabled(enabled);
+}
+
+- (BOOL)_dnsPrefetchingEnabled
+{
+    return _preferences->dnsPrefetchingEnabled();
+}
+
+- (void)_setInlineMediaPlaybackRequiresPlaysInlineAttribute:(BOOL)enabled
+{
+    _preferences->setInlineMediaPlaybackRequiresPlaysInlineAttribute(enabled);
+}
+
+- (BOOL)_inlineMediaPlaybackRequiresPlaysInlineAttribute
+{
+    return _preferences->inlineMediaPlaybackRequiresPlaysInlineAttribute();
+}
+
+- (void)_setInvisibleMediaAutoplayNotPermitted:(BOOL)enabled
+{
+    _preferences->setInvisibleAutoplayNotPermitted(enabled);
+}
+
+- (BOOL)_invisibleMediaAutoplayNotPermitted
+{
+    return _preferences->invisibleAutoplayNotPermitted();
+}
+
+- (void)_setLegacyEncryptedMediaAPIEnabled:(BOOL)enabled
+{
+    _preferences->setLegacyEncryptedMediaAPIEnabled(enabled);
+}
+
+- (BOOL)_legacyEncryptedMediaAPIEnabled
+{
+    return _preferences->legacyEncryptedMediaAPIEnabled();
+}
+
+- (void)_setMainContentUserGestureOverrideEnabled:(BOOL)enabled
+{
+    _preferences->setMainContentUserGestureOverrideEnabled(enabled);
+}
+
+- (BOOL)_mainContentUserGestureOverrideEnabled
+{
+    return _preferences->mainContentUserGestureOverrideEnabled();
+}
+
+- (void)_setMediaStreamEnabled:(BOOL)enabled
+{
+    _preferences->setMediaStreamEnabled(enabled);
+}
+
+- (BOOL)_mediaStreamEnabled
+{
+    return _preferences->mediaStreamEnabled();
+}
+
+- (void)_setNeedsStorageAccessFromFileURLsQuirk:(BOOL)enabled
+{
+    _preferences->setNeedsStorageAccessFromFileURLsQuirk(enabled);
+}
+
+- (BOOL)_needsStorageAccessFromFileURLsQuirk
+{
+    return _preferences->needsStorageAccessFromFileURLsQuirk();
+}
+
+- (void)_setPDFPluginEnabled:(BOOL)enabled
+{
+    _preferences->setPDFPluginEnabled(enabled);
+}
+
+- (BOOL)_pdfPluginEnabled
+{
+    return _preferences->pdfPluginEnabled();
+}
+
+- (void)_setRequiresUserGestureForAudioPlayback:(BOOL)enabled
+{
+    _preferences->setRequiresUserGestureForAudioPlayback(enabled);
+}
+
+- (BOOL)_requiresUserGestureForAudioPlayback
+{
+    return _preferences->requiresUserGestureForAudioPlayback();
+}
+
+- (void)_setRequiresUserGestureForVideoPlayback:(BOOL)enabled
+{
+    _preferences->setRequiresUserGestureForVideoPlayback(enabled);
+}
+
+- (BOOL)_requiresUserGestureForVideoPlayback
+{
+    return _preferences->requiresUserGestureForVideoPlayback();
+}
+
+- (void)_setServiceControlsEnabled:(BOOL)enabled
+{
+    _preferences->setServiceControlsEnabled(enabled);
+}
+
+- (BOOL)_serviceControlsEnabled
+{
+    return _preferences->serviceControlsEnabled();
+}
+
+- (void)_setShowsToolTipOverTruncatedText:(BOOL)enabled
+{
+    _preferences->setShowsToolTipOverTruncatedText(enabled);
+}
+
+- (BOOL)_showsToolTipOverTruncatedText
+{
+    return _preferences->showsToolTipOverTruncatedText();
+}
+
+- (void)_setTextAreasAreResizable:(BOOL)enabled
+{
+    _preferences->setTextAreasAreResizable(enabled);
+}
+
+- (BOOL)_textAreasAreResizable
+{
+    return _preferences->textAreasAreResizable();
+}
+
+- (void)_setUseGiantTiles:(BOOL)enabled
+{
+    _preferences->setUseGiantTiles(enabled);
+}
+
+- (BOOL)_useGiantTiles
+{
+    return _preferences->useGiantTiles();
+}
+
+- (void)_setWantsBalancedSetDefersLoadingBehavior:(BOOL)enabled
+{
+    _preferences->setWantsBalancedSetDefersLoadingBehavior(enabled);
+}
+
+- (BOOL)_wantsBalancedSetDefersLoadingBehavior
+{
+    return _preferences->wantsBalancedSetDefersLoadingBehavior();
+}
+
+- (void)_setWebAudioEnabled:(BOOL)enabled
+{
+    _preferences->setWebAudioEnabled(enabled);
+}
+
+- (BOOL)_webAudioEnabled
+{
+    return _preferences->webAudioEnabled();
+}
+
+- (void)_setAggressiveTileRetentionEnabled:(BOOL)enabled
+{
+    _preferences->setAggressiveTileRetentionEnabled(enabled);
+}
+
+- (BOOL)_aggressiveTileRetentionEnabled
+{
+    return _preferences->aggressiveTileRetentionEnabled();
+}
+
 #endif // PLATFORM(MAC)
 
 - (BOOL)_javaScriptCanAccessClipboard
@@ -1033,6 +1310,32 @@ static WebCore::EditableLinkBehavior toEditableLinkBehavior(_WKEditableLinkBehav
     return _preferences->domPasteAllowed();
 }
 
+- (void)_setShouldEnableTextAutosizingBoost:(BOOL)shouldEnableTextAutosizingBoost
+{
+#if ENABLE(TEXT_AUTOSIZING)
+    _preferences->setShouldEnableTextAutosizingBoost(shouldEnableTextAutosizingBoost);
+#endif
+}
+
+- (BOOL)_shouldEnableTextAutosizingBoost
+{
+#if ENABLE(TEXT_AUTOSIZING)
+    return _preferences->shouldEnableTextAutosizingBoost();
+#else
+    return NO;
+#endif
+}
+
+- (void)_setVideoQualityIncludesDisplayCompositingEnabled:(BOOL)videoQualityIncludesDisplayCompositingEnabled
+{
+    _preferences->setVideoQualityIncludesDisplayCompositingEnabled(videoQualityIncludesDisplayCompositingEnabled);
+}
+
+- (BOOL)_videoQualityIncludesDisplayCompositingEnabled
+{
+    return _preferences->videoQualityIncludesDisplayCompositingEnabled();
+}
+
 @end
 
 #endif // WK_API_ENABLED