<!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>[168795] branches/safari-538.34-branch</title>
</head>
<body>

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

<h3>Log Message</h3>
<pre>Merged <a href="http://trac.webkit.org/projects/webkit/changeset/168555">r168555</a>.  </pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari53834branchSourceWebKitiosChangeLog">branches/safari-538.34-branch/Source/WebKit/ios/ChangeLog</a></li>
<li><a href="#branchessafari53834branchSourceWebKitiosMiscWebGeolocationCoreLocationProviderh">branches/safari-538.34-branch/Source/WebKit/ios/Misc/WebGeolocationCoreLocationProvider.h</a></li>
<li><a href="#branchessafari53834branchSourceWebKitiosMiscWebGeolocationCoreLocationProvidermm">branches/safari-538.34-branch/Source/WebKit/ios/Misc/WebGeolocationCoreLocationProvider.mm</a></li>
<li><a href="#branchessafari53834branchSourceWebKitiosMiscWebGeolocationProviderIOSmm">branches/safari-538.34-branch/Source/WebKit/ios/Misc/WebGeolocationProviderIOS.mm</a></li>
<li><a href="#branchessafari53834branchSourceWebKitmacChangeLog">branches/safari-538.34-branch/Source/WebKit/mac/ChangeLog</a></li>
<li><a href="#branchessafari53834branchSourceWebKitmacWebCoreSupportWebGeolocationClientmm">branches/safari-538.34-branch/Source/WebKit/mac/WebCoreSupport/WebGeolocationClient.mm</a></li>
<li><a href="#branchessafari53834branchSourceWebKitmacWebViewWebViewPrivateh">branches/safari-538.34-branch/Source/WebKit/mac/WebView/WebViewPrivate.h</a></li>
<li><a href="#branchessafari53834branchSourceWebKit2ChangeLog">branches/safari-538.34-branch/Source/WebKit2/ChangeLog</a></li>
<li><a href="#branchessafari53834branchSourceWebKit2UIProcessiosWKGeolocationProviderIOSmm">branches/safari-538.34-branch/Source/WebKit2/UIProcess/ios/WKGeolocationProviderIOS.mm</a></li>
<li><a href="#branchessafari53834branchToolsChangeLog">branches/safari-538.34-branch/Tools/ChangeLog</a></li>
<li><a href="#branchessafari53834branchToolsDumpRenderTreemacMockGeolocationProvidermm">branches/safari-538.34-branch/Tools/DumpRenderTree/mac/MockGeolocationProvider.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari53834branchSourceWebKitiosChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-538.34-branch/Source/WebKit/ios/ChangeLog (168794 => 168795)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-538.34-branch/Source/WebKit/ios/ChangeLog        2014-05-14 06:42:24 UTC (rev 168794)
+++ branches/safari-538.34-branch/Source/WebKit/ios/ChangeLog        2014-05-14 06:45:52 UTC (rev 168795)
</span><span class="lines">@@ -1,3 +1,65 @@
</span><ins>+2014-04-17  Lucas Forschler  &lt;lforschler@apple.com&gt;
+
+        Merge r168555
+
+    2014-05-09  Benjamin Poulain  &lt;benjamin@webkit.org&gt;
+
+            [iOS] Switch geolocation to an explicit authorization query model
+            https://bugs.webkit.org/show_bug.cgi?id=132717
+            &lt;rdar://problem/16762390&gt;
+
+            Reviewed by Sam Weinig.
+
+            WebGeolocationCoreLocationProvider is the general WebKit wrapper for CoreLocation.
+
+            The old model was to start WebGeolocationCoreLocationProvider and have the start fail or succeed.
+            The new model is to explicitely ask for authorization through &quot;requestGeolocationAuthorization&quot;, and
+            listen to &quot;geolocationAuthorizationGranted&quot; and &quot;geolocationAuthorizationDenied&quot;.
+
+            We assume the client of WebGeolocationCoreLocationProvider is well behaved and ask for authorization
+            before invoking &quot;start&quot;.
+            If &quot;start&quot; is called and the authorization is not granted, we assume geolocation was reset since
+            the last time authorization was requested, and we reset the client.
+
+
+            WebGeolocationProviderIOS has been adapted to that model. Instead of doing the &quot;warmup&quot; sequence
+            to get the authorization, it queries WebGeolocationCoreLocationProvider explicitly.
+
+            * Misc/WebGeolocationCoreLocationProvider.h:
+            * Misc/WebGeolocationCoreLocationProvider.mm:
+            (-[WebGeolocationCoreLocationProvider createLocationManager]):
+            (-[WebGeolocationCoreLocationProvider dealloc]):
+            (-[WebGeolocationCoreLocationProvider requestGeolocationAuthorization]):
+            (isAuthorizationGranted):
+            (-[WebGeolocationCoreLocationProvider start]):
+            (-[WebGeolocationCoreLocationProvider stop]):
+            (-[WebGeolocationCoreLocationProvider locationManager:didChangeAuthorizationStatus:]):
+            (-[WebGeolocationCoreLocationProvider setEnableHighAccuracy:]):
+            (-[WebGeolocationCoreLocationProvider handleExternalAuthorizationStatusChange:]): Deleted.
+            * Misc/WebGeolocationProviderIOS.mm:
+            (-[WebGeolocationProviderIOS suspend]):
+            (-[WebGeolocationProviderIOS resume]):
+            (-[WebGeolocationProviderIOS registerWebView:]):
+            (-[WebGeolocationProviderIOS unregisterWebView:]):
+            (-[WebGeolocationProviderIOS setEnableHighAccuracy:]):
+            (-[WebGeolocationProviderIOS initializeGeolocationForWebView:listener:]):
+            (-[WebGeolocationProviderIOS geolocationAuthorizationGranted]):
+            (-[WebGeolocationProviderIOS geolocationAuthorizationDenied]):
+            (-[WebGeolocationProviderIOS stopTrackingWebView:]):
+            (-[WebGeolocationProviderIOS resetGeolocation]):
+            (-[_WebCoreLocationUpdateThreadingProxy geolocationAuthorizationGranted]):
+            (-[_WebCoreLocationUpdateThreadingProxy geolocationAuthorizationDenied]):
+            (-[_WebCoreLocationUpdateThreadingProxy positionChanged:WebCore::]):
+            (-[_WebCoreLocationUpdateThreadingProxy errorOccurred:]):
+            (-[_WebCoreLocationUpdateThreadingProxy resetGeolocation]):
+            (-[WebGeolocationProviderIOS _startCoreLocationDelegate]): Deleted.
+            (-[WebGeolocationProviderIOS _stopCoreLocationDelegateIfNeeded]): Deleted.
+            (-[WebGeolocationProviderIOS cancelWarmUpForWebView:]): Deleted.
+            (-[WebGeolocationProviderIOS geolocationDelegateStarted]): Deleted.
+            (-[WebGeolocationProviderIOS geolocationDelegateUnableToStart]): Deleted.
+            (-[_WebCoreLocationUpdateThreadingProxy geolocationDelegateStarted]): Deleted.
+            (-[_WebCoreLocationUpdateThreadingProxy geolocationDelegateUnableToStart]): Deleted.
+
</ins><span class="cx"> 2014-04-30  Anders Carlsson  &lt;andersca@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Move the legacy WebKit API into WebKitLegacy.framework and move it inside WebKit.framework
</span></span></pre></div>
<a id="branchessafari53834branchSourceWebKitiosMiscWebGeolocationCoreLocationProviderh"></a>
<div class="modfile"><h4>Modified: branches/safari-538.34-branch/Source/WebKit/ios/Misc/WebGeolocationCoreLocationProvider.h (168794 => 168795)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-538.34-branch/Source/WebKit/ios/Misc/WebGeolocationCoreLocationProvider.h        2014-05-14 06:42:24 UTC (rev 168794)
+++ branches/safari-538.34-branch/Source/WebKit/ios/Misc/WebGeolocationCoreLocationProvider.h        2014-05-14 06:45:52 UTC (rev 168795)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2008, 2009, 2010, 2012 Apple Inc. All Rights Reserved.
</del><ins>+ * Copyright (C) 2008, 2009, 2010, 2012, 2014 Apple Inc. All Rights Reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -41,8 +41,8 @@
</span><span class="cx"> // main thread.
</span><span class="cx"> 
</span><span class="cx"> @protocol WebGeolocationCoreLocationUpdateListener
</span><del>-- (void)geolocationDelegateStarted;
-- (void)geolocationDelegateUnableToStart;
</del><ins>+- (void)geolocationAuthorizationGranted;
+- (void)geolocationAuthorizationDenied;
</ins><span class="cx"> 
</span><span class="cx"> - (void)positionChanged:(WebCore::GeolocationPosition*)position;
</span><span class="cx"> - (void)errorOccurred:(NSString *)errorMessage;
</span><span class="lines">@@ -53,7 +53,10 @@
</span><span class="cx"> @interface WebGeolocationCoreLocationProvider : NSObject
</span><span class="cx"> - (id)initWithListener:(id&lt;WebGeolocationCoreLocationUpdateListener&gt;)listener;
</span><span class="cx"> 
</span><ins>+- (void)requestGeolocationAuthorization;
+
</ins><span class="cx"> - (void)start;
</span><span class="cx"> - (void)stop;
</span><ins>+
</ins><span class="cx"> - (void)setEnableHighAccuracy:(BOOL)flag;
</span><span class="cx"> @end
</span></span></pre></div>
<a id="branchessafari53834branchSourceWebKitiosMiscWebGeolocationCoreLocationProvidermm"></a>
<div class="modfile"><h4>Modified: branches/safari-538.34-branch/Source/WebKit/ios/Misc/WebGeolocationCoreLocationProvider.mm (168794 => 168795)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-538.34-branch/Source/WebKit/ios/Misc/WebGeolocationCoreLocationProvider.mm        2014-05-14 06:42:24 UTC (rev 168794)
+++ branches/safari-538.34-branch/Source/WebKit/ios/Misc/WebGeolocationCoreLocationProvider.mm        2014-05-14 06:45:52 UTC (rev 168795)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2008, 2009, 2010, 2012 Apple Inc. All Rights Reserved.
</del><ins>+ * Copyright (C) 2008, 2009, 2010, 2012, 2014 Apple Inc. All Rights Reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -71,7 +71,7 @@
</span><span class="cx">     _lastAuthorizationStatus = [CLLocationManager authorizationStatus];
</span><span class="cx"> #undef CLLocationManager
</span><span class="cx"> 
</span><del>-    [ _locationManager.get() setDelegate:self];
</del><ins>+    [ _locationManager setDelegate:self];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (id)initWithListener:(id&lt;WebGeolocationCoreLocationUpdateListener&gt;)listener
</span><span class="lines">@@ -88,67 +88,66 @@
</span><span class="cx"> - (void)dealloc
</span><span class="cx"> {
</span><span class="cx">     ASSERT_MAIN_THREAD();
</span><del>-    _locationManager.get().delegate = nil;
</del><ins>+    [_locationManager setDelegate:nil];
</ins><span class="cx">     [super dealloc];
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (BOOL)handleExternalAuthorizationStatusChange:(CLAuthorizationStatus)newStatus
</del><ins>+- (void)requestGeolocationAuthorization
</ins><span class="cx"> {
</span><del>-    CLAuthorizationStatus previousStatus = _lastAuthorizationStatus;
-    _lastAuthorizationStatus = newStatus;
-    if (!_isWaitingForAuthorization &amp;&amp; previousStatus != newStatus) {
-        [_locationManager.get() stopUpdatingLocation];
-        [_positionListener resetGeolocation];
-        return YES;
</del><ins>+    ASSERT_MAIN_THREAD();
+
+    if (![getCLLocationManagerClass() locationServicesEnabled]) {
+        [_positionListener geolocationAuthorizationDenied];
+        return;
</ins><span class="cx">     }
</span><del>-    return NO;
</del><ins>+
+    switch ([getCLLocationManagerClass() authorizationStatus]) {
+    case kCLAuthorizationStatusNotDetermined: {
+        if (!_isWaitingForAuthorization) {
+            _isWaitingForAuthorization = YES;
+            [_locationManager requestWhenInUseAuthorization];
+        }
+        break;
+    }
+    case kCLAuthorizationStatusAuthorizedAlways:
+    case kCLAuthorizationStatusAuthorizedWhenInUse: {
+        [_positionListener geolocationAuthorizationGranted];
+        break;
+    }
+    case kCLAuthorizationStatusRestricted:
+    case kCLAuthorizationStatusDenied:
+        [_positionListener geolocationAuthorizationDenied];
+        break;
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static bool isAuthorizationGranted(CLAuthorizationStatus authorizationStatus)
+{
+    return authorizationStatus == kCLAuthorizationStatusAuthorizedAlways || authorizationStatus == kCLAuthorizationStatusAuthorizedWhenInUse;
+}
+
</ins><span class="cx"> - (void)start
</span><span class="cx"> {
</span><span class="cx">     ASSERT_MAIN_THREAD();
</span><span class="cx"> 
</span><del>-#define CLLocationManager getCLLocationManagerClass()
-    CLAuthorizationStatus authorizationStatus = [CLLocationManager authorizationStatus];
-    if ([self handleExternalAuthorizationStatusChange:authorizationStatus])
</del><ins>+    if (![getCLLocationManagerClass() locationServicesEnabled]
+        || !isAuthorizationGranted([getCLLocationManagerClass() authorizationStatus])) {
+        [_locationManager stopUpdatingLocation];
+        [_positionListener resetGeolocation];
</ins><span class="cx">         return;
</span><del>-
-    if (![CLLocationManager locationServicesEnabled]) {
-        [_positionListener geolocationDelegateUnableToStart];
-        return;
</del><span class="cx">     }
</span><span class="cx"> 
</span><del>-    switch (authorizationStatus) {
-    case kCLAuthorizationStatusNotDetermined:
-        _isWaitingForAuthorization = YES;
-        [_locationManager.get() startUpdatingLocation];
-        return;
-    case kCLAuthorizationStatusDenied:
-    case kCLAuthorizationStatusRestricted:
-        [_positionListener geolocationDelegateUnableToStart];
-        return;
-    case kCLAuthorizationStatusAuthorizedAlways:
-    case kCLAuthorizationStatusAuthorizedWhenInUse:
-        [_locationManager.get() startUpdatingLocation];
-        [_positionListener geolocationDelegateStarted];
-        return;
-    }
-#undef CLLocationManager
-    ASSERT_NOT_REACHED();
-    [_positionListener geolocationDelegateUnableToStart];
</del><ins>+    [_locationManager startUpdatingLocation];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)stop
</span><span class="cx"> {
</span><span class="cx">     ASSERT_MAIN_THREAD();
</span><del>-    [_locationManager.get() stopUpdatingLocation];
</del><ins>+    [_locationManager stopUpdatingLocation];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status
</span><span class="cx"> {
</span><del>-    if ([self handleExternalAuthorizationStatusChange:status])
-        return;
-
</del><span class="cx">     if (_isWaitingForAuthorization) {
</span><span class="cx">         switch (status) {
</span><span class="cx">         case kCLAuthorizationStatusNotDetermined:
</span><span class="lines">@@ -157,15 +156,21 @@
</span><span class="cx">         case kCLAuthorizationStatusDenied:
</span><span class="cx">         case kCLAuthorizationStatusRestricted:
</span><span class="cx">             _isWaitingForAuthorization = NO;
</span><del>-            [_positionListener geolocationDelegateUnableToStart];
</del><ins>+            [_positionListener geolocationAuthorizationDenied];
</ins><span class="cx">             break;
</span><span class="cx">         case kCLAuthorizationStatusAuthorizedAlways:
</span><span class="cx">         case kCLAuthorizationStatusAuthorizedWhenInUse:
</span><span class="cx">             _isWaitingForAuthorization = NO;
</span><del>-            [_positionListener geolocationDelegateStarted];
</del><ins>+            [_positionListener geolocationAuthorizationGranted];
</ins><span class="cx">             break;
</span><span class="cx">         }
</span><ins>+    } else {
+        if (!(isAuthorizationGranted(_lastAuthorizationStatus) &amp;&amp; isAuthorizationGranted(status))) {
+            [_locationManager stopUpdatingLocation];
+            [_positionListener resetGeolocation];
+        }
</ins><span class="cx">     }
</span><ins>+    _lastAuthorizationStatus = status;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)sendLocation:(CLLocation *)newLocation
</span><span class="lines">@@ -220,7 +225,7 @@
</span><span class="cx"> - (void)setEnableHighAccuracy:(BOOL)flag
</span><span class="cx"> {
</span><span class="cx">     ASSERT_MAIN_THREAD();
</span><del>-    [_locationManager.get() setDesiredAccuracy:flag ? kCLLocationAccuracyBest : kCLLocationAccuracyHundredMeters];
</del><ins>+    [_locationManager setDesiredAccuracy:flag ? kCLLocationAccuracyBest : kCLLocationAccuracyHundredMeters];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> @end
</span></span></pre></div>
<a id="branchessafari53834branchSourceWebKitiosMiscWebGeolocationProviderIOSmm"></a>
<div class="modfile"><h4>Modified: branches/safari-538.34-branch/Source/WebKit/ios/Misc/WebGeolocationProviderIOS.mm (168794 => 168795)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-538.34-branch/Source/WebKit/ios/Misc/WebGeolocationProviderIOS.mm        2014-05-14 06:42:24 UTC (rev 168794)
+++ branches/safari-538.34-branch/Source/WebKit/ios/Misc/WebGeolocationProviderIOS.mm        2014-05-14 06:45:52 UTC (rev 168795)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2008, 2009, 2010, 2012 Apple Inc. All Rights Reserved.
</del><ins>+ * Copyright (C) 2008, 2009, 2010, 2012, 2014 Apple Inc. All Rights Reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -66,12 +66,8 @@
</span><span class="cx"> 
</span><span class="cx">     // WebViews waiting for CoreLocation to be ready. If the Application does not yet have the permission to use Geolocation
</span><span class="cx">     // we also have to wait for that to be granted.
</span><del>-    GeolocationInitializationCallbackMap _webViewsWaitingForCoreLocationStart;
</del><ins>+    GeolocationInitializationCallbackMap _webViewsWaitingForCoreLocationAuthorization;
</ins><span class="cx"> 
</span><del>-    // WebViews that have required location services and are in &quot;Warm Up&quot; while waiting to be registered or denied for the SecurityOrigin.
-    // The warm up expire after some time to avoid keeping CoreLocation alive while waiting for the user response for the Security Origin.
-    HashSet&lt;WebView*&gt; _warmUpWebViews;
-
</del><span class="cx">     // List of WebView needing the initial position after registerWebView:. This is needed because WebKit does not
</span><span class="cx">     // handle sending the position synchronously in response to registerWebView:, so we queue sending lastPosition behind a timer.
</span><span class="cx">     HashSet&lt;WebView*&gt; _pendingInitialPositionWebView;
</span><span class="lines">@@ -121,7 +117,7 @@
</span><span class="cx">     // A new position is acquired and sent to all registered views on resume.
</span><span class="cx">     _lastPosition.clear();
</span><span class="cx">     abortSendLastPosition(self);
</span><del>-    [_coreLocationProvider.get() stop];
</del><ins>+    [_coreLocationProvider stop];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)resume
</span><span class="lines">@@ -138,7 +134,7 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (_registeredWebViews.isEmpty() &amp;&amp; _webViewsWaitingForCoreLocationStart.isEmpty() &amp;&amp; _warmUpWebViews.isEmpty())
</del><ins>+    if (_registeredWebViews.isEmpty() &amp;&amp; _webViewsWaitingForCoreLocationAuthorization.isEmpty())
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     if (!_coreLocationProvider) {
</span><span class="lines">@@ -146,39 +142,18 @@
</span><span class="cx">         _coreLocationUpdateListenerProxy = adoptNS([[_WebCoreLocationUpdateThreadingProxy alloc] initWithProvider:self]);
</span><span class="cx">         _coreLocationProvider = adoptNS([[WebGeolocationCoreLocationProvider alloc] initWithListener:_coreLocationUpdateListenerProxy.get()]);
</span><span class="cx">     }
</span><del>-    [_coreLocationProvider.get() setEnableHighAccuracy:_enableHighAccuracy];
-    [_coreLocationProvider.get() start];
-}
</del><span class="cx"> 
</span><del>-#pragma mark - Internal utility methods
-- (void)_startCoreLocationDelegate
-{
-    ASSERT(!(_registeredWebViews.isEmpty() &amp;&amp; _webViewsWaitingForCoreLocationStart.isEmpty()));
</del><ins>+    if (!_webViewsWaitingForCoreLocationAuthorization.isEmpty())
+        [_coreLocationProvider requestGeolocationAuthorization];
</ins><span class="cx"> 
</span><del>-    if (_isSuspended)
-        return;
-
-    dispatch_async(dispatch_get_main_queue(), ^{
-        if (!_coreLocationProvider.get()) {
-            ASSERT(!_coreLocationUpdateListenerProxy);
-            _coreLocationUpdateListenerProxy = adoptNS([[_WebCoreLocationUpdateThreadingProxy alloc] initWithProvider:self]);
-            _coreLocationProvider = adoptNS([[WebGeolocationCoreLocationProvider alloc] initWithListener:_coreLocationUpdateListenerProxy.get()]);
-        }
-        [_coreLocationProvider.get() start];
-    });
-}
-
-- (void)_stopCoreLocationDelegateIfNeeded
-{
-    if (_registeredWebViews.isEmpty() &amp;&amp; _webViewsWaitingForCoreLocationStart.isEmpty() &amp;&amp; _warmUpWebViews.isEmpty()) {
-        dispatch_async(dispatch_get_main_queue(), ^{
-            [_coreLocationProvider.get() stop];
-        });
-        _enableHighAccuracy = NO;
-        _lastPosition.clear();
</del><ins>+    if (!_registeredWebViews.isEmpty()) {
+        [_coreLocationProvider setEnableHighAccuracy:_enableHighAccuracy];
+        [_coreLocationProvider start];
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#pragma mark - Internal utility methods
+
</ins><span class="cx"> - (void)_handlePendingInitialPosition:(NSTimer*)timer
</span><span class="cx"> {
</span><span class="cx">     ASSERT_UNUSED(timer, timer == _sendLastPositionAsynchronouslyTimer);
</span><span class="lines">@@ -202,13 +177,21 @@
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     _registeredWebViews.add(webView);
</span><del>-    _warmUpWebViews.remove(webView);
</del><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">     if (!CallUIDelegateReturningBoolean(YES, webView, @selector(webViewCanCheckGeolocationAuthorizationStatus:)))
</span><span class="cx">         return;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    [self _startCoreLocationDelegate];
</del><ins>+    if (!_isSuspended) {
+        dispatch_async(dispatch_get_main_queue(), ^{
+            if (!_coreLocationProvider) {
+                ASSERT(!_coreLocationUpdateListenerProxy);
+                _coreLocationUpdateListenerProxy = adoptNS([[_WebCoreLocationUpdateThreadingProxy alloc] initWithProvider:self]);
+                _coreLocationProvider = adoptNS([[WebGeolocationCoreLocationProvider alloc] initWithListener:_coreLocationUpdateListenerProxy.get()]);
+            }
+            [_coreLocationProvider start];
+        });
+    }
</ins><span class="cx"> 
</span><span class="cx">     // We send the lastPosition asynchronously because WebKit does not handle updating the position synchronously.
</span><span class="cx">     // On WebKit2, we could skip that and send the position directly from the UIProcess.
</span><span class="lines">@@ -230,7 +213,14 @@
</span><span class="cx"> 
</span><span class="cx">     _registeredWebViews.remove(webView);
</span><span class="cx">     _pendingInitialPositionWebView.remove(webView);
</span><del>-    [self _stopCoreLocationDelegateIfNeeded];
</del><ins>+
+    if (_registeredWebViews.isEmpty()) {
+        dispatch_async(dispatch_get_main_queue(), ^{
+            [_coreLocationProvider stop];
+        });
+        _enableHighAccuracy = NO;
+        _lastPosition.clear();
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (WebGeolocationPosition *)lastPosition
</span><span class="lines">@@ -244,7 +234,7 @@
</span><span class="cx">     ASSERT(WebThreadIsLockedOrDisabled());
</span><span class="cx">     _enableHighAccuracy = _enableHighAccuracy || enableHighAccuracy;
</span><span class="cx">     dispatch_async(dispatch_get_main_queue(), ^{
</span><del>-        [_coreLocationProvider.get() setEnableHighAccuracy:_enableHighAccuracy];
</del><ins>+        [_coreLocationProvider setEnableHighAccuracy:_enableHighAccuracy];
</ins><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -256,83 +246,49 @@
</span><span class="cx">     if (!CallUIDelegateReturningBoolean(YES, webView, @selector(webViewCanCheckGeolocationAuthorizationStatus:)))
</span><span class="cx">         return;
</span><span class="cx"> #endif
</span><del>-    _webViewsWaitingForCoreLocationStart.add(webView, listener);
</del><ins>+    _webViewsWaitingForCoreLocationAuthorization.add(webView, listener);
</ins><span class="cx">     _trackedWebViews.add(webView);
</span><span class="cx"> 
</span><del>-    [self _startCoreLocationDelegate];
</del><ins>+    dispatch_async(dispatch_get_main_queue(), ^{
+        if (!_coreLocationProvider) {
+            ASSERT(!_coreLocationUpdateListenerProxy);
+            _coreLocationUpdateListenerProxy = adoptNS([[_WebCoreLocationUpdateThreadingProxy alloc] initWithProvider:self]);
+            _coreLocationProvider = adoptNS([[WebGeolocationCoreLocationProvider alloc] initWithListener:_coreLocationUpdateListenerProxy.get()]);
+        }
+        [_coreLocationProvider requestGeolocationAuthorization];
+    });
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)cancelWarmUpForWebView:(WebView *)webView
</del><ins>+- (void)geolocationAuthorizationGranted
</ins><span class="cx"> {
</span><del>-    ASSERT(WebThreadIsLockedOrDisabled());
</del><ins>+    ASSERT(WebThreadIsCurrent());
</ins><span class="cx"> 
</span><del>-    _warmUpWebViews.remove(webView);
-    [self _stopCoreLocationDelegateIfNeeded];
-}
</del><ins>+    GeolocationInitializationCallbackMap requests;
+    requests.swap(_webViewsWaitingForCoreLocationAuthorization);
</ins><span class="cx"> 
</span><del>-- (void)stopTrackingWebView:(WebView*)webView
-{
-    ASSERT(WebThreadIsLockedOrDisabled());
-    _trackedWebViews.remove(webView);
</del><ins>+    for (const auto&amp; slot : requests)
+        [slot.value initializationAllowedWebView:slot.key.get()];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-#pragma mark - Mirror to WebGeolocationCoreLocationUpdateListener called by the proxy.
-- (void)geolocationDelegateStarted
</del><ins>+- (void)geolocationAuthorizationDenied
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(WebThreadIsCurrent());
</span><span class="cx"> 
</span><del>-    // This could be called recursively. We must clean _webViewsWaitingForCoreLocationStart before invoking the callbacks.
-    Vector&lt;RetainPtr&lt;WebView&gt; &gt; webViews;
-    copyKeysToVector(_webViewsWaitingForCoreLocationStart, webViews);
</del><ins>+    GeolocationInitializationCallbackMap requests;
+    requests.swap(_webViewsWaitingForCoreLocationAuthorization);
</ins><span class="cx"> 
</span><del>-    Vector&lt;RetainPtr&lt;id&lt;WebGeolocationProviderInitializationListener&gt; &gt; &gt; initializationListeners;
-    copyValuesToVector(_webViewsWaitingForCoreLocationStart, initializationListeners);
-
-    _webViewsWaitingForCoreLocationStart.clear();
-
-    // Start warmup period for each view in intialization.
-    const int64_t warmUpTimeoutInterval = 20 * NSEC_PER_SEC;
-    dispatch_time_t when = dispatch_time(DISPATCH_TIME_NOW, warmUpTimeoutInterval);
-    for (size_t i = 0; i &lt; webViews.size(); ++i) {
-        WebView *webView = webViews[i].get();
-
-        _warmUpWebViews.add(webView);
-
-        dispatch_after(when, dispatch_get_main_queue(), ^{
-            _warmUpWebViews.remove(webView);
-            [self _stopCoreLocationDelegateIfNeeded];
-        });
-    }
-
-    // Inform the listeners the initialization succeeded.
-    for (size_t i = 0; i &lt; webViews.size(); ++i) {
-        RetainPtr&lt;WebView&gt;&amp; webView = webViews[i];
-        RetainPtr&lt;id&lt;WebGeolocationProviderInitializationListener&gt; &gt;&amp; listener = initializationListeners[i];
-        [listener.get() initializationAllowedWebView:webView.get() provider:self];
-    }
</del><ins>+    for (const auto&amp; slot : requests)
+        [slot.value initializationDeniedWebView:slot.key.get()];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)geolocationDelegateUnableToStart
</del><ins>+- (void)stopTrackingWebView:(WebView*)webView
</ins><span class="cx"> {
</span><del>-    ASSERT(WebThreadIsCurrent());
-
-    // This could be called recursively. We must clean _webViewsWaitingForCoreLocationStart before invoking the callbacks.
-    Vector&lt;RetainPtr&lt;WebView&gt; &gt; webViews;
-    copyKeysToVector(_webViewsWaitingForCoreLocationStart, webViews);
-
-    Vector&lt;RetainPtr&lt;id&lt;WebGeolocationProviderInitializationListener&gt; &gt; &gt; initializationListeners;
-    copyValuesToVector(_webViewsWaitingForCoreLocationStart, initializationListeners);
-
-    _webViewsWaitingForCoreLocationStart.clear();
-
-    // Inform the listeners of the failure.
-    for (size_t i = 0; i &lt; webViews.size(); ++i) {
-        RetainPtr&lt;WebView&gt;&amp; webView = webViews[i];
-        RetainPtr&lt;id&lt;WebGeolocationProviderInitializationListener&gt; &gt;&amp; listener = initializationListeners[i];
-        [listener.get() initializationDeniedWebView:webView.get() provider:self];
-    }
</del><ins>+    ASSERT(WebThreadIsLockedOrDisabled());
+    _trackedWebViews.remove(webView);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#pragma mark - Mirror to WebGeolocationCoreLocationUpdateListener called by the proxy.
+
</ins><span class="cx"> - (void)positionChanged:(WebGeolocationPosition*)position
</span><span class="cx"> {
</span><span class="cx">     ASSERT(WebThreadIsCurrent());
</span><span class="lines">@@ -367,11 +323,9 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx">     // 1) Stop all ongoing Geolocation initialization and tracking.
</span><del>-    _webViewsWaitingForCoreLocationStart.clear();
-    _warmUpWebViews.clear();
</del><ins>+    _webViewsWaitingForCoreLocationAuthorization.clear();
</ins><span class="cx">     _registeredWebViews.clear();
</span><span class="cx">     abortSendLastPosition(self);
</span><del>-    [self _stopCoreLocationDelegateIfNeeded];
</del><span class="cx"> 
</span><span class="cx">     // 2) Reset the views, each frame will register back if needed.
</span><span class="cx">     Vector&lt;WebView*&gt; webViewsCopy;
</span><span class="lines">@@ -394,30 +348,40 @@
</span><span class="cx">     return self;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)geolocationDelegateStarted
</del><ins>+- (void)geolocationAuthorizationGranted
</ins><span class="cx"> {
</span><del>-    WebThreadRun(^{ [_provider geolocationDelegateStarted]; });
</del><ins>+    WebThreadRun(^{
+        [_provider geolocationAuthorizationGranted];
+    });
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)geolocationDelegateUnableToStart
</del><ins>+- (void)geolocationAuthorizationDenied
</ins><span class="cx"> {
</span><del>-    WebThreadRun(^{ [_provider geolocationDelegateUnableToStart]; });
</del><ins>+    WebThreadRun(^{
+        [_provider geolocationAuthorizationDenied];
+    });
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)positionChanged:(WebCore::GeolocationPosition*)position
</span><span class="cx"> {
</span><span class="cx">     RetainPtr&lt;WebGeolocationPosition&gt; webPosition = adoptNS([[WebGeolocationPosition alloc] initWithGeolocationPosition:position]);
</span><del>-    WebThreadRun(^{ [_provider positionChanged:webPosition.get()]; });
</del><ins>+    WebThreadRun(^{
+        [_provider positionChanged:webPosition.get()];
+    });
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)errorOccurred:(NSString *)errorMessage
</span><span class="cx"> {
</span><del>-    WebThreadRun(^{ [_provider errorOccurred:errorMessage]; });
</del><ins>+    WebThreadRun(^{
+        [_provider errorOccurred:errorMessage];
+    });
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)resetGeolocation
</span><span class="cx"> {
</span><del>-    WebThreadRun(^{ [_provider resetGeolocation]; });
</del><ins>+    WebThreadRun(^{
+        [_provider resetGeolocation];
+    });
</ins><span class="cx"> }
</span><span class="cx"> @end
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchessafari53834branchSourceWebKitmacChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-538.34-branch/Source/WebKit/mac/ChangeLog (168794 => 168795)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-538.34-branch/Source/WebKit/mac/ChangeLog        2014-05-14 06:42:24 UTC (rev 168794)
+++ branches/safari-538.34-branch/Source/WebKit/mac/ChangeLog        2014-05-14 06:45:52 UTC (rev 168795)
</span><span class="lines">@@ -1,5 +1,29 @@
</span><span class="cx"> 2014-04-17  Lucas Forschler  &lt;lforschler@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Merge r168555
+
+    2014-05-09  Benjamin Poulain  &lt;benjamin@webkit.org&gt;
+
+            [iOS] Switch geolocation to an explicit authorization query model
+            https://bugs.webkit.org/show_bug.cgi?id=132717
+
+            Reviewed by Sam Weinig.
+
+            Since there is no warmup code, WebGeolocationPolicyListener no longer need to know about the provider,
+            which is awesome :)
+
+            * WebCoreSupport/WebGeolocationClient.mm:
+            (-[WebGeolocationPolicyListener initWithGeolocation:forWebView:]):
+            (-[WebGeolocationPolicyListener deny]):
+            (-[WebGeolocationProviderInitializationListener initializationAllowedWebView:]):
+            (-[WebGeolocationProviderInitializationListener initializationDeniedWebView:]):
+            (-[WebGeolocationPolicyListener initWithGeolocation:forWebView:provider:]): Deleted.
+            (-[WebGeolocationProviderInitializationListener initializationAllowedWebView:provider:]): Deleted.
+            (-[WebGeolocationProviderInitializationListener initializationDeniedWebView:provider:]): Deleted.
+            * WebView/WebViewPrivate.h:
+
+2014-04-17  Lucas Forschler  &lt;lforschler@apple.com&gt;
+
</ins><span class="cx">         Merge r168452
</span><span class="cx"> 
</span><span class="cx">     2014-05-07  Pratik Solanki  &lt;psolanki@apple.com&gt;
</span></span></pre></div>
<a id="branchessafari53834branchSourceWebKitmacWebCoreSupportWebGeolocationClientmm"></a>
<div class="modfile"><h4>Modified: branches/safari-538.34-branch/Source/WebKit/mac/WebCoreSupport/WebGeolocationClient.mm (168794 => 168795)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-538.34-branch/Source/WebKit/mac/WebCoreSupport/WebGeolocationClient.mm        2014-05-14 06:42:24 UTC (rev 168794)
+++ branches/safari-538.34-branch/Source/WebKit/mac/WebCoreSupport/WebGeolocationClient.mm        2014-05-14 06:45:52 UTC (rev 168795)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2009, 2012 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2009, 2012, 2014 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -57,9 +57,8 @@
</span><span class="cx"> {
</span><span class="cx">     RefPtr&lt;Geolocation&gt; _geolocation;
</span><span class="cx">     RetainPtr&lt;WebView *&gt; _webView;
</span><del>-    RetainPtr&lt;id&lt;WebGeolocationProvider&gt; &gt; _geolocationProvider;
</del><span class="cx"> }
</span><del>-- (id)initWithGeolocation:(Geolocation*)geolocation forWebView:(WebView*)webView provider:(id&lt;WebGeolocationProvider&gt;)provider;
</del><ins>+- (id)initWithGeolocation:(Geolocation*)geolocation forWebView:(WebView*)webView;
</ins><span class="cx"> @end
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="lines">@@ -157,14 +156,13 @@
</span><span class="cx"> 
</span><span class="cx"> #else
</span><span class="cx"> @implementation WebGeolocationPolicyListener
</span><del>-- (id)initWithGeolocation:(Geolocation*)geolocation forWebView:(WebView*)webView provider:(id&lt;WebGeolocationProvider&gt;)provider
</del><ins>+- (id)initWithGeolocation:(Geolocation*)geolocation forWebView:(WebView*)webView
</ins><span class="cx"> {
</span><span class="cx">     self = [super init];
</span><span class="cx">     if (!self)
</span><span class="cx">         return nil;
</span><span class="cx">     _geolocation = geolocation;
</span><span class="cx">     _webView = webView;
</span><del>-    _geolocationProvider = provider;
</del><span class="cx">     return self;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -179,7 +177,6 @@
</span><span class="cx"> {
</span><span class="cx">     WebThreadRun(^{
</span><span class="cx">         _geolocation-&gt;setIsAllowed(false);
</span><del>-        [_geolocationProvider.get() cancelWarmUpForWebView:_webView.get()];
</del><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -211,17 +208,15 @@
</span><span class="cx">     return self;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)initializationAllowedWebView:(WebView *)webView provider:(id&lt;WebGeolocationProvider&gt;)provider
</del><ins>+- (void)initializationAllowedWebView:(WebView *)webView
</ins><span class="cx"> {
</span><span class="cx">     BEGIN_BLOCK_OBJC_EXCEPTIONS;
</span><span class="cx"> 
</span><span class="cx">     Frame* frame = m_geolocation-&gt;frame();
</span><del>-    if (!frame) {
-        [provider cancelWarmUpForWebView:webView];
</del><ins>+    if (!frame)
</ins><span class="cx">         return;
</span><del>-    }
</del><span class="cx">     WebSecurityOrigin *webOrigin = [[WebSecurityOrigin alloc] _initWithWebCoreSecurityOrigin:frame-&gt;document()-&gt;securityOrigin()];
</span><del>-    WebGeolocationPolicyListener *listener = [[WebGeolocationPolicyListener alloc] initWithGeolocation:m_geolocation.get() forWebView:webView provider:provider];
</del><ins>+    WebGeolocationPolicyListener *listener = [[WebGeolocationPolicyListener alloc] initWithGeolocation:m_geolocation.get() forWebView:webView];
</ins><span class="cx">     SEL selector = @selector(webView:decidePolicyForGeolocationRequestFromOrigin:frame:listener:);
</span><span class="cx">     CallUIDelegate(webView, selector, webOrigin, kit(frame), listener);
</span><span class="cx">     [webOrigin release];
</span><span class="lines">@@ -230,7 +225,7 @@
</span><span class="cx">     END_BLOCK_OBJC_EXCEPTIONS;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)initializationDeniedWebView:(WebView *)webView provider:(id&lt;WebGeolocationProvider&gt;)provider
</del><ins>+- (void)initializationDeniedWebView:(WebView *)webView
</ins><span class="cx"> {
</span><span class="cx">     m_geolocation-&gt;setIsAllowed(false);
</span><span class="cx"> }
</span></span></pre></div>
<a id="branchessafari53834branchSourceWebKitmacWebViewWebViewPrivateh"></a>
<div class="modfile"><h4>Modified: branches/safari-538.34-branch/Source/WebKit/mac/WebView/WebViewPrivate.h (168794 => 168795)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-538.34-branch/Source/WebKit/mac/WebView/WebViewPrivate.h        2014-05-14 06:42:24 UTC (rev 168794)
+++ branches/safari-538.34-branch/Source/WebKit/mac/WebView/WebViewPrivate.h        2014-05-14 06:45:52 UTC (rev 168795)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2005-2012 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2005-2014 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -975,8 +975,8 @@
</span><span class="cx"> @protocol WebGeolocationProvider;
</span><span class="cx"> 
</span><span class="cx"> @protocol WebGeolocationProviderInitializationListener &lt;NSObject&gt;
</span><del>-- (void)initializationAllowedWebView:(WebView *)webView provider:(id&lt;WebGeolocationProvider&gt;)provider;
-- (void)initializationDeniedWebView:(WebView *)webView provider:(id&lt;WebGeolocationProvider&gt;)provider;
</del><ins>+- (void)initializationAllowedWebView:(WebView *)webView;
+- (void)initializationDeniedWebView:(WebView *)webView;
</ins><span class="cx"> @end
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="lines">@@ -992,7 +992,6 @@
</span><span class="cx"> #if TARGET_OS_IPHONE
</span><span class="cx"> - (void)setEnableHighAccuracy:(BOOL)enableHighAccuracy;
</span><span class="cx"> - (void)initializeGeolocationForWebView:(WebView *)webView listener:(id&lt;WebGeolocationProviderInitializationListener&gt;)listener;
</span><del>-- (void)cancelWarmUpForWebView:(WebView *)webView;
</del><span class="cx"> - (void)stopTrackingWebView:(WebView *)webView;
</span><span class="cx"> #endif
</span><span class="cx"> @end
</span></span></pre></div>
<a id="branchessafari53834branchSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-538.34-branch/Source/WebKit2/ChangeLog (168794 => 168795)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-538.34-branch/Source/WebKit2/ChangeLog        2014-05-14 06:42:24 UTC (rev 168794)
+++ branches/safari-538.34-branch/Source/WebKit2/ChangeLog        2014-05-14 06:45:52 UTC (rev 168795)
</span><span class="lines">@@ -1,5 +1,36 @@
</span><span class="cx"> 2014-04-17  Lucas Forschler  &lt;lforschler@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Merge r168555
+
+    2014-05-09  Benjamin Poulain  &lt;benjamin@webkit.org&gt;
+
+            [iOS] Switch geolocation to an explicit authorization query model
+            https://bugs.webkit.org/show_bug.cgi?id=132717
+
+            Reviewed by Sam Weinig.
+
+            Switch WKGeolocationProviderIOS to use the new API of WebGeolocationCoreLocationProvider.
+
+            On WebKit2, the whole logic to track requesters is in WebGeolocationManagerProxy.
+
+            Without the warmup sequence, WKGeolocationProviderIOS becomes really dumb: it just provides
+            the two step authorization and forward the start/stop messages to the WebGeolocationCoreLocationProvider.
+
+            * UIProcess/ios/WKGeolocationProviderIOS.mm:
+            (-[WKGeolocationProviderIOS _stopUpdating]):
+            (-[WKGeolocationProviderIOS decidePolicyForGeolocationRequestFromOrigin:frame:request:window:]):
+            (-[WKGeolocationProviderIOS geolocationAuthorizationGranted]):
+            (-[WKGeolocationProviderIOS geolocationAuthorizationDenied]):
+            (-[WKWebAllowDenyPolicyListener initWithPermissionRequestProxy:]):
+            (-[WKWebAllowDenyPolicyListener deny]):
+            (-[WKGeolocationProviderIOS _stopUpdatingIfPossible]): Deleted.
+            (-[WKGeolocationProviderIOS geolocationDelegateStarted]): Deleted.
+            (-[WKGeolocationProviderIOS geolocationDelegateUnableToStart]): Deleted.
+            (-[WKGeolocationProviderIOS permissionDenied:]): Deleted.
+            (-[WKWebAllowDenyPolicyListener initWithProvider:permissionRequestProxy:]): Deleted.
+
+2014-04-17  Lucas Forschler  &lt;lforschler@apple.com&gt;
+
</ins><span class="cx">         Merge r168489
</span><span class="cx"> 
</span><span class="cx">     2014-05-08  Tim Horton  &lt;timothy_horton@apple.com&gt;
</span></span></pre></div>
<a id="branchessafari53834branchSourceWebKit2UIProcessiosWKGeolocationProviderIOSmm"></a>
<div class="modfile"><h4>Modified: branches/safari-538.34-branch/Source/WebKit2/UIProcess/ios/WKGeolocationProviderIOS.mm (168794 => 168795)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-538.34-branch/Source/WebKit2/UIProcess/ios/WKGeolocationProviderIOS.mm        2014-05-14 06:42:24 UTC (rev 168794)
+++ branches/safari-538.34-branch/Source/WebKit2/UIProcess/ios/WKGeolocationProviderIOS.mm        2014-05-14 06:45:52 UTC (rev 168795)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2012 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2012, 2014 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -50,17 +50,11 @@
</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 ()
--(void)_startUpdating;
--(void)_stopUpdating;
--(void)_setEnableHighAccuracy:(BOOL)enable;
-@end
-
</del><span class="cx"> @interface WKGeolocationProviderIOS (WebGeolocationCoreLocationUpdateListener) &lt;WebGeolocationCoreLocationUpdateListener&gt;
</span><span class="cx"> @end
</span><span class="cx"> 
</span><span class="cx"> @interface WKWebAllowDenyPolicyListener : NSObject&lt;WebAllowDenyPolicyListener&gt;
</span><del>-- (id)initWithProvider:(WKGeolocationProviderIOS*)provider permissionRequestProxy:(PassRefPtr&lt;GeolocationPermissionRequestProxy&gt;)permissionRequestProxy;
</del><ins>+- (id)initWithPermissionRequestProxy:(PassRefPtr&lt;GeolocationPermissionRequestProxy&gt;)permissionRequestProxy;
</ins><span class="cx"> - (void)denyOnlyThisRequest NO_RETURN_DUE_TO_ASSERT;
</span><span class="cx"> @end
</span><span class="cx"> 
</span><span class="lines">@@ -68,6 +62,23 @@
</span><span class="cx"> void decidePolicyForGeolocationRequestFromOrigin(WebCore::SecurityOrigin*, const String&amp; urlString, id&lt;WebAllowDenyPolicyListener&gt;, UIWindow*);
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+struct GeolocationRequestData {
+    RefPtr&lt;WebCore::SecurityOrigin&gt; origin;
+    RefPtr&lt;WebFrameProxy&gt; frame;
+    RefPtr&lt;GeolocationPermissionRequestProxy&gt; permissionRequest;
+    RetainPtr&lt;UIWindow&gt; window;
+};
+
+@implementation WKGeolocationProviderIOS {
+    RefPtr&lt;WebGeolocationManagerProxy&gt; _geolocationManager;
+    RetainPtr&lt;WebGeolocationCoreLocationProvider&gt; _coreLocationProvider;
+    BOOL _isWebCoreGeolocationActive;
+    RefPtr&lt;WebGeolocationPosition&gt; _lastActivePosition;
+    Vector&lt;GeolocationRequestData&gt; _requestsWaitingForCoreLocationAuthorization;
+}
+
+#pragma mark - WKGeolocationProvider callbacks implementation.
+
</ins><span class="cx"> static void startUpdatingCallback(WKGeolocationManagerRef geolocationManager, const void* clientInfo)
</span><span class="cx"> {
</span><span class="cx">     WKGeolocationProviderIOS *geolocationProvider = reinterpret_cast&lt;WKGeolocationProviderIOS*&gt;(const_cast&lt;void*&gt;(clientInfo));
</span><span class="lines">@@ -89,34 +100,6 @@
</span><span class="cx">     [geolocationProvider _setEnableHighAccuracy:enable];
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-struct GeolocationRequestData {
-    RefPtr&lt;WebCore::SecurityOrigin&gt; origin;
-    RefPtr&lt;WebFrameProxy&gt; frame;
-    RefPtr&lt;GeolocationPermissionRequestProxy&gt; permissionRequest;
-    RetainPtr&lt;UIWindow&gt; window;
-};
-
-@implementation WKGeolocationProviderIOS {
-    RefPtr&lt;WebGeolocationManagerProxy&gt; _geolocationManager;
-    RetainPtr&lt;WebGeolocationCoreLocationProvider&gt; _coreLocationProvider;
-    BOOL _isWebCoreGeolocationActive;
-    RefPtr&lt;WebGeolocationPosition&gt; _lastActivePosition;
-    Vector&lt;GeolocationRequestData&gt; _requestsWaitingForCoreLocationStart;
-    HashSet&lt;void*&gt; _requestsInWarmUp;
-}
-
--(void)_stopUpdatingIfPossible
-{
-    if (_isWebCoreGeolocationActive)
-        return;
-
-    if (_requestsWaitingForCoreLocationStart.isEmpty() &amp;&amp; _requestsInWarmUp.isEmpty()) {
-        [_coreLocationProvider stop];
-        _lastActivePosition.clear();
-    }
-}
-
-#pragma mark - WKGeolocationProvider callbacks implementation.
</del><span class="cx"> -(void)_startUpdating
</span><span class="cx"> {
</span><span class="cx">     _isWebCoreGeolocationActive = YES;
</span><span class="lines">@@ -131,7 +114,8 @@
</span><span class="cx"> -(void)_stopUpdating
</span><span class="cx"> {
</span><span class="cx">     _isWebCoreGeolocationActive = NO;
</span><del>-    [self _stopUpdatingIfPossible];
</del><ins>+    [_coreLocationProvider stop];
+    _lastActivePosition.clear();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> -(void)_setEnableHighAccuracy:(BOOL)enableHighAccuracy
</span><span class="lines">@@ -168,52 +152,36 @@
</span><span class="cx"> 
</span><span class="cx"> -(void)decidePolicyForGeolocationRequestFromOrigin:(WKSecurityOriginRef)origin frame:(WKFrameRef)frame request:(WKGeolocationPermissionRequestRef)permissionRequest window:(UIWindow*)window
</span><span class="cx"> {
</span><ins>+    // Step 1: ask the user if the app can use Geolocation.
</ins><span class="cx">     GeolocationRequestData geolocationRequestData;
</span><span class="cx">     geolocationRequestData.origin = toImpl(origin)-&gt;securityOrigin();
</span><span class="cx">     geolocationRequestData.frame = toImpl(frame);
</span><span class="cx">     geolocationRequestData.permissionRequest = toImpl(permissionRequest);
</span><span class="cx">     geolocationRequestData.window = window;
</span><del>-    _requestsWaitingForCoreLocationStart.append(geolocationRequestData);
-    [_coreLocationProvider start];
</del><ins>+    _requestsWaitingForCoreLocationAuthorization.append(geolocationRequestData);
+    [_coreLocationProvider requestGeolocationAuthorization];
</ins><span class="cx"> }
</span><span class="cx"> @end
</span><span class="cx"> 
</span><span class="cx"> #pragma mark - WebGeolocationCoreLocationUpdateListener implementation.
</span><span class="cx"> 
</span><span class="cx"> @implementation WKGeolocationProviderIOS (WebGeolocationCoreLocationUpdateListener)
</span><del>-- (void)geolocationDelegateStarted
</del><ins>+
+- (void)geolocationAuthorizationGranted
</ins><span class="cx"> {
</span><del>-    Vector&lt;GeolocationRequestData&gt; requests;
-    requests.swap(_requestsWaitingForCoreLocationStart);
-    HashSet&lt;void*&gt; latestRequestsForWarmup;
-    for (size_t i = 0; i &lt; requests.size(); ++i) {
-        GeolocationPermissionRequestProxy* permissionRequest = requests[i].permissionRequest.get();
-        latestRequestsForWarmup.add(permissionRequest);
-        _requestsInWarmUp.add(permissionRequest);
</del><ins>+    // Step 2: ask the user if the this particular page can use gelocation.
+    Vector&lt;GeolocationRequestData&gt; requests = std::move(_requestsWaitingForCoreLocationAuthorization);
+    for (const auto&amp; request : requests) {
+        RetainPtr&lt;WKWebAllowDenyPolicyListener&gt; policyListener = adoptNS([[WKWebAllowDenyPolicyListener alloc] initWithPermissionRequestProxy:request.permissionRequest.get()]);
+        decidePolicyForGeolocationRequestFromOrigin(request.origin.get(), request.frame-&gt;url(), policyListener.get(), request.window.get());
</ins><span class="cx">     }
</span><del>-
-    // Start the warmup period in which we keep CoreLocation running while waiting for the user response.
-    const int64_t warmUpTimeoutInterval = 20 * NSEC_PER_SEC;
-    dispatch_time_t when = dispatch_time(DISPATCH_TIME_NOW, warmUpTimeoutInterval);
-    dispatch_after(when, dispatch_get_main_queue(), ^{
-        HashSet&lt;void*&gt;::const_iterator end = latestRequestsForWarmup.end();
-        for (HashSet&lt;void*&gt;::const_iterator it = latestRequestsForWarmup.begin(); it != end; ++it)
-            _requestsInWarmUp.remove(*it);
-        [self _stopUpdatingIfPossible];
-    });
-
-    for (size_t i = 0; i &lt; requests.size(); ++i) {
-        RetainPtr&lt;WKWebAllowDenyPolicyListener&gt; policyListener = adoptNS([[WKWebAllowDenyPolicyListener alloc] initWithProvider:self permissionRequestProxy:requests[i].permissionRequest.get()]);
-        decidePolicyForGeolocationRequestFromOrigin(requests[i].origin.get(), requests[i].frame-&gt;url(), policyListener.get(), requests[i].window.get());
-    }
</del><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)geolocationDelegateUnableToStart
</del><ins>+- (void)geolocationAuthorizationDenied
</ins><span class="cx"> {
</span><del>-    for (size_t i = 0; i &lt; _requestsWaitingForCoreLocationStart.size(); ++i)
-        _requestsWaitingForCoreLocationStart[i].permissionRequest-&gt;deny();
-    _requestsWaitingForCoreLocationStart.clear();
-    [self _stopUpdatingIfPossible];
</del><ins>+    Vector&lt;GeolocationRequestData&gt; requests = std::move(_requestsWaitingForCoreLocationAuthorization);
+    for (const auto&amp; requestData : requests)
+        requestData.permissionRequest-&gt;deny();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)positionChanged:(WebCore::GeolocationPosition*)position
</span><span class="lines">@@ -232,28 +200,19 @@
</span><span class="cx">     _geolocationManager-&gt;resetPermissions();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-#pragma mark - Methods for udating the state WKWebAllowDenyPolicyListener
-- (void)permissionDenied:(GeolocationPermissionRequestProxy*)permissionRequestProxy
-{
-    _requestsInWarmUp.remove(permissionRequestProxy);
-    [self _stopUpdatingIfPossible];
-}
-
</del><span class="cx"> @end
</span><span class="cx"> 
</span><span class="cx"> # pragma mark - Implementation of WKWebAllowDenyPolicyListener
</span><span class="cx"> @implementation WKWebAllowDenyPolicyListener {
</span><del>-    RetainPtr&lt;WKGeolocationProviderIOS&gt; _provider;
</del><span class="cx">     RefPtr&lt;GeolocationPermissionRequestProxy&gt; _permissionRequestProxy;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (id)initWithProvider:(WKGeolocationProviderIOS*)provider permissionRequestProxy:(PassRefPtr&lt;GeolocationPermissionRequestProxy&gt;)permissionRequestProxy
</del><ins>+- (id)initWithPermissionRequestProxy:(PassRefPtr&lt;GeolocationPermissionRequestProxy&gt;)permissionRequestProxy
</ins><span class="cx"> {
</span><span class="cx">     self = [super init];
</span><span class="cx">     if (!self)
</span><span class="cx">         return nil;
</span><span class="cx"> 
</span><del>-    _provider = provider;
</del><span class="cx">     _permissionRequestProxy = permissionRequestProxy;
</span><span class="cx">     return self;
</span><span class="cx"> }
</span><span class="lines">@@ -265,7 +224,6 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)deny
</span><span class="cx"> {
</span><del>-    [_provider permissionDenied:_permissionRequestProxy.get()];
</del><span class="cx">     _permissionRequestProxy-&gt;deny();
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchessafari53834branchToolsChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-538.34-branch/Tools/ChangeLog (168794 => 168795)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-538.34-branch/Tools/ChangeLog        2014-05-14 06:42:24 UTC (rev 168794)
+++ branches/safari-538.34-branch/Tools/ChangeLog        2014-05-14 06:45:52 UTC (rev 168795)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2014-04-17  Lucas Forschler  &lt;lforschler@apple.com&gt;
+
+        Merge r168555
+
+    2014-05-09  Benjamin Poulain  &lt;benjamin@webkit.org&gt;
+
+            [iOS] Switch geolocation to an explicit authorization query model
+            https://bugs.webkit.org/show_bug.cgi?id=132717
+
+            Reviewed by Sam Weinig.
+
+            * DumpRenderTree/mac/MockGeolocationProvider.mm:
+            (-[MockGeolocationProvider initializeGeolocationForWebView:listener:]):
+            (-[MockGeolocationProvider cancelWarmUpForWebView:]): Deleted.
+
</ins><span class="cx"> 2014-05-13  Lucas Forschler  &lt;lforschler@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Merge r168546
</span></span></pre></div>
<a id="branchessafari53834branchToolsDumpRenderTreemacMockGeolocationProvidermm"></a>
<div class="modfile"><h4>Modified: branches/safari-538.34-branch/Tools/DumpRenderTree/mac/MockGeolocationProvider.mm (168794 => 168795)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-538.34-branch/Tools/DumpRenderTree/mac/MockGeolocationProvider.mm        2014-05-14 06:42:24 UTC (rev 168794)
+++ branches/safari-538.34-branch/Tools/DumpRenderTree/mac/MockGeolocationProvider.mm        2014-05-14 06:45:52 UTC (rev 168795)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2010, 2012 Apple Inc. All Rights Reserved.
</del><ins>+ * Copyright (C) 2010, 2012, 2014 Apple Inc. All Rights Reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -100,14 +100,9 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)initializeGeolocationForWebView:(WebView *)webView listener:(id&lt;WebGeolocationProviderInitializationListener&gt;)listener
</span><span class="cx"> {
</span><del>-    [listener initializationAllowedWebView:webView provider:self];
</del><ins>+    [listener initializationAllowedWebView:webView];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)cancelWarmUpForWebView:(WebView *)webView
-{
-    UNUSED_PARAM(webView);
-}
-
</del><span class="cx"> - (void)stopTrackingWebView:(WebView *)webView
</span><span class="cx"> {
</span><span class="cx">     UNUSED_PARAM(webView);
</span></span></pre>
</div>
</div>

</body>
</html>