Commit 960c8468 authored by Nazerke's avatar Nazerke Committed by Commit Bot

[iOS][coordinator] Modernize Password Breach Coordinator.

This CL modernizes the PasswordBreachCoordinator
 - to use the superclass -initWithBaseViewController:browser:
initializer,
 - to remove the public property for dispatcher,
 - to update the naming and usage of ‘dispatcher’ parameters to
match the usage guidelines.

Bug: 1029346
Change-Id: I26064ad9d0cf024185a28c33483db5631c4c7cd7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2000626
Commit-Queue: Nazerke Kalidolda <nazerke@google.com>
Reviewed-by: default avatarStepan Khapugin <stkhapugin@chromium.org>
Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Cr-Commit-Position: refs/heads/master@{#731997}
parent f68fc116
......@@ -325,8 +325,8 @@
browser:self.browser];
self.passwordBreachCoordinator = [[PasswordBreachCoordinator alloc]
initWithBaseViewController:self.viewController];
self.passwordBreachCoordinator.dispatcher = self.dispatcher;
initWithBaseViewController:self.viewController
browser:self.browser];
self.printController = [[PrintController alloc] init];
......
......@@ -23,6 +23,7 @@ source_set("passwords") {
"//components/password_manager/core/browser",
"//components/strings:components_strings_grit",
"//ios/chrome/app/strings",
"//ios/chrome/browser/main:public",
"//ios/chrome/browser/ui/commands",
"//ios/chrome/browser/ui/coordinators:chrome_coordinators",
"//ios/chrome/browser/ui/util",
......
......@@ -7,15 +7,19 @@
#import "ios/chrome/browser/ui/coordinators/chrome_coordinator.h"
@class CommandDispatcher;
// Presents and stops the Password Breach feature, which consists in alerting
// the user that Chrome detected a leaked credential. In some scenarios it
// prompts for a checkup of the stored passwords.
@interface PasswordBreachCoordinator : ChromeCoordinator
// The dispatcher used to register commands.
@property(nonatomic, weak) CommandDispatcher* dispatcher;
// Unavailable, use -initWithBaseViewController:browser:.
- (instancetype)initWithBaseViewController:(UIViewController*)viewController
NS_UNAVAILABLE;
// Unavailable, use -initWithBaseViewController:browser:.
- (instancetype)initWithBaseViewController:(UIViewController*)viewController
browserState:
(ios::ChromeBrowserState*)browserState
NS_UNAVAILABLE;
@end
......
......@@ -4,6 +4,7 @@
#import "ios/chrome/browser/ui/passwords/password_breach_coordinator.h"
#import "ios/chrome/browser/main/browser.h"
#import "ios/chrome/browser/ui/commands/command_dispatcher.h"
#import "ios/chrome/browser/ui/commands/password_breach_commands.h"
#import "ios/chrome/browser/ui/passwords/password_breach_learn_more_view_controller.h"
......@@ -37,9 +38,13 @@
// To start, a mediator and view controller should be ready.
DCHECK(self.viewController);
DCHECK(self.mediator);
DCHECK(self.browser);
[self.baseViewController presentViewController:self.viewController
animated:YES
completion:nil];
CommandDispatcher* dispatcher = self.browser->GetCommandDispatcher();
[dispatcher startDispatchingToTarget:self
forProtocol:@protocol(PasswordBreachCommands)];
}
- (void)stop {
......@@ -50,18 +55,8 @@
completion:nil];
self.viewController = nil;
[super stop];
}
#pragma mark - Setters
- (void)setDispatcher:(CommandDispatcher*)dispatcher {
if (_dispatcher == dispatcher) {
return;
}
[_dispatcher stopDispatchingToTarget:self];
[dispatcher startDispatchingToTarget:self
forProtocol:@protocol(PasswordBreachCommands)];
_dispatcher = dispatcher;
CommandDispatcher* dispatcher = self.browser->GetCommandDispatcher();
[dispatcher stopDispatchingToTarget:self];
}
#pragma mark - PasswordBreachCommands
......@@ -73,8 +68,8 @@
if (@available(iOS 13, *)) {
self.viewController.modalInPresentation = YES;
}
id<ApplicationCommands> dispatcher =
static_cast<id<ApplicationCommands>>(self.dispatcher);
id<ApplicationCommands> dispatcher = static_cast<id<ApplicationCommands>>(
self.browser->GetCommandDispatcher());
self.mediator =
[[PasswordBreachMediator alloc] initWithConsumer:self.viewController
presenter:self
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment