Bug 223183

Summary: Add a new delegate for geolocation permission
Product: WebKit Reporter: youenn fablet <youennf>
Component: WebKit2Assignee: youenn fablet <youennf>
Status: RESOLVED FIXED    
Severity: Normal CC: cdumez, dvpdiner2, eric.carlson, ews-watchlist, ggaren, glenn, jer.noble, kkinnunen, philipj, sergio, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Local Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
ews-feeder: commit-queue-
Patch
none
Patch for landing none

Description youenn fablet 2021-03-15 07:25:09 PDT
Add a new delegate for geolocation permission
Comment 1 youenn fablet 2021-03-15 07:34:25 PDT
Created attachment 423178 [details]
Patch
Comment 2 Radar WebKit Bug Importer 2021-03-15 08:39:10 PDT
<rdar://problem/75430600>
Comment 3 youenn fablet 2021-03-15 08:49:28 PDT
Created attachment 423183 [details]
Patch
Comment 4 youenn fablet 2021-03-15 09:06:15 PDT
Created attachment 423185 [details]
Patch
Comment 5 Eric Carlson 2021-03-15 11:04:43 PDT
Comment on attachment 423185 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=423185&action=review

> Source/WebKit/UIProcess/Cocoa/UIDelegate.mm:415
> +        [(id <WKUIDelegatePrivate>)delegate _webView:m_uiDelegate->m_webView.get().get() requestGeolocationPermissionForOrigin:wrapper(API::SecurityOrigin::create(securityOrigin.get())) initiatedByFrame:wrapper(API::FrameInfo::create(FrameInfoData { frameInfo }, &page)) decisionHandler:makeBlockPtr([completionHandler = std::exchange(completionHandler, nullptr), securityOrigin = securityOrigin->data(), checker = WTFMove(checker), page = makeWeakPtr(page)] (_WKPermissionDecision decision) mutable {

This is *much* harder to read and understand than the one you updated for `UIClient::decidePolicyForUserMediaPermissionRequest`, so it might be worth using a local variable or two to aid readability.
Comment 6 youenn fablet 2021-03-15 11:44:06 PDT
(In reply to Eric Carlson from comment #5)
> Comment on attachment 423185 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=423185&action=review
> 
> > Source/WebKit/UIProcess/Cocoa/UIDelegate.mm:415
> > +        [(id <WKUIDelegatePrivate>)delegate _webView:m_uiDelegate->m_webView.get().get() requestGeolocationPermissionForOrigin:wrapper(API::SecurityOrigin::create(securityOrigin.get())) initiatedByFrame:wrapper(API::FrameInfo::create(FrameInfoData { frameInfo }, &page)) decisionHandler:makeBlockPtr([completionHandler = std::exchange(completionHandler, nullptr), securityOrigin = securityOrigin->data(), checker = WTFMove(checker), page = makeWeakPtr(page)] (_WKPermissionDecision decision) mutable {
> 
> This is *much* harder to read and understand than the one you updated for
> `UIClient::decidePolicyForUserMediaPermissionRequest`, so it might be worth
> using a local variable or two to aid readability.

OK, will add a local variable for the decisionHandler
Comment 7 youenn fablet 2021-03-15 11:44:49 PDT
Created attachment 423211 [details]
Patch for landing
Comment 8 youenn fablet 2021-03-16 00:58:11 PDT
Comment on attachment 423211 [details]
Patch for landing

Win test failure is unrelated
Comment 9 EWS 2021-03-16 01:25:57 PDT
Committed r274469: <https://commits.webkit.org/r274469>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 423211 [details].
Comment 10 Darryl Pogue 2021-03-16 10:57:31 PDT
Comment on attachment 423211 [details]
Patch for landing

View in context: https://bugs.webkit.org/attachment.cgi?id=423211&action=review

> Source/WebKit/UIProcess/Cocoa/MediaPermissionUtilities.mm:139
> +        return [NSString stringWithFormat:WEB_UI_NSSTRING(@"Allow â%@â to use your current location?", @"Message for geolocation prompt"), visibleDomain(origin.host)];

Is there a reason not to use visibleOrigin here to show the app name for apps that embed WKWebView with custom schemes?
Comment 11 youenn fablet 2021-03-16 12:10:05 PDT
(In reply to Darryl Pogue from comment #10)
> Comment on attachment 423211 [details]
> Patch for landing
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=423211&action=review
> 
> > Source/WebKit/UIProcess/Cocoa/MediaPermissionUtilities.mm:139
> > +        return [NSString stringWithFormat:WEB_UI_NSSTRING(@"Allow â%@â to use your current location?", @"Message for geolocation prompt"), visibleDomain(origin.host)];
> 
> Is there a reason not to use visibleOrigin here to show the app name for
> apps that embed WKWebView with custom schemes?

No, we should probably update it accordingly.