Commit 1f3bf422 authored by Javier Ernesto Flores Robles's avatar Javier Ernesto Flores Robles Committed by Commit Bot

[iOS][MF] Present All Passwords

All passwords is now presented from the browser coordinator.
Browser Coordinator is now the AutofillSecurityAlertPresenter.
PasswordListNavigator has been split into 2 protocols.
FormInputAccessoryCoordinatorDelegate is renamed to
FormInputAccessoryCoordinatorNavigator
ivars named manualFillInjectionHandler renamed to injectionHandler.

Regression test: crrev.com/c/1783446

Bug: 997632
Change-Id: I85166491cdd6b898ee4451a6fcb9e0b343c75e5a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1784614
Commit-Queue: Javier Ernesto Flores Robles <javierrobles@chromium.org>
Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Cr-Commit-Position: refs/heads/master@{#694220}
parent 546a380f
......@@ -9,10 +9,11 @@
#import "ios/web/public/web_state/web_state_observer_bridge.h"
@class ManualFillInjectionHandler;
class WebStateList;
// Delegate for the coordinator actions.
@protocol FormInputAccessoryCoordinatorDelegate <NSObject>
@protocol FormInputAccessoryCoordinatorNavigator <NSObject>
// Opens the passwords settings.
- (void)openPasswordSettings;
......@@ -23,6 +24,9 @@ class WebStateList;
// Opens the credit cards settings.
- (void)openCreditCardSettings;
// Opens the all passwords picker, used for manual fallback.
- (void)openAllPasswordsPicker;
@end
// Creates and manages a custom input accessory view while the user is
......@@ -31,14 +35,16 @@ class WebStateList;
@interface FormInputAccessoryCoordinator : ChromeCoordinator
// The delegate for the coordinator. Must be set before it starts.
@property(nonatomic, weak) id<FormInputAccessoryCoordinatorDelegate> delegate;
@property(nonatomic, weak) id<FormInputAccessoryCoordinatorNavigator> navigator;
// Creates a coordinator that uses a |viewController| a |browserState| and
// a |webStateList|.
- (instancetype)initWithBaseViewController:(UIViewController*)viewController
browserState:
(ios::ChromeBrowserState*)browserState
webStateList:(WebStateList*)webStateList;
- (instancetype)
initWithBaseViewController:(UIViewController*)viewController
browserState:(ios::ChromeBrowserState*)browserState
webStateList:(WebStateList*)webStateList
injectionHandler:(ManualFillInjectionHandler*)injectionHandler
NS_DESIGNATED_INITIALIZER;
// Unavailable, use -initWithBaseViewController:browserState:webStateList:.
- (instancetype)initWithBaseViewController:(UIViewController*)viewController
......@@ -46,6 +52,9 @@ class WebStateList;
(ios::ChromeBrowserState*)browserState
NS_UNAVAILABLE;
- (instancetype)initWithBaseViewController:(UIViewController*)viewController
browser:(Browser*)browser NS_UNAVAILABLE;
@end
#endif // IOS_CHROME_BROWSER_UI_AUTOFILL_FORM_INPUT_ACCESSORY_FORM_INPUT_ACCESSORY_COORDINATOR_H_
......@@ -19,12 +19,12 @@
#import "ios/chrome/browser/ui/autofill/form_input_accessory/form_input_accessory_view_controller.h"
#import "ios/chrome/browser/ui/autofill/manual_fill/address_coordinator.h"
#import "ios/chrome/browser/ui/autofill/manual_fill/card_coordinator.h"
#import "ios/chrome/browser/ui/autofill/manual_fill/fallback_view_controller.h"
#import "ios/chrome/browser/ui/autofill/manual_fill/manual_fill_accessory_view_controller.h"
#import "ios/chrome/browser/ui/autofill/manual_fill/manual_fill_injection_handler.h"
#import "ios/chrome/browser/ui/autofill/manual_fill/password_coordinator.h"
#include "ios/chrome/browser/ui/util/ui_util.h"
#import "ios/chrome/browser/web_state_list/web_state_list.h"
#include "ios/chrome/grit/ios_strings.h"
#import "ios/web/public/web_state.h"
#include "ui/base/l10n/l10n_util_mac.h"
......@@ -33,7 +33,6 @@
#endif
@interface FormInputAccessoryCoordinator () <
AutofillSecurityAlertPresenter,
AddressCoordinatorDelegate,
CardCoordinatorDelegate,
FormInputAccessoryMediatorDelegate,
......@@ -50,8 +49,7 @@
// The object in charge of interacting with the web view. Used to fill the data
// in the forms.
@property(nonatomic, strong)
ManualFillInjectionHandler* manualFillInjectionHandler;
@property(nonatomic, strong) ManualFillInjectionHandler* injectionHandler;
// The WebStateList for this instance. Used to instantiate the child
// coordinators lazily.
......@@ -61,10 +59,11 @@
@implementation FormInputAccessoryCoordinator
- (instancetype)initWithBaseViewController:(UIViewController*)viewController
browserState:
(ios::ChromeBrowserState*)browserState
webStateList:(WebStateList*)webStateList {
- (instancetype)
initWithBaseViewController:(UIViewController*)viewController
browserState:(ios::ChromeBrowserState*)browserState
webStateList:(WebStateList*)webStateList
injectionHandler:(ManualFillInjectionHandler*)injectionHandler {
DCHECK(browserState);
DCHECK(webStateList);
self = [super initWithBaseViewController:viewController
......@@ -72,9 +71,7 @@
if (self) {
_webStateList = webStateList;
_manualFillInjectionHandler =
[[ManualFillInjectionHandler alloc] initWithWebStateList:webStateList
securityAlertPresenter:self];
_injectionHandler = injectionHandler;
_formInputAccessoryViewController =
[[FormInputAccessoryViewController alloc]
......@@ -123,7 +120,7 @@
initWithBaseViewController:self.baseViewController
browserState:self.browserState
URL:URL
injectionHandler:self.manualFillInjectionHandler];
injectionHandler:self.injectionHandler];
passwordCoordinator.delegate = self;
if (IsIPadIdiom()) {
[passwordCoordinator presentFromButton:button];
......@@ -141,7 +138,7 @@
browserState:self.browserState
->GetOriginalChromeBrowserState()
webStateList:self.webStateList
injectionHandler:self.manualFillInjectionHandler];
injectionHandler:self.injectionHandler];
cardCoordinator.delegate = self;
if (IsIPadIdiom()) {
[cardCoordinator presentFromButton:button];
......@@ -158,7 +155,7 @@
initWithBaseViewController:self.baseViewController
browserState:self.browserState
->GetOriginalChromeBrowserState()
injectionHandler:self.manualFillInjectionHandler];
injectionHandler:self.injectionHandler];
addressCoordinator.delegate = self;
if (IsIPadIdiom()) {
[addressCoordinator presentFromButton:button];
......@@ -222,42 +219,23 @@
#pragma mark - PasswordCoordinatorDelegate
- (void)openPasswordSettings {
[self.delegate openPasswordSettings];
[self.navigator openPasswordSettings];
}
- (void)openAllPasswordsPicker {
[self.navigator openAllPasswordsPicker];
}
#pragma mark - CardCoordinatorDelegate
- (void)openCardSettings {
[self.delegate openCreditCardSettings];
[self.navigator openCreditCardSettings];
}
#pragma mark - AddressCoordinatorDelegate
- (void)openAddressSettings {
[self.delegate openAddressSettings];
}
#pragma mark - AutofillSecurityAlertPresenter
- (void)presentSecurityWarningAlertWithText:(NSString*)body {
NSString* alertTitle =
l10n_util::GetNSString(IDS_IOS_MANUAL_FALLBACK_NOT_SECURE_TITLE);
NSString* defaultActionTitle =
l10n_util::GetNSString(IDS_IOS_MANUAL_FALLBACK_NOT_SECURE_OK_BUTTON);
UIAlertController* alert =
[UIAlertController alertControllerWithTitle:alertTitle
message:body
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* defaultAction =
[UIAlertAction actionWithTitle:defaultActionTitle
style:UIAlertActionStyleDefault
handler:^(UIAlertAction* action){
}];
[alert addAction:defaultAction];
[self.baseViewController presentViewController:alert
animated:YES
completion:nil];
[self.navigator openAddressSettings];
}
@end
......@@ -28,10 +28,10 @@ source_set("manual_fill") {
"form_observer_helper.mm",
"manual_fill_injection_handler.h",
"manual_fill_injection_handler.mm",
"manual_fill_password_mediator.h",
"manual_fill_password_mediator.mm",
"password_coordinator.h",
"password_coordinator.mm",
"password_mediator.h",
"password_mediator.mm",
]
deps = [
":requesters",
......
......@@ -74,7 +74,7 @@ initWithBaseViewController:(UIViewController*)viewController
_addressMediator =
[[ManualFillAddressMediator alloc] initWithProfiles:profiles];
_addressMediator.navigationDelegate = self;
_addressMediator.contentInjector = self.manualFillInjectionHandler;
_addressMediator.contentInjector = self.injectionHandler;
_addressMediator.consumer = _addressViewController;
}
return self;
......
......@@ -9,34 +9,11 @@
@protocol PasswordListNavigator;
namespace manual_fill {
extern NSString* const kPasswordDoneButtonAccessibilityIdentifier;
} // namespace manual_fill
// Creates and manages a view controller to present all the passwords to the
// user. The view controller contains a search bar. The presentation is done
// with a table view presentation controller. Any selected password will be sent
// to the current field in the active web state.
@interface ManualFillAllPasswordCoordinator : FallbackCoordinator
// Creates a coordinator with the passed args.
- (instancetype)
initWithBaseViewController:(UIViewController*)viewController
browserState:(ios::ChromeBrowserState*)browserState
injectionHandler:(ManualFillInjectionHandler*)injectionHandler
navigator:(id<PasswordListNavigator>)navigator
NS_DESIGNATED_INITIALIZER;
// Unavailable, use
// -initWithBaseViewController:browserState:webStateList:injectionHandler:.
- (instancetype)
initWithBaseViewController:(UIViewController*)viewController
browserState:(ios::ChromeBrowserState*)browserState
injectionHandler:(ManualFillInjectionHandler*)injectionHandler
NS_UNAVAILABLE;
@end
#endif // IOS_CHROME_BROWSER_UI_AUTOFILL_MANUAL_FILL_ALL_PASSWORD_COORDINATOR_H_
......@@ -10,27 +10,20 @@
#include "ios/chrome/browser/favicon/ios_chrome_favicon_loader_factory.h"
#include "ios/chrome/browser/passwords/ios_chrome_password_store_factory.h"
#import "ios/chrome/browser/ui/autofill/manual_fill/manual_fill_injection_handler.h"
#import "ios/chrome/browser/ui/autofill/manual_fill/manual_fill_password_mediator.h"
#import "ios/chrome/browser/ui/autofill/manual_fill/password_list_navigator.h"
#import "ios/chrome/browser/ui/autofill/manual_fill/password_mediator.h"
#import "ios/chrome/browser/ui/autofill/manual_fill/password_view_controller.h"
#import "ios/chrome/browser/ui/table_view/table_view_animator.h"
#import "ios/chrome/browser/ui/table_view/table_view_navigation_controller.h"
#import "ios/chrome/browser/ui/table_view/table_view_presentation_controller.h"
#include "ios/chrome/browser/ui/util/ui_util.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
namespace manual_fill {
NSString* const kPasswordDoneButtonAccessibilityIdentifier =
@"kManualFillPasswordDoneButtonAccessibilityIdentifier";
} // namespace manual_fill
@interface ManualFillAllPasswordCoordinator () <
UIViewControllerTransitioningDelegate>
ManualFillPasswordMediatorDelegate,
PasswordViewControllerDelegate>
// Fetches and filters the passwords for the view controller.
@property(nonatomic, strong) ManualFillPasswordMediator* passwordMediator;
......@@ -43,64 +36,38 @@ NSString* const kPasswordDoneButtonAccessibilityIdentifier =
@implementation ManualFillAllPasswordCoordinator
// Property tagged dynamic because it overrides super class delegate with and
// extension of the super delegate type (i.e. PasswordCoordinatorDelegate
// extends FallbackCoordinatorDelegate).
@dynamic delegate;
- (instancetype)
initWithBaseViewController:(UIViewController*)viewController
browserState:(ios::ChromeBrowserState*)browserState
injectionHandler:(ManualFillInjectionHandler*)injectionHandler
navigator:(id<PasswordListNavigator>)navigator {
self = [super initWithBaseViewController:viewController
browserState:browserState
injectionHandler:injectionHandler];
if (self) {
- (void)start {
[super start];
UISearchController* searchController =
[[UISearchController alloc] initWithSearchResultsController:nil];
_passwordViewController = [[PasswordViewController alloc]
self.passwordViewController = [[PasswordViewController alloc]
initWithSearchController:searchController];
_passwordViewController.contentInsetsAlwaysEqualToSafeArea = YES;
self.passwordViewController.contentInsetsAlwaysEqualToSafeArea = YES;
self.passwordViewController.delegate = self;
auto passwordStore = IOSChromePasswordStoreFactory::GetForBrowserState(
browserState, ServiceAccessType::EXPLICIT_ACCESS);
self.browserState, ServiceAccessType::EXPLICIT_ACCESS);
FaviconLoader* faviconLoader =
IOSChromeFaviconLoaderFactory::GetForBrowserState(self.browserState);
_passwordMediator = [[ManualFillPasswordMediator alloc]
initWithPasswordStore:passwordStore
self.passwordMediator =
[[ManualFillPasswordMediator alloc] initWithPasswordStore:passwordStore
faviconLoader:faviconLoader];
[self.passwordMediator fetchPasswordsForURL:GURL::EmptyGURL()];
self.passwordMediator.actionSectionEnabled = NO;
self.passwordMediator.consumer = self.passwordViewController;
self.passwordMediator.contentInjector = self.injectionHandler;
self.passwordMediator.delegate = self;
[_passwordMediator fetchPasswordsForURL:GURL::EmptyGURL()];
_passwordMediator.actionSectionEnabled = NO;
_passwordMediator.consumer = _passwordViewController;
_passwordMediator.contentInjector = injectionHandler;
_passwordMediator.navigator = navigator;
_passwordViewController.imageDataSource = _passwordMediator;
searchController.searchResultsUpdater = _passwordMediator;
UIBarButtonItem* doneButton = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemDone
target:navigator
action:@selector(dismissPresentedViewController)];
doneButton.accessibilityIdentifier =
manual_fill::kPasswordDoneButtonAccessibilityIdentifier;
_passwordViewController.navigationItem.rightBarButtonItem = doneButton;
}
return self;
}
self.passwordViewController.imageDataSource = self.passwordMediator;
searchController.searchResultsUpdater = self.passwordMediator;
- (void)start {
[super start];
TableViewNavigationController* navigationController =
[[TableViewNavigationController alloc]
initWithTable:self.passwordViewController];
navigationController.transitioningDelegate = self;
[navigationController setModalPresentationStyle:UIModalPresentationCustom];
navigationController.modalPresentationStyle = UIModalPresentationFormSheet;
navigationController.modalTransitionStyle =
UIModalTransitionStyleCoverVertical;
[self.baseViewController presentViewController:navigationController
animated:YES
......@@ -108,59 +75,31 @@ NSString* const kPasswordDoneButtonAccessibilityIdentifier =
}
- (void)stop {
[self.passwordViewController dismissViewControllerAnimated:NO completion:nil];
[self.passwordViewController dismissViewControllerAnimated:YES
completion:nil];
self.passwordViewController = nil;
self.passwordMediator = nil;
[super stop];
}
#pragma mark - UIViewControllerTransitioningDelegate
- (UIPresentationController*)
presentationControllerForPresentedViewController:
(UIViewController*)presented
presentingViewController:
(UIViewController*)presenting
sourceViewController:(UIViewController*)source {
TableViewPresentationController* presentationController =
[[TableViewPresentationController alloc]
initWithPresentedViewController:presented
presentingViewController:presenting];
return presentationController;
}
#pragma mark - FallbackCoordinator
- (id<UIViewControllerAnimatedTransitioning>)
animationControllerForPresentedController:(UIViewController*)presented
presentingController:(UIViewController*)presenting
sourceController:(UIViewController*)source {
UITraitCollection* traitCollection = presenting.traitCollection;
if (traitCollection.horizontalSizeClass == UIUserInterfaceSizeClassCompact &&
traitCollection.verticalSizeClass != UIUserInterfaceSizeClassCompact) {
// Use the default animator for fullscreen presentations.
return nil;
}
TableViewAnimator* animator = [[TableViewAnimator alloc] init];
animator.presenting = YES;
return animator;
- (UIViewController*)viewController {
return self.passwordViewController;
}
- (id<UIViewControllerAnimatedTransitioning>)
animationControllerForDismissedController:(UIViewController*)dismissed {
UITraitCollection* traitCollection = dismissed.traitCollection;
if (traitCollection.horizontalSizeClass == UIUserInterfaceSizeClassCompact &&
traitCollection.verticalSizeClass != UIUserInterfaceSizeClassCompact) {
// Use the default animator for fullscreen presentations.
return nil;
}
TableViewAnimator* animator = [[TableViewAnimator alloc] init];
animator.presenting = NO;
return animator;
#pragma mark - ManualFillPasswordMediatorDelegate
- (void)manualFillPasswordMediatorWillInjectContent:
(ManualFillPasswordMediator*)mediator {
[self stop]; // The job is done.
}
#pragma mark - FallbackCoordinator
#pragma mark - PasswordViewControllerDelegate
- (UIViewController*)viewController {
return self.passwordViewController;
- (void)passwordViewControllerDidTapDoneButton:
(PasswordViewController*)passwordViewController {
[self stop]; // The job is done.
}
@end
......@@ -77,7 +77,7 @@ initWithBaseViewController:(UIViewController*)viewController
_cardMediator = [[ManualFillCardMediator alloc] initWithCards:cards];
_cardMediator.navigationDelegate = self;
_cardMediator.contentInjector = self.manualFillInjectionHandler;
_cardMediator.contentInjector = self.injectionHandler;
_cardMediator.consumer = _cardViewController;
_cardRequester = [[ManualFillFullCardRequester alloc]
......
......@@ -33,8 +33,7 @@
// The object in charge of interacting with the web view. Used to fill the data
// in the forms.
@property(nonatomic, strong)
ManualFillInjectionHandler* manualFillInjectionHandler;
@property(nonatomic, strong) ManualFillInjectionHandler* injectionHandler;
// Creates a coordinator that uses a |viewController|, |browserState| and an
// |injectionHandler|.
......
......@@ -11,6 +11,7 @@
#include "components/autofill/ios/browser/autofill_driver_ios.h"
#include "components/keyed_service/core/service_access_type.h"
#include "ios/chrome/browser/autofill/personal_data_manager_factory.h"
#import "ios/chrome/browser/ui/autofill/manual_fill/fallback_view_controller.h"
#import "ios/chrome/browser/ui/autofill/manual_fill/manual_fill_injection_handler.h"
#import "ios/chrome/browser/ui/table_view/chrome_table_view_controller.h"
#import "ios/chrome/browser/ui/table_view/table_view_navigation_controller.h"
......@@ -34,7 +35,7 @@ initWithBaseViewController:(UIViewController*)viewController
self = [super initWithBaseViewController:viewController
browserState:browserState];
if (self) {
_manualFillInjectionHandler = injectionHandler;
_injectionHandler = injectionHandler;
}
return self;
}
......
......@@ -90,7 +90,7 @@ constexpr CGFloat kMinimumLoadingTime = 0.5;
self.tableView.allowsSelection = NO;
self.definesPresentationContext = YES;
if (!self.tableViewModel) {
if (IsIPadIdiom()) {
if (self.popoverPresentationController) {
self.preferredContentSize = CGSizeMake(
PopoverPreferredWidth, AlignValueToPixel(PopoverLoadingHeight));
}
......@@ -234,7 +234,7 @@ constexpr CGFloat kMinimumLoadingTime = 0.5;
}
}
[self.tableView reloadData];
if (IsIPadIdiom()) {
if (self.popoverPresentationController) {
// Update the preffered content size on iPad so the popover shows the right
// size.
[self.tableView layoutIfNeeded];
......
......@@ -2,8 +2,8 @@
// 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_AUTOFILL_MANUAL_FILL_PASSWORD_MEDIATOR_H_
#define IOS_CHROME_BROWSER_UI_AUTOFILL_MANUAL_FILL_PASSWORD_MEDIATOR_H_
#ifndef IOS_CHROME_BROWSER_UI_AUTOFILL_MANUAL_FILL_MANUAL_FILL_PASSWORD_MEDIATOR_H_
#define IOS_CHROME_BROWSER_UI_AUTOFILL_MANUAL_FILL_MANUAL_FILL_PASSWORD_MEDIATOR_H_
#import <UIKit/UIKit.h>
......@@ -11,6 +11,7 @@
#import "ios/chrome/browser/ui/table_view/table_view_favicon_data_source.h"
@protocol ManualFillContentInjector;
@class ManualFillPasswordMediator;
@protocol ManualFillPasswordConsumer;
@protocol PasswordListNavigator;
......@@ -20,7 +21,6 @@ class PasswordStore;
class FaviconLoader;
class GURL;
class WebStateList;
namespace manual_fill {
......@@ -30,6 +30,13 @@ extern NSString* const SuggestPasswordAccessibilityIdentifier;
} // namespace manual_fill
// Delegate for the password mediator.
@protocol ManualFillPasswordMediatorDelegate <NSObject>
// The mediator will attempt to inject content.
- (void)manualFillPasswordMediatorWillInjectContent:
(ManualFillPasswordMediator*)mediator;
@end
// Object in charge of getting the passwords relevant for the manual fill
// passwords UI.
@interface ManualFillPasswordMediator
......@@ -42,6 +49,8 @@ extern NSString* const SuggestPasswordAccessibilityIdentifier;
@property(nonatomic, weak) id<ManualFillContentInjector> contentInjector;
// The object in charge of navigation.
@property(nonatomic, weak) id<PasswordListNavigator> navigator;
// The delegate for this object.
@property(nonatomic, weak) id<ManualFillPasswordMediatorDelegate> delegate;
// If YES actions will be post to the consumer. Set this value before
// setting the consumer, since just setting this won't trigger the consumer
// callbacks. Defaults to NO.
......@@ -55,7 +64,7 @@ extern NSString* const SuggestPasswordAccessibilityIdentifier;
faviconLoader:(FaviconLoader*)faviconLoader
NS_DESIGNATED_INITIALIZER;
// Unavailable. Use |initWithWebStateList:passwordStore:|.
// Unavailable. Use |initWithPasswordStore:faviconLoader:|.
- (instancetype)init NS_UNAVAILABLE;
// Fetches passwords using |origin| as the filter. If origin is empty (invalid)
......@@ -64,4 +73,4 @@ extern NSString* const SuggestPasswordAccessibilityIdentifier;
@end
#endif // IOS_CHROME_BROWSER_UI_AUTOFILL_MANUAL_FILL_PASSWORD_MEDIATOR_H_
#endif // IOS_CHROME_BROWSER_UI_AUTOFILL_MANUAL_FILL_MANUAL_FILL_PASSWORD_MEDIATOR_H_
......@@ -2,7 +2,7 @@
// 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/autofill/manual_fill/password_mediator.h"
#import "ios/chrome/browser/ui/autofill/manual_fill/manual_fill_password_mediator.h"
#include <vector>
......@@ -65,10 +65,6 @@ BOOL AreCredentialsAtIndexesConnected(
scoped_refptr<password_manager::PasswordStore> _passwordStore;
}
// The |WebStateList| containing the active web state. Used to filter the list
// of credentials based on the active web state.
@property(nonatomic, assign) WebStateList* webStateList;
// The password fetcher to query the user profile.
@property(nonatomic, strong) PasswordFetcher* passwordFetcher;
......@@ -248,7 +244,7 @@ BOOL AreCredentialsAtIndexesConnected(
- (void)userDidPickContent:(NSString*)content
passwordField:(BOOL)passwordField
requiresHTTPS:(BOOL)requiresHTTPS {
[self.navigator dismissPresentedViewController];
[self.delegate manualFillPasswordMediatorWillInjectContent:self];
[self.contentInjector userDidPickContent:content
passwordField:passwordField
requiresHTTPS:requiresHTTPS];
......
......@@ -15,6 +15,9 @@ class GURL;
// Opens the passwords settings.
- (void)openPasswordSettings;
// Opens the all passwords picker, used for manual fallback.
- (void)openAllPasswordsPicker;
@end
// Creates and manages a view controller to present passwords to the user. It
......
......@@ -10,10 +10,9 @@
#import "ios/chrome/browser/favicon/favicon_loader.h"
#include "ios/chrome/browser/favicon/ios_chrome_favicon_loader_factory.h"
#include "ios/chrome/browser/passwords/ios_chrome_password_store_factory.h"
#import "ios/chrome/browser/ui/autofill/manual_fill/all_password_coordinator.h"
#import "ios/chrome/browser/ui/autofill/manual_fill/manual_fill_injection_handler.h"
#import "ios/chrome/browser/ui/autofill/manual_fill/manual_fill_password_mediator.h"
#import "ios/chrome/browser/ui/autofill/manual_fill/password_list_navigator.h"
#import "ios/chrome/browser/ui/autofill/manual_fill/password_mediator.h"
#import "ios/chrome/browser/ui/autofill/manual_fill/password_view_controller.h"
#include "ios/chrome/browser/ui/util/ui_util.h"
......@@ -105,34 +104,7 @@
}];
return;
}
ManualFillAllPasswordCoordinator* allPasswordCoordinator =
[[ManualFillAllPasswordCoordinator alloc]
initWithBaseViewController:self.baseViewController
browserState:self.browserState
injectionHandler:self.manualFillInjectionHandler
navigator:self];
[allPasswordCoordinator start];
[self.childCoordinators addObject:allPasswordCoordinator];
}
- (void)dismissPresentedViewController {
if (self.viewController.presentingViewController) {
return;
}
// Dismiss the full screen view controller and present the pop over.
__weak __typeof(self) weakSelf = self;
FallbackCoordinator* activeCoordinator =
base::mac::ObjCCast<FallbackCoordinator>(self.activeChildCoordinator);
[activeCoordinator.viewController.presentingViewController
dismissViewControllerAnimated:YES
completion:^{
[weakSelf.childCoordinators removeAllObjects];
if (weakSelf.presentingButton) {
[weakSelf presentFromButton:self.presentingButton];
}
}];
[self.delegate openAllPasswordsPicker];
}
- (void)openPasswordSettings {
......
......@@ -8,10 +8,6 @@
// Object to navigate different views in manual fallback's passwords list.
@protocol PasswordListNavigator
// Dismisses the presented view controller and continues as pop over on iPads
// or above the keyboard elsewhere.
- (void)dismissPresentedViewController;
// Requests to open the list of all passwords.
- (void)openAllPasswordsList;
......
......@@ -12,15 +12,30 @@
namespace manual_fill {
extern NSString* const PasswordSearchBarAccessibilityIdentifier;
extern NSString* const PasswordTableViewAccessibilityIdentifier;
extern NSString* const kPasswordDoneButtonAccessibilityIdentifier;
extern NSString* const kPasswordSearchBarAccessibilityIdentifier;
extern NSString* const kPasswordTableViewAccessibilityIdentifier;
} // namespace manual_fill
@class PasswordViewController;
// Delegate of the PasswordViewController.
@protocol PasswordViewControllerDelegate <NSObject>
// User Tapped "Done" button.
- (void)passwordViewControllerDidTapDoneButton:
(PasswordViewController*)passwordViewController;
@end
// This class presents a list of usernames and passwords in a table view.
@interface PasswordViewController
: FallbackViewController<ManualFillPasswordConsumer>
// Delegate for the view controller.
@property(nonatomic, weak) id<PasswordViewControllerDelegate> delegate;
- (instancetype)initWithSearchController:(UISearchController*)searchController
NS_DESIGNATED_INITIALIZER;
......
......@@ -33,9 +33,11 @@ typedef NS_ENUM(NSInteger, ManualFallbackItemType) {
namespace manual_fill {
NSString* const PasswordSearchBarAccessibilityIdentifier =
NSString* const kPasswordDoneButtonAccessibilityIdentifier =
@"kManualFillPasswordDoneButtonAccessibilityIdentifier";
NSString* const kPasswordSearchBarAccessibilityIdentifier =
@"kManualFillPasswordSearchBarAccessibilityIdentifier";
NSString* const PasswordTableViewAccessibilityIdentifier =
NSString* const kPasswordTableViewAccessibilityIdentifier =
@"kManualFillPasswordTableViewAccessibilityIdentifier";
} // namespace manual_fill
......@@ -61,7 +63,7 @@ NSString* const PasswordTableViewAccessibilityIdentifier =
[super viewDidLoad];
self.tableView.accessibilityIdentifier =
manual_fill::PasswordTableViewAccessibilityIdentifier;
manual_fill::kPasswordTableViewAccessibilityIdentifier;
self.definesPresentationContext = YES;
self.searchController.searchBar.backgroundColor = [UIColor clearColor];
......@@ -69,7 +71,7 @@ NSString* const PasswordTableViewAccessibilityIdentifier =
self.navigationItem.searchController = self.searchController;
self.navigationItem.hidesSearchBarWhenScrolling = NO;
self.searchController.searchBar.accessibilityIdentifier =
manual_fill::PasswordSearchBarAccessibilityIdentifier;
manual_fill::kPasswordSearchBarAccessibilityIdentifier;
NSString* titleString =
l10n_util::GetNSString(IDS_IOS_MANUAL_FALLBACK_USE_OTHER_PASSWORD);
self.title = titleString;
......@@ -81,6 +83,14 @@ NSString* const PasswordTableViewAccessibilityIdentifier =
UIOffsetMake(0.0f, kTableViewNavigationVerticalOffsetForSearchHeader);
self.searchController.searchBar.searchFieldBackgroundPositionAdjustment =
offset;
UIBarButtonItem* doneButton = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemDone
target:self
action:@selector(handleDoneButton)];
doneButton.accessibilityIdentifier =
manual_fill::kPasswordDoneButtonAccessibilityIdentifier;
self.navigationItem.rightBarButtonItem = doneButton;
}
- (void)viewWillAppear:(BOOL)animated {
......@@ -190,4 +200,8 @@ NSString* const PasswordTableViewAccessibilityIdentifier =
}];
}
- (void)handleDoneButton {
[self.delegate passwordViewControllerDidTapDoneButton:self];
}
@end
......@@ -18,7 +18,7 @@
#include "ios/chrome/browser/passwords/ios_chrome_password_store_factory.h"
#import "ios/chrome/browser/ui/autofill/manual_fill/all_password_coordinator.h"
#import "ios/chrome/browser/ui/autofill/manual_fill/manual_fill_accessory_view_controller.h"
#import "ios/chrome/browser/ui/autofill/manual_fill/password_mediator.h"
#import "ios/chrome/browser/ui/autofill/manual_fill/manual_fill_password_mediator.h"
#import "ios/chrome/browser/ui/autofill/manual_fill/password_view_controller.h"
#import "ios/chrome/browser/ui/settings/password/passwords_table_view_controller.h"
#import "ios/chrome/browser/ui/util/ui_util.h"
......@@ -61,13 +61,13 @@ id<GREYMatcher> KeyboardIconMatcher() {
// Returns a matcher for the password table view in manual fallback.
id<GREYMatcher> PasswordTableViewMatcher() {
return grey_accessibilityID(
manual_fill::PasswordTableViewAccessibilityIdentifier);
manual_fill::kPasswordTableViewAccessibilityIdentifier);
}
// Returns a matcher for the password search bar in manual fallback.
id<GREYMatcher> PasswordSearchBarMatcher() {
return grey_accessibilityID(
manual_fill::PasswordSearchBarAccessibilityIdentifier);
manual_fill::kPasswordSearchBarAccessibilityIdentifier);
}
// Returns a matcher for the button to open password settings in manual
......@@ -366,12 +366,8 @@ BOOL WaitForJavaScriptCondition(NSString* java_script_condition) {
// Tests that the Password View Controller is resumed after dismissing "Other
// Passwords".
- (void)testPasswordControllerResumesWhenOtherPasswordsDismiss {
if (base::ios::IsRunningOnIOS13OrLater() && [ChromeEarlGrey isIPadIdiom]) {
// TODO(crbug.com/984977): Support this behavior in iPads again.
return;
}
// TODO(crbug.com/984977): Support this behavior again.
- (void)DISABLED_testPasswordControllerResumesWhenOtherPasswordsDismiss {
// Bring up the keyboard.
[[EarlGrey selectElementWithMatcher:chrome_test_util::WebViewMatcher()]
performAction:chrome_test_util::TapWebElement(kFormElementUsername)];
......
......@@ -20,6 +20,8 @@
#import "ios/chrome/browser/ui/alert_coordinator/repost_form_coordinator.h"
#import "ios/chrome/browser/ui/app_launcher/app_launcher_coordinator.h"
#import "ios/chrome/browser/ui/autofill/form_input_accessory/form_input_accessory_coordinator.h"
#import "ios/chrome/browser/ui/autofill/manual_fill/all_password_coordinator.h"
#import "ios/chrome/browser/ui/autofill/manual_fill/manual_fill_injection_handler.h"
#import "ios/chrome/browser/ui/browser_container/browser_container_coordinator.h"
#import "ios/chrome/browser/ui/browser_view/browser_view_controller+private.h"
#import "ios/chrome/browser/ui/browser_view/browser_view_controller.h"
......@@ -45,13 +47,16 @@
#import "ios/chrome/browser/web/repost_form_tab_helper_delegate.h"
#include "ios/chrome/browser/web_state_list/web_state_list.h"
#import "ios/chrome/browser/web_state_list/web_state_list_observer_bridge.h"
#include "ios/chrome/grit/ios_strings.h"
#include "net/url_request/url_request_context_getter.h"
#include "ui/base/l10n/l10n_util_mac.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@interface BrowserCoordinator () <FormInputAccessoryCoordinatorDelegate,
@interface BrowserCoordinator () <AutofillSecurityAlertPresenter,
FormInputAccessoryCoordinatorNavigator,
RepostFormTabHelperDelegate,
URLLoadingServiceDelegate,
WebStateListObserving>
......@@ -84,6 +89,14 @@
@property(nonatomic, strong)
FormInputAccessoryCoordinator* formInputAccessoryCoordinator;
// The object in charge of interacting with the web view. Used to fill the data
// in the forms.
@property(nonatomic, strong) ManualFillInjectionHandler* injectionHandler;
// Coordinator in charge of the presenting password autofill options as a modal.
@property(nonatomic, strong)
ManualFillAllPasswordCoordinator* allPasswordCoordinator;
// Coordinator for Page Info UI.
@property(nonatomic, strong) PageInfoLegacyCoordinator* pageInfoCoordinator;
......@@ -247,11 +260,15 @@
webStateList:self.tabModel.webStateList];
[self.ARQuickLookCoordinator start];
self.injectionHandler = [[ManualFillInjectionHandler alloc]
initWithWebStateList:self.tabModel.webStateList
securityAlertPresenter:self];
self.formInputAccessoryCoordinator = [[FormInputAccessoryCoordinator alloc]
initWithBaseViewController:self.viewController
browserState:self.browserState
webStateList:self.tabModel.webStateList];
self.formInputAccessoryCoordinator.delegate = self;
webStateList:self.tabModel.webStateList
injectionHandler:self.injectionHandler];
self.formInputAccessoryCoordinator.navigator = self;
[self.formInputAccessoryCoordinator start];
self.translateInfobarCoordinator = [[TranslateInfobarCoordinator alloc]
......@@ -297,6 +314,9 @@
// Stops child coordinators.
- (void)stopChildCoordinators {
[self.allPasswordCoordinator stop];
self.allPasswordCoordinator = nil;
// TODO(crbug.com/906541) : AppLauncherCoordinator is not a subclass of
// ChromeCoordinator, and does not have a |-stop| method.
self.appLauncherCoordinator = nil;
......@@ -337,6 +357,31 @@
self.translateInfobarCoordinator = nil;
}
#pragma mark - AutofillSecurityAlertPresenter
- (void)presentSecurityWarningAlertWithText:(NSString*)body {
NSString* alertTitle =
l10n_util::GetNSString(IDS_IOS_MANUAL_FALLBACK_NOT_SECURE_TITLE);
NSString* defaultActionTitle =
l10n_util::GetNSString(IDS_IOS_MANUAL_FALLBACK_NOT_SECURE_OK_BUTTON);
UIAlertController* alert =
[UIAlertController alertControllerWithTitle:alertTitle
message:body
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* defaultAction =
[UIAlertAction actionWithTitle:defaultActionTitle
style:UIAlertActionStyleDefault
handler:^(UIAlertAction* action){
}];
[alert addAction:defaultAction];
UIViewController* presenter = self.viewController;
while (presenter.presentedViewController) {
presenter = presenter.presentedViewController;
}
[presenter presentViewController:alert animated:YES completion:nil];
}
#pragma mark - BrowserCoordinatorCommands
- (void)printTab {
......@@ -377,7 +422,7 @@
[self.recentTabsCoordinator start];
}
#pragma mark - FormInputAccessoryCoordinatorDelegate
#pragma mark - FormInputAccessoryCoordinatorNavigator
- (void)openPasswordSettings {
[self.applicationCommandHandler
......@@ -394,6 +439,14 @@
showCreditCardSettingsFromViewController:self.viewController];
}
- (void)openAllPasswordsPicker {
self.allPasswordCoordinator = [[ManualFillAllPasswordCoordinator alloc]
initWithBaseViewController:self.viewController
browserState:self.browserState
injectionHandler:self.injectionHandler];
[self.allPasswordCoordinator start];
}
#pragma mark - RepostFormTabHelperDelegate
- (void)repostFormTabHelper:(RepostFormTabHelper*)helper
......
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