Commit 646aad5e authored by Javier Ernesto Flores Robles's avatar Javier Ernesto Flores Robles Committed by Commit Bot

[iOS][Password-Breach] Stop the cordinator on dismiss.

Create PasswordBreachPresenter protocol so the mediator can stop the
feature when done.

Bug: 1008862
Change-Id: I460d175c910909cdd6e55abee109f6705f508dc5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1845001Reviewed-by: default avatarStepan Khapugin <stkhapugin@chromium.org>
Commit-Queue: Javier Ernesto Flores Robles <javierrobles@chromium.org>
Cr-Commit-Position: refs/heads/master@{#703297}
parent c4f83cee
......@@ -13,7 +13,8 @@
#error "This file requires ARC support."
#endif
@interface PasswordBreachCoordinator () <PasswordBreachCommands>
@interface PasswordBreachCoordinator () <PasswordBreachCommands,
PasswordBreachPresenter>
// The main view controller for this coordinator.
@property(nonatomic, strong) PasswordBreachViewController* viewController;
......@@ -63,6 +64,7 @@
self.viewController = [[PasswordBreachViewController alloc] init];
self.mediator =
[[PasswordBreachMediator alloc] initWithConsumer:self.viewController
presenter:self
URL:URL
leakType:leakType];
self.viewController.actionHandler = self.mediator;
......
......@@ -14,10 +14,19 @@ class GURL;
@protocol PasswordBreachConsumer;
// Object presenting the feature.
@protocol PasswordBreachPresenter <NSObject>
// Informs the presenter that the feature should dismiss.
- (void)stop;
@end
// Manages the state and interactions of the consumer.
@interface PasswordBreachMediator : NSObject <PasswordBreachActionHandler>
- (instancetype)initWithConsumer:(id<PasswordBreachConsumer>)consumer
presenter:(id<PasswordBreachPresenter>)presenter
URL:(const GURL&)URL
leakType:(password_manager::CredentialLeakType)leakType;
......
......@@ -20,13 +20,22 @@ using password_manager::GetDescription;
using password_manager::GetTitle;
using password_manager::ShouldCheckPasswords;
@interface PasswordBreachMediator ()
// The presenter of the feature.
@property(nonatomic, weak) id<PasswordBreachPresenter> presenter;
@end
@implementation PasswordBreachMediator
- (instancetype)initWithConsumer:(id<PasswordBreachConsumer>)consumer
presenter:(id<PasswordBreachPresenter>)presenter
URL:(const GURL&)URL
leakType:(CredentialLeakType)leakType {
self = [super init];
if (self) {
_presenter = presenter;
NSString* subtitle = SysUTF16ToNSString(GetDescription(leakType, URL));
NSString* primaryActionString =
SysUTF16ToNSString(GetAcceptButtonLabel(leakType));
......@@ -41,7 +50,7 @@ using password_manager::ShouldCheckPasswords;
#pragma mark - PasswordBreachConsumerDelegate
- (void)passwordBreachDone {
// TODO(crbug.com/1008862): Hook up with the coordinator to stop it.
[self.presenter stop];
}
- (void)passwordBreachPrimaryAction {
......
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