<!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>[188255] trunk</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/188255">188255</a></dd>
<dt>Author</dt> <dd>mitz@apple.com</dd>
<dt>Date</dt> <dd>2015-08-11 09:14:15 -0700 (Tue, 11 Aug 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>[Cocoa] The UI delegate can't tell if printing was user-initiated
https://bugs.webkit.org/show_bug.cgi?id=147869

Reviewed by Sam Weinig.

Source/WebKit2:

* UIProcess/API/APIUIClient.h:
(API::UIClient::printFrame): Added processingUserGesture argument.

* UIProcess/API/C/WKPage.cpp:
(WKPageSetPageUIClient): Updated for new client function signature.

* UIProcess/API/Cocoa/WKUIDelegatePrivate.h: Added userInitiated boolean argument to
  -_webView:printFrame:.

* UIProcess/Cocoa/UIDelegate.h: Added bool to m_delegateMethods for the new method.
* UIProcess/Cocoa/UIDelegate.mm:
(WebKit::UIDelegate::UIDelegate):
(WebKit::UIDelegate::setDelegate): Initialized new bool.
(WebKit::UIDelegate::UIClient::printFrame): Pass processingUserGesture as the delegate’s
  userInitiated argument.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::printFrame): Added processingUserGesture argument, passing it along
  to the client.
* UIProcess/WebPageProxy.h:

* UIProcess/WebPageProxy.messages.in: Added processingUserGesture argument to printFrame.

* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::print): Pass new argument.

Tools:

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit2Cocoa/PrintFrame.mm: Added.
(-[PrintFrameController webView:didFinishNavigation:]):
(-[PrintFrameController _webView:printFrame:userInitiated:]):
(TEST):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIAPIUIClienth">trunk/Source/WebKit2/UIProcess/API/APIUIClient.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICWKPagecpp">trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKUIDelegatePrivateh">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegatePrivate.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessCocoaUIDelegateh">trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessCocoaUIDelegatemm">trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxycpp">trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxyh">trunk/Source/WebKit2/UIProcess/WebPageProxy.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxymessagesin">trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebCoreSupportWebChromeClientcpp">trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj">trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2CocoaPrintFramemm">trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/PrintFrame.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (188254 => 188255)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2015-08-11 14:56:37 UTC (rev 188254)
+++ trunk/Source/WebKit2/ChangeLog        2015-08-11 16:14:15 UTC (rev 188255)
</span><span class="lines">@@ -1,3 +1,36 @@
</span><ins>+2015-08-11  Dan Bernstein  &lt;mitz@apple.com&gt;
+
+        [Cocoa] The UI delegate can't tell if printing was user-initiated
+        https://bugs.webkit.org/show_bug.cgi?id=147869
+
+        Reviewed by Sam Weinig.
+
+        * UIProcess/API/APIUIClient.h:
+        (API::UIClient::printFrame): Added processingUserGesture argument.
+
+        * UIProcess/API/C/WKPage.cpp:
+        (WKPageSetPageUIClient): Updated for new client function signature.
+
+        * UIProcess/API/Cocoa/WKUIDelegatePrivate.h: Added userInitiated boolean argument to
+          -_webView:printFrame:.
+
+        * UIProcess/Cocoa/UIDelegate.h: Added bool to m_delegateMethods for the new method.
+        * UIProcess/Cocoa/UIDelegate.mm:
+        (WebKit::UIDelegate::UIDelegate):
+        (WebKit::UIDelegate::setDelegate): Initialized new bool.
+        (WebKit::UIDelegate::UIClient::printFrame): Pass processingUserGesture as the delegate’s
+          userInitiated argument.
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::printFrame): Added processingUserGesture argument, passing it along
+          to the client.
+        * UIProcess/WebPageProxy.h:
+
+        * UIProcess/WebPageProxy.messages.in: Added processingUserGesture argument to printFrame.
+
+        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+        (WebKit::WebChromeClient::print): Pass new argument.
+
</ins><span class="cx"> 2015-08-10  Matthew Daiter  &lt;mdaiter@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Add MediaDeviceIdentifier to WebsiteDataTypes
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIAPIUIClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/APIUIClient.h (188254 => 188255)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/APIUIClient.h        2015-08-11 14:56:37 UTC (rev 188254)
+++ trunk/Source/WebKit2/UIProcess/API/APIUIClient.h        2015-08-11 16:14:15 UTC (rev 188255)
</span><span class="lines">@@ -139,7 +139,7 @@
</span><span class="cx">     virtual float footerHeight(WebKit::WebPageProxy*, WebKit::WebFrameProxy*) { return 0; }
</span><span class="cx">     virtual void drawHeader(WebKit::WebPageProxy*, WebKit::WebFrameProxy*, const WebCore::FloatRect&amp;) { }
</span><span class="cx">     virtual void drawFooter(WebKit::WebPageProxy*, WebKit::WebFrameProxy*, const WebCore::FloatRect&amp;) { }
</span><del>-    virtual void printFrame(WebKit::WebPageProxy*, WebKit::WebFrameProxy*) { }
</del><ins>+    virtual void printFrame(WebKit::WebPageProxy*, WebKit::WebFrameProxy*, bool processingUserGesture) { }
</ins><span class="cx"> 
</span><span class="cx">     virtual bool canRunModal() const { return false; }
</span><span class="cx">     virtual void runModal(WebKit::WebPageProxy*) { }
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICWKPagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp (188254 => 188255)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp        2015-08-11 14:56:37 UTC (rev 188254)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp        2015-08-11 16:14:15 UTC (rev 188255)
</span><span class="lines">@@ -1730,7 +1730,7 @@
</span><span class="cx">             m_client.drawFooter(toAPI(page), toAPI(frame), toAPI(rect), m_client.base.clientInfo);
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        virtual void printFrame(WebPageProxy* page, WebFrameProxy* frame) override
</del><ins>+        virtual void printFrame(WebPageProxy* page, WebFrameProxy* frame, bool) override
</ins><span class="cx">         {
</span><span class="cx">             if (!m_client.printFrame)
</span><span class="cx">                 return;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKUIDelegatePrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegatePrivate.h (188254 => 188255)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegatePrivate.h        2015-08-11 14:56:37 UTC (rev 188254)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegatePrivate.h        2015-08-11 16:14:15 UTC (rev 188255)
</span><span class="lines">@@ -48,7 +48,7 @@
</span><span class="cx"> // FIXME: This should be handled by the WKWebsiteDataStore delegate.
</span><span class="cx"> - (void)_webView:(WKWebView *)webView decideWebApplicationCacheQuotaForSecurityOrigin:(WKSecurityOrigin *)securityOrigin currentQuota:(unsigned long long)currentQuota totalBytesNeeded:(unsigned long long)totalBytesNeeded decisionHandler:(void (^)(unsigned long long newQuota))decisionHandler;
</span><span class="cx"> 
</span><del>-- (void)_webView:(WKWebView *)webView printFrame:(_WKFrameHandle *)frame;
</del><ins>+- (void)_webView:(WKWebView *)webView printFrame:(_WKFrameHandle *)frame userInitiated:(BOOL)userInitiated WK_AVAILABLE(WK_MAC_TBA, WK_IOS_TBA);
</ins><span class="cx"> 
</span><span class="cx"> - (void)_webViewClose:(WKWebView *)webView;
</span><span class="cx"> - (void)_webViewFullscreenMayReturnToInline:(WKWebView *)webView;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaUIDelegateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.h (188254 => 188255)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.h        2015-08-11 14:56:37 UTC (rev 188254)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.h        2015-08-11 16:14:15 UTC (rev 188255)
</span><span class="lines">@@ -68,7 +68,7 @@
</span><span class="cx">         virtual void runJavaScriptPrompt(WebKit::WebPageProxy*, const WTF::String&amp;, const WTF::String&amp;, WebKit::WebFrameProxy*, const WebKit::SecurityOriginData&amp;, std::function&lt;void (const WTF::String&amp;)&gt; completionHandler) override;
</span><span class="cx">         virtual void exceededDatabaseQuota(WebPageProxy*, WebFrameProxy*, API::SecurityOrigin*, const WTF::String&amp; databaseName, const WTF::String&amp; displayName, unsigned long long currentQuota, unsigned long long currentOriginUsage, unsigned long long currentUsage, unsigned long long expectedUsage, std::function&lt;void (unsigned long long)&gt;) override;
</span><span class="cx">         virtual void reachedApplicationCacheOriginQuota(WebPageProxy*, const WebCore::SecurityOrigin&amp;, uint64_t currentQuota, uint64_t totalBytesNeeded, std::function&lt;void (unsigned long long)&gt; completionHandler) override;
</span><del>-        virtual void printFrame(WebKit::WebPageProxy*, WebKit::WebFrameProxy*) override;
</del><ins>+        virtual void printFrame(WebKit::WebPageProxy*, WebKit::WebFrameProxy*, bool processingUserGesture) override;
</ins><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx"> #if HAVE(APP_LINKS)
</span><span class="cx">         virtual bool shouldIncludeAppLinkActionsForElement(_WKActivatedElementInfo *) override;
</span><span class="lines">@@ -94,6 +94,7 @@
</span><span class="cx">         bool webViewDecideDatabaseQuotaForSecurityOriginCurrentQuotaCurrentOriginUsageCurrentDatabaseUsageExpectedUsageDecisionHandler : 1;
</span><span class="cx">         bool webViewDecideWebApplicationCacheQuotaForSecurityOriginCurrentQuotaTotalBytesNeeded : 1;
</span><span class="cx">         bool webViewPrintFrame : 1;
</span><ins>+        bool webViewPrintFrameUserInitiated : 1;
</ins><span class="cx">         bool webViewDidClose : 1;
</span><span class="cx">         bool webViewClose : 1;
</span><span class="cx">         bool webViewFullscreenMayReturnToInline : 1;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaUIDelegatemm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.mm (188254 => 188255)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.mm        2015-08-11 14:56:37 UTC (rev 188254)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/UIDelegate.mm        2015-08-11 16:14:15 UTC (rev 188255)
</span><span class="lines">@@ -41,6 +41,11 @@
</span><span class="cx"> #import &quot;_WKFrameHandleInternal.h&quot;
</span><span class="cx"> #import &lt;WebCore/URL.h&gt;
</span><span class="cx"> 
</span><ins>+@protocol WKUIDelegatePrivateDeprecated &lt;WKUIDelegatePrivate&gt;
+@optional
+- (void)_webView:(WKWebView *)webView printFrame:(_WKFrameHandle *)frame;
+@end
+
</ins><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><span class="cx"> UIDelegate::UIDelegate(WKWebView *webView)
</span><span class="lines">@@ -73,6 +78,7 @@
</span><span class="cx">     m_delegateMethods.webViewDecideDatabaseQuotaForSecurityOriginCurrentQuotaCurrentOriginUsageCurrentDatabaseUsageExpectedUsageDecisionHandler = [delegate respondsToSelector:@selector(_webView:decideDatabaseQuotaForSecurityOrigin:currentQuota:currentOriginUsage:currentDatabaseUsage:expectedUsage:decisionHandler:)];
</span><span class="cx">     m_delegateMethods.webViewDecideWebApplicationCacheQuotaForSecurityOriginCurrentQuotaTotalBytesNeeded = [delegate respondsToSelector:@selector(_webView:decideWebApplicationCacheQuotaForSecurityOrigin:currentQuota:totalBytesNeeded:decisionHandler:)];
</span><span class="cx">     m_delegateMethods.webViewPrintFrame = [delegate respondsToSelector:@selector(_webView:printFrame:)];
</span><ins>+    m_delegateMethods.webViewPrintFrameUserInitiated = [delegate respondsToSelector:@selector(_webView:printFrame:userInitiated:)];
</ins><span class="cx">     m_delegateMethods.webViewDidClose = [delegate respondsToSelector:@selector(webViewDidClose:)];
</span><span class="cx">     m_delegateMethods.webViewClose = [delegate respondsToSelector:@selector(_webViewClose:)];
</span><span class="cx">     m_delegateMethods.webViewFullscreenMayReturnToInline = [delegate respondsToSelector:@selector(_webViewFullscreenMayReturnToInline:)];
</span><span class="lines">@@ -230,18 +236,21 @@
</span><span class="cx">     }];
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void UIDelegate::UIClient::printFrame(WebKit::WebPageProxy*, WebKit::WebFrameProxy* webFrameProxy)
</del><ins>+void UIDelegate::UIClient::printFrame(WebKit::WebPageProxy*, WebKit::WebFrameProxy* webFrameProxy, bool processingUserGesture)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT_ARG(webFrameProxy, webFrameProxy);
</span><span class="cx"> 
</span><del>-    if (!m_uiDelegate.m_delegateMethods.webViewPrintFrame)
</del><ins>+    if (!m_uiDelegate.m_delegateMethods.webViewPrintFrame  &amp;&amp; !m_uiDelegate.m_delegateMethods.webViewPrintFrameUserInitiated)
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     auto delegate = m_uiDelegate.m_delegate.get();
</span><span class="cx">     if (!delegate)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    [(id &lt;WKUIDelegatePrivate&gt;)delegate _webView:m_uiDelegate.m_webView printFrame:wrapper(API::FrameHandle::create(webFrameProxy-&gt;frameID()))];
</del><ins>+    if (m_uiDelegate.m_delegateMethods.webViewPrintFrameUserInitiated)
+        [(id &lt;WKUIDelegatePrivate&gt;)delegate _webView:m_uiDelegate.m_webView printFrame:wrapper(API::FrameHandle::create(webFrameProxy-&gt;frameID())) userInitiated:processingUserGesture];
+    else
+        [(id &lt;WKUIDelegatePrivateDeprecated&gt;)delegate _webView:m_uiDelegate.m_webView printFrame:wrapper(API::FrameHandle::create(webFrameProxy-&gt;frameID()))];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void UIDelegate::UIClient::close(WebKit::WebPageProxy*)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (188254 => 188255)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp        2015-08-11 14:56:37 UTC (rev 188254)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp        2015-08-11 16:14:15 UTC (rev 188255)
</span><span class="lines">@@ -3836,7 +3836,7 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPageProxy::printFrame(uint64_t frameID)
</del><ins>+void WebPageProxy::printFrame(uint64_t frameID, bool processingUserGesture)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(!m_isPerformingDOMPrintOperation);
</span><span class="cx">     m_isPerformingDOMPrintOperation = true;
</span><span class="lines">@@ -3844,17 +3844,12 @@
</span><span class="cx">     WebFrameProxy* frame = m_process-&gt;webFrame(frameID);
</span><span class="cx">     MESSAGE_CHECK(frame);
</span><span class="cx"> 
</span><del>-    m_uiClient-&gt;printFrame(this, frame);
</del><ins>+    m_uiClient-&gt;printFrame(this, frame, processingUserGesture);
</ins><span class="cx"> 
</span><span class="cx">     endPrinting(); // Send a message synchronously while m_isPerformingDOMPrintOperation is still true.
</span><span class="cx">     m_isPerformingDOMPrintOperation = false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPageProxy::printMainFrame()
-{
-    printFrame(m_mainFrame-&gt;frameID());
-}
-
</del><span class="cx"> void WebPageProxy::setMediaVolume(float volume)
</span><span class="cx"> {
</span><span class="cx">     if (volume == m_mediaVolume)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (188254 => 188255)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h        2015-08-11 14:56:37 UTC (rev 188254)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h        2015-08-11 16:14:15 UTC (rev 188255)
</span><span class="lines">@@ -913,8 +913,6 @@
</span><span class="cx"> 
</span><span class="cx">     void setShouldSendEventsSynchronously(bool sync) { m_shouldSendEventsSynchronously = sync; };
</span><span class="cx"> 
</span><del>-    void printMainFrame();
-    
</del><span class="cx">     void setMediaVolume(float);
</span><span class="cx">     void setMuted(bool);
</span><span class="cx">     void setMayStartMediaWhenInWindow(bool);
</span><span class="lines">@@ -1180,7 +1178,7 @@
</span><span class="cx">     void didChangeViewportProperties(const WebCore::ViewportAttributes&amp;);
</span><span class="cx">     void pageDidScroll();
</span><span class="cx">     void runOpenPanel(uint64_t frameID, const WebCore::FileChooserSettings&amp;);
</span><del>-    void printFrame(uint64_t frameID);
</del><ins>+    void printFrame(uint64_t frameID, bool processingUserGesture);
</ins><span class="cx">     void exceededDatabaseQuota(uint64_t frameID, const String&amp; originIdentifier, const String&amp; databaseName, const String&amp; displayName, uint64_t currentQuota, uint64_t currentOriginUsage, uint64_t currentDatabaseUsage, uint64_t expectedUsage, PassRefPtr&lt;Messages::WebPageProxy::ExceededDatabaseQuota::DelayedReply&gt;);
</span><span class="cx">     void reachedApplicationCacheOriginQuota(const String&amp; originIdentifier, uint64_t currentQuota, uint64_t totalBytesNeeded, PassRefPtr&lt;Messages::WebPageProxy::ReachedApplicationCacheOriginQuota::DelayedReply&gt;);
</span><span class="cx">     void requestGeolocationPermissionForFrame(uint64_t geolocationID, uint64_t frameID, String originIdentifier);
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxymessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in (188254 => 188255)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in        2015-08-11 14:56:37 UTC (rev 188254)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in        2015-08-11 16:14:15 UTC (rev 188255)
</span><span class="lines">@@ -76,7 +76,7 @@
</span><span class="cx">     RunBeforeUnloadConfirmPanel(String message, uint64_t frameID) -&gt; (bool shouldClose)
</span><span class="cx">     PageDidScroll()
</span><span class="cx">     RunOpenPanel(uint64_t frameID, struct WebCore::FileChooserSettings parameters)
</span><del>-    PrintFrame(uint64_t frameID) -&gt; ()
</del><ins>+    PrintFrame(uint64_t frameID, bool processingUserGesture) -&gt; ()
</ins><span class="cx">     RunModal()
</span><span class="cx">     NotifyScrollerThumbIsVisibleInRect(WebCore::IntRect scrollerThumb)
</span><span class="cx">     RecommendedScrollbarStyleDidChange(int32_t newStyle)
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebCoreSupportWebChromeClientcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp (188254 => 188255)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp        2015-08-11 14:56:37 UTC (rev 188254)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp        2015-08-11 16:14:15 UTC (rev 188255)
</span><span class="lines">@@ -680,7 +680,7 @@
</span><span class="cx">     if (WebPage::synchronousMessagesShouldSpinRunLoop())
</span><span class="cx">         syncSendFlags |= IPC::SpinRunLoopWhileWaitingForReply;
</span><span class="cx">     
</span><del>-    m_page-&gt;sendSync(Messages::WebPageProxy::PrintFrame(webFrame-&gt;frameID()), Messages::WebPageProxy::PrintFrame::Reply(), std::chrono::milliseconds::max(), syncSendFlags);
</del><ins>+    m_page-&gt;sendSync(Messages::WebPageProxy::PrintFrame(webFrame-&gt;frameID(), ScriptController::processingUserGesture()), Messages::WebPageProxy::PrintFrame::Reply(), std::chrono::milliseconds::max(), syncSendFlags);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebChromeClient::exceededDatabaseQuota(Frame* frame, const String&amp; databaseName, DatabaseDetails details)
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (188254 => 188255)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2015-08-11 14:56:37 UTC (rev 188254)
+++ trunk/Tools/ChangeLog        2015-08-11 16:14:15 UTC (rev 188255)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2015-08-11  Dan Bernstein  &lt;mitz@apple.com&gt;
+
+        [Cocoa] The UI delegate can't tell if printing was user-initiated
+        https://bugs.webkit.org/show_bug.cgi?id=147869
+
+        Reviewed by Sam Weinig.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKit2Cocoa/PrintFrame.mm: Added.
+        (-[PrintFrameController webView:didFinishNavigation:]):
+        (-[PrintFrameController _webView:printFrame:userInitiated:]):
+        (TEST):
+
</ins><span class="cx"> 2015-08-10  Alex Christensen  &lt;achristensen@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Another build fix after r188239.
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (188254 => 188255)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2015-08-11 14:56:37 UTC (rev 188254)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2015-08-11 16:14:15 UTC (rev 188255)
</span><span class="lines">@@ -39,6 +39,7 @@
</span><span class="cx">                 33DC8912141955FE00747EF7 /* simple-iframe.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 33DC890E1419539300747EF7 /* simple-iframe.html */; };
</span><span class="cx">                 33DC89141419579F00747EF7 /* LoadCanceledNoServerRedirectCallback_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 33DC89131419579F00747EF7 /* LoadCanceledNoServerRedirectCallback_Bundle.cpp */; };
</span><span class="cx">                 33E79E06137B5FD900E32D99 /* mouse-move-listener.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 33E79E05137B5FCE00E32D99 /* mouse-move-listener.html */; };
</span><ins>+                376481801B79CD8D00D24B97 /* PrintFrame.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3764817D1B79CD7D00D24B97 /* PrintFrame.mm */; settings = {ASSET_TAGS = (); }; };
</ins><span class="cx">                 378E64771632655E00B6C676 /* InjectedBundleFrameHitTest_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 378E64751632655D00B6C676 /* InjectedBundleFrameHitTest_Bundle.cpp */; };
</span><span class="cx">                 378E64791632707400B6C676 /* link-with-title.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 378E647816326FDF00B6C676 /* link-with-title.html */; };
</span><span class="cx">                 379028B914FAC24C007E6B43 /* acceptsFirstMouse.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 379028B814FABE49007E6B43 /* acceptsFirstMouse.html */; };
</span><span class="lines">@@ -496,6 +497,7 @@
</span><span class="cx">                 33E79E05137B5FCE00E32D99 /* mouse-move-listener.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = &quot;mouse-move-listener.html&quot;; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 3722C8681461E03E00C45D00 /* RenderedImageFromDOMRange.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RenderedImageFromDOMRange.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 3751AF7A169518F800764319 /* DOMNodeFromJSObject.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMNodeFromJSObject.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                3764817D1B79CD7D00D24B97 /* PrintFrame.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PrintFrame.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 3776BC62150946BC0043A66D /* DeviceScaleFactorInDashboardRegions.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DeviceScaleFactorInDashboardRegions.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 378E64711632646D00B6C676 /* InjectedBundleFrameHitTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedBundleFrameHitTest.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 378E64751632655D00B6C676 /* InjectedBundleFrameHitTest_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedBundleFrameHitTest_Bundle.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -866,6 +868,7 @@
</span><span class="cx">                                 1ABC3DED1899BE6D004F0626 /* Navigation.mm */,
</span><span class="cx">                                 CEA6CF2219CCF5BD0064F5A7 /* OpenAndCloseWindow.mm */,
</span><span class="cx">                                 C95501BE19AD2FAF0049BE3E /* Preferences.mm */,
</span><ins>+                                3764817D1B79CD7D00D24B97 /* PrintFrame.mm */,
</ins><span class="cx">                                 37D36F311B004DD400BAF5D9 /* ProvisionalURLChange.mm */,
</span><span class="cx">                                 37BCA61B1B596BA9002012CA /* ShouldOpenExternalURLsInNewWindowActions.mm */,
</span><span class="cx">                                 2D9A53AE1B31FA8D0074D5AA /* ShrinkToFit.mm */,
</span><span class="lines">@@ -1561,6 +1564,7 @@
</span><span class="cx">                                 7CCE7F0B1A411AE600447C4C /* PreventEmptyUserAgent.cpp in Sources */,
</span><span class="cx">                                 7CCE7F2C1A411B1000447C4C /* PreventImageLoadWithAutoResizing.mm in Sources */,
</span><span class="cx">                                 7CCE7F0C1A411AE600447C4C /* PrivateBrowsingPushStateNoHistoryCallback.cpp in Sources */,
</span><ins>+                                376481801B79CD8D00D24B97 /* PrintFrame.mm in Sources */,
</ins><span class="cx">                                 7CCE7EC81A411A7E00447C4C /* PublicSuffix.mm in Sources */,
</span><span class="cx">                                 7CCE7F3E1A411B8E00447C4C /* RedBlackTree.cpp in Sources */,
</span><span class="cx">                                 7CCE7F3F1A411B8E00447C4C /* Ref.cpp in Sources */,
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2CocoaPrintFramemm"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/PrintFrame.mm (0 => 188255)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/PrintFrame.mm                                (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/PrintFrame.mm        2015-08-11 16:14:15 UTC (rev 188255)
</span><span class="lines">@@ -0,0 +1,92 @@
</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;
+
+#if PLATFORM(MAC)
+
+#import &quot;PlatformUtilities.h&quot;
+#import &lt;WebKit/WKUIDelegatePrivate.h&gt;
+#import &lt;WebKit/WKWebView.h&gt;
+#import &lt;wtf/RetainPtr.h&gt;
+
+#if WK_API_ENABLED
+
+static bool isDone;
+static bool isUserInitiated;
+
+@interface PrintFrameController : NSObject &lt;WKNavigationDelegate, WKUIDelegate&gt;
+@end
+
+@implementation PrintFrameController
+
+- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation
+{
+    isDone = true;
+}
+
+- (void)_webView:(WKWebView *)webView printFrame:(_WKFrameHandle *)frame userInitiated:(BOOL)userInitiated
+{
+    isUserInitiated = userInitiated;
+    isDone = true;
+}
+
+@end
+
+TEST(WebKit2, PrintFrame)
+{
+    auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
+
+    auto window = adoptNS([[NSWindow alloc] initWithContentRect:[webView frame] styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:YES]);
+    [[window contentView] addSubview:webView.get()];
+
+    auto controller = adoptNS([[PrintFrameController alloc] init]);
+    [webView setNavigationDelegate:controller.get()];
+    [webView setUIDelegate:controller.get()];
+
+    [webView loadHTMLString:@&quot;&lt;body onclick=\&quot;print()\&quot;&gt;&quot; baseURL:nil];
+    TestWebKitAPI::Util::run(&amp;isDone);
+    isDone = false;
+
+    NSPoint clickPoint = NSMakePoint(100, 100);
+
+    [[webView hitTest:clickPoint] mouseDown:[NSEvent mouseEventWithType:NSLeftMouseDown location:clickPoint modifierFlags:0 timestamp:0 windowNumber:[window windowNumber] context:nil eventNumber:0 clickCount:1 pressure:1]];
+    [[webView hitTest:clickPoint] mouseUp:[NSEvent mouseEventWithType:NSLeftMouseUp location:clickPoint modifierFlags:0 timestamp:0 windowNumber:[window windowNumber] context:nil eventNumber:0 clickCount:1 pressure:1]];
+    TestWebKitAPI::Util::run(&amp;isDone);
+    isDone = false;
+
+    ASSERT_TRUE(isUserInitiated);
+
+    [webView evaluateJavaScript:@&quot;print()&quot; completionHandler:nil];
+
+    TestWebKitAPI::Util::run(&amp;isDone);
+    isDone = false;
+
+    ASSERT_FALSE(isUserInitiated);
+}
+
+#endif
+
+#endif
</ins></span></pre>
</div>
</div>

</body>
</html>