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

[iOS][MF] Reset input accessory when moving to background

Bug: 1001409
Change-Id: I2c97c64a9fded5935dda6142d0be18b00bef230f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1803444Reviewed-by: default avatarOlivier Robin <olivierrobin@chromium.org>
Commit-Queue: Javier Ernesto Flores Robles <javierrobles@chromium.org>
Cr-Commit-Position: refs/heads/master@{#697215}
parent 7dc09655
......@@ -185,6 +185,11 @@
}
}
- (void)mediatorDidDetectMovingToBackground:
(FormInputAccessoryMediator*)mediator {
[self.formInputAccessoryViewController reset];
}
#pragma mark - ManualFillAccessoryViewControllerDelegate
- (void)keyboardButtonPressed {
......
......@@ -35,6 +35,11 @@ class WebStateList;
// present on the screen.
- (void)mediatorDidDetectKeyboardHide:(FormInputAccessoryMediator*)mediator;
// The mediator detected that the keyboard was hidden and it is no longer
// present on the screen.
- (void)mediatorDidDetectMovingToBackground:
(FormInputAccessoryMediator*)mediator;
@end
// This class contains all the logic to get and provide keyboard input accessory
......
......@@ -169,37 +169,42 @@
selector:@selector(handleTextInputDidEndEditing:)
name:UITextFieldTextDidEndEditingNotification
object:nil];
[defaultCenter addObserver:self
selector:@selector(applicationDidEnterBackground:)
name:UIApplicationDidEnterBackgroundNotification
object:nil];
_keyboardObserver = [[KeyboardObserverHelper alloc] init];
_keyboardObserver.consumer = self;
}
// In BVC unit tests the password store doesn't exist. Skip creating the
// fetcher.
// TODO:(crbug.com/878388) Remove this workaround.
if (passwordStore) {
_passwordFetcher =
[[PasswordFetcher alloc] initWithPasswordStore:passwordStore
delegate:self
URL:GURL::EmptyGURL()];
}
if (personalDataManager) {
_personalDataManager = personalDataManager;
_personalDataManagerObserver.reset(
new autofill::PersonalDataManagerObserverBridge(self));
personalDataManager->AddObserver(_personalDataManagerObserver.get());
// TODO:(crbug.com/845472) Add earl grey test to verify the credit card
// button is hidden when local cards are saved and then
// kAutofillCreditCardEnabled is changed to disabled.
consumer.creditCardButtonHidden =
personalDataManager->GetCreditCards().empty();
consumer.addressButtonHidden =
personalDataManager->GetProfilesToSuggest().empty();
} else {
consumer.creditCardButtonHidden = YES;
consumer.addressButtonHidden = YES;
}
// In BVC unit tests the password store doesn't exist. Skip creating the
// fetcher.
// TODO:(crbug.com/878388) Remove this workaround.
if (passwordStore) {
_passwordFetcher =
[[PasswordFetcher alloc] initWithPasswordStore:passwordStore
delegate:self
URL:GURL::EmptyGURL()];
}
if (personalDataManager) {
_personalDataManager = personalDataManager;
_personalDataManagerObserver.reset(
new autofill::PersonalDataManagerObserverBridge(self));
personalDataManager->AddObserver(_personalDataManagerObserver.get());
// TODO:(crbug.com/845472) Add earl grey test to verify the credit card
// button is hidden when local cards are saved and then
// kAutofillCreditCardEnabled is changed to disabled.
consumer.creditCardButtonHidden =
personalDataManager->GetCreditCards().empty();
consumer.addressButtonHidden =
personalDataManager->GetProfilesToSuggest().empty();
} else {
consumer.creditCardButtonHidden = YES;
consumer.addressButtonHidden = YES;
}
}
return self;
}
......@@ -507,6 +512,11 @@
}
}
// Inform the delegate that the app went to the background.
- (void)applicationDidEnterBackground:(NSNotification*)notification {
[self.delegate mediatorDidDetectMovingToBackground:self];
}
#pragma mark - Keyboard Notifications
// When any text field or text view (e.g. omnibox, settings search bar)
......
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