<!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>[215246] 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/215246">215246</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2017-04-11 11:43:46 -0700 (Tue, 11 Apr 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>Add SPI for handling geolocation authorization requests
https://bugs.webkit.org/show_bug.cgi?id=170362
rdar://problem/17508627

Patch by David Quesada &lt;david_quesada@apple.com&gt; on 2017-04-11
Reviewed by Alex Christensen.

Source/WebKit2:

Add a new WKUIDelegate method for the WKGeolocationProviderIOS to call when a web page
requests geolocation access. To support testing this change, make it possible to override
the CoreLocation abstraction WKGeolocationProviderIOS uses. There is now a configurable
object on the process pool that implements a protocol for providing location updates for
web views in the process pool. If the client doesn't provide this object,
WKGeolocationProviderIOS falls back to an object that wraps the existing WebKit1
WebGeolocationCoreLocationProvider and conforms to the new protocol.

* Shared/Cocoa/APIObject.mm:
(API::Object::newObject):
* Shared/WebGeolocationPosition.h:
(WebKit::WebGeolocationPosition::create):
* UIProcess/API/C/WKGeolocationPosition.cpp:
(WKGeolocationPositionCreate_b):
* UIProcess/API/Cocoa/WKProcessPool.mm:
(-[WKProcessPool _coreLocationProvider]):
(-[WKProcessPool _setCoreLocationProvider:]):
* UIProcess/API/Cocoa/WKProcessPoolPrivate.h:
* UIProcess/API/Cocoa/WKUIDelegatePrivate.h:
* UIProcess/API/Cocoa/_WKGeolocationCoreLocationProvider.h: Copied from Source/WebKit2/UIProcess/API/C/WKGeolocationPosition.cpp.
* UIProcess/API/Cocoa/_WKGeolocationPosition.h: Copied from Source/WebKit2/UIProcess/API/C/WKGeolocationPosition.cpp.
* UIProcess/API/Cocoa/_WKGeolocationPosition.mm: Added.
(WebKit::if):
(-[_WKGeolocationPosition dealloc]):
(-[_WKGeolocationPosition _apiObject]):
* UIProcess/API/Cocoa/_WKGeolocationPositionInternal.h: Copied from Source/WebKit2/UIProcess/API/C/WKGeolocationPosition.cpp.
(WebKit::wrapper):
* UIProcess/ios/WKGeolocationProviderIOS.mm:
(kit):
(-[WKGeolocationProviderIOS initWithProcessPool:]):
(-[WKGeolocationProviderIOS geolocationAuthorizationGranted]):
(-[WKGeolocationProviderIOS positionChanged:]):
(-[WKLegacyCoreLocationProvider setListener:]):
(-[WKLegacyCoreLocationProvider requestGeolocationAuthorization]):
(-[WKLegacyCoreLocationProvider start]):
(-[WKLegacyCoreLocationProvider stop]):
(-[WKLegacyCoreLocationProvider setEnableHighAccuracy:]):
(-[WKLegacyCoreLocationProvider geolocationAuthorizationGranted]):
(-[WKLegacyCoreLocationProvider geolocationAuthorizationDenied]):
(-[WKLegacyCoreLocationProvider positionChanged:]):
(-[WKLegacyCoreLocationProvider errorOccurred:]):
(-[WKLegacyCoreLocationProvider resetGeolocation]):
Implement a new class that bridges the currently used WebGeolocationCoreLocationProvider
to conform to the _WKGeolocationCoreLocationProvider protocol that WKGeolocationProviderIOS
expects.
* WebKit2.xcodeproj/project.pbxproj:

Tools:

Add API tests for the new WKUIDelegate SPI for allowing or denying websites permission
to use geolocation. Adopt the new WKProcessPool._coreLocationProvider property to
provide a stub object to simulate the various configurations of geolocation permissions:
1. The app doesn't have permission to use geolocation.
2. The app is allowed to use geolocation, but the UI delegate denies the web view permission.
3. The app is allowed to use geolocation, and the UI delegate allows the web view permission.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit2Cocoa/Geolocation.mm: Added.
(-[TestCoreLocationProvider setListener:]):
(-[TestCoreLocationProvider requestGeolocationAuthorization]):
(-[TestCoreLocationProvider start]):
(-[TestCoreLocationProvider stop]):
(-[TestCoreLocationProvider setEnableHighAccuracy:]):
(expectException):
(-[GeolocationTestUIDelegate _webView:requestGeolocationAuthorizationForURL:frame:decisionHandler:]):
(-[GeolocationTestUIDelegate webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:]):
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/WebKit2Cocoa/GeolocationGetCurrentPositionResult.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2SharedCocoaAPIObjectmm">trunk/Source/WebKit2/Shared/Cocoa/APIObject.mm</a></li>
<li><a href="#trunkSourceWebKit2SharedWebGeolocationPositionh">trunk/Source/WebKit2/Shared/WebGeolocationPosition.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICWKGeolocationPositioncpp">trunk/Source/WebKit2/UIProcess/API/C/WKGeolocationPosition.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKProcessPoolmm">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKProcessPool.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKProcessPoolPrivateh">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKUIDelegatePrivateh">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegatePrivate.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosWKGeolocationProviderIOSmm">trunk/Source/WebKit2/UIProcess/ios/WKGeolocationProviderIOS.mm</a></li>
<li><a href="#trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj">trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj</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="#trunkSourceWebKit2UIProcessAPICocoa_WKGeolocationCoreLocationProviderh">trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKGeolocationCoreLocationProvider.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoa_WKGeolocationPositionh">trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKGeolocationPosition.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoa_WKGeolocationPositionmm">trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKGeolocationPosition.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoa_WKGeolocationPositionInternalh">trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKGeolocationPositionInternal.h</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2CocoaGeolocationmm">trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/Geolocation.mm</a></li>
<li><a href="#trunkToolsTestWebKitAPITestsWebKit2CocoaGeolocationGetCurrentPositionResulthtml">trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/GeolocationGetCurrentPositionResult.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (215245 => 215246)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2017-04-11 18:41:39 UTC (rev 215245)
+++ trunk/Source/WebKit2/ChangeLog        2017-04-11 18:43:46 UTC (rev 215246)
</span><span class="lines">@@ -1,3 +1,58 @@
</span><ins>+2017-04-11  David Quesada  &lt;david_quesada@apple.com&gt;
+
+        Add SPI for handling geolocation authorization requests
+        https://bugs.webkit.org/show_bug.cgi?id=170362
+        rdar://problem/17508627
+
+        Reviewed by Alex Christensen.
+
+        Add a new WKUIDelegate method for the WKGeolocationProviderIOS to call when a web page
+        requests geolocation access. To support testing this change, make it possible to override
+        the CoreLocation abstraction WKGeolocationProviderIOS uses. There is now a configurable
+        object on the process pool that implements a protocol for providing location updates for
+        web views in the process pool. If the client doesn't provide this object,
+        WKGeolocationProviderIOS falls back to an object that wraps the existing WebKit1
+        WebGeolocationCoreLocationProvider and conforms to the new protocol.
+
+        * Shared/Cocoa/APIObject.mm:
+        (API::Object::newObject):
+        * Shared/WebGeolocationPosition.h:
+        (WebKit::WebGeolocationPosition::create):
+        * UIProcess/API/C/WKGeolocationPosition.cpp:
+        (WKGeolocationPositionCreate_b):
+        * UIProcess/API/Cocoa/WKProcessPool.mm:
+        (-[WKProcessPool _coreLocationProvider]):
+        (-[WKProcessPool _setCoreLocationProvider:]):
+        * UIProcess/API/Cocoa/WKProcessPoolPrivate.h:
+        * UIProcess/API/Cocoa/WKUIDelegatePrivate.h:
+        * UIProcess/API/Cocoa/_WKGeolocationCoreLocationProvider.h: Copied from Source/WebKit2/UIProcess/API/C/WKGeolocationPosition.cpp.
+        * UIProcess/API/Cocoa/_WKGeolocationPosition.h: Copied from Source/WebKit2/UIProcess/API/C/WKGeolocationPosition.cpp.
+        * UIProcess/API/Cocoa/_WKGeolocationPosition.mm: Added.
+        (WebKit::if):
+        (-[_WKGeolocationPosition dealloc]):
+        (-[_WKGeolocationPosition _apiObject]):
+        * UIProcess/API/Cocoa/_WKGeolocationPositionInternal.h: Copied from Source/WebKit2/UIProcess/API/C/WKGeolocationPosition.cpp.
+        (WebKit::wrapper):
+        * UIProcess/ios/WKGeolocationProviderIOS.mm:
+        (kit):
+        (-[WKGeolocationProviderIOS initWithProcessPool:]):
+        (-[WKGeolocationProviderIOS geolocationAuthorizationGranted]):
+        (-[WKGeolocationProviderIOS positionChanged:]):
+        (-[WKLegacyCoreLocationProvider setListener:]):
+        (-[WKLegacyCoreLocationProvider requestGeolocationAuthorization]):
+        (-[WKLegacyCoreLocationProvider start]):
+        (-[WKLegacyCoreLocationProvider stop]):
+        (-[WKLegacyCoreLocationProvider setEnableHighAccuracy:]):
+        (-[WKLegacyCoreLocationProvider geolocationAuthorizationGranted]):
+        (-[WKLegacyCoreLocationProvider geolocationAuthorizationDenied]):
+        (-[WKLegacyCoreLocationProvider positionChanged:]):
+        (-[WKLegacyCoreLocationProvider errorOccurred:]):
+        (-[WKLegacyCoreLocationProvider resetGeolocation]):
+        Implement a new class that bridges the currently used WebGeolocationCoreLocationProvider
+        to conform to the _WKGeolocationCoreLocationProvider protocol that WKGeolocationProviderIOS
+        expects.
+        * WebKit2.xcodeproj/project.pbxproj:
+
</ins><span class="cx"> 2017-04-11  Eric Carlson  &lt;eric.carlson@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [MediaStream] Set correct audio session category when capturing audio
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedCocoaAPIObjectmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/Cocoa/APIObject.mm (215245 => 215246)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/Cocoa/APIObject.mm        2017-04-11 18:41:39 UTC (rev 215245)
+++ trunk/Source/WebKit2/Shared/Cocoa/APIObject.mm        2017-04-11 18:43:46 UTC (rev 215246)
</span><span class="lines">@@ -72,6 +72,7 @@
</span><span class="cx"> #import &quot;_WKDownloadInternal.h&quot;
</span><span class="cx"> #import &quot;_WKExperimentalFeatureInternal.h&quot;
</span><span class="cx"> #import &quot;_WKFrameHandleInternal.h&quot;
</span><ins>+#import &quot;_WKGeolocationPositionInternal.h&quot;
</ins><span class="cx"> #import &quot;_WKHitTestResultInternal.h&quot;
</span><span class="cx"> #import &quot;_WKProcessPoolConfigurationInternal.h&quot;
</span><span class="cx"> #import &quot;_WKUserContentWorldInternal.h&quot;
</span><span class="lines">@@ -179,6 +180,12 @@
</span><span class="cx">         wrapper = [WKFrameInfo alloc];
</span><span class="cx">         break;
</span><span class="cx"> 
</span><ins>+#if PLATFORM(IOS)
+    case Type::GeolocationPosition:
+        wrapper = [_WKGeolocationPosition alloc];
+        break;
+#endif
+
</ins><span class="cx">     case Type::HTTPCookieStore:
</span><span class="cx">         wrapper = [WKHTTPCookieStore alloc];
</span><span class="cx">         break;
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedWebGeolocationPositionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/WebGeolocationPosition.h (215245 => 215246)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/WebGeolocationPosition.h        2017-04-11 18:41:39 UTC (rev 215245)
+++ trunk/Source/WebKit2/Shared/WebGeolocationPosition.h        2017-04-11 18:43:46 UTC (rev 215246)
</span><span class="lines">@@ -58,9 +58,9 @@
</span><span class="cx">         bool canProvideSpeed;
</span><span class="cx">     };
</span><span class="cx"> 
</span><del>-    static PassRefPtr&lt;WebGeolocationPosition&gt; create(double timestamp, double latitude, double longitude, double accuracy, bool providesAltitude, double altitude, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed)
</del><ins>+    static Ref&lt;WebGeolocationPosition&gt; create(double timestamp, double latitude, double longitude, double accuracy, bool providesAltitude, double altitude, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed)
</ins><span class="cx">     {
</span><del>-        return adoptRef(new WebGeolocationPosition(timestamp, latitude, longitude, accuracy, providesAltitude, altitude, providesAltitudeAccuracy, altitudeAccuracy, providesHeading, heading, providesSpeed, speed));
</del><ins>+        return adoptRef(*new WebGeolocationPosition(timestamp, latitude, longitude, accuracy, providesAltitude, altitude, providesAltitudeAccuracy, altitudeAccuracy, providesHeading, heading, providesSpeed, speed));
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     virtual ~WebGeolocationPosition();
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICWKGeolocationPositioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/C/WKGeolocationPosition.cpp (215245 => 215246)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/C/WKGeolocationPosition.cpp        2017-04-11 18:41:39 UTC (rev 215245)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKGeolocationPosition.cpp        2017-04-11 18:43:46 UTC (rev 215246)
</span><span class="lines">@@ -44,5 +44,5 @@
</span><span class="cx"> WKGeolocationPositionRef WKGeolocationPositionCreate_b(double timestamp, double latitude, double longitude, double accuracy, bool providesAltitude, double altitude, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed)
</span><span class="cx"> {
</span><span class="cx">     auto position = WebGeolocationPosition::create(timestamp, latitude, longitude, accuracy, providesAltitude, altitude, providesAltitudeAccuracy, altitudeAccuracy, providesHeading, heading, providesSpeed, speed);
</span><del>-    return toAPI(position.leakRef());
</del><ins>+    return toAPI(&amp;position.leakRef());
</ins><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKProcessPoolmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKProcessPool.mm (215245 => 215246)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKProcessPool.mm        2017-04-11 18:41:39 UTC (rev 215245)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKProcessPool.mm        2017-04-11 18:43:46 UTC (rev 215246)
</span><span class="lines">@@ -61,6 +61,7 @@
</span><span class="cx">     RetainPtr&lt;_WKAutomationSession&gt; _automationSession;
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">     RetainPtr&lt;WKGeolocationProviderIOS&gt; _geolocationProvider;
</span><ins>+    RetainPtr&lt;id &lt;_WKGeolocationCoreLocationProvider&gt;&gt; _coreLocationProvider;
</ins><span class="cx"> #endif // PLATFORM(IOS)
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -308,6 +309,21 @@
</span><span class="cx">     _processPool-&gt;setCookieStoragePartitioningEnabled(enabled);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#if PLATFORM(IOS)
+- (id &lt;_WKGeolocationCoreLocationProvider&gt;)_coreLocationProvider
+{
+    return _coreLocationProvider.get();
+}
+
+- (void)_setCoreLocationProvider:(id&lt;_WKGeolocationCoreLocationProvider&gt;)coreLocationProvider
+{
+    if (_geolocationProvider)
+        [NSException raise:NSGenericException format:@&quot;Changing the location provider is not supported after a web view in the process pool has begun servicing geolocation requests.&quot;];
+
+    _coreLocationProvider = coreLocationProvider;
+}
+#endif // PLATFORM(IOS)
+
</ins><span class="cx"> @end
</span><span class="cx"> 
</span><span class="cx"> #endif // WK_API_ENABLED
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKProcessPoolPrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h (215245 => 215246)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h        2017-04-11 18:41:39 UTC (rev 215245)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKProcessPoolPrivate.h        2017-04-11 18:43:46 UTC (rev 215246)
</span><span class="lines">@@ -31,6 +31,7 @@
</span><span class="cx"> @class _WKProcessPoolConfiguration;
</span><span class="cx"> @protocol _WKAutomationDelegate;
</span><span class="cx"> @protocol _WKDownloadDelegate;
</span><ins>+@protocol _WKGeolocationCoreLocationProvider;
</ins><span class="cx"> 
</span><span class="cx"> @interface WKProcessPool ()
</span><span class="cx"> - (instancetype)_initWithConfiguration:(_WKProcessPoolConfiguration *)configuration __attribute__((objc_method_family(init))) NS_DESIGNATED_INITIALIZER;
</span><span class="lines">@@ -54,6 +55,10 @@
</span><span class="cx"> @property (nonatomic, weak, setter=_setDownloadDelegate:) id &lt;_WKDownloadDelegate&gt; _downloadDelegate;
</span><span class="cx"> @property (nonatomic, weak, setter=_setAutomationDelegate:) id &lt;_WKAutomationDelegate&gt; _automationDelegate WK_API_AVAILABLE(macosx(10.12), ios(10.0));
</span><span class="cx"> 
</span><ins>+#if TARGET_OS_IPHONE
+@property (nonatomic, setter=_setCoreLocationProvider:) id &lt;_WKGeolocationCoreLocationProvider&gt; _coreLocationProvider WK_API_AVAILABLE(ios(WK_IOS_TBA));
+#endif
+
</ins><span class="cx"> + (NSURL *)_websiteDataURLForContainerWithURL:(NSURL *)containerURL;
</span><span class="cx"> + (NSURL *)_websiteDataURLForContainerWithURL:(NSURL *)containerURL bundleIdentifierIfNotInContainer:(NSString *)bundleIdentifier;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKUIDelegatePrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegatePrivate.h (215245 => 215246)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegatePrivate.h        2017-04-11 18:41:39 UTC (rev 215245)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegatePrivate.h        2017-04-11 18:43:46 UTC (rev 215246)
</span><span class="lines">@@ -35,6 +35,7 @@
</span><span class="cx"> @class UIItemProvider;
</span><span class="cx"> @class UIScrollView;
</span><span class="cx"> @class UIViewController;
</span><ins>+@class WKFrameInfo;
</ins><span class="cx"> @class _WKContextMenuElementInfo;
</span><span class="cx"> @class _WKActivatedElementInfo;
</span><span class="cx"> @class _WKElementAction;
</span><span class="lines">@@ -72,6 +73,7 @@
</span><span class="cx"> - (NSArray *)_webView:(WKWebView *)webView actionsForElement:(_WKActivatedElementInfo *)element defaultActions:(NSArray&lt;_WKElementAction *&gt; *)defaultActions;
</span><span class="cx"> - (void)_webView:(WKWebView *)webView didNotHandleTapAsClickAtPoint:(CGPoint)point;
</span><span class="cx"> - (BOOL)_webView:(WKWebView *)webView shouldRequestGeolocationAuthorizationForURL:(NSURL *)url isMainFrame:(BOOL)isMainFrame mainFrameURL:(NSURL *)mainFrameURL;
</span><ins>+- (void)_webView:(WKWebView *)webView requestGeolocationAuthorizationForURL:(NSURL *)url frame:(WKFrameInfo *)frame decisionHandler:(void (^)(BOOL authorized))decisionHandler WK_API_AVAILABLE(ios(WK_IOS_TBA));
</ins><span class="cx"> - (UIViewController *)_webView:(WKWebView *)webView previewViewControllerForURL:(NSURL *)url WK_API_AVAILABLE(ios(9.0));
</span><span class="cx"> - (void)_webView:(WKWebView *)webView commitPreviewedViewController:(UIViewController *)previewedViewController WK_API_AVAILABLE(ios(9.0));
</span><span class="cx"> - (void)_webView:(WKWebView *)webView willPreviewImageWithURL:(NSURL *)imageURL WK_API_AVAILABLE(ios(9.0));
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoa_WKGeolocationCoreLocationProviderhfromrev215245trunkSourceWebKit2UIProcessAPICWKGeolocationPositioncpp"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKGeolocationCoreLocationProvider.h (from rev 215245, trunk/Source/WebKit2/UIProcess/API/C/WKGeolocationPosition.cpp) (0 => 215246)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKGeolocationCoreLocationProvider.h                                (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKGeolocationCoreLocationProvider.h        2017-04-11 18:43:46 UTC (rev 215246)
</span><span class="lines">@@ -0,0 +1,54 @@
</span><ins>+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * 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;
+
+#if WK_API_ENABLED &amp;&amp; TARGET_OS_IPHONE
+
+#import &lt;Foundation/NSObject.h&gt;
+
+NS_ASSUME_NONNULL_BEGIN
+
+@class _WKGeolocationPosition;
+
+@protocol _WKGeolocationCoreLocationListener &lt;NSObject&gt;
+- (void)geolocationAuthorizationGranted;
+- (void)geolocationAuthorizationDenied;
+- (void)positionChanged:(_WKGeolocationPosition *)position;
+- (void)errorOccurred:(NSString *)errorMessage;
+- (void)resetGeolocation;
+@end
+
+@protocol _WKGeolocationCoreLocationProvider &lt;NSObject&gt;
+- (void)setListener:(id &lt;_WKGeolocationCoreLocationListener&gt;)listener;
+- (void)requestGeolocationAuthorization;
+- (void)start;
+- (void)stop;
+- (void)setEnableHighAccuracy:(BOOL)flag;
+@end
+
+NS_ASSUME_NONNULL_END
+
+#endif // WK_API_ENABLED &amp;&amp; TARGET_OS_IPHONE
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoa_WKGeolocationPositionhfromrev215245trunkSourceWebKit2UIProcessAPICWKGeolocationPositioncpp"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKGeolocationPosition.h (from rev 215245, trunk/Source/WebKit2/UIProcess/API/C/WKGeolocationPosition.cpp) (0 => 215246)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKGeolocationPosition.h                                (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKGeolocationPosition.h        2017-04-11 18:43:46 UTC (rev 215246)
</span><span class="lines">@@ -0,0 +1,45 @@
</span><ins>+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * 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;
+
+#if WK_API_ENABLED &amp;&amp; TARGET_OS_IPHONE
+
+#import &lt;Foundation/Foundation.h&gt;
+
+@class CLLocation;
+
+NS_ASSUME_NONNULL_BEGIN
+
+WK_CLASS_AVAILABLE(ios(WK_IOS_TBA))
+@interface _WKGeolocationPosition : NSObject
+
++ (instancetype)positionWithLocation:(CLLocation *)location;
+
+@end
+
+NS_ASSUME_NONNULL_END
+
+#endif // WK_API_ENABLED &amp;&amp; TARGET_OS_IPHONE
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoa_WKGeolocationPositionmm"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKGeolocationPosition.mm (0 => 215246)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKGeolocationPosition.mm                                (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKGeolocationPosition.mm        2017-04-11 18:43:46 UTC (rev 215246)
</span><span class="lines">@@ -0,0 +1,83 @@
</span><ins>+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * 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;_WKGeolocationPositionInternal.h&quot;
+
+#if WK_API_ENABLED &amp;&amp; TARGET_OS_IPHONE
+
+#import &lt;CoreLocation/CLLocation.h&gt;
+
+using namespace WebKit;
+
+@implementation _WKGeolocationPosition
+
++ (instancetype)positionWithLocation:(CLLocation *)location
+{
+    if (!location)
+        return nil;
+
+    bool canProvideAltitude = true;
+    bool canProvideAltitudeAccuracy = true;
+    double altitude = location.altitude;
+    double altitudeAccuracy = location.verticalAccuracy;
+    if (altitudeAccuracy &lt; 0.0) {
+        canProvideAltitude = false;
+        canProvideAltitudeAccuracy = false;
+    }
+
+    bool canProvideSpeed = true;
+    double speed = location.speed;
+    if (speed &lt; 0.0)
+        canProvideSpeed = false;
+
+    bool canProvideHeading = true;
+    double heading = location.course;
+    if (heading &lt; 0.0)
+        canProvideHeading = false;
+
+    CLLocationCoordinate2D coordinate = location.coordinate;
+    double timestamp = location.timestamp.timeIntervalSince1970;
+
+    return [wrapper(WebGeolocationPosition::create(timestamp, coordinate.latitude, coordinate.longitude, location.horizontalAccuracy, canProvideAltitude, altitude, canProvideAltitudeAccuracy, altitudeAccuracy, canProvideHeading, heading, canProvideSpeed, speed).leakRef()) autorelease];
+}
+
+- (void)dealloc
+{
+    _geolocationPosition-&gt;~WebGeolocationPosition();
+
+    [super dealloc];
+}
+
+#pragma mark WKObject protocol implementation
+
+- (API::Object&amp;)_apiObject
+{
+    return *_geolocationPosition;
+}
+
+@end
+
+#endif // WK_API_ENABLED &amp;&amp; TARGET_OS_IPHONE
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoa_WKGeolocationPositionInternalhfromrev215245trunkSourceWebKit2UIProcessAPICWKGeolocationPositioncpp"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKGeolocationPositionInternal.h (from rev 215245, trunk/Source/WebKit2/UIProcess/API/C/WKGeolocationPosition.cpp) (0 => 215246)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKGeolocationPositionInternal.h                                (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKGeolocationPositionInternal.h        2017-04-11 18:43:46 UTC (rev 215246)
</span><span class="lines">@@ -0,0 +1,48 @@
</span><ins>+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * 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;_WKGeolocationPosition.h&quot;
+
+#if WK_API_ENABLED &amp;&amp; TARGET_OS_IPHONE
+
+#import &quot;WebGeolocationPosition.h&quot;
+
+namespace WebKit {
+
+inline _WKGeolocationPosition *wrapper(WebKit::WebGeolocationPosition &amp;position)
+{
+    ASSERT([position.wrapper() isKindOfClass:[_WKGeolocationPosition class]]);
+    return (_WKGeolocationPosition *)position.wrapper();
+}
+
+}
+
+@interface _WKGeolocationPosition () &lt;WKObject&gt; {
+@package
+    API::ObjectStorage&lt;WebKit::WebGeolocationPosition&gt; _geolocationPosition;
+}
+@end
+
+#endif // WK_API_ENABLED &amp;&amp; TARGET_OS_IPHONE
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosWKGeolocationProviderIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/WKGeolocationProviderIOS.mm (215245 => 215246)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/WKGeolocationProviderIOS.mm        2017-04-11 18:41:39 UTC (rev 215245)
+++ trunk/Source/WebKit2/UIProcess/ios/WKGeolocationProviderIOS.mm        2017-04-11 18:43:46 UTC (rev 215246)
</span><span class="lines">@@ -28,16 +28,23 @@
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx"> 
</span><ins>+#import &quot;APIFrameInfo.h&quot;
</ins><span class="cx"> #import &quot;APISecurityOrigin.h&quot;
</span><ins>+#import &quot;CompletionHandlerCallChecker.h&quot;
</ins><span class="cx"> #import &quot;GeolocationPermissionRequestProxy.h&quot;
</span><ins>+#import &quot;WKFrameInfoInternal.h&quot;
+#import &quot;WKProcessPoolInternal.h&quot;
</ins><span class="cx"> #import &quot;WKUIDelegatePrivate.h&quot;
</span><span class="cx"> #import &quot;WKWebView.h&quot;
</span><span class="cx"> #import &quot;WebGeolocationManagerProxy.h&quot;
</span><span class="cx"> #import &quot;WebProcessPool.h&quot;
</span><ins>+#import &quot;_WKGeolocationCoreLocationProvider.h&quot;
+#import &quot;_WKGeolocationPositionInternal.h&quot;
</ins><span class="cx"> #import &lt;WebCore/GeolocationPosition.h&gt;
</span><span class="cx"> #import &lt;WebCore/URL.h&gt;
</span><span class="cx"> #import &lt;WebGeolocationPosition.h&gt;
</span><span class="cx"> #import &lt;wtf/Assertions.h&gt;
</span><ins>+#import &lt;wtf/BlockPtr.h&gt;
</ins><span class="cx"> #import &lt;wtf/HashSet.h&gt;
</span><span class="cx"> #import &lt;wtf/PassRefPtr.h&gt;
</span><span class="cx"> #import &lt;wtf/RefPtr.h&gt;
</span><span class="lines">@@ -53,9 +60,12 @@
</span><span class="cx"> #pragma clang diagnostic push
</span><span class="cx"> #pragma clang diagnostic ignored &quot;-Wdeprecated-declarations&quot;
</span><span class="cx"> 
</span><del>-@interface WKGeolocationProviderIOS (WebGeolocationCoreLocationUpdateListener) &lt;WebGeolocationCoreLocationUpdateListener&gt;
</del><ins>+@interface WKGeolocationProviderIOS (_WKGeolocationCoreLocationListener) &lt;_WKGeolocationCoreLocationListener&gt;
</ins><span class="cx"> @end
</span><span class="cx"> 
</span><ins>+@interface WKLegacyCoreLocationProvider : NSObject&lt;_WKGeolocationCoreLocationProvider, WebGeolocationCoreLocationUpdateListener&gt;
+@end
+
</ins><span class="cx"> @interface WKWebAllowDenyPolicyListener : NSObject&lt;WebAllowDenyPolicyListener&gt;
</span><span class="cx"> - (id)initWithPermissionRequestProxy:(PassRefPtr&lt;GeolocationPermissionRequestProxy&gt;)permissionRequestProxy;
</span><span class="cx"> - (void)denyOnlyThisRequest NO_RETURN_DUE_TO_ASSERT;
</span><span class="lines">@@ -65,6 +75,11 @@
</span><span class="cx"> void decidePolicyForGeolocationRequestFromOrigin(SecurityOrigin*, const String&amp; urlString, id&lt;WebAllowDenyPolicyListener&gt;, UIWindow*);
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+static inline Ref&lt;WebGeolocationPosition&gt; kit(WebCore::GeolocationPosition *position)
+{
+    return WebGeolocationPosition::create(position-&gt;timestamp(), position-&gt;latitude(), position-&gt;longitude(), position-&gt;accuracy(), position-&gt;canProvideAltitude(), position-&gt;altitude(), position-&gt;canProvideAltitudeAccuracy(), position-&gt;altitudeAccuracy(), position-&gt;canProvideHeading(), position-&gt;heading(), position-&gt;canProvideSpeed(), position-&gt;speed());
+}
+
</ins><span class="cx"> struct GeolocationRequestData {
</span><span class="cx">     RefPtr&lt;SecurityOrigin&gt; origin;
</span><span class="cx">     RefPtr&lt;WebFrameProxy&gt; frame;
</span><span class="lines">@@ -74,7 +89,7 @@
</span><span class="cx"> 
</span><span class="cx"> @implementation WKGeolocationProviderIOS {
</span><span class="cx">     RefPtr&lt;WebGeolocationManagerProxy&gt; _geolocationManager;
</span><del>-    RetainPtr&lt;WebGeolocationCoreLocationProvider&gt; _coreLocationProvider;
</del><ins>+    RetainPtr&lt;id &lt;_WKGeolocationCoreLocationProvider&gt;&gt; _coreLocationProvider;
</ins><span class="cx">     BOOL _isWebCoreGeolocationActive;
</span><span class="cx">     RefPtr&lt;WebGeolocationPosition&gt; _lastActivePosition;
</span><span class="cx">     Vector&lt;GeolocationRequestData&gt; _requestsWaitingForCoreLocationAuthorization;
</span><span class="lines">@@ -148,7 +163,8 @@
</span><span class="cx">         setEnableHighAccuracy
</span><span class="cx">     };
</span><span class="cx">     _geolocationManager-&gt;initializeProvider(reinterpret_cast&lt;WKGeolocationProviderBase*&gt;(&amp;providerCallback));
</span><del>-    _coreLocationProvider = adoptNS([[WebGeolocationCoreLocationProvider alloc] initWithListener:self]);
</del><ins>+    _coreLocationProvider = wrapper(processPool)._coreLocationProvider ?: adoptNS(static_cast&lt;id &lt;_WKGeolocationCoreLocationProvider&gt;&gt;([[WKLegacyCoreLocationProvider alloc] init]));
+    [_coreLocationProvider setListener:self];
</ins><span class="cx">     return self;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -177,6 +193,22 @@
</span><span class="cx">         bool requiresUserAuthorization = true;
</span><span class="cx"> 
</span><span class="cx">         id&lt;WKUIDelegatePrivate&gt; uiDelegate = static_cast&lt;id &lt;WKUIDelegatePrivate&gt;&gt;([request.view UIDelegate]);
</span><ins>+        if ([uiDelegate respondsToSelector:@selector(_webView:requestGeolocationAuthorizationForURL:frame:decisionHandler:)]) {
+            URL requestFrameURL(URL(), request.frame-&gt;url());
+            RetainPtr&lt;WKFrameInfo&gt; frameInfo = wrapper(API::FrameInfo::create(*request.frame.get(), *request.origin.get()));
+            RefPtr&lt;CompletionHandlerCallChecker&gt; checker = CompletionHandlerCallChecker::create(uiDelegate, @selector(_webView:requestGeolocationAuthorizationForURL:frame:decisionHandler:));
+            [uiDelegate _webView:request.view.get() requestGeolocationAuthorizationForURL:requestFrameURL frame:frameInfo.get() decisionHandler:BlockPtr&lt;void(BOOL)&gt;::fromCallable([request, checker = WTFMove(checker)](BOOL authorized) {
+                if (checker-&gt;completionHandlerHasBeenCalled())
+                    return;
+                if (authorized)
+                    request.permissionRequest-&gt;allow();
+                else
+                    request.permissionRequest-&gt;deny();
+                checker-&gt;didCallCompletionHandler();
+            }).get()];
+            return;
+        }
+
</ins><span class="cx">         if ([uiDelegate respondsToSelector:@selector(_webView:shouldRequestGeolocationAuthorizationForURL:isMainFrame:mainFrameURL:)]) {
</span><span class="cx">             const WebFrameProxy* mainFrame = request.frame-&gt;page()-&gt;mainFrame();
</span><span class="cx">             bool isMainFrame = request.frame == mainFrame;
</span><span class="lines">@@ -203,9 +235,9 @@
</span><span class="cx">         requestData.permissionRequest-&gt;deny();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)positionChanged:(GeolocationPosition*)position
</del><ins>+- (void)positionChanged:(_WKGeolocationPosition *)position
</ins><span class="cx"> {
</span><del>-    _lastActivePosition = WebGeolocationPosition::create(position-&gt;timestamp(), position-&gt;latitude(), position-&gt;longitude(), position-&gt;accuracy(), position-&gt;canProvideAltitude(), position-&gt;altitude(), position-&gt;canProvideAltitudeAccuracy(), position-&gt;altitudeAccuracy(), position-&gt;canProvideHeading(), position-&gt;heading(), position-&gt;canProvideSpeed(), position-&gt;speed());
</del><ins>+    _lastActivePosition = position-&gt;_geolocationPosition.get();
</ins><span class="cx">     _geolocationManager-&gt;providerDidChangePosition(_lastActivePosition.get());
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -221,6 +253,81 @@
</span><span class="cx"> 
</span><span class="cx"> @end
</span><span class="cx"> 
</span><ins>+# pragma mark - Implementation of WKLegacyCoreLocationProvider
+
+@implementation WKLegacyCoreLocationProvider {
+    id &lt;_WKGeolocationCoreLocationListener&gt; _listener;
+    RetainPtr&lt;WebGeolocationCoreLocationProvider&gt; _provider;
+}
+
+// &lt;_WKGeolocationCoreLocationProvider&gt; Methods
+
+- (void)setListener:(id&lt;_WKGeolocationCoreLocationListener&gt;)listener
+{
+    ASSERT(listener &amp;&amp; !_listener &amp;&amp; !_provider);
+    _listener = listener;
+    _provider = adoptNS([[WebGeolocationCoreLocationProvider alloc] initWithListener:self]);
+}
+
+- (void)requestGeolocationAuthorization
+{
+    ASSERT(_provider);
+    [_provider requestGeolocationAuthorization];
+}
+
+- (void)start
+{
+    ASSERT(_provider);
+    [_provider start];
+}
+
+- (void)stop
+{
+    ASSERT(_provider);
+    [_provider stop];
+}
+
+- (void)setEnableHighAccuracy:(BOOL)flag
+{
+    ASSERT(_provider);
+    [_provider setEnableHighAccuracy:flag];
+}
+
+// &lt;WebGeolocationCoreLocationUpdateListener&gt; Methods
+
+- (void)geolocationAuthorizationGranted
+{
+    ASSERT(_listener);
+    [_listener geolocationAuthorizationGranted];
+}
+
+- (void)geolocationAuthorizationDenied
+{
+    ASSERT(_listener);
+    [_listener geolocationAuthorizationDenied];
+}
+
+- (void)positionChanged:(WebCore::GeolocationPosition *)corePosition
+{
+    ASSERT(_listener);
+    auto position = kit(corePosition);
+    [_listener positionChanged:wrapper(position.get())];
+}
+
+- (void)errorOccurred:(NSString *)errorMessage
+{
+    ASSERT(_listener);
+    [_listener errorOccurred:errorMessage];
+}
+
+- (void)resetGeolocation
+{
+    ASSERT(_listener);
+    [_listener resetGeolocation];
+}
+
+@end
+
</ins><span class="cx"> # pragma mark - Implementation of WKWebAllowDenyPolicyListener
</span><span class="cx"> @implementation WKWebAllowDenyPolicyListener {
</span><span class="cx">     RefPtr&lt;GeolocationPermissionRequestProxy&gt; _permissionRequestProxy;
</span></span></pre></div>
<a id="trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (215245 => 215246)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2017-04-11 18:41:39 UTC (rev 215245)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2017-04-11 18:43:46 UTC (rev 215246)
</span><span class="lines">@@ -1171,6 +1171,10 @@
</span><span class="cx">                 5CD286581E7235D10094FDC8 /* WKContentExtensionStorePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CD286501E722F440094FDC8 /* WKContentExtensionStorePrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 5CE85B201C88E64B0070BFCE /* PingLoad.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CE85B1F1C88E6430070BFCE /* PingLoad.h */; };
</span><span class="cx">                 5CFECB041E1ED1CC00F88504 /* LegacyCustomProtocolManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5CFECB031E1ED1C800F88504 /* LegacyCustomProtocolManager.cpp */; };
</span><ins>+                636353A51E9858DF0009F8AF /* _WKGeolocationCoreLocationProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 63FABE191E970D65003011D5 /* _WKGeolocationCoreLocationProvider.h */; settings = {ATTRIBUTES = (Private, ); }; };
+                63C32C251E9810D900699BD0 /* _WKGeolocationPosition.mm in Sources */ = {isa = PBXBuildFile; fileRef = 63C32C231E9810D900699BD0 /* _WKGeolocationPosition.mm */; };
+                63C32C261E9810D900699BD0 /* _WKGeolocationPosition.h in Headers */ = {isa = PBXBuildFile; fileRef = 63C32C241E9810D900699BD0 /* _WKGeolocationPosition.h */; settings = {ATTRIBUTES = (Private, ); }; };
+                63C32C281E98119000699BD0 /* _WKGeolocationPositionInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 63C32C271E98119000699BD0 /* _WKGeolocationPositionInternal.h */; };
</ins><span class="cx">                 6501BD1A12F1243400E9F248 /* WKBundleInspector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65B86F1712F11D7B00B7DD8A /* WKBundleInspector.cpp */; };
</span><span class="cx">                 659C551E130006410025C0C2 /* InjectedBundlePageResourceLoadClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6546A82913000164000CEB1C /* InjectedBundlePageResourceLoadClient.cpp */; };
</span><span class="cx">                 65B86F1E12F11DE300B7DD8A /* WKBundleInspector.h in Headers */ = {isa = PBXBuildFile; fileRef = 65B86F1812F11D7B00B7DD8A /* WKBundleInspector.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="lines">@@ -3431,6 +3435,10 @@
</span><span class="cx">                 5CFECB031E1ED1C800F88504 /* LegacyCustomProtocolManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LegacyCustomProtocolManager.cpp; path = NetworkProcess/CustomProtocols/LegacyCustomProtocolManager.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 5D442A5516D5856700AC3331 /* PluginService.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = PluginService.entitlements; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 5DAD73F1116FF90C00EE5396 /* BaseTarget.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = BaseTarget.xcconfig; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                63C32C231E9810D900699BD0 /* _WKGeolocationPosition.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = _WKGeolocationPosition.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
+                63C32C241E9810D900699BD0 /* _WKGeolocationPosition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKGeolocationPosition.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                63C32C271E98119000699BD0 /* _WKGeolocationPositionInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKGeolocationPositionInternal.h; sourceTree = &quot;&lt;group&gt;&quot;; };
+                63FABE191E970D65003011D5 /* _WKGeolocationCoreLocationProvider.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = _WKGeolocationCoreLocationProvider.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 6546A82913000164000CEB1C /* InjectedBundlePageResourceLoadClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedBundlePageResourceLoadClient.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 6546A82A13000164000CEB1C /* InjectedBundlePageResourceLoadClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InjectedBundlePageResourceLoadClient.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 65B86F1712F11D7B00B7DD8A /* WKBundleInspector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKBundleInspector.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -5522,6 +5530,10 @@
</span><span class="cx">                                 2E7A94491BBD95C600945547 /* _WKFocusedElementInfo.h */,
</span><span class="cx">                                 37A64E5618F38F4600EB30F1 /* _WKFormInputSession.h */,
</span><span class="cx">                                 CD78E1181DB7E5AD0014A2DE /* _WKFullscreenDelegate.h */,
</span><ins>+                                63FABE191E970D65003011D5 /* _WKGeolocationCoreLocationProvider.h */,
+                                63C32C241E9810D900699BD0 /* _WKGeolocationPosition.h */,
+                                63C32C231E9810D900699BD0 /* _WKGeolocationPosition.mm */,
+                                63C32C271E98119000699BD0 /* _WKGeolocationPositionInternal.h */,
</ins><span class="cx">                                 5143B25E1DDCDFD10014FAC6 /* _WKIconLoadingDelegate.h */,
</span><span class="cx">                                 37A64E5418F38E3C00EB30F1 /* _WKInputDelegate.h */,
</span><span class="cx">                                 2D790A9C1AD7050D00AB90B3 /* _WKLayoutMode.h */,
</span><span class="lines">@@ -8081,6 +8093,7 @@
</span><span class="cx">                                 93A88B3B1BC710D900ABA5C2 /* _WKHitTestResultInternal.h in Headers */,
</span><span class="cx">                                 510F59101DDE296900412FF5 /* _WKIconLoadingDelegate.h in Headers */,
</span><span class="cx">                                 37A64E5518F38E3C00EB30F1 /* _WKInputDelegate.h in Headers */,
</span><ins>+                                63C32C281E98119000699BD0 /* _WKGeolocationPositionInternal.h in Headers */,
</ins><span class="cx">                                 2D790A9D1AD7050D00AB90B3 /* _WKLayoutMode.h in Headers */,
</span><span class="cx">                                 510F59111DDE297000412FF5 /* _WKLinkIconParameters.h in Headers */,
</span><span class="cx">                                 A118A9F31908B8EA00F7C92B /* _WKNSFileManagerExtras.h in Headers */,
</span><span class="lines">@@ -8277,6 +8290,7 @@
</span><span class="cx">                                 BCCF6B2512C93E7A008F9C35 /* ImageOptions.h in Headers */,
</span><span class="cx">                                 1A1EC69E1872092100B951F0 /* ImportanceAssertion.h in Headers */,
</span><span class="cx">                                 BC204EE311C83E98008F3375 /* InjectedBundle.h in Headers */,
</span><ins>+                                636353A51E9858DF0009F8AF /* _WKGeolocationCoreLocationProvider.h in Headers */,
</ins><span class="cx">                                 935EEBA2127761D0003322B8 /* InjectedBundleBackForwardList.h in Headers */,
</span><span class="cx">                                 935EEBA4127761D6003322B8 /* InjectedBundleBackForwardListItem.h in Headers */,
</span><span class="cx">                                 BCEE7DC5128B645D009827DA /* InjectedBundleClient.h in Headers */,
</span><span class="lines">@@ -8790,6 +8804,7 @@
</span><span class="cx">                                 BC14DF9F120B635F00826C0C /* WKBundleScriptWorld.h in Headers */,
</span><span class="cx">                                 BC4075F6124FF0270068F20A /* WKCertificateInfo.h in Headers */,
</span><span class="cx">                                 BC407627124FF0400068F20A /* WKCertificateInfoMac.h in Headers */,
</span><ins>+                                63C32C261E9810D900699BD0 /* _WKGeolocationPosition.h in Headers */,
</ins><span class="cx">                                 BCA284D71492F2C7001F9042 /* WKConnection.h in Headers */,
</span><span class="cx">                                 BC5C75C814954DA600BC4775 /* WKConnectionInternal.h in Headers */,
</span><span class="cx">                                 BC4A6297147313A0006C681A /* WKConnectionRef.h in Headers */,
</span><span class="lines">@@ -10326,6 +10341,7 @@
</span><span class="cx">                                 2DA944A31884E4F000ED86DB /* WebTouchEventIOS.cpp in Sources */,
</span><span class="cx">                                 BCA0EF8012331E78007D3CFB /* WebUndoStep.cpp in Sources */,
</span><span class="cx">                                 51D124281E6D3F5D002B2820 /* WebURLSchemeHandler.cpp in Sources */,
</span><ins>+                                63C32C251E9810D900699BD0 /* _WKGeolocationPosition.mm in Sources */,
</ins><span class="cx">                                 51D124331E6DE6CA002B2820 /* WebURLSchemeHandlerCocoa.mm in Sources */,
</span><span class="cx">                                 51D1242C1E6D41FD002B2820 /* WebURLSchemeHandlerProxy.cpp in Sources */,
</span><span class="cx">                                 51E8B68E1E712877001B7132 /* WebURLSchemeHandlerTask.cpp in Sources */,
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (215245 => 215246)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2017-04-11 18:41:39 UTC (rev 215245)
+++ trunk/Tools/ChangeLog        2017-04-11 18:43:46 UTC (rev 215246)
</span><span class="lines">@@ -1,3 +1,31 @@
</span><ins>+2017-04-11  David Quesada  &lt;david_quesada@apple.com&gt;
+
+        Add SPI for handling geolocation authorization requests
+        https://bugs.webkit.org/show_bug.cgi?id=170362
+        rdar://problem/17508627
+
+        Reviewed by Alex Christensen.
+
+        Add API tests for the new WKUIDelegate SPI for allowing or denying websites permission
+        to use geolocation. Adopt the new WKProcessPool._coreLocationProvider property to
+        provide a stub object to simulate the various configurations of geolocation permissions:
+        1. The app doesn't have permission to use geolocation.
+        2. The app is allowed to use geolocation, but the UI delegate denies the web view permission.
+        3. The app is allowed to use geolocation, and the UI delegate allows the web view permission.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKit2Cocoa/Geolocation.mm: Added.
+        (-[TestCoreLocationProvider setListener:]):
+        (-[TestCoreLocationProvider requestGeolocationAuthorization]):
+        (-[TestCoreLocationProvider start]):
+        (-[TestCoreLocationProvider stop]):
+        (-[TestCoreLocationProvider setEnableHighAccuracy:]):
+        (expectException):
+        (-[GeolocationTestUIDelegate _webView:requestGeolocationAuthorizationForURL:frame:decisionHandler:]):
+        (-[GeolocationTestUIDelegate webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:]):
+        (TestWebKitAPI::TEST):
+        * TestWebKitAPI/Tests/WebKit2Cocoa/GeolocationGetCurrentPositionResult.html: Added.
+
</ins><span class="cx"> 2017-04-10  Matt Rajca  &lt;mrajca@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Change autoplay state to &quot;prevented&quot; when media is paused due to restrictions.
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (215245 => 215246)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2017-04-11 18:41:39 UTC (rev 215245)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2017-04-11 18:43:46 UTC (rev 215246)
</span><span class="lines">@@ -196,6 +196,9 @@
</span><span class="cx">                 5C9E59431D3EB5AC00E3C62E /* ApplicationCache.db-wal in Copy Resources */ = {isa = PBXBuildFile; fileRef = 5C9E59401D3EB1DE00E3C62E /* ApplicationCache.db-wal */; };
</span><span class="cx">                 5CE354D91E70DA5C00BEFE3B /* WKUserContentExtensionStore.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5CE354D81E70D9C300BEFE3B /* WKUserContentExtensionStore.mm */; };
</span><span class="cx">                 5E4B1D2E1D404C6100053621 /* WKScrollViewDelegateCrash.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5E4B1D2C1D404C6100053621 /* WKScrollViewDelegateCrash.mm */; };
</span><ins>+                631EFFF61E7B5E8D00D2EBB8 /* Geolocation.mm in Sources */ = {isa = PBXBuildFile; fileRef = 631EFFF51E7B5E8D00D2EBB8 /* Geolocation.mm */; };
+                634910E01E9D3FF300880309 /* CoreLocation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 634910DF1E9D3FF300880309 /* CoreLocation.framework */; };
+                636353A71E98665D0009F8AF /* GeolocationGetCurrentPositionResult.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 636353A61E9861940009F8AF /* GeolocationGetCurrentPositionResult.html */; };
</ins><span class="cx">                 6BFD294C1D5E6C1D008EC968 /* HashCountedSet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7A38D7E51C752D5F004F157D /* HashCountedSet.cpp */; };
</span><span class="cx">                 755A20AF1E6E38630093C69F /* DatabaseTrackerTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 755A20AE1E6E38630093C69F /* DatabaseTrackerTest.cpp */; };
</span><span class="cx">                 764322D71B61CCC30024F801 /* WordBoundaryTypingAttributes.mm in Sources */ = {isa = PBXBuildFile; fileRef = 764322D51B61CCA40024F801 /* WordBoundaryTypingAttributes.mm */; };
</span><span class="lines">@@ -669,6 +672,7 @@
</span><span class="cx">                                 379028B914FAC24C007E6B43 /* acceptsFirstMouse.html in Copy Resources */,
</span><span class="cx">                                 1C2B81871C8925A000A5529F /* Ahem.ttf in Copy Resources */,
</span><span class="cx">                                 1A63479F183D72A4005B1707 /* all-content-in-one-iframe.html in Copy Resources */,
</span><ins>+                                636353A71E98665D0009F8AF /* GeolocationGetCurrentPositionResult.html in Copy Resources */,
</ins><span class="cx">                                 C25CCA0D1E5141840026CB8A /* AllAhem.svg in Copy Resources */,
</span><span class="cx">                                 5C9E59411D3EB5AC00E3C62E /* ApplicationCache.db in Copy Resources */,
</span><span class="cx">                                 5C9E59421D3EB5AC00E3C62E /* ApplicationCache.db-shm in Copy Resources */,
</span><span class="lines">@@ -1121,6 +1125,9 @@
</span><span class="cx">                 5C9E59401D3EB1DE00E3C62E /* ApplicationCache.db-wal */ = {isa = PBXFileReference; lastKnownFileType = file; path = &quot;ApplicationCache.db-wal&quot;; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 5CE354D81E70D9C300BEFE3B /* WKUserContentExtensionStore.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKUserContentExtensionStore.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 5E4B1D2C1D404C6100053621 /* WKScrollViewDelegateCrash.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WKScrollViewDelegateCrash.mm; path = ../ios/WKScrollViewDelegateCrash.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                631EFFF51E7B5E8D00D2EBB8 /* Geolocation.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Geolocation.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
+                634910DF1E9D3FF300880309 /* CoreLocation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreLocation.framework; path = System/Library/Frameworks/CoreLocation.framework; sourceTree = SDKROOT; };
+                636353A61E9861940009F8AF /* GeolocationGetCurrentPositionResult.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = GeolocationGetCurrentPositionResult.html; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 755A20AE1E6E38630093C69F /* DatabaseTrackerTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DatabaseTrackerTest.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 7560917719259C59009EF06E /* MemoryCacheAddImageToCacheIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MemoryCacheAddImageToCacheIOS.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 75F3133F18C171B70041CAEC /* EphemeralSessionPushStateNoHistoryCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EphemeralSessionPushStateNoHistoryCallback.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -1506,6 +1513,7 @@
</span><span class="cx">                         isa = PBXFrameworksBuildPhase;
</span><span class="cx">                         buildActionMask = 2147483647;
</span><span class="cx">                         files = (
</span><ins>+                                634910E01E9D3FF300880309 /* CoreLocation.framework in Frameworks */,
</ins><span class="cx">                                 7A010BCB1D877C0500EDE72A /* CoreGraphics.framework in Frameworks */,
</span><span class="cx">                                 7C83E03F1D0A61A000FEBCF3 /* libicucore.dylib in Frameworks */,
</span><span class="cx">                                 7A010BCD1D877C0D00EDE72A /* QuartzCore.framework in Frameworks */,
</span><span class="lines">@@ -1645,6 +1653,7 @@
</span><span class="cx">                                 CD78E11A1DB7EA360014A2DE /* FullscreenDelegate.mm */,
</span><span class="cx">                                 3F1B52681D3D7129008D60C4 /* FullscreenLayoutConstraints.mm */,
</span><span class="cx">                                 CDE195B31CFE0ADE0053D256 /* FullscreenTopContentInset.mm */,
</span><ins>+                                631EFFF51E7B5E8D00D2EBB8 /* Geolocation.mm */,
</ins><span class="cx">                                 510477751D298E03009747EB /* IDBDeleteRecovery.mm */,
</span><span class="cx">                                 5110FCEF1E01CBAA006F8D0B /* IDBIndexUpgradeToV2.mm */,
</span><span class="cx">                                 51A587841D272EF3004BA9AF /* IndexedDBDatabaseProcessKill.mm */,
</span><span class="lines">@@ -1787,6 +1796,7 @@
</span><span class="cx">                 7C83E0281D0A5CDF00FEBCF3 /* Frameworks */ = {
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</span><ins>+                                634910DF1E9D3FF300880309 /* CoreLocation.framework */,
</ins><span class="cx">                                 7A010BCA1D877C0500EDE72A /* CoreGraphics.framework */,
</span><span class="cx">                                 7C83E0331D0A5F2700FEBCF3 /* libicucore.dylib */,
</span><span class="cx">                                 7C83E0291D0A5CDF00FEBCF3 /* libWTF.a */,
</span><span class="lines">@@ -1840,6 +1850,7 @@
</span><span class="cx">                                 CD78E11B1DB7EA360014A2DE /* FullscreenDelegate.html */,
</span><span class="cx">                                 3FBD1B491D39D1DB00E6D6FA /* FullscreenLayoutConstraints.html */,
</span><span class="cx">                                 CDE195B21CFE0ADE0053D256 /* FullscreenTopContentInset.html */,
</span><ins>+                                636353A61E9861940009F8AF /* GeolocationGetCurrentPositionResult.html */,
</ins><span class="cx">                                 F4DEF6EC1E9B4D950048EF61 /* image-in-link-and-input.html */,
</span><span class="cx">                                 510477761D298E57009747EB /* IDBDeleteRecovery.html */,
</span><span class="cx">                                 5104776F1D298D85009747EB /* IDBDeleteRecovery.sqlite3 */,
</span><span class="lines">@@ -2796,6 +2807,7 @@
</span><span class="cx">                                 7C83E0BD1D0A650C00FEBCF3 /* FullscreenTopContentInset.mm in Sources */,
</span><span class="cx">                                 CDBFCC451A9FF45300A7B691 /* FullscreenZoomInitialFrame.mm in Sources */,
</span><span class="cx">                                 7CCE7EF81A411AE600447C4C /* Geolocation.cpp in Sources */,
</span><ins>+                                631EFFF61E7B5E8D00D2EBB8 /* Geolocation.mm in Sources */,
</ins><span class="cx">                                 7CCE7EE11A411A9A00447C4C /* GetBackingScaleFactor.mm in Sources */,
</span><span class="cx">                                 7CCE7EF91A411AE600447C4C /* GetInjectedBundleInitializationUserDataCallback.cpp in Sources */,
</span><span class="cx">                                 7CCE7EE21A411A9A00447C4C /* GetPIDAfterAbortedProcessLaunch.cpp in Sources */,
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2CocoaGeolocationmm"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/Geolocation.mm (0 => 215246)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/Geolocation.mm                                (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/Geolocation.mm        2017-04-11 18:43:46 UTC (rev 215246)
</span><span class="lines">@@ -0,0 +1,270 @@
</span><ins>+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * 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 WK_API_ENABLED &amp;&amp; PLATFORM(IOS)
+
+#import &quot;PlatformUtilities.h&quot;
+#import &quot;TestWKWebView.h&quot;
+#import &lt;CoreLocation/CLLocation.h&gt;
+#import &lt;WebKit/WKProcessPoolPrivate.h&gt;
+#import &lt;WebKit/WKUIDelegatePrivate.h&gt;
+#import &lt;WebKit/_WKGeolocationCoreLocationProvider.h&gt;
+#import &lt;WebKit/_WKGeolocationPosition.h&gt;
+#import &lt;wtf/MainThread.h&gt;
+#import &lt;wtf/RetainPtr.h&gt;
+
+static bool hasReceivedAlert;
+
+@interface TestCoreLocationProvider : NSObject&lt;_WKGeolocationCoreLocationProvider&gt;
+@property (nonatomic) BOOL shouldAuthorizeGeolocation;
+@property (nonatomic) BOOL authorizationWasRequested;
+@property (nonatomic) BOOL simulateError;
+@end
+
+@implementation TestCoreLocationProvider {
+    __unsafe_unretained id &lt;_WKGeolocationCoreLocationListener&gt; _listener;
+}
+
+// _WKGeolocationCoreLocationProvider implementation
+
+- (void)setListener:(id &lt;_WKGeolocationCoreLocationListener&gt;)listener
+{
+    ASSERT(!_listener);
+    _listener = listener;
+}
+
+- (void)requestGeolocationAuthorization
+{
+    _authorizationWasRequested = YES;
+    WTF::callOnMainThread([shouldAuthorizeGeolocation = _shouldAuthorizeGeolocation, listener = _listener] {
+        if (shouldAuthorizeGeolocation)
+            [listener geolocationAuthorizationGranted];
+        else
+            [listener geolocationAuthorizationDenied];
+    });
+}
+
+- (void)start
+{
+    ASSERT(_shouldAuthorizeGeolocation);
+    WTF::callOnMainThread([listener = _listener, simulateError = _simulateError] {
+        if (!simulateError) {
+            auto location = adoptNS([[CLLocation alloc] initWithLatitude:37.3348 longitude:-122.009]);
+            [listener positionChanged:[_WKGeolocationPosition positionWithLocation:location.get()]];
+        } else
+            [listener errorOccurred:@&quot;Error Message&quot;];
+    });
+}
+
+- (void)stop
+{
+}
+
+- (void)setEnableHighAccuracy:(BOOL)flag
+{
+}
+
+@end
+
+@interface GeolocationTestUIDelegate : NSObject &lt;WKUIDelegatePrivate&gt;
+
+@property (nonatomic) BOOL allowGeolocation;
+@property (nonatomic) BOOL callDecisionHandlerTwice;
+@property (nonatomic) BOOL authorizationWasRequested;
+@property (nonatomic, readonly) NSString *alertMessage;
+
+@end
+
+@implementation GeolocationTestUIDelegate
+
+static void expectException(void (^completionHandler)())
+{
+    bool exceptionThrown = false;
+    @try {
+        completionHandler();
+    } @catch (NSException *exception) {
+        EXPECT_WK_STREQ(NSInternalInconsistencyException, exception.name);
+        exceptionThrown = true;
+    }
+    EXPECT_TRUE(exceptionThrown);
+}
+
+- (void)_webView:(WKWebView *)webView requestGeolocationAuthorizationForURL:(NSURL *)url frame:(WKFrameInfo *)frame decisionHandler:(void (^)(BOOL))decisionHandler
+{
+    _authorizationWasRequested = YES;
+    decisionHandler(_allowGeolocation);
+
+    if (_callDecisionHandlerTwice) {
+        expectException(^ {
+            decisionHandler(_allowGeolocation);
+        });
+    }
+}
+
+- (void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)())completionHandler
+{
+    completionHandler();
+    _alertMessage = message;
+    hasReceivedAlert = true;
+}
+
+@end
+
+
+using namespace std;
+
+namespace TestWebKitAPI {
+
+// These tests need to use TestWKWebView because it sets up a visible window for the web
+// view. Without this, the web process would wait until the page is visible before sending
+// the requests to the UI process.
+
+TEST(WebKit2, GeolocationDeniedByLocationProvider)
+{
+    auto uiDelegate = adoptNS([[GeolocationTestUIDelegate alloc] init]);
+    auto coreLocationProvider = adoptNS([[TestCoreLocationProvider alloc] init]);
+    auto processPool = adoptNS([[WKProcessPool alloc] init]);
+    processPool.get()._coreLocationProvider = coreLocationProvider.get();
+    auto config = adoptNS([[WKWebViewConfiguration alloc] init]);
+    config.get().processPool = processPool.get();
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:config.get()]);
+    webView.get().UIDelegate = uiDelegate.get();
+
+    coreLocationProvider.get().shouldAuthorizeGeolocation = NO;
+    uiDelegate.get().allowGeolocation = NO;
+    
+    hasReceivedAlert = false;
+    [webView loadTestPageNamed:@&quot;GeolocationGetCurrentPositionResult&quot;];
+
+    TestWebKitAPI::Util::run(&amp;hasReceivedAlert);
+
+    EXPECT_WK_STREQ(uiDelegate.get().alertMessage, &quot;ERROR:1&quot;);
+    EXPECT_TRUE(coreLocationProvider.get().authorizationWasRequested);
+    EXPECT_FALSE(uiDelegate.get().authorizationWasRequested);
+}
+
+TEST(WebKit2, GeolocationDeniedByAPI)
+{
+    auto uiDelegate = adoptNS([[GeolocationTestUIDelegate alloc] init]);
+    auto coreLocationProvider = adoptNS([[TestCoreLocationProvider alloc] init]);
+    auto processPool = adoptNS([[WKProcessPool alloc] init]);
+    processPool.get()._coreLocationProvider = coreLocationProvider.get();
+    auto config = adoptNS([[WKWebViewConfiguration alloc] init]);
+    config.get().processPool = processPool.get();
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:config.get()]);
+    webView.get().UIDelegate = uiDelegate.get();
+
+    coreLocationProvider.get().shouldAuthorizeGeolocation = YES;
+    uiDelegate.get().allowGeolocation = NO;
+
+    hasReceivedAlert = false;
+    [webView loadTestPageNamed:@&quot;GeolocationGetCurrentPositionResult&quot;];
+
+    TestWebKitAPI::Util::run(&amp;hasReceivedAlert);
+
+    EXPECT_WK_STREQ(uiDelegate.get().alertMessage, &quot;ERROR:1&quot;);
+    EXPECT_TRUE(coreLocationProvider.get().authorizationWasRequested);
+    EXPECT_TRUE(uiDelegate.get().authorizationWasRequested);
+}
+
+TEST(WebKit2, GeolocationAllowedByAPI)
+{
+    auto uiDelegate = adoptNS([[GeolocationTestUIDelegate alloc] init]);
+    auto coreLocationProvider = adoptNS([[TestCoreLocationProvider alloc] init]);
+    auto processPool = adoptNS([[WKProcessPool alloc] init]);
+    processPool.get()._coreLocationProvider = coreLocationProvider.get();
+    auto config = adoptNS([[WKWebViewConfiguration alloc] init]);
+    config.get().processPool = processPool.get();
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:config.get()]);
+    webView.get().UIDelegate = uiDelegate.get();
+
+    coreLocationProvider.get().shouldAuthorizeGeolocation = YES;
+    uiDelegate.get().allowGeolocation = YES;
+
+    hasReceivedAlert = false;
+    [webView loadTestPageNamed:@&quot;GeolocationGetCurrentPositionResult&quot;];
+
+    TestWebKitAPI::Util::run(&amp;hasReceivedAlert);
+
+    EXPECT_WK_STREQ(uiDelegate.get().alertMessage, &quot;SUCCESS&quot;);
+    EXPECT_TRUE(coreLocationProvider.get().authorizationWasRequested);
+    EXPECT_TRUE(uiDelegate.get().authorizationWasRequested);
+}
+
+TEST(WebKit2, GeolocationError)
+{
+    auto uiDelegate = adoptNS([[GeolocationTestUIDelegate alloc] init]);
+    auto coreLocationProvider = adoptNS([[TestCoreLocationProvider alloc] init]);
+    auto processPool = adoptNS([[WKProcessPool alloc] init]);
+    processPool.get()._coreLocationProvider = coreLocationProvider.get();
+    auto config = adoptNS([[WKWebViewConfiguration alloc] init]);
+    config.get().processPool = processPool.get();
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:config.get()]);
+    webView.get().UIDelegate = uiDelegate.get();
+
+    coreLocationProvider.get().shouldAuthorizeGeolocation = YES;
+    coreLocationProvider.get().simulateError = YES;
+    uiDelegate.get().allowGeolocation = YES;
+
+    hasReceivedAlert = false;
+    [webView loadTestPageNamed:@&quot;GeolocationGetCurrentPositionResult&quot;];
+
+    TestWebKitAPI::Util::run(&amp;hasReceivedAlert);
+
+    EXPECT_WK_STREQ(uiDelegate.get().alertMessage, &quot;ERROR:2&quot;);
+    EXPECT_TRUE(coreLocationProvider.get().authorizationWasRequested);
+    EXPECT_TRUE(uiDelegate.get().authorizationWasRequested);
+}
+
+TEST(WebKit2, DuplicateGeolocationAuthorizationCallbackCalls)
+{
+    auto uiDelegate = adoptNS([[GeolocationTestUIDelegate alloc] init]);
+    auto coreLocationProvider = adoptNS([[TestCoreLocationProvider alloc] init]);
+    auto processPool = adoptNS([[WKProcessPool alloc] init]);
+    processPool.get()._coreLocationProvider = coreLocationProvider.get();
+    auto config = adoptNS([[WKWebViewConfiguration alloc] init]);
+    config.get().processPool = processPool.get();
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:config.get()]);
+    webView.get().UIDelegate = uiDelegate.get();
+
+    coreLocationProvider.get().shouldAuthorizeGeolocation = YES;
+    uiDelegate.get().allowGeolocation = YES;
+    uiDelegate.get().callDecisionHandlerTwice = YES;
+
+    hasReceivedAlert = false;
+    [webView loadTestPageNamed:@&quot;GeolocationGetCurrentPositionResult&quot;];
+
+    TestWebKitAPI::Util::run(&amp;hasReceivedAlert);
+
+    EXPECT_WK_STREQ(uiDelegate.get().alertMessage, &quot;SUCCESS&quot;);
+    EXPECT_TRUE(coreLocationProvider.get().authorizationWasRequested);
+    EXPECT_TRUE(uiDelegate.get().authorizationWasRequested);
+}
+
+} // namespace TestWebKitAPI
+
+#endif // WK_API_ENABLED &amp;&amp; PLATFORM(IOS)
</ins></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsWebKit2CocoaGeolocationGetCurrentPositionResulthtml"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/GeolocationGetCurrentPositionResult.html (0 => 215246)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/GeolocationGetCurrentPositionResult.html                                (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/GeolocationGetCurrentPositionResult.html        2017-04-11 18:43:46 UTC (rev 215246)
</span><span class="lines">@@ -0,0 +1,9 @@
</span><ins>+&lt;script&gt;
+function success(position) {
+    alert(&quot;SUCCESS&quot;);
+}
+function error(err) {
+    alert(&quot;ERROR:&quot; + err.code);
+}
+navigator.geolocation.getCurrentPosition(success, error);
+&lt;/script&gt;
</ins></span></pre>
</div>
</div>

</body>
</html>