<!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>[184741] trunk/Source</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/184741">184741</a></dd>
<dt>Author</dt> <dd>beidson@apple.com</dd>
<dt>Date</dt> <dd>2015-05-21 17:35:53 -0700 (Thu, 21 May 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Add an &quot;initiated by user gesture&quot; flag to ResourceRequest.
https://bugs.webkit.org/show_bug.cgi?id=145281

Reviewed by Alex Christensen.

Source/WebCore:

Allow WebKit to tell WebCore what the new property key is:
* platform/ios/WebCoreSystemInterfaceIOS.mm:
* platform/mac/WebCoreSystemInterface.h:
* platform/mac/WebCoreSystemInterface.mm:

Add the flag to ResourceRequest, and make sure it encodes/decodes:
* platform/network/ResourceRequestBase.h:
(WebCore::ResourceRequestBase::initiatedByUserGesture):
(WebCore::ResourceRequestBase::setInitiatedByUserGesture):
(WebCore::ResourceRequestBase::encodeWithoutPlatformData):
(WebCore::ResourceRequestBase::decodeWithoutPlatformData):

Set/get the property on native CFURLRequestRefs:
* platform/network/cf/ResourceRequestCFNet.cpp:
(WebCore::ResourceRequest::doUpdatePlatformRequest):
(WebCore::ResourceRequest::doUpdateResourceRequest):

Set/get the property on native NSURLRequests:
* platform/network/cocoa/ResourceRequestCocoa.mm:
(WebCore::ResourceRequest::doUpdateResourceRequest):
(WebCore::ResourceRequest::doUpdatePlatformRequest):

Source/WebKit/mac:

* WebCoreSupport/WebSystemInterface.mm:
(WKResourceRequestIsUserInitiatedKey):
(InitWebCoreSystemInterface):

Source/WebKit2:

Expose a new category on NSURLRequest to allow SPI clients to easily set/get the flag:
* Shared/API/Cocoa/_WKNSURLRequestExtras.h: Added.
* Shared/API/Cocoa/_WKNSURLRequestExtras.mm: Added.
(-[NSURLRequest _web_isUserInitiated]):
(-[NSMutableURLRequest _web_setIsUserInitiated:]):

* WebKit2.xcodeproj/project.pbxproj:

Expose the new property key to WebCore:
* WebProcess/WebCoreSupport/mac/WebSystemInterface.mm:
(WKResourceRequestIsUserInitiatedKey):
(InitWebCoreSystemInterface):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformiosWebCoreSystemInterfaceIOSmm">trunk/Source/WebCore/platform/ios/WebCoreSystemInterfaceIOS.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformmacWebCoreSystemInterfaceh">trunk/Source/WebCore/platform/mac/WebCoreSystemInterface.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmacWebCoreSystemInterfacemm">trunk/Source/WebCore/platform/mac/WebCoreSystemInterface.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformnetworkResourceRequestBaseh">trunk/Source/WebCore/platform/network/ResourceRequestBase.h</a></li>
<li><a href="#trunkSourceWebCoreplatformnetworkcfResourceRequestCFNetcpp">trunk/Source/WebCore/platform/network/cf/ResourceRequestCFNet.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformnetworkcocoaResourceRequestCocoamm">trunk/Source/WebCore/platform/network/cocoa/ResourceRequestCocoa.mm</a></li>
<li><a href="#trunkSourceWebKitmacChangeLog">trunk/Source/WebKit/mac/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitmacWebCoreSupportWebSystemInterfacemm">trunk/Source/WebKit/mac/WebCoreSupport/WebSystemInterface.mm</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj">trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebCoreSupportmacWebSystemInterfacemm">trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2SharedAPICocoa_WKNSURLRequestExtrash">trunk/Source/WebKit2/Shared/API/Cocoa/_WKNSURLRequestExtras.h</a></li>
<li><a href="#trunkSourceWebKit2SharedAPICocoa_WKNSURLRequestExtrasmm">trunk/Source/WebKit2/Shared/API/Cocoa/_WKNSURLRequestExtras.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (184740 => 184741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-05-22 00:34:12 UTC (rev 184740)
+++ trunk/Source/WebCore/ChangeLog        2015-05-22 00:35:53 UTC (rev 184741)
</span><span class="lines">@@ -1,3 +1,32 @@
</span><ins>+2015-05-21  Brady Eidson  &lt;beidson@apple.com&gt;
+
+        Add an &quot;initiated by user gesture&quot; flag to ResourceRequest.
+        https://bugs.webkit.org/show_bug.cgi?id=145281
+
+        Reviewed by Alex Christensen.
+
+        Allow WebKit to tell WebCore what the new property key is:
+        * platform/ios/WebCoreSystemInterfaceIOS.mm:
+        * platform/mac/WebCoreSystemInterface.h:
+        * platform/mac/WebCoreSystemInterface.mm:
+
+        Add the flag to ResourceRequest, and make sure it encodes/decodes:
+        * platform/network/ResourceRequestBase.h:
+        (WebCore::ResourceRequestBase::initiatedByUserGesture):
+        (WebCore::ResourceRequestBase::setInitiatedByUserGesture):
+        (WebCore::ResourceRequestBase::encodeWithoutPlatformData):
+        (WebCore::ResourceRequestBase::decodeWithoutPlatformData):
+
+        Set/get the property on native CFURLRequestRefs:
+        * platform/network/cf/ResourceRequestCFNet.cpp:
+        (WebCore::ResourceRequest::doUpdatePlatformRequest):
+        (WebCore::ResourceRequest::doUpdateResourceRequest):
+
+        Set/get the property on native NSURLRequests:
+        * platform/network/cocoa/ResourceRequestCocoa.mm:
+        (WebCore::ResourceRequest::doUpdateResourceRequest):
+        (WebCore::ResourceRequest::doUpdatePlatformRequest):
+
</ins><span class="cx"> 2015-05-21  Daniel Bates  &lt;dabates@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Rollout &lt;http://trac.webkit.org/changeset/183909&gt;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformiosWebCoreSystemInterfaceIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ios/WebCoreSystemInterfaceIOS.mm (184740 => 184741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/WebCoreSystemInterfaceIOS.mm        2015-05-22 00:34:12 UTC (rev 184740)
+++ trunk/Source/WebCore/platform/ios/WebCoreSystemInterfaceIOS.mm        2015-05-22 00:35:53 UTC (rev 184741)
</span><span class="lines">@@ -124,3 +124,5 @@
</span><span class="cx"> 
</span><span class="cx"> WEBCORE_EXPORT bool (*wkQueryDecoderAvailability)(void);
</span><span class="cx"> 
</span><ins>+WEBCORE_EXPORT CFStringRef (*wkResourceRequestIsUserInitiatedKey)(void);
+
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformmacWebCoreSystemInterfaceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mac/WebCoreSystemInterface.h (184740 => 184741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mac/WebCoreSystemInterface.h        2015-05-22 00:34:12 UTC (rev 184740)
+++ trunk/Source/WebCore/platform/mac/WebCoreSystemInterface.h        2015-05-22 00:35:53 UTC (rev 184741)
</span><span class="lines">@@ -318,6 +318,8 @@
</span><span class="cx"> extern CFStringRef (*wkCachePartitionKey)(void);
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+extern CFStringRef (*wkResourceRequestIsUserInitiatedKey)(void);
+
</ins><span class="cx"> typedef enum {
</span><span class="cx">     wkExternalPlaybackTypeNone,
</span><span class="cx">     wkExternalPlaybackTypeAirPlay,
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmacWebCoreSystemInterfacemm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mac/WebCoreSystemInterface.mm (184740 => 184741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mac/WebCoreSystemInterface.mm        2015-05-22 00:34:12 UTC (rev 184740)
+++ trunk/Source/WebCore/platform/mac/WebCoreSystemInterface.mm        2015-05-22 00:35:53 UTC (rev 184741)
</span><span class="lines">@@ -170,6 +170,8 @@
</span><span class="cx"> CFStringRef (*wkCachePartitionKey)(void);
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+CFStringRef (*wkResourceRequestIsUserInitiatedKey)(void);
+
</ins><span class="cx"> int (*wkExernalDeviceTypeForPlayer)(AVPlayer *);
</span><span class="cx"> NSString *(*wkExernalDeviceDisplayNameForPlayer)(AVPlayer *);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformnetworkResourceRequestBaseh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/network/ResourceRequestBase.h (184740 => 184741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/network/ResourceRequestBase.h        2015-05-22 00:34:12 UTC (rev 184740)
+++ trunk/Source/WebCore/platform/network/ResourceRequestBase.h        2015-05-22 00:35:53 UTC (rev 184741)
</span><span class="lines">@@ -147,6 +147,9 @@
</span><span class="cx">         bool hiddenFromInspector() const { return m_hiddenFromInspector; }
</span><span class="cx">         void setHiddenFromInspector(bool hiddenFromInspector) { m_hiddenFromInspector = hiddenFromInspector; }
</span><span class="cx"> 
</span><ins>+        bool initiatedByUserGesture() const { return m_initiatedByUserGesture; }
+        void setInitiatedByUserGesture(bool initiatedByUserGesture) { m_initiatedByUserGesture = initiatedByUserGesture; }
+
</ins><span class="cx">         enum class Requester { Unspecified, Main, XHR };
</span><span class="cx">         Requester requester() const { return m_requester; }
</span><span class="cx">         void setRequester(Requester requester) { m_requester = requester; }
</span><span class="lines">@@ -213,6 +216,7 @@
</span><span class="cx">         bool m_reportLoadTiming { false };
</span><span class="cx">         bool m_reportRawHeaders { false };
</span><span class="cx">         bool m_hiddenFromInspector { false };
</span><ins>+        bool m_initiatedByUserGesture { false };
</ins><span class="cx">         ResourceLoadPriority m_priority { ResourceLoadPriority::Low };
</span><span class="cx">         Requester m_requester { Requester::Unspecified };
</span><span class="cx"> 
</span><span class="lines">@@ -264,6 +268,7 @@
</span><span class="cx">     encoder &lt;&lt; m_allowCookies;
</span><span class="cx">     encoder.encodeEnum(m_priority);
</span><span class="cx">     encoder.encodeEnum(m_requester);
</span><ins>+    encoder &lt;&lt; m_initiatedByUserGesture;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> template&lt;class Decoder&gt;
</span><span class="lines">@@ -309,6 +314,9 @@
</span><span class="cx">     if (!decoder.decodeEnum(m_requester))
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><ins>+    if (!decoder.decode(m_initiatedByUserGesture))
+        return false;
+
</ins><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformnetworkcfResourceRequestCFNetcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/network/cf/ResourceRequestCFNet.cpp (184740 => 184741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/network/cf/ResourceRequestCFNet.cpp        2015-05-22 00:34:12 UTC (rev 184740)
+++ trunk/Source/WebCore/platform/network/cf/ResourceRequestCFNet.cpp        2015-05-22 00:35:53 UTC (rev 184741)
</span><span class="lines">@@ -186,6 +186,11 @@
</span><span class="cx">     }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if !PLATFORM(WIN)
+    if (initiatedByUserGesture())
+        _CFURLRequestSetProtocolProperty(cfRequest, wkResourceRequestIsUserInitiatedKey(), kCFBooleanTrue);
+#endif
+
</ins><span class="cx">     m_cfRequest = adoptCF(cfRequest);
</span><span class="cx"> #if PLATFORM(COCOA)
</span><span class="cx">     clearOrUpdateNSURLRequest();
</span><span class="lines">@@ -290,6 +295,12 @@
</span><span class="cx">     if (cachePartition)
</span><span class="cx">         m_cachePartition = cachePartition.get();
</span><span class="cx"> #endif
</span><ins>+
+#if !PLATFORM(WIN)
+    RetainPtr&lt;CFBooleanRef&gt; initiatedByUserGesture = adoptCF(static_cast&lt;CFBooleanRef&gt;(_CFURLRequestCopyProtocolPropertyForKey(m_cfRequest.get(), wkResourceRequestIsUserInitiatedKey())));
+    if (initiatedByUserGesture)
+        setInitiatedByUserGesture(CFBooleanGetValue(initiatedByUserGesture.get()));
+#endif
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void ResourceRequest::doUpdateResourceHTTPBody()
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformnetworkcocoaResourceRequestCocoamm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/network/cocoa/ResourceRequestCocoa.mm (184740 => 184741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/network/cocoa/ResourceRequestCocoa.mm        2015-05-22 00:34:12 UTC (rev 184740)
+++ trunk/Source/WebCore/platform/network/cocoa/ResourceRequestCocoa.mm        2015-05-22 00:35:53 UTC (rev 184741)
</span><span class="lines">@@ -102,6 +102,10 @@
</span><span class="cx">             m_cachePartition = cachePartition;
</span><span class="cx">     }
</span><span class="cx"> #endif
</span><ins>+
+    NSNumber *initiatedByUserGesture = [NSURLProtocol propertyForKey:(NSString *)wkResourceRequestIsUserInitiatedKey() inRequest:m_nsRequest.get()];
+    if (initiatedByUserGesture)
+        setInitiatedByUserGesture(initiatedByUserGesture.boolValue);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void ResourceRequest::doUpdateResourceHTTPBody()
</span><span class="lines">@@ -178,6 +182,9 @@
</span><span class="cx">         [NSURLProtocol setProperty:partitionValue forKey:(NSString *)wkCachePartitionKey() inRequest:nsRequest];
</span><span class="cx">     }
</span><span class="cx"> #endif
</span><ins>+
+    if (initiatedByUserGesture())
+        [NSURLProtocol setProperty:@YES forKey:(NSString *)wkResourceRequestIsUserInitiatedKey() inRequest:nsRequest];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void ResourceRequest::doUpdatePlatformHTTPBody()
</span></span></pre></div>
<a id="trunkSourceWebKitmacChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/ChangeLog (184740 => 184741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/ChangeLog        2015-05-22 00:34:12 UTC (rev 184740)
+++ trunk/Source/WebKit/mac/ChangeLog        2015-05-22 00:35:53 UTC (rev 184741)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2015-05-21  Brady Eidson  &lt;beidson@apple.com&gt;
+
+        Add an &quot;initiated by user gesture&quot; flag to ResourceRequest.
+        https://bugs.webkit.org/show_bug.cgi?id=145281
+
+        Reviewed by Alex Christensen.
+
+        * WebCoreSupport/WebSystemInterface.mm:
+        (WKResourceRequestIsUserInitiatedKey):
+        (InitWebCoreSystemInterface):
+
</ins><span class="cx"> 2015-05-20  Anders Carlsson  &lt;andersca@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Fix build.
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebCoreSupportWebSystemInterfacemm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebSystemInterface.mm (184740 => 184741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebCoreSupport/WebSystemInterface.mm        2015-05-22 00:34:12 UTC (rev 184740)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebSystemInterface.mm        2015-05-22 00:35:53 UTC (rev 184741)
</span><span class="lines">@@ -36,6 +36,12 @@
</span><span class="cx"> 
</span><span class="cx"> #define INIT(function) wk##function = WK##function
</span><span class="cx"> 
</span><ins>+static CFStringRef WKResourceRequestIsUserInitiatedKey()
+{
+    static CFStringRef key = CFSTR(&quot;WKResourceRequestIsUserInitiatedKey&quot;);
+    return key;
+}
+
</ins><span class="cx"> void InitWebCoreSystemInterface(void)
</span><span class="cx"> {
</span><span class="cx">     static bool didInit;
</span><span class="lines">@@ -210,6 +216,7 @@
</span><span class="cx">     INIT(CachePartitionKey);
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+    INIT(ResourceRequestIsUserInitiatedKey);
</ins><span class="cx">     INIT(ExernalDeviceTypeForPlayer);
</span><span class="cx">     INIT(ExernalDeviceDisplayNameForPlayer);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (184740 => 184741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2015-05-22 00:34:12 UTC (rev 184740)
+++ trunk/Source/WebKit2/ChangeLog        2015-05-22 00:35:53 UTC (rev 184741)
</span><span class="lines">@@ -1,3 +1,23 @@
</span><ins>+2015-05-21  Brady Eidson  &lt;beidson@apple.com&gt;
+
+        Add an &quot;initiated by user gesture&quot; flag to ResourceRequest.
+        https://bugs.webkit.org/show_bug.cgi?id=145281
+
+        Reviewed by Alex Christensen.
+
+        Expose a new category on NSURLRequest to allow SPI clients to easily set/get the flag:
+        * Shared/API/Cocoa/_WKNSURLRequestExtras.h: Added.
+        * Shared/API/Cocoa/_WKNSURLRequestExtras.mm: Added.
+        (-[NSURLRequest _web_isUserInitiated]):
+        (-[NSMutableURLRequest _web_setIsUserInitiated:]):
+
+        * WebKit2.xcodeproj/project.pbxproj:
+
+        Expose the new property key to WebCore:
+        * WebProcess/WebCoreSupport/mac/WebSystemInterface.mm:
+        (WKResourceRequestIsUserInitiatedKey):
+        (InitWebCoreSystemInterface):
+
</ins><span class="cx"> 2015-05-21  Daniel Bates  &lt;dabates@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Rollout &lt;http://trac.webkit.org/changeset/183909&gt;
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedAPICocoa_WKNSURLRequestExtrash"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/Shared/API/Cocoa/_WKNSURLRequestExtras.h (0 => 184741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/API/Cocoa/_WKNSURLRequestExtras.h                                (rev 0)
+++ trunk/Source/WebKit2/Shared/API/Cocoa/_WKNSURLRequestExtras.h        2015-05-22 00:35:53 UTC (rev 184741)
</span><span class="lines">@@ -0,0 +1,38 @@
</span><ins>+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import &lt;WebKit/WKFoundation.h&gt;
+
+@interface NSURLRequest (WKExtras)
+
+- (BOOL)_web_isUserInitiated;
+
+@end
+
+@interface NSMutableURLRequest (WKExtras)
+
+- (void)_web_setIsUserInitiated:(BOOL)userInitiated;
+
+@end
</ins></span></pre></div>
<a id="trunkSourceWebKit2SharedAPICocoa_WKNSURLRequestExtrasmm"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/Shared/API/Cocoa/_WKNSURLRequestExtras.mm (0 => 184741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/API/Cocoa/_WKNSURLRequestExtras.mm                                (rev 0)
+++ trunk/Source/WebKit2/Shared/API/Cocoa/_WKNSURLRequestExtras.mm        2015-05-22 00:35:53 UTC (rev 184741)
</span><span class="lines">@@ -0,0 +1,48 @@
</span><ins>+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import &quot;config.h&quot;
+#import &quot;_WKNSURLRequestExtras.h&quot;
+
+#import &lt;WebCore/WebCoreSystemInterface.h&gt;
+
+@implementation NSURLRequest (WKExtras)
+
+- (BOOL)_web_isUserInitiated
+{
+    NSNumber *userInitiated = [NSURLProtocol propertyForKey:(NSString *)wkResourceRequestIsUserInitiatedKey() inRequest:self];
+    return userInitiated.boolValue;
+}
+
+@end
+
+@implementation NSMutableURLRequest (WKExtras)
+
+- (void)_web_setIsUserInitiated:(BOOL)userInitiated
+{
+    [NSURLProtocol setProperty:userInitiated ? @YES : @NO forKey:(NSString *)wkResourceRequestIsUserInitiatedKey() inRequest:self];
+}
+
+@end
</ins></span></pre></div>
<a id="trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (184740 => 184741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2015-05-22 00:34:12 UTC (rev 184740)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2015-05-22 00:35:53 UTC (rev 184741)
</span><span class="lines">@@ -1014,6 +1014,8 @@
</span><span class="cx">                 51AD35731AD2F3940057B38E /* WebHitTestResult.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51AD35721AD2F3750057B38E /* WebHitTestResult.mm */; };
</span><span class="cx">                 51B15A8413843A3900321AD8 /* EnvironmentUtilities.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51B15A8213843A3900321AD8 /* EnvironmentUtilities.cpp */; };
</span><span class="cx">                 51B15A8513843A3900321AD8 /* EnvironmentUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 51B15A8313843A3900321AD8 /* EnvironmentUtilities.h */; };
</span><ins>+                51B8F4831B0E539A008FC4BD /* _WKNSURLRequestExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = 51B8F47F1B0E530C008FC4BD /* _WKNSURLRequestExtras.h */; settings = {ATTRIBUTES = (Private, ); }; };
+                51B8F4841B0E53A1008FC4BD /* _WKNSURLRequestExtras.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51B8F4801B0E530C008FC4BD /* _WKNSURLRequestExtras.mm */; };
</ins><span class="cx">                 51BA24441858EE3000EA2811 /* AsyncTask.h in Headers */ = {isa = PBXBuildFile; fileRef = 51BA24431858EE3000EA2811 /* AsyncTask.h */; };
</span><span class="cx">                 51BA24461858F55D00EA2811 /* WebCrossThreadCopier.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51BA24451858F41500EA2811 /* WebCrossThreadCopier.cpp */; };
</span><span class="cx">                 51C96118183D294700D2002E /* WebIDBServerConnectionMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 51C96116183D294700D2002E /* WebIDBServerConnectionMessageReceiver.cpp */; };
</span><span class="lines">@@ -3219,6 +3221,8 @@
</span><span class="cx">                 51AD35721AD2F3750057B38E /* WebHitTestResult.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WebHitTestResult.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 51B15A8213843A3900321AD8 /* EnvironmentUtilities.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = EnvironmentUtilities.cpp; path = unix/EnvironmentUtilities.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 51B15A8313843A3900321AD8 /* EnvironmentUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = EnvironmentUtilities.h; path = unix/EnvironmentUtilities.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                51B8F47F1B0E530C008FC4BD /* _WKNSURLRequestExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKNSURLRequestExtras.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                51B8F4801B0E530C008FC4BD /* _WKNSURLRequestExtras.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = _WKNSURLRequestExtras.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 51BA24431858EE3000EA2811 /* AsyncTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AsyncTask.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 51BA24451858F41500EA2811 /* WebCrossThreadCopier.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WebCrossThreadCopier.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 51C96115183C95FF00D2002E /* WebIDBServerConnection.messages.in */ = {isa = PBXFileReference; lastKnownFileType = text; path = WebIDBServerConnection.messages.in; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -5504,6 +5508,8 @@
</span><span class="cx">                                 373D122618A473F60066D9CC /* _WKFrameHandleInternal.h */,
</span><span class="cx">                                 A118A9F11908B8EA00F7C92B /* _WKNSFileManagerExtras.h */,
</span><span class="cx">                                 A118A9F01908B8EA00F7C92B /* _WKNSFileManagerExtras.mm */,
</span><ins>+                                51B8F47F1B0E530C008FC4BD /* _WKNSURLRequestExtras.h */,
+                                51B8F4801B0E530C008FC4BD /* _WKNSURLRequestExtras.mm */,
</ins><span class="cx">                                 1A9E328B182165A900F5D04C /* _WKRemoteObjectInterface.h */,
</span><span class="cx">                                 1A9E328C182165A900F5D04C /* _WKRemoteObjectInterface.mm */,
</span><span class="cx">                                 1AABFE391829C1ED005B070E /* _WKRemoteObjectInterfaceInternal.h */,
</span><span class="lines">@@ -7829,6 +7835,7 @@
</span><span class="cx">                                 1A4A9C5612B816CF008FE984 /* NetscapePluginModule.h in Headers */,
</span><span class="cx">                                 1AA5889211EE70400061B882 /* NetscapePluginStream.h in Headers */,
</span><span class="cx">                                 E1798C7A16E6818800240139 /* NetworkBlobRegistry.h in Headers */,
</span><ins>+                                51B8F4831B0E539A008FC4BD /* _WKNSURLRequestExtras.h in Headers */,
</ins><span class="cx">                                 E4436ECC1A0D040B00EAD204 /* NetworkCache.h in Headers */,
</span><span class="cx">                                 E49D40D71AD3FB170066B7B9 /* NetworkCacheBlobStorage.h in Headers */,
</span><span class="cx">                                 E489D28A1A0A2DB80078C06A /* NetworkCacheCoder.h in Headers */,
</span><span class="lines">@@ -9569,6 +9576,7 @@
</span><span class="cx">                                 1A1D8BA11731A36300141DA4 /* LocalStorageDatabase.cpp in Sources */,
</span><span class="cx">                                 1A8C728C1738477C000A6554 /* LocalStorageDatabaseTracker.cpp in Sources */,
</span><span class="cx">                                 51A7F2F5125BF8D4008AEB1D /* Logging.cpp in Sources */,
</span><ins>+                                51B8F4841B0E53A1008FC4BD /* _WKNSURLRequestExtras.mm in Sources */,
</ins><span class="cx">                                 5160BFE113381DF900918999 /* LoggingFoundation.mm in Sources */,
</span><span class="cx">                                 1A24B5F211F531E800C38269 /* MachUtilities.cpp in Sources */,
</span><span class="cx">                                 51933DF01965EB31008AC3EA /* MenuUtilities.mm in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebCoreSupportmacWebSystemInterfacemm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm (184740 => 184741)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm        2015-05-22 00:34:12 UTC (rev 184740)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm        2015-05-22 00:35:53 UTC (rev 184741)
</span><span class="lines">@@ -31,6 +31,12 @@
</span><span class="cx"> 
</span><span class="cx"> #define INIT(function) wk##function = WK##function
</span><span class="cx"> 
</span><ins>+static CFStringRef WKResourceRequestIsUserInitiatedKey()
+{
+    static CFStringRef key = CFSTR(&quot;WKResourceRequestIsUserInitiatedKey&quot;);
+    return key;
+}
+
</ins><span class="cx"> void InitWebCoreSystemInterface(void)
</span><span class="cx"> {
</span><span class="cx">     static dispatch_once_t initOnce;
</span><span class="lines">@@ -201,7 +207,8 @@
</span><span class="cx"> #if ENABLE(CACHE_PARTITIONING)
</span><span class="cx">         INIT(CachePartitionKey);
</span><span class="cx"> #endif
</span><del>-        
</del><ins>+
+        INIT(ResourceRequestIsUserInitiatedKey);
</ins><span class="cx">         INIT(ExernalDeviceTypeForPlayer);
</span><span class="cx">         INIT(ExernalDeviceDisplayNameForPlayer);
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>