Commit 889f24f6 authored by Javier Ernesto Flores Robles's avatar Javier Ernesto Flores Robles Committed by Commit Bot

[iOS][Password-Breach] Show more feature info

Enable the help action to open a new view controller containing more
info related to the feature.

More info in
https://docs.google.com/presentation/d/16XlBDqPZ5dQ0hRyaOn7r6G3apqrpi2Ng0VUUnoX3o4M

Screenshots: attached in bug

Bug: 1028095
Change-Id: I651c7e44254d37dff9d525ffdc47fe723311b5de
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1937371Reviewed-by: default avatarPeter Lee <pkl@chromium.org>
Commit-Queue: Javier Ernesto Flores Robles <javierrobles@chromium.org>
Cr-Commit-Position: refs/heads/master@{#719469}
parent f0f00cdb
......@@ -9,8 +9,11 @@ source_set("passwords") {
"password_breach_consumer.h",
"password_breach_coordinator.h",
"password_breach_coordinator.mm",
"password_breach_learn_more_view_controller.h",
"password_breach_learn_more_view_controller.mm",
"password_breach_mediator.h",
"password_breach_mediator.mm",
"password_breach_presenter.h",
"password_breach_view_controller.h",
"password_breach_view_controller.mm",
]
......@@ -18,6 +21,7 @@ source_set("passwords") {
"resources",
"//base",
"//components/password_manager/core/browser",
"//components/strings:components_strings_grit",
"//ios/chrome/app/strings",
"//ios/chrome/browser/ui/commands",
"//ios/chrome/browser/ui/coordinators:chrome_coordinators",
......
......@@ -15,6 +15,9 @@
// The "Primary Action" should be excecuted.
- (void)passwordBreachPrimaryAction;
// The "Learn More" info should be presented.
- (void)passwordBreachLearnMoreAction;
@end
#endif // IOS_CHROME_BROWSER_UI_PASSWORDS_PASSWORD_BREACH_ACTION_HANDLER_H_
......@@ -6,7 +6,9 @@
#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"
#import "ios/chrome/browser/ui/passwords/password_breach_mediator.h"
#import "ios/chrome/browser/ui/passwords/password_breach_presenter.h"
#import "ios/chrome/browser/ui/passwords/password_breach_view_controller.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
......@@ -16,10 +18,14 @@
@interface PasswordBreachCoordinator () <PasswordBreachCommands,
PasswordBreachPresenter>
// The main view controller for this coordinator.
// Main view controller for this coordinator.
@property(nonatomic, strong) PasswordBreachViewController* viewController;
// The main mediator for this coordinator.
// Learn more view controller, when presented.
@property(nonatomic, strong)
PasswordBreachLearnMoreViewController* learnMoreViewController;
// Main mediator for this coordinator.
@property(nonatomic, strong) PasswordBreachMediator* mediator;
@end
......@@ -79,4 +85,27 @@
[self start];
}
#pragma mark - PasswordBreachPresenter
- (void)presentLearnMore {
self.learnMoreViewController =
[[PasswordBreachLearnMoreViewController alloc] initWithPresenter:self];
UINavigationController* navigationViewController =
[[UINavigationController alloc]
initWithRootViewController:self.learnMoreViewController];
self.learnMoreViewController.title = self.viewController.titleString;
self.learnMoreViewController.modalPresentationStyle =
UIModalPresentationFormSheet;
[self.viewController presentViewController:navigationViewController
animated:YES
completion:nil];
}
- (void)dismissLearnMore {
[self.learnMoreViewController.presentingViewController
dismissViewControllerAnimated:YES
completion:nil];
self.learnMoreViewController = nil;
}
@end
// 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_PASSWORDS_PASSWORD_BREACH_LEARN_MORE_VIEW_CONTROLLER_H_
#define IOS_CHROME_BROWSER_UI_PASSWORDS_PASSWORD_BREACH_LEARN_MORE_VIEW_CONTROLLER_H_
#import <UIKit/UIKit.h>
@protocol PasswordBreachPresenter;
// Static view controller with the password breach learn more information.
@interface PasswordBreachLearnMoreViewController : UIViewController
// |Presenter| is used to dismiss this view controller when done.
- (instancetype)initWithPresenter:(id<PasswordBreachPresenter>)presenter
NS_DESIGNATED_INITIALIZER;
- (instancetype)init NS_UNAVAILABLE;
- (instancetype)initWithCoder:(NSCoder*)coder NS_UNAVAILABLE;
- (instancetype)initWithNibName:(NSString*)nibNameOrNil
bundle:(NSBundle*)nibBundleOrNil NS_UNAVAILABLE;
@end
#endif // IOS_CHROME_BROWSER_UI_PASSWORDS_PASSWORD_BREACH_LEARN_MORE_VIEW_CONTROLLER_H_
// 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.
#import "ios/chrome/browser/ui/passwords/password_breach_learn_more_view_controller.h"
#include "components/strings/grit/components_strings.h"
#import "ios/chrome/browser/ui/passwords/password_breach_presenter.h"
#import "ios/chrome/common/colors/semantic_color_names.h"
#import "ios/chrome/common/ui_util/constraints_ui_util.h"
#include "ui/base/l10n/l10n_util.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@interface PasswordBreachLearnMoreViewController ()
// Presenter used to dismiss this when finished.
@property(weak, readonly) id<PasswordBreachPresenter> presenter;
@end
@implementation PasswordBreachLearnMoreViewController
- (instancetype)initWithPresenter:(id<PasswordBreachPresenter>)presenter {
self = [super initWithNibName:nil bundle:nil];
if (self) {
_presenter = presenter;
}
return self;
}
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor colorNamed:kBackgroundColor];
UITextView* textView = [[UITextView alloc] init];
textView.editable = NO;
textView.textAlignment = NSTextAlignmentNatural;
textView.adjustsFontForContentSizeCategory = YES;
textView.text =
l10n_util::GetNSString(IDS_PASSWORD_MANAGER_LEAK_HELP_MESSAGE);
textView.translatesAutoresizingMaskIntoConstraints = NO;
textView.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
[self.view addSubview:textView];
AddSameConstraints(textView, self.view.layoutMarginsGuide);
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemDone
target:self
action:@selector(didTapDoneButton)];
}
#pragma mark - Helpers
// Done button was tapped, inform the presenter.
- (void)didTapDoneButton {
[self.presenter dismissLearnMore];
}
@end
......@@ -14,14 +14,7 @@ class GURL;
@protocol ApplicationCommands;
@protocol PasswordBreachConsumer;
// Object presenting the feature.
@protocol PasswordBreachPresenter <NSObject>
// Informs the presenter that the feature should dismiss.
- (void)stop;
@end
@protocol PasswordBreachPresenter;
// Manages the state and interactions of the consumer.
@interface PasswordBreachMediator : NSObject <PasswordBreachActionHandler>
......
......@@ -10,6 +10,7 @@
#import "ios/chrome/browser/ui/commands/application_commands.h"
#import "ios/chrome/browser/ui/commands/open_new_tab_command.h"
#import "ios/chrome/browser/ui/passwords/password_breach_consumer.h"
#import "ios/chrome/browser/ui/passwords/password_breach_presenter.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
......@@ -89,4 +90,8 @@ using password_manager::metrics_util::LogLeakDialogTypeAndDismissalReason;
[self.dispatcher openURLInNewTab:newTabCommand];
}
- (void)passwordBreachLearnMoreAction {
[self.presenter presentLearnMore];
}
@end
// 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_PASSWORDS_PASSWORD_BREACH_PRESENTER_H_
#define IOS_CHROME_BROWSER_UI_PASSWORDS_PASSWORD_BREACH_PRESENTER_H_
#import <Foundation/Foundation.h>
// Object presenting the feature.
@protocol PasswordBreachPresenter <NSObject>
// Presents more information related to the feature.
- (void)presentLearnMore;
// Dismisses more information related to the feature.
- (void)dismissLearnMore;
// Informs the presenter that the feature should dismiss.
- (void)stop;
@end
#endif // IOS_CHROME_BROWSER_UI_PASSWORDS_PASSWORD_BREACH_PRESENTER_H_
......@@ -14,6 +14,9 @@
@interface PasswordBreachViewController
: UIViewController <PasswordBreachConsumer>
// The headline below the image.
@property(nonatomic, readonly) NSString* titleString;
// The action handler for interactions in this View Controller.
@property(nonatomic, weak) id<PasswordBreachActionHandler> actionHandler;
......
......@@ -246,7 +246,7 @@ constexpr CGFloat kSafeAreaMultiplier = 0.8;
// Handle taps on the help button.
- (void)didTapHelpButton {
// TODO(crbug.com/1028095): Open help center article.
[self.actionHandler passwordBreachLearnMoreAction];
}
// Handle taps on the primary action button.
......
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