<html>
<head>
<base href="https://bugs.webkit.org/">
</head>
<body>
<p>
<div>
<b><a class="bz_bug_link
bz_status_NEW "
title="NEW - Add SPI for handling geolocation authorization requests"
href="https://bugs.webkit.org/show_bug.cgi?id=170362#c3">Comment # 3</a>
on <a class="bz_bug_link
bz_status_NEW "
title="NEW - Add SPI for handling geolocation authorization requests"
href="https://bugs.webkit.org/show_bug.cgi?id=170362">bug 170362</a>
from <span class="vcard"><a class="email" href="mailto:david_quesada@apple.com" title="David Quesada <david_quesada@apple.com>"> <span class="fn">David Quesada</span></a>
</span></b>
<pre>Comment on <span class=""><a href="attachment.cgi?id=306015&action=diff" name="attach_306015" title="Patch">attachment 306015</a> <a href="attachment.cgi?id=306015&action=edit" title="Patch">[details]</a></span>
Patch
<span class="quote">>commit 8d19071e1f4ffcbe354b901238e104b85728994a
>Author: David Quesada <<a href="mailto:david_quesada@apple.com">david_quesada@apple.com</a>>
>Date: Fri Mar 31 14:53:01 2017 -0700</span >
>
<span class="quote">> Add SPI for handling geolocation authorization requests
> <a class="bz_bug_link
bz_status_NEW "
title="NEW - Add SPI for handling geolocation authorization requests"
href="show_bug.cgi?id=170362">https://bugs.webkit.org/show_bug.cgi?id=170362</a>
> rdar://problem/17508627
>
> Reviewed by NOBODY (OOPS!).
>
> * UIProcess/API/Cocoa/WKUIDelegatePrivate.h:
> * UIProcess/ios/WKGeolocationProviderIOS.mm:
> (-[WKGeolocationProviderIOS geolocationAuthorizationGranted]):</span >
>
<span class="quote">>diff --git a/Source/WebKit2/ChangeLog b/Source/WebKit2/ChangeLog
>index 9ca40daa58b..5b969402e17 100644
>--- a/Source/WebKit2/ChangeLog
>+++ b/Source/WebKit2/ChangeLog
>@@ -1,3 +1,15 @@
>+2017-03-31 David Quesada <<a href="mailto:david_quesada@apple.com">david_quesada@apple.com</a>>
>+
>+ Add SPI for handling geolocation authorization requests
>+ <a class="bz_bug_link
bz_status_NEW "
title="NEW - Add SPI for handling geolocation authorization requests"
href="show_bug.cgi?id=170362">https://bugs.webkit.org/show_bug.cgi?id=170362</a>
>+ rdar://problem/17508627
>+
>+ Reviewed by NOBODY (OOPS!).
>+
>+ * UIProcess/API/Cocoa/WKUIDelegatePrivate.h:
>+ * UIProcess/ios/WKGeolocationProviderIOS.mm:
>+ (-[WKGeolocationProviderIOS geolocationAuthorizationGranted]):
>+
> 2017-03-31 Csaba Osztrogonác <<a href="mailto:ossy@webkit.org">ossy@webkit.org</a>>
>
> Mac cmake buildfix after r214403
>diff --git a/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegatePrivate.h b/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegatePrivate.h
>index 05a1096fb8c..4e3614eaa69 100644
>--- a/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegatePrivate.h
>+++ b/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegatePrivate.h
>@@ -35,6 +35,7 @@
> @class UIItemProvider;
> @class UIScrollView;
> @class UIViewController;
>+@class WKFrameInfo;
> @class _WKContextMenuElementInfo;
> @class _WKActivatedElementInfo;
> @class _WKElementAction;
>@@ -72,6 +73,7 @@ struct UIEdgeInsets;
> - (NSArray *)_webView:(WKWebView *)webView actionsForElement:(_WKActivatedElementInfo *)element defaultActions:(NSArray<_WKElementAction *> *)defaultActions;
> - (void)_webView:(WKWebView *)webView didNotHandleTapAsClickAtPoint:(CGPoint)point;
> - (BOOL)_webView:(WKWebView *)webView shouldRequestGeolocationAuthorizationForURL:(NSURL *)url isMainFrame:(BOOL)isMainFrame mainFrameURL:(NSURL *)mainFrameURL;
>+- (void)_webView:(WKWebView *)webView requestGeolocationAuthorizationForURL:(NSURL *)url frame:(WKFrameInfo *)frame decisionHandler:(void (^)(BOOL authorized))decisionHandler WK_API_AVAILABLE(ios(WK_IOS_TBA));
> - (UIViewController *)_webView:(WKWebView *)webView previewViewControllerForURL:(NSURL *)url WK_API_AVAILABLE(ios(9.0));
> - (void)_webView:(WKWebView *)webView commitPreviewedViewController:(UIViewController *)previewedViewController WK_API_AVAILABLE(ios(9.0));
> - (void)_webView:(WKWebView *)webView willPreviewImageWithURL:(NSURL *)imageURL WK_API_AVAILABLE(ios(9.0));
>diff --git a/Source/WebKit2/UIProcess/ios/WKGeolocationProviderIOS.mm b/Source/WebKit2/UIProcess/ios/WKGeolocationProviderIOS.mm
>index 24781044816..839939d4c5a 100644
>--- a/Source/WebKit2/UIProcess/ios/WKGeolocationProviderIOS.mm
>+++ b/Source/WebKit2/UIProcess/ios/WKGeolocationProviderIOS.mm
>@@ -28,8 +28,11 @@
>
> #if PLATFORM(IOS)
>
>+#import "APIFrameInfo.h"
> #import "APISecurityOrigin.h"
>+#import "CompletionHandlerCallChecker.h"
> #import "GeolocationPermissionRequestProxy.h"
>+#import "WKFrameInfoInternal.h"
> #import "WKUIDelegatePrivate.h"
> #import "WKWebView.h"
> #import "WebGeolocationManagerProxy.h"
>@@ -38,6 +41,7 @@
> #import <WebCore/URL.h>
> #import <WebGeolocationPosition.h>
> #import <wtf/Assertions.h>
>+#import <wtf/BlockPtr.h>
> #import <wtf/HashSet.h>
> #import <wtf/PassRefPtr.h>
> #import <wtf/RefPtr.h>
>@@ -177,6 +181,22 @@ - (void)geolocationAuthorizationGranted
> bool requiresUserAuthorization = true;
>
> id<WKUIDelegatePrivate> uiDelegate = static_cast<id <WKUIDelegatePrivate>>([request.view UIDelegate]);
>+ if ([uiDelegate respondsToSelector:@selector(_webView:requestGeolocationAuthorizationForURL:frame:decisionHandler:)]) {
>+ URL requestFrameURL(URL(), request.frame->url());
>+ RetainPtr<WKFrameInfo> frameInfo = wrapper(API::FrameInfo::create(*request.frame.get(), *request.origin.get()));
>+ RefPtr<CompletionHandlerCallChecker> checker = CompletionHandlerCallChecker::create(uiDelegate, @selector(_webView:requestGeolocationAuthorizationForURL:frame:decisionHandler:));
>+ [uiDelegate _webView:request.view.get() requestGeolocationAuthorizationForURL:requestFrameURL frame:frameInfo.get() decisionHandler:BlockPtr<void(BOOL)>::fromCallable([request, checker = WTFMove(checker)](BOOL authorized) {
>+ if (checker->completionHandlerHasBeenCalled())
>+ return;
>+ if (authorized)
>+ request.permissionRequest->allow();
>+ else
>+ request.permissionRequest->deny();
>+ checker->didCallCompletionHandler();
>+ }).get()];
>+ return;
>+ }
>+
> if ([uiDelegate respondsToSelector:@selector(_webView:shouldRequestGeolocationAuthorizationForURL:isMainFrame:mainFrameURL:)]) {
> const WebFrameProxy* mainFrame = request.frame->page()->mainFrame();
> bool isMainFrame = request.frame == mainFrame;</span ></pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>