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 @@ ...@@ -8,6 +8,8 @@
#import "components/autofill/ios/browser/js_suggestion_manager.h" #import "components/autofill/ios/browser/js_suggestion_manager.h"
#import "ios/chrome/browser/autofill/form_input_accessory_view_controller.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/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_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"
...@@ -19,6 +21,8 @@ ...@@ -19,6 +21,8 @@
@interface FormInputAccessoryCoordinator ()< @interface FormInputAccessoryCoordinator ()<
ManualFillAccessoryViewControllerDelegate, ManualFillAccessoryViewControllerDelegate,
AddressCoordinatorDelegate,
CardCoordinatorDelegate,
PasswordCoordinatorDelegate> PasswordCoordinatorDelegate>
// The Mediator for the input accessory view controller. // The Mediator for the input accessory view controller.
...@@ -117,6 +121,41 @@ ...@@ -117,6 +121,41 @@
[self.formInputAccessoryMediator disableSuggestions]; [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 #pragma mark - ManualFillAccessoryViewControllerDelegate
- (void)keyboardButtonPressed { - (void)keyboardButtonPressed {
...@@ -124,14 +163,14 @@ ...@@ -124,14 +163,14 @@
[self.formInputAccessoryMediator enableSuggestions]; [self.formInputAccessoryMediator enableSuggestions];
} }
- (void)accountButtonPressed { - (void)accountButtonPressed:(UIButton*)sender {
[self stopChildren]; [self stopChildren];
// TODO(crbug.com/845472): implement. [self startAddressFromButton:sender];
} }
- (void)cardButtonPressed { - (void)cardButtonPressed:(UIButton*)sender {
[self stopChildren]; [self stopChildren];
// TODO(crbug.com/845472): implement. [self startCardsFromButton:sender];
} }
- (void)passwordButtonPressed:(UIButton*)sender { - (void)passwordButtonPressed:(UIButton*)sender {
...@@ -149,4 +188,16 @@ ...@@ -149,4 +188,16 @@
[self.manualFillAccessoryViewController reset]; [self.manualFillAccessoryViewController reset];
} }
#pragma mark - CardCoordinatorDelegate
- (void)openCardSettings {
// TODO(crbug.com/845472): implement.
}
#pragma mark - AddressCoordinatorDelegate
- (void)openAddressSettings {
// TODO(crbug.com/845472): implement.
}
@end @end
...@@ -45,7 +45,9 @@ initWithBaseViewController:(UIViewController*)viewController ...@@ -45,7 +45,9 @@ initWithBaseViewController:(UIViewController*)viewController
completion:completion]; completion:completion];
return YES; return YES;
} else { } else {
if (completion) {
completion(); completion();
}
return NO; return NO;
} }
} }
......
...@@ -24,10 +24,10 @@ extern NSString* const AccessoryCreditCardAccessibilityIdentifier; ...@@ -24,10 +24,10 @@ extern NSString* const AccessoryCreditCardAccessibilityIdentifier;
@protocol ManualFillAccessoryViewControllerDelegate @protocol ManualFillAccessoryViewControllerDelegate
// Invoked after the user touches the `accounts` button. // Invoked after the user touches the `accounts` button.
- (void)accountButtonPressed; - (void)accountButtonPressed:(UIButton*)sender;
// Invoked after the user touches the `credit cards` button. // Invoked after the user touches the `credit cards` button.
- (void)cardButtonPressed; - (void)cardButtonPressed:(UIButton*)sender;
// Invoked after the user touches the `keyboard` button. // Invoked after the user touches the `keyboard` button.
- (void)keyboardButtonPressed; - (void)keyboardButtonPressed;
......
...@@ -109,7 +109,7 @@ static NSTimeInterval MFAnimationDuration = 0.20; ...@@ -109,7 +109,7 @@ static NSTimeInterval MFAnimationDuration = 0.20;
self.cardsButton.tintColor = tintColor; self.cardsButton.tintColor = tintColor;
self.cardsButton.translatesAutoresizingMaskIntoConstraints = NO; self.cardsButton.translatesAutoresizingMaskIntoConstraints = NO;
[self.cardsButton addTarget:self [self.cardsButton addTarget:self
action:@selector(cardButtonPressed) action:@selector(cardButtonPressed:)
forControlEvents:UIControlEventTouchUpInside]; forControlEvents:UIControlEventTouchUpInside];
self.cardsButton.accessibilityIdentifier = self.cardsButton.accessibilityIdentifier =
manual_fill::AccessoryCreditCardAccessibilityIdentifier; manual_fill::AccessoryCreditCardAccessibilityIdentifier;
...@@ -121,7 +121,7 @@ static NSTimeInterval MFAnimationDuration = 0.20; ...@@ -121,7 +121,7 @@ static NSTimeInterval MFAnimationDuration = 0.20;
self.accountButton.tintColor = tintColor; self.accountButton.tintColor = tintColor;
self.accountButton.translatesAutoresizingMaskIntoConstraints = NO; self.accountButton.translatesAutoresizingMaskIntoConstraints = NO;
[self.accountButton addTarget:self [self.accountButton addTarget:self
action:@selector(accountButtonPressed) action:@selector(accountButtonPressed:)
forControlEvents:UIControlEventTouchUpInside]; forControlEvents:UIControlEventTouchUpInside];
self.accountButton.accessibilityIdentifier = self.accountButton.accessibilityIdentifier =
manual_fill::AccessoryAddressAccessibilityIdentifier; manual_fill::AccessoryAddressAccessibilityIdentifier;
...@@ -198,20 +198,19 @@ static NSTimeInterval MFAnimationDuration = 0.20; ...@@ -198,20 +198,19 @@ static NSTimeInterval MFAnimationDuration = 0.20;
[self.delegate passwordButtonPressed:sender]; [self.delegate passwordButtonPressed:sender];
} }
- (void)cardButtonPressed { - (void)cardButtonPressed:(UIButton*)sender {
base::RecordAction(base::UserMetricsAction("ManualFallback_OpenCreditCard")); base::RecordAction(base::UserMetricsAction("ManualFallback_OpenCreditCard"));
[self animateKeyboardButtonHidden:NO]; [self animateKeyboardButtonHidden:NO];
[self resetTintColors]; [self resetTintColors];
[self.cardsButton setTintColor:UIColor.cr_manualFillTintColor]; [self.cardsButton setTintColor:UIColor.cr_manualFillTintColor];
[self.delegate cardButtonPressed]; [self.delegate cardButtonPressed:sender];
} }
- (void)accountButtonPressed { - (void)accountButtonPressed:(UIButton*)sender {
base::RecordAction(base::UserMetricsAction("ManualFallback_OpenProfile"));
[self animateKeyboardButtonHidden:NO]; [self animateKeyboardButtonHidden:NO];
[self resetTintColors]; [self resetTintColors];
[self.accountButton setTintColor:UIColor.cr_manualFillTintColor]; [self.accountButton setTintColor:UIColor.cr_manualFillTintColor];
[self.delegate accountButtonPressed]; [self.delegate accountButtonPressed:sender];
} }
@end @end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment