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