Bug 196971 - Show prompt for device orientation access if the client does not implement the corresponding API delegate
Summary: Show prompt for device orientation access if the client does not implement th...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit2 (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2019-04-16 10:51 PDT by Chris Dumez
Modified: 2019-04-16 15:44 PDT (History)
4 users (show)

See Also:


Attachments
Patch (13.09 KB, patch)
2019-04-16 10:55 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (13.89 KB, patch)
2019-04-16 11:44 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (15.00 KB, patch)
2019-04-16 11:53 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (15.07 KB, patch)
2019-04-16 13:27 PDT, Chris Dumez
achristensen: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2019-04-16 10:51:54 PDT
Show prompt for device orientation access if the client does not implement the corresponding API delegate.
Comment 1 Radar WebKit Bug Importer 2019-04-16 10:53:04 PDT
<rdar://problem/49945840>
Comment 2 Chris Dumez 2019-04-16 10:55:39 PDT
Created attachment 367545 [details]
Patch
Comment 3 Alex Christensen 2019-04-16 11:18:47 PDT
Comment on attachment 367545 [details]
Patch

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

> Source/WebKit/UIProcess/Cocoa/WKOrientationAccessAlert.h:31
> +#import <wtf/CompletionHandler.h>
> +#import <wtf/text/WTFString.h>

wtf/Forward.h should have everything necessary for this.

> Source/WebKit/UIProcess/Cocoa/WKOrientationAccessAlert.mm:35
> +    String alertText = makeString('"', host, "\" Would Like to Access Motion and Orientation");

These strings need to be localized.

> Source/WebKit/UIProcess/Cocoa/WKOrientationAccessAlert.mm:40
> +    auto completionBlock = makeBlockPtr([completionHandler = WTFMove(completionHandler)](bool shouldAllow) mutable {

I think this code would look better if we made a BlockPtr twice.
Comment 4 Chris Dumez 2019-04-16 11:38:39 PDT
(In reply to Alex Christensen from comment #3)
> Comment on attachment 367545 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=367545&action=review
> 
> > Source/WebKit/UIProcess/Cocoa/WKOrientationAccessAlert.h:31
> > +#import <wtf/CompletionHandler.h>
> > +#import <wtf/text/WTFString.h>
> 
> wtf/Forward.h should have everything necessary for this.

Ok.

> 
> > Source/WebKit/UIProcess/Cocoa/WKOrientationAccessAlert.mm:35
> > +    String alertText = makeString('"', host, "\" Would Like to Access Motion and Orientation");
> 
> These strings need to be localized.

Oops.

> 
> > Source/WebKit/UIProcess/Cocoa/WKOrientationAccessAlert.mm:40
> > +    auto completionBlock = makeBlockPtr([completionHandler = WTFMove(completionHandler)](bool shouldAllow) mutable {
> 
> I think this code would look better if we made a BlockPtr twice.

How do I make a BlockPtr twice with a single CompletionHandler?
Comment 5 Chris Dumez 2019-04-16 11:44:08 PDT
Created attachment 367550 [details]
Patch
Comment 6 Alex Christensen 2019-04-16 11:46:05 PDT
Comment on attachment 367550 [details]
Patch

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

> Source/WebKit/UIProcess/Cocoa/WKOrientationAccessAlert.mm:40
> +    auto completionBlock = makeBlockPtr([completionHandler = WTFMove(completionHandler)](bool shouldAllow) mutable {

Yep, we definitely need something like this.

> Source/WebKit/UIProcess/Cocoa/WKOrientationAccessAlert.mm:44
> +    UIAlertAction* cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:[completionBlock](UIAlertAction *action) {

Cancel and Allow also should be localized.
Comment 7 Chris Dumez 2019-04-16 11:53:58 PDT
Created attachment 367551 [details]
Patch
Comment 8 Chris Dumez 2019-04-16 13:27:40 PDT
Created attachment 367558 [details]
Patch
Comment 9 Chris Dumez 2019-04-16 15:31:43 PDT
Alex, ping review? Does it look good to you now?
Comment 10 Chris Dumez 2019-04-16 15:44:01 PDT
Committed r244360: <https://trac.webkit.org/changeset/244360>