<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[201154] branches/safari-602.1.32-branch</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/201154">201154</a></dd>
<dt>Author</dt> <dd>bshafiei@apple.com</dd>
<dt>Date</dt> <dd>2016-05-19 02:35:58 -0700 (Thu, 19 May 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Merge <a href="http://trac.webkit.org/projects/webkit/changeset/200951">r200951</a>. rdar://problem/25584201</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari602132branchSourceWebKit2ChangeLog">branches/safari-602.1.32-branch/Source/WebKit2/ChangeLog</a></li>
<li><a href="#branchessafari602132branchSourceWebKit2SharedWebPreferencesDefinitionsh">branches/safari-602.1.32-branch/Source/WebKit2/Shared/WebPreferencesDefinitions.h</a></li>
<li><a href="#branchessafari602132branchSourceWebKit2UIProcessAPICocoaWKWebViewmm">branches/safari-602.1.32-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm</a></li>
<li><a href="#branchessafari602132branchSourceWebKit2UIProcessAPICocoaWKWebViewConfigurationh">branches/safari-602.1.32-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfiguration.h</a></li>
<li><a href="#branchessafari602132branchSourceWebKit2UIProcessAPICocoaWKWebViewConfigurationmm">branches/safari-602.1.32-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfiguration.mm</a></li>
<li><a href="#branchessafari602132branchSourceWebKit2UIProcessAPICocoaWKWebViewConfigurationPrivateh">branches/safari-602.1.32-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h</a></li>
<li><a href="#branchessafari602132branchSourceWebKit2UIProcessCocoaVersionChecksh">branches/safari-602.1.32-branch/Source/WebKit2/UIProcess/Cocoa/VersionChecks.h</a></li>
<li><a href="#branchessafari602132branchToolsChangeLog">branches/safari-602.1.32-branch/Tools/ChangeLog</a></li>
<li><a href="#branchessafari602132branchToolsTestWebKitAPITestsWebKit2CocoaRequiresUserActionForPlaybackmm">branches/safari-602.1.32-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/RequiresUserActionForPlayback.mm</a></li>
<li><a href="#branchessafari602132branchToolsWebKitTestRunnercocoaTestControllerCocoamm">branches/safari-602.1.32-branch/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari602132branchSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-602.1.32-branch/Source/WebKit2/ChangeLog (201153 => 201154)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602.1.32-branch/Source/WebKit2/ChangeLog        2016-05-19 08:41:20 UTC (rev 201153)
+++ branches/safari-602.1.32-branch/Source/WebKit2/ChangeLog        2016-05-19 09:35:58 UTC (rev 201154)
</span><span class="lines">@@ -1,5 +1,36 @@
</span><span class="cx"> 2016-05-19  Babak Shafiei  &lt;bshafiei@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Merge r200951. rdar://problem/25584201
+
+    2016-04-06  Jer Noble  &lt;jer.noble@apple.com&gt;
+
+            [WK2] Add API to WKWebViewConfiguration to control autoplay policy.
+            https://bugs.webkit.org/show_bug.cgi?id=156312
+
+            Reviewed by Dan Bernstein.
+
+            Add a new API to WKWebViewConfiguration to allow fine-grained control over when media is allowed
+            to play without a user gesture, and simultaneously deprecate the existing, all-or-nothing API,
+            and deprecated the equivalent SPIs.
+
+            * UIProcess/API/Cocoa/WKWebView.mm:
+            (-[WKWebView _initializeWithConfiguration:]):
+            * UIProcess/API/Cocoa/WKWebViewConfiguration.h:
+            * UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
+            (-[WKWebViewConfiguration init]):
+            (-[WKWebViewConfiguration encodeWithCoder:]):
+            (-[WKWebViewConfiguration initWithCoder:]):
+            (-[WKWebViewConfiguration copyWithZone:]):
+            (-[WKWebViewConfiguration _requiresUserActionForVideoPlayback]):
+            (-[WKWebViewConfiguration _setRequiresUserActionForVideoPlayback:]):
+            (-[WKWebViewConfiguration _requiresUserActionForAudioPlayback]):
+            (-[WKWebViewConfiguration _setRequiresUserActionForAudioPlayback:]):
+            (-[WKWebViewConfiguration requiresUserActionForMediaPlayback]):
+            (-[WKWebViewConfiguration setRequiresUserActionForMediaPlayback:]):
+            * UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h:
+
+2016-05-19  Babak Shafiei  &lt;bshafiei@apple.com&gt;
+
</ins><span class="cx">         Merge r201079. rdar://problem/26334648
</span><span class="cx"> 
</span><span class="cx">     2016-05-18  Brian Burg  &lt;bburg@apple.com&gt;
</span></span></pre></div>
<a id="branchessafari602132branchSourceWebKit2SharedWebPreferencesDefinitionsh"></a>
<div class="modfile"><h4>Modified: branches/safari-602.1.32-branch/Source/WebKit2/Shared/WebPreferencesDefinitions.h (201153 => 201154)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602.1.32-branch/Source/WebKit2/Shared/WebPreferencesDefinitions.h        2016-05-19 08:41:20 UTC (rev 201153)
+++ branches/safari-602.1.32-branch/Source/WebKit2/Shared/WebPreferencesDefinitions.h        2016-05-19 09:35:58 UTC (rev 201154)
</span><span class="lines">@@ -74,7 +74,6 @@
</span><span class="cx"> #define DEFAULT_INLINE_MEDIA_PLAYBACK_REQUIRES_PLAYS_INLINE_ATTRIBUTE true
</span><span class="cx"> #define DEFAULT_INVISIBLE_AUTOPLAY_NOT_PERMITTED true
</span><span class="cx"> #define DEFAULT_MEDIA_DATA_LOADS_AUTOMATICALLY false
</span><del>-#define DEFAULT_REQUIRES_USER_GESTURE_FOR_MEDIA_PLAYBACK true
</del><span class="cx"> #define DEFAULT_MEDIA_CONTROLS_SCALE_WITH_PAGE_ZOOM false
</span><span class="cx"> #define DEFAULT_TEMPORARY_TILE_COHORT_RETENTION_ENABLED false
</span><span class="cx"> #else
</span><span class="lines">@@ -89,7 +88,6 @@
</span><span class="cx"> #define DEFAULT_INLINE_MEDIA_PLAYBACK_REQUIRES_PLAYS_INLINE_ATTRIBUTE false
</span><span class="cx"> #define DEFAULT_INVISIBLE_AUTOPLAY_NOT_PERMITTED false
</span><span class="cx"> #define DEFAULT_MEDIA_DATA_LOADS_AUTOMATICALLY true
</span><del>-#define DEFAULT_REQUIRES_USER_GESTURE_FOR_MEDIA_PLAYBACK false
</del><span class="cx"> #define DEFAULT_MEDIA_CONTROLS_SCALE_WITH_PAGE_ZOOM true
</span><span class="cx"> #define DEFAULT_TEMPORARY_TILE_COHORT_RETENTION_ENABLED true
</span><span class="cx"> #endif
</span><span class="lines">@@ -150,9 +148,9 @@
</span><span class="cx">     macro(AllowFileAccessFromFileURLs, allowFileAccessFromFileURLs, Bool, bool, false, &quot;&quot;, &quot;&quot;) \
</span><span class="cx">     macro(AVFoundationEnabled, isAVFoundationEnabled, Bool, bool, true, &quot;&quot;, &quot;&quot;) \
</span><span class="cx">     macro(AVFoundationNSURLSessionEnabled, isAVFoundationNSURLSessionEnabled, Bool, bool, true, &quot;&quot;, &quot;&quot;) \
</span><del>-    macro(RequiresUserGestureForMediaPlayback, requiresUserGestureForMediaPlayback, Bool, bool, DEFAULT_REQUIRES_USER_GESTURE_FOR_MEDIA_PLAYBACK, &quot;&quot;, &quot;&quot;) \
</del><ins>+    macro(RequiresUserGestureForMediaPlayback, requiresUserGestureForMediaPlayback, Bool, bool, false, &quot;&quot;, &quot;&quot;) \
</ins><span class="cx">     macro(RequiresUserGestureForVideoPlayback, requiresUserGestureForVideoPlayback, Bool, bool, false, &quot;&quot;, &quot;&quot;) \
</span><del>-    macro(RequiresUserGestureForAudioPlayback, requiresUserGestureForAudioPlayback, Bool, bool, false, &quot;&quot;, &quot;&quot;) \
</del><ins>+    macro(RequiresUserGestureForAudioPlayback, requiresUserGestureForAudioPlayback, Bool, bool, true, &quot;&quot;, &quot;&quot;) \
</ins><span class="cx">     macro(MainContentUserGestureOverrideEnabled, mainContentUserGestureOverrideEnabled, Bool, bool, false, &quot;&quot;, &quot;&quot;) \
</span><span class="cx">     macro(AllowsInlineMediaPlayback, allowsInlineMediaPlayback, Bool, bool, DEFAULT_ALLOWS_INLINE_MEDIA_PLAYBACK, &quot;&quot;, &quot;&quot;) \
</span><span class="cx">     macro(InlineMediaPlaybackRequiresPlaysInlineAttribute, inlineMediaPlaybackRequiresPlaysInlineAttribute, Bool, bool, DEFAULT_INLINE_MEDIA_PLAYBACK_REQUIRES_PLAYS_INLINE_ATTRIBUTE, &quot;&quot;, &quot;&quot;) \
</span></span></pre></div>
<a id="branchessafari602132branchSourceWebKit2UIProcessAPICocoaWKWebViewmm"></a>
<div class="modfile"><h4>Modified: branches/safari-602.1.32-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (201153 => 201154)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602.1.32-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm        2016-05-19 08:41:20 UTC (rev 201153)
+++ branches/safari-602.1.32-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm        2016-05-19 09:35:58 UTC (rev 201154)
</span><span class="lines">@@ -457,13 +457,13 @@
</span><span class="cx">     pageConfiguration-&gt;preferenceValues().set(WebKit::WebPreferencesKey::allowsInlineMediaPlaybackKey(), WebKit::WebPreferencesStore::Value(!![_configuration allowsInlineMediaPlayback]));
</span><span class="cx">     pageConfiguration-&gt;preferenceValues().set(WebKit::WebPreferencesKey::inlineMediaPlaybackRequiresPlaysInlineAttributeKey(), WebKit::WebPreferencesStore::Value(!![_configuration _inlineMediaPlaybackRequiresPlaysInlineAttribute]));
</span><span class="cx">     pageConfiguration-&gt;preferenceValues().set(WebKit::WebPreferencesKey::allowsPictureInPictureMediaPlaybackKey(), WebKit::WebPreferencesStore::Value(!![_configuration allowsPictureInPictureMediaPlayback] &amp;&amp; shouldAllowPictureInPictureMediaPlayback()));
</span><del>-    pageConfiguration-&gt;preferenceValues().set(WebKit::WebPreferencesKey::requiresUserGestureForMediaPlaybackKey(), WebKit::WebPreferencesStore::Value(!![_configuration requiresUserActionForMediaPlayback]));
</del><span class="cx">     pageConfiguration-&gt;preferenceValues().set(WebKit::WebPreferencesKey::userInterfaceDirectionPolicyKey(), WebKit::WebPreferencesStore::Value(static_cast&lt;uint32_t&gt;(WebCore::UserInterfaceDirectionPolicy::Content)));
</span><span class="cx">     pageConfiguration-&gt;preferenceValues().set(WebKit::WebPreferencesKey::systemLayoutDirectionKey(), WebKit::WebPreferencesStore::Value(static_cast&lt;uint32_t&gt;(WebCore::LTR)));
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    pageConfiguration-&gt;preferenceValues().set(WebKit::WebPreferencesKey::requiresUserGestureForVideoPlaybackKey(), WebKit::WebPreferencesStore::Value(!![_configuration _requiresUserActionForVideoPlayback]));
-    pageConfiguration-&gt;preferenceValues().set(WebKit::WebPreferencesKey::requiresUserGestureForAudioPlaybackKey(), WebKit::WebPreferencesStore::Value(!![_configuration _requiresUserActionForAudioPlayback]));
</del><ins>+    WKAudiovisualMediaTypes mediaTypesRequiringUserGesture = [_configuration mediaTypesRequiringUserActionForPlayback];
+    pageConfiguration-&gt;preferenceValues().set(WebKit::WebPreferencesKey::requiresUserGestureForVideoPlaybackKey(), WebKit::WebPreferencesStore::Value((mediaTypesRequiringUserGesture &amp; WKAudiovisualMediaTypeVideo) == WKAudiovisualMediaTypeVideo));
+    pageConfiguration-&gt;preferenceValues().set(WebKit::WebPreferencesKey::requiresUserGestureForAudioPlaybackKey(), WebKit::WebPreferencesStore::Value(((mediaTypesRequiringUserGesture &amp; WKAudiovisualMediaTypeAudio) == WKAudiovisualMediaTypeAudio)));
</ins><span class="cx">     pageConfiguration-&gt;preferenceValues().set(WebKit::WebPreferencesKey::mainContentUserGestureOverrideEnabledKey(), WebKit::WebPreferencesStore::Value(!![_configuration _mainContentUserGestureOverrideEnabled]));
</span><span class="cx">     pageConfiguration-&gt;preferenceValues().set(WebKit::WebPreferencesKey::invisibleAutoplayNotPermittedKey(), WebKit::WebPreferencesStore::Value(!![_configuration _invisibleAutoplayNotPermitted]));
</span><span class="cx">     pageConfiguration-&gt;preferenceValues().set(WebKit::WebPreferencesKey::mediaDataLoadsAutomaticallyKey(), WebKit::WebPreferencesStore::Value(!![_configuration _mediaDataLoadsAutomatically]));
</span></span></pre></div>
<a id="branchessafari602132branchSourceWebKit2UIProcessAPICocoaWKWebViewConfigurationh"></a>
<div class="modfile"><h4>Modified: branches/safari-602.1.32-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfiguration.h (201153 => 201154)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602.1.32-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfiguration.h        2016-05-19 08:41:20 UTC (rev 201153)
+++ branches/safari-602.1.32-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfiguration.h        2016-05-19 09:35:58 UTC (rev 201154)
</span><span class="lines">@@ -95,6 +95,20 @@
</span><span class="cx"> 
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+/*! @enum WKAudiovisualMediaTypes
+ @abstract The types of audiovisual media which will require a user gesture to begin playing.
+ @constant WKAudiovisualMediaTypeNone No audiovisual media will require a user gesture to begin playing.
+ @constant WKAudiovisualMediaTypeAudio Audiovisual media containing audio will require a user gesture to begin playing.
+ @constant WKAudiovisualMediaTypeVideo Audiovisual media containing video will require a user gesture to begin playing.
+ @constant WKAudiovisualMediaTypeAll All audiovisual media will require a user gesture to begin playing.
+*/
+typedef NS_OPTIONS(NSUInteger, WKAudiovisualMediaTypes) {
+    WKAudiovisualMediaTypeNone = 0,
+    WKAudiovisualMediaTypeAudio = 1 &lt;&lt; 0,
+    WKAudiovisualMediaTypeVideo = 1 &lt;&lt; 1,
+    WKAudiovisualMediaTypeAll = NSUIntegerMax
+} WK_ENUM_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA);
+
</ins><span class="cx"> /*! A WKWebViewConfiguration object is a collection of properties with
</span><span class="cx">  which to initialize a web view.
</span><span class="cx">  @helps Contains properties used to configure a @link WKWebView @/link.
</span><span class="lines">@@ -137,6 +151,8 @@
</span><span class="cx">  */
</span><span class="cx"> @property (nonatomic) BOOL allowsAirPlayForMediaPlayback WK_AVAILABLE(10_11, 9_0);
</span><span class="cx"> 
</span><ins>+@property (nonatomic) WKAudiovisualMediaTypes mediaTypesRequiringUserActionForPlayback WK_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA);
+
</ins><span class="cx"> #if TARGET_OS_IPHONE
</span><span class="cx"> /*! @abstract A Boolean value indicating whether HTML5 videos play inline
</span><span class="cx">  (YES) or use the native full-screen controller (NO).
</span><span class="lines">@@ -144,12 +160,6 @@
</span><span class="cx">  */
</span><span class="cx"> @property (nonatomic) BOOL allowsInlineMediaPlayback;
</span><span class="cx"> 
</span><del>-/*! @abstract A Boolean value indicating whether HTML5 videos require the
- user to start playing them (YES) or can play automatically (NO).
- @discussion The default value is YES.
- */
-@property (nonatomic) BOOL requiresUserActionForMediaPlayback WK_AVAILABLE(NA, 9_0);
-
</del><span class="cx"> /*! @abstract The level of granularity with which the user can interactively
</span><span class="cx">  select content in the web view.
</span><span class="cx">  @discussion Possible values are described in WKSelectionGranularity.
</span><span class="lines">@@ -189,6 +199,7 @@
</span><span class="cx"> #if TARGET_OS_IPHONE
</span><span class="cx"> @property (nonatomic) BOOL mediaPlaybackRequiresUserAction WK_DEPRECATED(NA, NA, 8_0, 9_0, &quot;Please use requiresUserActionForMediaPlayback&quot;);
</span><span class="cx"> @property (nonatomic) BOOL mediaPlaybackAllowsAirPlay WK_DEPRECATED(NA, NA, 8_0, 9_0, &quot;Please use allowsAirPlayForMediaPlayback&quot;);
</span><ins>+@property (nonatomic) BOOL requiresUserActionForMediaPlayback WK_DEPRECATED(NA, NA, 9_0, 10_0, &quot;Please use mediaTypesRequiringUserActionForPlayback&quot;);
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> @end
</span></span></pre></div>
<a id="branchessafari602132branchSourceWebKit2UIProcessAPICocoaWKWebViewConfigurationmm"></a>
<div class="modfile"><h4>Modified: branches/safari-602.1.32-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfiguration.mm (201153 => 201154)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602.1.32-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfiguration.mm        2016-05-19 08:41:20 UTC (rev 201153)
+++ branches/safari-602.1.32-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfiguration.mm        2016-05-19 09:35:58 UTC (rev 201154)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> #if WK_API_ENABLED
</span><span class="cx"> 
</span><span class="cx"> #import &quot;APIPageConfiguration.h&quot;
</span><ins>+#import &quot;VersionChecks.h&quot;
</ins><span class="cx"> #import &quot;WKPreferences.h&quot;
</span><span class="cx"> #import &quot;WKProcessPool.h&quot;
</span><span class="cx"> #import &quot;WKUserContentController.h&quot;
</span><span class="lines">@@ -112,8 +113,6 @@
</span><span class="cx">     BOOL _invisibleAutoplayNotPermitted;
</span><span class="cx">     BOOL _mediaDataLoadsAutomatically;
</span><span class="cx">     BOOL _attachmentElementEnabled;
</span><del>-    BOOL _requiresUserActionForVideoPlayback;
-    BOOL _requiresUserActionForAudioPlayback;
</del><span class="cx">     BOOL _mainContentUserGestureOverrideEnabled;
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(MAC)
</span><span class="lines">@@ -133,7 +132,6 @@
</span><span class="cx">         return nil;
</span><span class="cx">     
</span><span class="cx"> #if PLATFORM(IOS)
</span><del>-    _requiresUserActionForMediaPlayback = YES;
</del><span class="cx">     _allowsPictureInPictureMediaPlayback = YES;
</span><span class="cx">     _allowsInlineMediaPlayback = WebCore::deviceClass() == MGDeviceClassiPad;
</span><span class="cx">     _inlineMediaPlaybackRequiresPlaysInlineAttribute = !_allowsInlineMediaPlayback;
</span><span class="lines">@@ -142,8 +140,10 @@
</span><span class="cx">     _mediaDataLoadsAutomatically = YES;
</span><span class="cx">     _userInterfaceDirectionPolicy = WKUserInterfaceDirectionPolicyContent;
</span><span class="cx"> #endif
</span><del>-    _requiresUserActionForVideoPlayback = NO;
-    _requiresUserActionForAudioPlayback = NO;
</del><ins>+    if (linkedOnOrAfter(WebKit::LibraryVersion::FirstWithMediaTypesRequiringUserActionForPlayback))
+        _mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeAudio;
+    else
+        _mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeAll;
</ins><span class="cx">     _mainContentUserGestureOverrideEnabled = NO;
</span><span class="cx">     _invisibleAutoplayNotPermitted = NO;
</span><span class="cx"> 
</span><span class="lines">@@ -202,7 +202,7 @@
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">     [coder encodeInteger:self.dataDetectorTypes forKey:@&quot;dataDetectorTypes&quot;];
</span><span class="cx">     [coder encodeBool:self.allowsInlineMediaPlayback forKey:@&quot;allowsInlineMediaPlayback&quot;];
</span><del>-    [coder encodeBool:self.requiresUserActionForMediaPlayback forKey:@&quot;requiresUserActionForMediaPlayback&quot;];
</del><ins>+    [coder encodeBool:self.mediaTypesRequiringUserActionForPlayback forKey:@&quot;mediaTypesRequiringUserActionForPlayback&quot;];
</ins><span class="cx">     [coder encodeInteger:self.selectionGranularity forKey:@&quot;selectionGranularity&quot;];
</span><span class="cx">     [coder encodeBool:self.allowsPictureInPictureMediaPlayback forKey:@&quot;allowsPictureInPictureMediaPlayback&quot;];
</span><span class="cx"> #else
</span><span class="lines">@@ -227,7 +227,7 @@
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">     self.dataDetectorTypes = [coder decodeIntegerForKey:@&quot;dataDetectorTypes&quot;];
</span><span class="cx">     self.allowsInlineMediaPlayback = [coder decodeBoolForKey:@&quot;allowsInlineMediaPlayback&quot;];
</span><del>-    self.requiresUserActionForMediaPlayback = [coder decodeBoolForKey:@&quot;requiresUserActionForMediaPlayback&quot;];
</del><ins>+    self.mediaTypesRequiringUserActionForPlayback = [coder decodeBoolForKey:@&quot;mediaTypesRequiringUserActionForPlayback&quot;];
</ins><span class="cx">     self.selectionGranularity = static_cast&lt;WKSelectionGranularity&gt;([coder decodeIntegerForKey:@&quot;selectionGranularity&quot;]);
</span><span class="cx">     self.allowsPictureInPictureMediaPlayback = [coder decodeBoolForKey:@&quot;allowsPictureInPictureMediaPlayback&quot;];
</span><span class="cx"> #else
</span><span class="lines">@@ -269,14 +269,12 @@
</span><span class="cx">     configuration-&gt;_invisibleAutoplayNotPermitted = self-&gt;_invisibleAutoplayNotPermitted;
</span><span class="cx">     configuration-&gt;_mediaDataLoadsAutomatically = self-&gt;_mediaDataLoadsAutomatically;
</span><span class="cx">     configuration-&gt;_attachmentElementEnabled = self-&gt;_attachmentElementEnabled;
</span><del>-    configuration-&gt;_requiresUserActionForVideoPlayback = self-&gt;_requiresUserActionForVideoPlayback;
-    configuration-&gt;_requiresUserActionForAudioPlayback = self-&gt;_requiresUserActionForAudioPlayback;
</del><ins>+    configuration-&gt;_mediaTypesRequiringUserActionForPlayback = self-&gt;_mediaTypesRequiringUserActionForPlayback;
</ins><span class="cx">     configuration-&gt;_mainContentUserGestureOverrideEnabled = self-&gt;_mainContentUserGestureOverrideEnabled;
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">     configuration-&gt;_allowsInlineMediaPlayback = self-&gt;_allowsInlineMediaPlayback;
</span><span class="cx">     configuration-&gt;_inlineMediaPlaybackRequiresPlaysInlineAttribute = self-&gt;_inlineMediaPlaybackRequiresPlaysInlineAttribute;
</span><del>-    configuration-&gt;_requiresUserActionForMediaPlayback = self-&gt;_requiresUserActionForMediaPlayback;
</del><span class="cx">     configuration-&gt;_allowsPictureInPictureMediaPlayback = self-&gt;_allowsPictureInPictureMediaPlayback;
</span><span class="cx">     configuration-&gt;_alwaysRunsAtForegroundPriority = _alwaysRunsAtForegroundPriority;
</span><span class="cx">     configuration-&gt;_selectionGranularity = self-&gt;_selectionGranularity;
</span><span class="lines">@@ -598,22 +596,28 @@
</span><span class="cx"> 
</span><span class="cx"> - (BOOL)_requiresUserActionForVideoPlayback
</span><span class="cx"> {
</span><del>-    return _requiresUserActionForVideoPlayback;
</del><ins>+    return self.mediaTypesRequiringUserActionForPlayback &amp; WKAudiovisualMediaTypeVideo;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)_setRequiresUserActionForVideoPlayback:(BOOL)requiresUserActionForVideoPlayback
</span><span class="cx"> {
</span><del>-    _requiresUserActionForVideoPlayback = requiresUserActionForVideoPlayback;
</del><ins>+    if (requiresUserActionForVideoPlayback)
+        self.mediaTypesRequiringUserActionForPlayback |= WKAudiovisualMediaTypeVideo;
+    else
+        self.mediaTypesRequiringUserActionForPlayback &amp;= ~WKAudiovisualMediaTypeVideo;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (BOOL)_requiresUserActionForAudioPlayback
</span><span class="cx"> {
</span><del>-    return _requiresUserActionForAudioPlayback;
</del><ins>+    return self.mediaTypesRequiringUserActionForPlayback &amp; WKAudiovisualMediaTypeAudio;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)_setRequiresUserActionForAudioPlayback:(BOOL)requiresUserActionForAudioPlayback
</span><span class="cx"> {
</span><del>-    _requiresUserActionForAudioPlayback = requiresUserActionForAudioPlayback;
</del><ins>+    if (requiresUserActionForAudioPlayback)
+        self.mediaTypesRequiringUserActionForPlayback |= WKAudiovisualMediaTypeAudio;
+    else
+        self.mediaTypesRequiringUserActionForPlayback &amp;= ~WKAudiovisualMediaTypeAudio;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (BOOL)_mainContentUserGestureOverrideEnabled
</span><span class="lines">@@ -686,6 +690,17 @@
</span><span class="cx"> {
</span><span class="cx">     self.requiresUserActionForMediaPlayback = required;
</span><span class="cx"> }
</span><ins>+
+- (BOOL)requiresUserActionForMediaPlayback
+{
+    return self.mediaTypesRequiringUserActionForPlayback == WKAudiovisualMediaTypeAll;
+}
+
+- (void)setRequiresUserActionForMediaPlayback:(BOOL)requiresUserActionForMediaPlayback
+{
+    self.mediaTypesRequiringUserActionForPlayback = requiresUserActionForMediaPlayback ? WKAudiovisualMediaTypeAll : WKAudiovisualMediaTypeNone;
+}
+
</ins><span class="cx"> #endif // PLATFORM(IOS)
</span><span class="cx"> 
</span><span class="cx"> @end
</span></span></pre></div>
<a id="branchessafari602132branchSourceWebKit2UIProcessAPICocoaWKWebViewConfigurationPrivateh"></a>
<div class="modfile"><h4>Modified: branches/safari-602.1.32-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h (201153 => 201154)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602.1.32-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h        2016-05-19 08:41:20 UTC (rev 201153)
+++ branches/safari-602.1.32-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h        2016-05-19 09:35:58 UTC (rev 201154)
</span><span class="lines">@@ -50,8 +50,6 @@
</span><span class="cx"> @property (nonatomic, setter=_setConvertsPositionStyleOnCopy:) BOOL _convertsPositionStyleOnCopy WK_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA);
</span><span class="cx"> @property (nonatomic, setter=_setAllowsMetaRefresh:) BOOL _allowsMetaRefresh WK_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA);
</span><span class="cx"> @property (nonatomic, setter=_setAllowUniversalAccessFromFileURLs:) BOOL _allowUniversalAccessFromFileURLs WK_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA);
</span><del>-@property (nonatomic, setter=_setRequiresUserActionForAudioPlayback:) BOOL _requiresUserActionForAudioPlayback WK_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA);
-@property (nonatomic, setter=_setRequiresUserActionForVideoPlayback:) BOOL _requiresUserActionForVideoPlayback WK_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA);
</del><span class="cx"> @property (nonatomic, setter=_setMainContentUserGestureOverrideEnabled:) BOOL _mainContentUserGestureOverrideEnabled WK_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA);
</span><span class="cx"> @property (nonatomic, setter=_setInvisibleAutoplayNotPermitted:) BOOL _invisibleAutoplayNotPermitted WK_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA);
</span><span class="cx"> @property (nonatomic, setter=_setMediaDataLoadsAutomatically:) BOOL _mediaDataLoadsAutomatically WK_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA);
</span><span class="lines">@@ -69,6 +67,8 @@
</span><span class="cx"> @property (nonatomic, strong, setter=_setVisitedLinkProvider:) _WKVisitedLinkProvider *_visitedLinkProvider WK_DEPRECATED(10_10, WK_MAC_TBA, 8_0, WK_IOS_TBA, &quot;Please use _visitedLinkStore instead&quot;);
</span><span class="cx"> 
</span><span class="cx"> @property (nonatomic, strong, setter=_setWebsiteDataStore:) _WKWebsiteDataStore *_websiteDataStore WK_DEPRECATED(10_10, 10_11, 8_0, 9_0, &quot;Please use websiteDataStore instead&quot;);
</span><ins>+@property (nonatomic, setter=_setRequiresUserActionForAudioPlayback:) BOOL _requiresUserActionForAudioPlayback WK_DEPRECATED(WK_MAC_TBA, WK_MAC_TBA, WK_IOS_TBA, WK_IOS_TBA, &quot;Please use mediaTypesRequiringUserActionForPlayback&quot;);
+@property (nonatomic, setter=_setRequiresUserActionForVideoPlayback:) BOOL _requiresUserActionForVideoPlayback WK_DEPRECATED(WK_MAC_TBA, WK_MAC_TBA, WK_IOS_TBA, WK_IOS_TBA, &quot;Please use mediaTypesRequiringUserActionForPlayback&quot;);
</ins><span class="cx"> 
</span><span class="cx"> @end
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchessafari602132branchSourceWebKit2UIProcessCocoaVersionChecksh"></a>
<div class="modfile"><h4>Modified: branches/safari-602.1.32-branch/Source/WebKit2/UIProcess/Cocoa/VersionChecks.h (201153 => 201154)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602.1.32-branch/Source/WebKit2/UIProcess/Cocoa/VersionChecks.h        2016-05-19 08:41:20 UTC (rev 201153)
+++ branches/safari-602.1.32-branch/Source/WebKit2/UIProcess/Cocoa/VersionChecks.h        2016-05-19 09:35:58 UTC (rev 201154)
</span><span class="lines">@@ -39,6 +39,7 @@
</span><span class="cx"> */
</span><span class="cx"> enum class LibraryVersion {
</span><span class="cx">     FirstWithNetworkCache = 0x02590116, // 601.1.22
</span><ins>+    FirstWithMediaTypesRequiringUserActionForPlayback = 0x025A0121, // 602.1.33
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> bool linkedOnOrAfter(LibraryVersion);
</span></span></pre></div>
<a id="branchessafari602132branchToolsChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-602.1.32-branch/Tools/ChangeLog (201153 => 201154)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602.1.32-branch/Tools/ChangeLog        2016-05-19 08:41:20 UTC (rev 201153)
+++ branches/safari-602.1.32-branch/Tools/ChangeLog        2016-05-19 09:35:58 UTC (rev 201154)
</span><span class="lines">@@ -1,5 +1,21 @@
</span><span class="cx"> 2016-05-19  Babak Shafiei  &lt;bshafiei@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Merge r200951. rdar://problem/25584201
+
+    2016-04-06  Jer Noble  &lt;jer.noble@apple.com&gt;
+
+            [WK2] Add API to WKWebViewConfiguration to control autoplay policy.
+            https://bugs.webkit.org/show_bug.cgi?id=156312
+
+            Reviewed by Dan Bernstein.
+
+            * WebKitTestRunner/cocoa/TestControllerCocoa.mm:
+            (WTR::initializeWebViewConfiguration):
+            * TestWebKitAPI/Tests/WebKit2Cocoa/RequiresUserActionForPlayback.mm:
+            (TEST_F):
+
+2016-05-19  Babak Shafiei  &lt;bshafiei@apple.com&gt;
+
</ins><span class="cx">         Merge r201090. rdar://problem/26334636
</span><span class="cx"> 
</span><span class="cx">     2016-05-18  Simon Fraser  &lt;simon.fraser@apple.com&gt;
</span></span></pre></div>
<a id="branchessafari602132branchToolsTestWebKitAPITestsWebKit2CocoaRequiresUserActionForPlaybackmm"></a>
<div class="modfile"><h4>Modified: branches/safari-602.1.32-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/RequiresUserActionForPlayback.mm (201153 => 201154)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602.1.32-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/RequiresUserActionForPlayback.mm        2016-05-19 08:41:20 UTC (rev 201153)
+++ branches/safari-602.1.32-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/RequiresUserActionForPlayback.mm        2016-05-19 09:35:58 UTC (rev 201154)
</span><span class="lines">@@ -77,7 +77,6 @@
</span><span class="cx"> #if TARGET_OS_IPHONE
</span><span class="cx">         configuration.get().allowsInlineMediaPlayback = YES;
</span><span class="cx">         configuration.get()._inlineMediaPlaybackRequiresPlaysInlineAttribute = NO;
</span><del>-        configuration.get().requiresUserActionForMediaPlayback = NO;
</del><span class="cx"> #endif
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -169,6 +168,45 @@
</span><span class="cx"> 
</span><span class="cx"> TEST_F(RequiresUserActionForPlaybackTest, RequiresUserActionForAudioAndVideoPlayback)
</span><span class="cx"> {
</span><ins>+    configuration.get().mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeAudio | WKAudiovisualMediaTypeVideo;
+    createWebView();
+
+    testVideoWithAudio();
+    EXPECT_WK_STREQ(@&quot;not playing&quot;, (NSString *)[lastScriptMessage body]);
+    testVideoWithoutAudio();
+    EXPECT_WK_STREQ(@&quot;not playing&quot;, (NSString *)[lastScriptMessage body]);
+    testAudioOnly();
+    EXPECT_WK_STREQ(@&quot;not playing&quot;, (NSString *)[lastScriptMessage body]);
+}
+
+TEST_F(RequiresUserActionForPlaybackTest, RequiresUserActionForAudioButNotVideoPlayback)
+{
+    configuration.get().mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeAudio;
+    createWebView();
+
+    testVideoWithAudio();
+    EXPECT_WK_STREQ(@&quot;not playing&quot;, (NSString *)[lastScriptMessage body]);
+    testVideoWithoutAudio();
+    EXPECT_WK_STREQ(@&quot;playing&quot;, (NSString *)[lastScriptMessage body]);
+    testAudioOnly();
+    EXPECT_WK_STREQ(@&quot;not playing&quot;, (NSString *)[lastScriptMessage body]);
+}
+
+TEST_F(RequiresUserActionForPlaybackTest, RequiresUserActionForVideoButNotAudioPlayback)
+{
+    configuration.get().mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeVideo;
+    createWebView();
+
+    testVideoWithAudio();
+    EXPECT_WK_STREQ(@&quot;not playing&quot;, (NSString *)[lastScriptMessage body]);
+    testVideoWithoutAudio();
+    EXPECT_WK_STREQ(@&quot;not playing&quot;, (NSString *)[lastScriptMessage body]);
+    testAudioOnly();
+    EXPECT_WK_STREQ(@&quot;playing&quot;, (NSString *)[lastScriptMessage body]);
+}
+
+TEST_F(RequiresUserActionForPlaybackTest, DeprecatedRequiresUserActionForAudioAndVideoPlayback)
+{
</ins><span class="cx">     configuration.get()._requiresUserActionForAudioPlayback = YES;
</span><span class="cx">     configuration.get()._requiresUserActionForVideoPlayback = YES;
</span><span class="cx">     createWebView();
</span><span class="lines">@@ -181,7 +219,7 @@
</span><span class="cx">     EXPECT_WK_STREQ(@&quot;not playing&quot;, (NSString *)[lastScriptMessage body]);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-TEST_F(RequiresUserActionForPlaybackTest, RequiresUserActionForAudioButNotVideoPlayback)
</del><ins>+TEST_F(RequiresUserActionForPlaybackTest, DeprecatedRequiresUserActionForAudioButNotVideoPlayback)
</ins><span class="cx"> {
</span><span class="cx">     configuration.get()._requiresUserActionForAudioPlayback = YES;
</span><span class="cx">     configuration.get()._requiresUserActionForVideoPlayback = NO;
</span><span class="lines">@@ -195,7 +233,7 @@
</span><span class="cx">     EXPECT_WK_STREQ(@&quot;not playing&quot;, (NSString *)[lastScriptMessage body]);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-TEST_F(RequiresUserActionForPlaybackTest, RequiresUserActionForVideoButNotAudioPlayback)
</del><ins>+TEST_F(RequiresUserActionForPlaybackTest, DeprecatedRequiresUserActionForVideoButNotAudioPlayback)
</ins><span class="cx"> {
</span><span class="cx">     configuration.get()._requiresUserActionForAudioPlayback = NO;
</span><span class="cx">     configuration.get()._requiresUserActionForVideoPlayback = YES;
</span></span></pre></div>
<a id="branchessafari602132branchToolsWebKitTestRunnercocoaTestControllerCocoamm"></a>
<div class="modfile"><h4>Modified: branches/safari-602.1.32-branch/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm (201153 => 201154)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-602.1.32-branch/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm        2016-05-19 08:41:20 UTC (rev 201153)
+++ branches/safari-602.1.32-branch/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm        2016-05-19 09:35:58 UTC (rev 201154)
</span><span class="lines">@@ -66,6 +66,7 @@
</span><span class="cx">     globalWebViewConfiguration._mediaDataLoadsAutomatically = YES;
</span><span class="cx">     globalWebViewConfiguration.requiresUserActionForMediaPlayback = NO;
</span><span class="cx"> #endif
</span><ins>+    globalWebViewConfiguration.mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone;
</ins><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>