Bug 198874 - Move SOAuthorization from WebKitAdditions to WebKit
Summary: Move SOAuthorization from WebKitAdditions to WebKit
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Jiewen Tan
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2019-06-14 17:30 PDT by Jiewen Tan
Modified: 2019-06-17 17:27 PDT (History)
12 users (show)

See Also:


Attachments
Patch (230.69 KB, patch)
2019-06-14 17:53 PDT, Jiewen Tan
no flags Details | Formatted Diff | Diff
Patch (230.59 KB, patch)
2019-06-14 19:05 PDT, Jiewen Tan
bfulgham: review+
Details | Formatted Diff | Diff
Patch for landing (231.24 KB, patch)
2019-06-17 12:57 PDT, Jiewen Tan
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jiewen Tan 2019-06-14 17:30:59 PDT
Move SOAuthorization from WebKitAdditions to WebKit.
Comment 1 Jiewen Tan 2019-06-14 17:31:26 PDT
<rdar://problem/47573431>
Comment 2 Jiewen Tan 2019-06-14 17:53:34 PDT
Created attachment 372158 [details]
Patch
Comment 3 Jiewen Tan 2019-06-14 18:02:10 PDT
Comment on attachment 372158 [details]
Patch

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

> Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp:110
> +

Deleted.
Comment 4 Jiewen Tan 2019-06-14 18:07:51 PDT
The internal counterpart is on <rdar://problem/51768865>.
Comment 5 Jiewen Tan 2019-06-14 19:05:09 PDT
Created attachment 372164 [details]
Patch
Comment 6 Brent Fulgham 2019-06-17 11:52:48 PDT
Comment on attachment 372164 [details]
Patch

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

r=me. Nice to get it into Open Source finally.

> Source/WebKit/ChangeLog:10
> +        Besides, it replaces all the load optimizer nonsenses with SOAuthorization.

I'd say: "It also replaces the LoadOptimizer nonsense with the actual SOAuthorization API.
Comment 7 Darin Adler 2019-06-17 11:58:48 PDT
Comment on attachment 372164 [details]
Patch

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

> Source/WebKit/UIProcess/Cocoa/SOAuthorization/NavigationSOAuthorizationSession.h:42
> +class NavigationSOAuthorizationSession : public WebViewDidMoveToWindowObserver, public SOAuthorizationSession {

Can either of the base classes be private or protected instead of pubic?

> Source/WebKit/UIProcess/Cocoa/SOAuthorization/NavigationSOAuthorizationSession.h:44
> +    using Callback = CompletionHandler<void(bool)>;

Can this be protected instead of public?

> Source/WebKit/UIProcess/Cocoa/SOAuthorization/NavigationSOAuthorizationSession.h:47
> +    using WebViewDidMoveToWindowObserver::weakPtrFactory;
> +    using WeakValueType = WebViewDidMoveToWindowObserver::WeakValueType;

Can either of these be protected or private?

> Source/WebKit/UIProcess/Cocoa/SOAuthorization/NavigationSOAuthorizationSession.h:52
> +    // WebViewDidMoveToWindowObserver
> +    void webViewDidMoveToWindow() final;

This could be private. Why public?

> Source/WebKit/UIProcess/Cocoa/SOAuthorization/NavigationSOAuthorizationSession.h:57
> +    void callback(bool intercepted) { m_callback(intercepted); }

The word "callback" is a noun, not a verb. So this function should ideally be named something like invokeCallback.

> Source/WebKit/UIProcess/Cocoa/SOAuthorization/PopUpSOAuthorizationSession.h:47
> +    static Ref<SOAuthorizationSession> create(SOAuthorization *soAuthorization, WebPageProxy& page, Ref<API::NavigationAction>&& navigationAction, NewPageCallback&& newPageCallback, UIClientCallback&& uiClientCallback)

I think it’s a slightly better pattern to have the function body be in the .cpp file. Nicer to inline the constructor in the not-inlined create function instead of inlining the create function at the call site and calling the constructor out of line. If this is called more than once, it’s better for code size to share a single create function. Also a tiny bit better to have a little less code in headers.

> Source/WebKit/UIProcess/Cocoa/SOAuthorization/PopUpSOAuthorizationSession.mm:40
> +@package

Why @package? This is private within a single file so it seems @private would be OK.

> Source/WebKit/UIProcess/Cocoa/SOAuthorization/PopUpSOAuthorizationSession.mm:42
> +WeakPtr<WebKit::PopUpSOAuthorizationSession> _session;
> +BOOL _isFirstNavigation;

normally we would indent these.

> Source/WebKit/UIProcess/Cocoa/SOAuthorization/PopUpSOAuthorizationSession.mm:53
> +    if (self = [super init]) {

Usually requires an extra set of parentheses in this line of code to avoid a warning. I’m surprised there is no warning!

> Source/WebKit/UIProcess/Cocoa/SOAuthorization/SOAuthorizationCoordinator.h:64
> +    inline bool canAuthorize(const URL&) const;

This use of "inline" is not valuable. I think you can omit it.
Comment 8 Jiewen Tan 2019-06-17 11:59:53 PDT
Comment on attachment 372164 [details]
Patch

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

Thanks Brent for r+ this patch.

>> Source/WebKit/ChangeLog:10
>> +        Besides, it replaces all the load optimizer nonsenses with SOAuthorization.
> 
> I'd say: "It also replaces the LoadOptimizer nonsense with the actual SOAuthorization API.

Fixed.
Comment 9 Jiewen Tan 2019-06-17 12:53:11 PDT
Comment on attachment 372164 [details]
Patch

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

Thanks Darin for reviewing the patch.

>> Source/WebKit/UIProcess/Cocoa/SOAuthorization/NavigationSOAuthorizationSession.h:42
>> +class NavigationSOAuthorizationSession : public WebViewDidMoveToWindowObserver, public SOAuthorizationSession {
> 
> Can either of the base classes be private or protected instead of pubic?

Moved WebViewDidMoveToWindowObserver to private and keep SOAuthorizationSession public in order to use RefCounted/WeakPtr.

>> Source/WebKit/UIProcess/Cocoa/SOAuthorization/NavigationSOAuthorizationSession.h:44
>> +    using Callback = CompletionHandler<void(bool)>;
> 
> Can this be protected instead of public?

Yes.

>> Source/WebKit/UIProcess/Cocoa/SOAuthorization/NavigationSOAuthorizationSession.h:47
>> +    using WeakValueType = WebViewDidMoveToWindowObserver::WeakValueType;
> 
> Can either of these be protected or private?

I don't think so as WebPageProxy::addObserver needs to make WeakPtrs for NavigationSOAuthorizationSession objects.

>> Source/WebKit/UIProcess/Cocoa/SOAuthorization/NavigationSOAuthorizationSession.h:52
>> +    void webViewDidMoveToWindow() final;
> 
> This could be private. Why public?

True.

>> Source/WebKit/UIProcess/Cocoa/SOAuthorization/NavigationSOAuthorizationSession.h:57
>> +    void callback(bool intercepted) { m_callback(intercepted); }
> 
> The word "callback" is a noun, not a verb. So this function should ideally be named something like invokeCallback.

Fixed.

>> Source/WebKit/UIProcess/Cocoa/SOAuthorization/PopUpSOAuthorizationSession.h:47
>> +    static Ref<SOAuthorizationSession> create(SOAuthorization *soAuthorization, WebPageProxy& page, Ref<API::NavigationAction>&& navigationAction, NewPageCallback&& newPageCallback, UIClientCallback&& uiClientCallback)
> 
> I think it’s a slightly better pattern to have the function body be in the .cpp file. Nicer to inline the constructor in the not-inlined create function instead of inlining the create function at the call site and calling the constructor out of line. If this is called more than once, it’s better for code size to share a single create function. Also a tiny bit better to have a little less code in headers.

Fixed.

>> Source/WebKit/UIProcess/Cocoa/SOAuthorization/PopUpSOAuthorizationSession.mm:40
>> +@package
> 
> Why @package? This is private within a single file so it seems @private would be OK.

Fixed.

>> Source/WebKit/UIProcess/Cocoa/SOAuthorization/PopUpSOAuthorizationSession.mm:42
>> +BOOL _isFirstNavigation;
> 
> normally we would indent these.

Fixed.

>> Source/WebKit/UIProcess/Cocoa/SOAuthorization/PopUpSOAuthorizationSession.mm:53
>> +    if (self = [super init]) {
> 
> Usually requires an extra set of parentheses in this line of code to avoid a warning. I’m surprised there is no warning!

Added in case anything happens later.

>> Source/WebKit/UIProcess/Cocoa/SOAuthorization/SOAuthorizationCoordinator.h:64
>> +    inline bool canAuthorize(const URL&) const;
> 
> This use of "inline" is not valuable. I think you can omit it.

Removed.
Comment 10 Jiewen Tan 2019-06-17 12:57:26 PDT
Created attachment 372265 [details]
Patch for landing
Comment 11 Sam Weinig 2019-06-17 13:13:55 PDT
Is "SO" a common enough acronym that we should use it here? I assume it stands for "sign-on", but I am not totally sure.
Comment 12 Jiewen Tan 2019-06-17 13:38:13 PDT
(In reply to Sam Weinig from comment #11)
> Is "SO" a common enough acronym that we should use it here? I assume it
> stands for "sign-on", but I am not totally sure.

Probably not. I followed the naming conversion on the SPI that I called, and therefore it is easier to connect them together instead of having our own names, for example, @interface WKSOAuthorizationDelegate : NSObject <SOAuthorizationDelegate>.
Comment 13 WebKit Commit Bot 2019-06-17 13:40:16 PDT
Comment on attachment 372265 [details]
Patch for landing

Clearing flags on attachment: 372265

Committed r246514: <https://trac.webkit.org/changeset/246514>
Comment 14 Alex Christensen 2019-06-17 15:27:40 PDT
http://trac.webkit.org/r246519
Comment 15 Jiewen Tan 2019-06-17 17:27:11 PDT
Another build fix:
Committed r246527: <https://trac.webkit.org/changeset/246527>