Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(765)

Issue 2930763003: [iOS Clean] Added HTTP authentication dialog support.

Created:
3 years, 6 months ago by kkhorimoto
Modified:
3 years, 6 months ago
CC:
chromium-reviews, marq+scrutinize_chromium.org, ios-reviews+clean_chromium.org, ios-reviews_chromium.org
Target Ref:
refs/heads/master
Project:
chromium
Visibility:
Public.

Description

[iOS Clean] Added HTTP authentication dialog support. This CL adds a coordinator/mediator to present a DialogViewController for HTTP authentication dialogs. BUG=none

Patch Set 1 #

Patch Set 2 : Removed old consumer classes #

Patch Set 3 : rebased, subclassed DialogMediator #

Total comments: 24

Patch Set 4 : rebase && Mark's comments #

Unified diffs Side-by-side diffs Delta from patch set Stats (+472 lines, -0 lines) Patch
M ios/clean/chrome/browser/ui/commands/BUILD.gn View 1 2 3 1 chunk +1 line, -0 lines 0 comments Download
A ios/clean/chrome/browser/ui/commands/http_auth_dialog_commands.h View 1 2 3 1 chunk +17 lines, -0 lines 0 comments Download
M ios/clean/chrome/browser/ui/dialogs/BUILD.gn View 1 2 3 1 chunk +6 lines, -0 lines 0 comments Download
A ios/clean/chrome/browser/ui/dialogs/http_auth_dialogs/BUILD.gn View 1 2 3 1 chunk +32 lines, -0 lines 0 comments Download
A ios/clean/chrome/browser/ui/dialogs/http_auth_dialogs/http_auth_dialog_coordinator.h View 1 2 3 1 chunk +25 lines, -0 lines 0 comments Download
A ios/clean/chrome/browser/ui/dialogs/http_auth_dialogs/http_auth_dialog_coordinator.mm View 1 2 3 1 chunk +92 lines, -0 lines 0 comments Download
A ios/clean/chrome/browser/ui/dialogs/http_auth_dialogs/http_auth_dialog_mediator.h View 1 2 3 1 chunk +26 lines, -0 lines 0 comments Download
A ios/clean/chrome/browser/ui/dialogs/http_auth_dialogs/http_auth_dialog_mediator.mm View 1 2 3 1 chunk +119 lines, -0 lines 0 comments Download
A ios/clean/chrome/browser/ui/dialogs/http_auth_dialogs/http_auth_dialog_request.h View 1 2 3 1 chunk +52 lines, -0 lines 0 comments Download
A ios/clean/chrome/browser/ui/dialogs/http_auth_dialogs/http_auth_dialog_request.mm View 1 2 3 1 chunk +84 lines, -0 lines 0 comments Download
M ios/clean/chrome/browser/ui/web_contents/BUILD.gn View 1 2 3 1 chunk +1 line, -0 lines 0 comments Download
M ios/clean/chrome/browser/ui/web_contents/web_coordinator.mm View 1 2 3 2 chunks +17 lines, -0 lines 0 comments Download

Depends on Patchset:

Messages

Total messages: 7 (1 generated)
kkhorimoto
3 years, 6 months ago (2017-06-07 21:09:22 UTC) #2
kkhorimoto
Removed old consumer classes
3 years, 6 months ago (2017-06-07 21:11:57 UTC) #3
kkhorimoto
rebased, subclassed DialogMediator
3 years, 6 months ago (2017-06-08 00:40:47 UTC) #4
marq (ping after 24h)
Having seen this, I think I'd like to codify how we request user input using ...
3 years, 6 months ago (2017-06-14 11:19:17 UTC) #5
kkhorimoto
rebase && Mark's comments
3 years, 6 months ago (2017-06-23 06:25:28 UTC) #6
kkhorimoto
3 years, 6 months ago (2017-06-23 06:25:42 UTC) #7
https://codereview.chromium.org/2930763003/diff/40001/ios/clean/chrome/browse...
File
ios/clean/chrome/browser/ui/dialogs/http_auth_dialogs/http_auth_dialog_coordinator.h
(right):

https://codereview.chromium.org/2930763003/diff/40001/ios/clean/chrome/browse...
ios/clean/chrome/browser/ui/dialogs/http_auth_dialogs/http_auth_dialog_coordinator.h:14:
// A coordinator for the UI elements used to present JavaScript dialogs.
On 2017/06/14 11:19:15, marq (ping after 24h) wrote:
> JavaScript dialogs, or HTTP auth dialogs?
> 

HTTP auth!

https://codereview.chromium.org/2930763003/diff/40001/ios/clean/chrome/browse...
File
ios/clean/chrome/browser/ui/dialogs/http_auth_dialogs/http_auth_dialog_coordinator.mm
(right):

https://codereview.chromium.org/2930763003/diff/40001/ios/clean/chrome/browse...
ios/clean/chrome/browser/ui/dialogs/http_auth_dialogs/http_auth_dialog_coordinator.mm:86:
[self.state runCallbackWithUserName:username password:password];
On 2017/06/14 11:19:15, marq (ping after 24h) wrote:
> I'd rather have the mediator handle stuff like running callbacks the web layer
> exposes.

Done.  We'll still need to run the callback here for |-cancelOverlay|, but that
greatly HTTPAuthDialogDismissalCommands, since we don't need to send the
parameters anymore.  It'll help even more for JavaScript dialogs.

https://codereview.chromium.org/2930763003/diff/40001/ios/clean/chrome/browse...
File
ios/clean/chrome/browser/ui/dialogs/http_auth_dialogs/http_auth_dialog_mediator.mm
(right):

https://codereview.chromium.org/2930763003/diff/40001/ios/clean/chrome/browse...
ios/clean/chrome/browser/ui/dialogs/http_auth_dialogs/http_auth_dialog_mediator.mm:79:
NSMutableArray<DialogButtonItem*>* items = [[NSMutableArray alloc] init];
On 2017/06/14 11:19:15, marq (ping after 24h) wrote:
> I'd prefer just a static array return here:
>    
> return @[
>   [DialogButtonItem ..
>   [DialogButtonItem ...
> ];

Done.

https://codereview.chromium.org/2930763003/diff/40001/ios/clean/chrome/browse...
ios/clean/chrome/browser/ui/dialogs/http_auth_dialogs/http_auth_dialog_mediator.mm:91:
NSMutableArray<DialogTextFieldItem*>* items = [[NSMutableArray alloc] init];
On 2017/06/14 11:19:15, marq (ping after 24h) wrote:
> Static array return here too.

Done.

https://codereview.chromium.org/2930763003/diff/40001/ios/clean/chrome/browse...
ios/clean/chrome/browser/ui/dialogs/http_auth_dialogs/http_auth_dialog_mediator.mm:112:
NSString* username = inputStrings[USER_NAME_IDX];
On 2017/06/14 11:19:15, marq (ping after 24h) wrote:
> Hmm.
> 
> Should the text field items be mutable objects that the mediator owns? They
get
> passed into the dialog view controller, and then it can populate a
'userString'
> property when the user provides a value. Then the mediator can just use the
> item's property. 
> 
> That gets rid of any synchronization of the ordering of strings sent via the
> dismiss commands; the expectation is that whoever owns the items associated
with
> the dialog identified with |id| will check them for populated strings.

As we discussed in the weekly meeting, I just implemented the text fields using
a dictionary with identifiers, similarly to how we do button identifiers.

https://codereview.chromium.org/2930763003/diff/40001/ios/clean/chrome/browse...
File
ios/clean/chrome/browser/ui/dialogs/http_auth_dialogs/http_auth_dialog_state.h
(right):

https://codereview.chromium.org/2930763003/diff/40001/ios/clean/chrome/browse...
ios/clean/chrome/browser/ui/dialogs/http_auth_dialogs/http_auth_dialog_state.h:17:
// A container object encapsulating all the state necessary to support an
On 2017/06/14 11:19:15, marq (ping after 24h) wrote:
> Name quibbles -- I'm not wild about "State", because it implies the state may
> change at some point. Maybe HTTPAuthDialogRequest?

Done.

https://codereview.chromium.org/2930763003/diff/40001/ios/clean/chrome/browse...
ios/clean/chrome/browser/ui/dialogs/http_auth_dialogs/http_auth_dialog_state.h:21:
// the lifetime of every JavaScriptDialogState.
On 2017/06/14 11:19:16, marq (ping after 24h) wrote:
> HTTPAuthDialogState, here an elsewhere. Careful with that (copy/paste errors)
in
> general.
> 
> Should this class and JSDialogState share a parent class?

Fixed.  I don't think they should share a superclass since the thing shared
between them is that they both have a WebState.  They both have similar
purposes, but are different enough that forcing them to have a superclass would
add complexity in the object hierarchy without actually improving it IMO.

https://codereview.chromium.org/2930763003/diff/40001/ios/clean/chrome/browse...
ios/clean/chrome/browser/ui/dialogs/http_auth_dialogs/http_auth_dialog_state.h:34:
@property(nonatomic, readonly) NSString* title;
On 2017/06/14 11:19:15, marq (ping after 24h) wrote:
> You're marking other readonly string properties as strong elsewhere; be
> consistent here.

Done.

https://codereview.chromium.org/2930763003/diff/40001/ios/clean/chrome/browse...
ios/clean/chrome/browser/ui/dialogs/http_auth_dialogs/http_auth_dialog_state.h:42:
// Calls the callback passed on initialization with the provided parameters.
On 2017/06/14 11:19:15, marq (ping after 24h) wrote:
> I regard the callback as an implementation detail. Can it be
> 'completeAuthenticationWith...'.
> 
> The semantics of nil username and password should be documented here.

Done.

https://codereview.chromium.org/2930763003/diff/40001/ios/clean/chrome/browse...
File
ios/clean/chrome/browser/ui/dialogs/http_auth_dialogs/http_auth_dialog_state.mm
(right):

https://codereview.chromium.org/2930763003/diff/40001/ios/clean/chrome/browse...
ios/clean/chrome/browser/ui/dialogs/http_auth_dialogs/http_auth_dialog_state.mm:45:
DCHECK(webState);
On 2017/06/14 11:19:16, marq (ping after 24h) wrote:
> Document these assertions in the header.

Done.  Should we start adding nullablity annotations to objc selector arguments?

https://codereview.chromium.org/2930763003/diff/40001/ios/clean/chrome/browse...
ios/clean/chrome/browser/ui/dialogs/http_auth_dialogs/http_auth_dialog_state.mm:61:
DCHECK(_callbackHasBeenExecuted);
On 2017/06/14 11:19:16, marq (ping after 24h) wrote:
> Would it be correct to run the callback (nil, nil) if it hasn't run at this
> point?

We shouldn't be using both DCHECKs and defensive programming, only one or the
other.  I prefer to keep it as a DCHECK because silently executing the callback
might hide bugs where these coordinators might be deallocated before their
completion blocks are explicitly executed.  Having the DCHECK here is helpful
because it's easier to understand its semantic purpose than if the exception was
thrown by a deallocated WebKit completion block.

https://codereview.chromium.org/2930763003/diff/40001/ios/clean/chrome/browse...
ios/clean/chrome/browser/ui/dialogs/http_auth_dialogs/http_auth_dialog_state.mm:66:
+ (instancetype)stateWithWebState:(web::WebState*)webState
On 2017/06/14 11:19:17, marq (ping after 24h) wrote:
> Ordering nit: all initializers before dealloc.

The initializer is before |-dealloc|.  This is the factory method, which is part
of the public interface that uses our private designated initializer declared at
the top of this class.

Powered by Google App Engine
This is Rietveld 408576698