Commit 78dc5e34 authored by harrisonsean's avatar harrisonsean Committed by Commit Bot

[iOS][Safety Check] Change cancel behavior

Cancel reverts to previous state, for unfinished checks, instead
of blank state.

Bug: 1078782
Change-Id: Ia643389a6e1844d62d22be145b6ddeb9a53d7ba0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2401164
Commit-Queue: Sean Harrison <harrisonsean@chromium.org>
Reviewed-by: default avatarJavier Ernesto Flores Robles <javierrobles@chromium.org>
Cr-Commit-Position: refs/heads/master@{#810555}
parent 48cc206b
...@@ -156,18 +156,29 @@ typedef NS_ENUM(NSInteger, CheckStartStates) { ...@@ -156,18 +156,29 @@ typedef NS_ENUM(NSInteger, CheckStartStates) {
@property(nonatomic, assign) @property(nonatomic, assign)
SafeBrowsingCheckRowStates safeBrowsingCheckRowState; SafeBrowsingCheckRowStates safeBrowsingCheckRowState;
// Previous on load or finished check state of the Safe Browsing check.
@property(nonatomic, assign)
SafeBrowsingCheckRowStates previousSafeBrowsingCheckRowState;
// SettingsCheckItem used to display the state of the update check. // SettingsCheckItem used to display the state of the update check.
@property(nonatomic, strong) SettingsCheckItem* updateCheckItem; @property(nonatomic, strong) SettingsCheckItem* updateCheckItem;
// Current state of the update check. // Current state of the update check.
@property(nonatomic, assign) UpdateCheckRowStates updateCheckRowState; @property(nonatomic, assign) UpdateCheckRowStates updateCheckRowState;
// Previous on load or finished check state of the update check.
@property(nonatomic, assign) UpdateCheckRowStates previousUpdateCheckRowState;
// SettingsCheckItem used to display the state of the password check. // SettingsCheckItem used to display the state of the password check.
@property(nonatomic, strong) SettingsCheckItem* passwordCheckItem; @property(nonatomic, strong) SettingsCheckItem* passwordCheckItem;
// Current state of the password check. // Current state of the password check.
@property(nonatomic, assign) PasswordCheckRowStates passwordCheckRowState; @property(nonatomic, assign) PasswordCheckRowStates passwordCheckRowState;
// Previous on load or finished check state of the password check.
@property(nonatomic, assign)
PasswordCheckRowStates previousPasswordCheckRowState;
// Row button to start the safety check. // Row button to start the safety check.
@property(nonatomic, strong) TableViewTextItem* checkStartItem; @property(nonatomic, strong) TableViewTextItem* checkStartItem;
...@@ -257,6 +268,8 @@ typedef NS_ENUM(NSInteger, CheckStartStates) { ...@@ -257,6 +268,8 @@ typedef NS_ENUM(NSInteger, CheckStartStates) {
_updateCheckRowState = UpdateCheckRowStateOutOfDate; _updateCheckRowState = UpdateCheckRowStateOutOfDate;
} }
_previousUpdateCheckRowState = _updateCheckRowState;
_passwordCheckRowState = PasswordCheckRowStateDefault; _passwordCheckRowState = PasswordCheckRowStateDefault;
_passwordCheckItem = _passwordCheckItem =
[[SettingsCheckItem alloc] initWithType:PasswordItemType]; [[SettingsCheckItem alloc] initWithType:PasswordItemType];
...@@ -279,7 +292,10 @@ typedef NS_ENUM(NSInteger, CheckStartStates) { ...@@ -279,7 +292,10 @@ typedef NS_ENUM(NSInteger, CheckStartStates) {
_passwordCheckRowState = PasswordCheckRowStateUnSafe; _passwordCheckRowState = PasswordCheckRowStateUnSafe;
} }
_previousPasswordCheckRowState = _passwordCheckRowState;
_safeBrowsingCheckRowState = SafeBrowsingCheckRowStateDefault; _safeBrowsingCheckRowState = SafeBrowsingCheckRowStateDefault;
_previousSafeBrowsingCheckRowState = _safeBrowsingCheckRowState;
_safeBrowsingCheckItem = _safeBrowsingCheckItem =
[[SettingsCheckItem alloc] initWithType:SafeBrowsingItemType]; [[SettingsCheckItem alloc] initWithType:SafeBrowsingItemType];
_safeBrowsingCheckItem.text = l10n_util::GetNSString( _safeBrowsingCheckItem.text = l10n_util::GetNSString(
...@@ -615,35 +631,48 @@ typedef NS_ENUM(NSInteger, CheckStartStates) { ...@@ -615,35 +631,48 @@ typedef NS_ENUM(NSInteger, CheckStartStates) {
- (void)checkStartOrCancel { - (void)checkStartOrCancel {
// If a check is already running cancel it. // If a check is already running cancel it.
if (self.checksRemaining) { if (self.checksRemaining) {
// Reset check items to default. self.checkDidRun = NO;
self.updateCheckRowState = UpdateCheckRowStateDefault; // Revert checks that are still running to their previous state.
self.passwordCheckRowState = PasswordCheckRowStateDefault; if (self.updateCheckRowState == UpdateCheckRowStateRunning) {
self.safeBrowsingCheckRowState = SafeBrowsingCheckRowStateDefault; self.updateCheckRowState = self.previousUpdateCheckRowState;
[self reconfigureUpdateCheckItem];
}
if (self.passwordCheckRowState == PasswordCheckRowStateRunning) {
self.passwordCheckManager->StopPasswordCheck();
self.passwordCheckRowState = self.previousPasswordCheckRowState;
[self reconfigurePasswordCheckItem];
}
if (self.safeBrowsingCheckRowState == SafeBrowsingCheckRowStateRunning) {
self.safeBrowsingCheckRowState = self.previousSafeBrowsingCheckRowState;
[self reconfigureSafeBrowsingCheckItem];
}
// Change checkStartItem to default state. // Change checkStartItem to default state.
self.checkStartState = CheckStartStateDefault; self.checkStartState = CheckStartStateDefault;
[self reconfigureCheckStartSection];
// Stop any running checks. return;
self.passwordCheckManager->StopPasswordCheck(); }
self.checkDidRun = NO; // Otherwise start a check.
} else { // Record the current state of the checks.
// Otherwise start a check. self.previousUpdateCheckRowState = self.updateCheckRowState;
self.previousPasswordCheckRowState = self.passwordCheckRowState;
self.previousSafeBrowsingCheckRowState = self.safeBrowsingCheckRowState;
// Set check items to spinning wheel. // Set check items to spinning wheel.
self.updateCheckRowState = UpdateCheckRowStateRunning; self.updateCheckRowState = UpdateCheckRowStateRunning;
self.passwordCheckRowState = PasswordCheckRowStateRunning; self.passwordCheckRowState = PasswordCheckRowStateRunning;
self.safeBrowsingCheckRowState = SafeBrowsingCheckRowStateRunning; self.safeBrowsingCheckRowState = SafeBrowsingCheckRowStateRunning;
// Change checkStartItem to cancel state. // Change checkStartItem to cancel state.
self.checkStartState = CheckStartStateCancel; self.checkStartState = CheckStartStateCancel;
// Hide the timestamp while running. // Hide the timestamp while running.
[self.consumer setTimestampFooterItem:nil]; [self.consumer setTimestampFooterItem:nil];
self.checkDidRun = YES; self.checkDidRun = YES;
}
// Update the display. // Update the display.
[self reconfigureUpdateCheckItem]; [self reconfigureUpdateCheckItem];
......
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