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

[iOS][Password-Breach] Disable toggle when logged off

Bug: 986322
Change-Id: Ib8b784aefcd8267fbcf285b6d5c564097bdeb5e8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1852426
Commit-Queue: Javier Ernesto Flores Robles <javierrobles@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#704664}
parent f96075a8
...@@ -31,6 +31,7 @@ source_set("password") { ...@@ -31,6 +31,7 @@ source_set("password") {
"//ios/chrome/browser", "//ios/chrome/browser",
"//ios/chrome/browser/browser_state", "//ios/chrome/browser/browser_state",
"//ios/chrome/browser/passwords", "//ios/chrome/browser/passwords",
"//ios/chrome/browser/signin",
"//ios/chrome/browser/ui:feature_flags", "//ios/chrome/browser/ui:feature_flags",
"//ios/chrome/browser/ui/commands", "//ios/chrome/browser/ui/commands",
"//ios/chrome/browser/ui/settings:settings_root", "//ios/chrome/browser/ui/settings:settings_root",
......
...@@ -30,6 +30,8 @@ ...@@ -30,6 +30,8 @@
#include "ios/chrome/browser/browser_state/chrome_browser_state.h" #include "ios/chrome/browser/browser_state/chrome_browser_state.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/passwords/save_passwords_consumer.h" #import "ios/chrome/browser/passwords/save_passwords_consumer.h"
#import "ios/chrome/browser/signin/authentication_service.h"
#include "ios/chrome/browser/signin/authentication_service_factory.h"
#include "ios/chrome/browser/system_flags.h" #include "ios/chrome/browser/system_flags.h"
#import "ios/chrome/browser/ui/settings/cells/settings_cells_constants.h" #import "ios/chrome/browser/ui/settings/cells/settings_cells_constants.h"
#import "ios/chrome/browser/ui/settings/cells/settings_switch_cell.h" #import "ios/chrome/browser/ui/settings/cells/settings_switch_cell.h"
...@@ -464,6 +466,11 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf( ...@@ -464,6 +466,11 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf(
leakCheckItem.text = l10n_util::GetNSString(IDS_IOS_LEAK_CHECK_SWITCH); leakCheckItem.text = l10n_util::GetNSString(IDS_IOS_LEAK_CHECK_SWITCH);
leakCheckItem.on = [passwordLeakCheckEnabled_ value]; leakCheckItem.on = [passwordLeakCheckEnabled_ value];
leakCheckItem.accessibilityIdentifier = @"leakCheckItem_switch"; leakCheckItem.accessibilityIdentifier = @"leakCheckItem_switch";
AuthenticationService* authService =
AuthenticationServiceFactory::GetForBrowserState(browserState_);
leakCheckItem.enabled = authService->IsAuthenticated();
return leakCheckItem; return leakCheckItem;
} }
...@@ -1243,11 +1250,14 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf( ...@@ -1243,11 +1250,14 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf(
} }
// Sets the leak check switch item's enabled status to |enabled| and // Sets the leak check switch item's enabled status to |enabled| and
// reconfigures the corresponding cell. // reconfigures the corresponding cell. If the user is not sign in, |enabled| is
// overriden with |NO|.
- (void)setLeakCheckSwitchItemEnabled:(BOOL)enabled { - (void)setLeakCheckSwitchItemEnabled:(BOOL)enabled {
if (!base::FeatureList::IsEnabled(password_manager::features::kLeakDetection)) if (!base::FeatureList::IsEnabled(password_manager::features::kLeakDetection))
return; return;
[leakCheckItem_ setEnabled:enabled]; AuthenticationService* authService =
AuthenticationServiceFactory::GetForBrowserState(browserState_);
[leakCheckItem_ setEnabled:enabled && authService->IsAuthenticated()];
[self reconfigureCellsForItems:@[ leakCheckItem_ ]]; [self reconfigureCellsForItems:@[ leakCheckItem_ ]];
} }
......
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