Commit 80fca10f authored by Javier Ernesto Flores Robles's avatar Javier Ernesto Flores Robles Committed by Commit Bot

[iOS][Password-Breach] Add dispatcher command

Bug: 1834141
Change-Id: I67f95f6ffd9f35b8197b0cb9c8021eaaa62aa1cb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1834147
Commit-Queue: Javier Ernesto Flores Robles <javierrobles@chromium.org>
Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Cr-Commit-Position: refs/heads/master@{#703250}
parent 67be65ef
...@@ -322,6 +322,7 @@ ...@@ -322,6 +322,7 @@
self.passwordBreachCoordinator = [[PasswordBreachCoordinator alloc] self.passwordBreachCoordinator = [[PasswordBreachCoordinator alloc]
initWithBaseViewController:self.viewController]; initWithBaseViewController:self.viewController];
self.passwordBreachCoordinator.dispatcher = self.dispatcher;
self.printController = [[PrintController alloc] self.printController = [[PrintController alloc]
initWithContextGetter:self.browserState->GetRequestContext()]; initWithContextGetter:self.browserState->GetRequestContext()];
......
...@@ -19,6 +19,7 @@ source_set("commands") { ...@@ -19,6 +19,7 @@ source_set("commands") {
"open_new_tab_command.h", "open_new_tab_command.h",
"open_new_tab_command.mm", "open_new_tab_command.mm",
"page_info_commands.h", "page_info_commands.h",
"password_breach_commands.h",
"popup_menu_commands.h", "popup_menu_commands.h",
"qr_scanner_commands.h", "qr_scanner_commands.h",
"reading_list_add_command.h", "reading_list_add_command.h",
...@@ -41,6 +42,7 @@ source_set("commands") { ...@@ -41,6 +42,7 @@ source_set("commands") {
public_deps = [ public_deps = [
"//base", "//base",
"//components/browsing_data/core", "//components/browsing_data/core",
"//components/password_manager/core/browser",
"//components/signin/public/base", "//components/signin/public/base",
"//ios/chrome/browser/browsing_data:browsing_data_remove_mask", "//ios/chrome/browser/browsing_data:browsing_data_remove_mask",
] ]
......
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_CHROME_BROWSER_UI_COMMANDS_PASSWORD_BREACH_COMMANDS_H_
#define IOS_CHROME_BROWSER_UI_COMMANDS_PASSWORD_BREACH_COMMANDS_H_
#import <UIKit/UIKit.h>
#include "components/password_manager/core/browser/leak_detection_dialog_utils.h"
class GURL;
using password_manager::CredentialLeakType;
// Commands related to Password Breach.
@protocol PasswordBreachCommands
// Shows Password Breach for |leakType| and |URL|.
- (void)showPasswordBreachForLeakType:(CredentialLeakType)leakType
URL:(const GURL&)URL;
@end
#endif // IOS_CHROME_BROWSER_UI_COMMANDS_PASSWORD_BREACH_COMMANDS_H_
...@@ -19,6 +19,7 @@ source_set("passwords") { ...@@ -19,6 +19,7 @@ source_set("passwords") {
"//base", "//base",
"//components/password_manager/core/browser", "//components/password_manager/core/browser",
"//ios/chrome/app/strings", "//ios/chrome/app/strings",
"//ios/chrome/browser/ui/commands",
"//ios/chrome/browser/ui/coordinators:chrome_coordinators", "//ios/chrome/browser/ui/coordinators:chrome_coordinators",
"//ios/chrome/common/colors", "//ios/chrome/common/colors",
"//ios/chrome/common/ui_util", "//ios/chrome/common/ui_util",
......
...@@ -7,10 +7,16 @@ ...@@ -7,10 +7,16 @@
#import "ios/chrome/browser/ui/coordinators/chrome_coordinator.h" #import "ios/chrome/browser/ui/coordinators/chrome_coordinator.h"
@class CommandDispatcher;
// Presents and stops the Password Breach feature, which consists in alerting // Presents and stops the Password Breach feature, which consists in alerting
// the user that Chrome detected a leaked credential. In some scenarios it // the user that Chrome detected a leaked credential. In some scenarios it
// prompts for a checkup of the stored passwords. // prompts for a checkup of the stored passwords.
@interface PasswordBreachCoordinator : ChromeCoordinator @interface PasswordBreachCoordinator : ChromeCoordinator
// The dispatcher used to register commands.
@property(nonatomic, weak) CommandDispatcher* dispatcher;
@end @end
#endif // IOS_CHROME_BROWSER_UI_PASSWORDS_PASSWORD_BREACH_COORDINATOR_H_ #endif // IOS_CHROME_BROWSER_UI_PASSWORDS_PASSWORD_BREACH_COORDINATOR_H_
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
#import "ios/chrome/browser/ui/passwords/password_breach_coordinator.h" #import "ios/chrome/browser/ui/passwords/password_breach_coordinator.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_mediator.h" #import "ios/chrome/browser/ui/passwords/password_breach_mediator.h"
#import "ios/chrome/browser/ui/passwords/password_breach_view_controller.h" #import "ios/chrome/browser/ui/passwords/password_breach_view_controller.h"
...@@ -11,7 +13,7 @@ ...@@ -11,7 +13,7 @@
#error "This file requires ARC support." #error "This file requires ARC support."
#endif #endif
@interface PasswordBreachCoordinator () @interface PasswordBreachCoordinator () <PasswordBreachCommands>
// The main view controller for this coordinator. // The main view controller for this coordinator.
@property(nonatomic, strong) PasswordBreachViewController* viewController; @property(nonatomic, strong) PasswordBreachViewController* viewController;
...@@ -25,7 +27,9 @@ ...@@ -25,7 +27,9 @@
- (void)start { - (void)start {
[super start]; [super start];
self.viewController = [[PasswordBreachViewController alloc] init]; // To start, a mediator and view controller should be ready.
DCHECK(self.viewController);
DCHECK(self.mediator);
[self.baseViewController presentViewController:self.viewController [self.baseViewController presentViewController:self.viewController
animated:YES animated:YES
completion:nil]; completion:nil];
...@@ -40,4 +44,29 @@ ...@@ -40,4 +44,29 @@
[super stop]; [super stop];
} }
#pragma mark - Setters
- (void)setDispatcher:(CommandDispatcher*)dispatcher {
if (_dispatcher == dispatcher) {
return;
}
[_dispatcher stopDispatchingToTarget:self];
[dispatcher startDispatchingToTarget:self
forProtocol:@protocol(PasswordBreachCommands)];
_dispatcher = dispatcher;
}
#pragma mark - PasswordBreachCommands
- (void)showPasswordBreachForLeakType:(CredentialLeakType)leakType
URL:(const GURL&)URL {
self.viewController = [[PasswordBreachViewController alloc] init];
self.mediator =
[[PasswordBreachMediator alloc] initWithConsumer:self.viewController
URL:URL
leakType:leakType];
self.viewController.actionHandler = self.mediator;
[self start];
}
@end @end
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