Commit ec464d0a authored by David Jean's avatar David Jean Committed by Commit Bot

[ios] plug in manual fallback for credit card and address

Bug: 845472
Change-Id: Ie26e9022b60612b5ef90c7e9b2bde4202e6e745c
Reviewed-on: https://chromium-review.googlesource.com/c/1319594
Commit-Queue: David Jean <djean@chromium.org>
Reviewed-by: default avatarMoe Ahmadi <mahmadi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#606869}
parent 1c8c6f7e
......@@ -8,6 +8,8 @@
#import "components/autofill/ios/browser/js_suggestion_manager.h"
#import "ios/chrome/browser/autofill/form_input_accessory_view_controller.h"
#import "ios/chrome/browser/ui/autofill/form_input_accessory_mediator.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/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"
......@@ -19,6 +21,8 @@
@interface FormInputAccessoryCoordinator ()<
ManualFillAccessoryViewControllerDelegate,
AddressCoordinatorDelegate,
CardCoordinatorDelegate,
PasswordCoordinatorDelegate>
// The Mediator for the input accessory view controller.
......@@ -117,6 +121,41 @@
[self.formInputAccessoryMediator disableSuggestions];
}
- (void)startCardsFromButton:(UIButton*)button {
CardCoordinator* cardCoordinator = [[CardCoordinator alloc]
initWithBaseViewController:self.baseViewController
browserState:self.browserState
webStateList:self.webStateList
injectionHandler:self.manualFillInjectionHandler];
cardCoordinator.delegate = self;
if (IsIPadIdiom()) {
[cardCoordinator presentFromButton:button];
} else {
[self.formInputAccessoryViewController
presentView:cardCoordinator.viewController.view];
}
[self.childCoordinators addObject:cardCoordinator];
[self.formInputAccessoryMediator disableSuggestions];
}
- (void)startAddressFromButton:(UIButton*)button {
AddressCoordinator* addressCoordinator = [[AddressCoordinator alloc]
initWithBaseViewController:self.baseViewController
browserState:self.browserState
injectionHandler:self.manualFillInjectionHandler];
addressCoordinator.delegate = self;
if (IsIPadIdiom()) {
[addressCoordinator presentFromButton:button];
} else {
[self.formInputAccessoryViewController
presentView:addressCoordinator.viewController.view];
}
[self.childCoordinators addObject:addressCoordinator];
[self.formInputAccessoryMediator disableSuggestions];
}
#pragma mark - ManualFillAccessoryViewControllerDelegate
- (void)keyboardButtonPressed {
......@@ -124,14 +163,14 @@
[self.formInputAccessoryMediator enableSuggestions];
}
- (void)accountButtonPressed {
- (void)accountButtonPressed:(UIButton*)sender {
[self stopChildren];
// TODO(crbug.com/845472): implement.
[self startAddressFromButton:sender];
}
- (void)cardButtonPressed {
- (void)cardButtonPressed:(UIButton*)sender {
[self stopChildren];
// TODO(crbug.com/845472): implement.
[self startCardsFromButton:sender];
}
- (void)passwordButtonPressed:(UIButton*)sender {
......@@ -149,4 +188,16 @@
[self.manualFillAccessoryViewController reset];
}
#pragma mark - CardCoordinatorDelegate
- (void)openCardSettings {
// TODO(crbug.com/845472): implement.
}
#pragma mark - AddressCoordinatorDelegate
- (void)openAddressSettings {
// TODO(crbug.com/845472): implement.
}
@end
......@@ -45,7 +45,9 @@ initWithBaseViewController:(UIViewController*)viewController
completion:completion];
return YES;
} else {
completion();
if (completion) {
completion();
}
return NO;
}
}
......
......@@ -24,10 +24,10 @@ extern NSString* const AccessoryCreditCardAccessibilityIdentifier;
@protocol ManualFillAccessoryViewControllerDelegate
// Invoked after the user touches the `accounts` button.
- (void)accountButtonPressed;
- (void)accountButtonPressed:(UIButton*)sender;
// Invoked after the user touches the `credit cards` button.
- (void)cardButtonPressed;
- (void)cardButtonPressed:(UIButton*)sender;
// Invoked after the user touches the `keyboard` button.
- (void)keyboardButtonPressed;
......
......@@ -109,7 +109,7 @@ static NSTimeInterval MFAnimationDuration = 0.20;
self.cardsButton.tintColor = tintColor;
self.cardsButton.translatesAutoresizingMaskIntoConstraints = NO;
[self.cardsButton addTarget:self
action:@selector(cardButtonPressed)
action:@selector(cardButtonPressed:)
forControlEvents:UIControlEventTouchUpInside];
self.cardsButton.accessibilityIdentifier =
manual_fill::AccessoryCreditCardAccessibilityIdentifier;
......@@ -121,7 +121,7 @@ static NSTimeInterval MFAnimationDuration = 0.20;
self.accountButton.tintColor = tintColor;
self.accountButton.translatesAutoresizingMaskIntoConstraints = NO;
[self.accountButton addTarget:self
action:@selector(accountButtonPressed)
action:@selector(accountButtonPressed:)
forControlEvents:UIControlEventTouchUpInside];
self.accountButton.accessibilityIdentifier =
manual_fill::AccessoryAddressAccessibilityIdentifier;
......@@ -198,20 +198,19 @@ static NSTimeInterval MFAnimationDuration = 0.20;
[self.delegate passwordButtonPressed:sender];
}
- (void)cardButtonPressed {
- (void)cardButtonPressed:(UIButton*)sender {
base::RecordAction(base::UserMetricsAction("ManualFallback_OpenCreditCard"));
[self animateKeyboardButtonHidden:NO];
[self resetTintColors];
[self.cardsButton setTintColor:UIColor.cr_manualFillTintColor];
[self.delegate cardButtonPressed];
[self.delegate cardButtonPressed:sender];
}
- (void)accountButtonPressed {
base::RecordAction(base::UserMetricsAction("ManualFallback_OpenProfile"));
- (void)accountButtonPressed:(UIButton*)sender {
[self animateKeyboardButtonHidden:NO];
[self resetTintColors];
[self.accountButton setTintColor:UIColor.cr_manualFillTintColor];
[self.delegate accountButtonPressed];
[self.delegate accountButtonPressed:sender];
}
@end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment