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

[iOS][Password-Breach] Remove toggle from settings -> Passwords

Bug: 1028095

Change-Id: I6ca136c360e3ad62a171445f2a8e256b248a4d77
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1937327
Commit-Queue: Javier Ernesto Flores Robles <javierrobles@chromium.org>
Reviewed-by: default avatarEric Noyau <noyau@chromium.org>
Cr-Commit-Position: refs/heads/master@{#719375}
parent 5034ff12
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#include "components/password_manager/core/browser/password_manager_metrics_util.h" #include "components/password_manager/core/browser/password_manager_metrics_util.h"
#include "components/password_manager/core/browser/password_store.h" #include "components/password_manager/core/browser/password_store.h"
#include "components/password_manager/core/browser/password_ui_utils.h" #include "components/password_manager/core/browser/password_ui_utils.h"
#include "components/password_manager/core/common/password_manager_features.h"
#include "components/password_manager/core/common/password_manager_pref_names.h" #include "components/password_manager/core/common/password_manager_pref_names.h"
#include "components/prefs/pref_member.h" #include "components/prefs/pref_member.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
...@@ -81,7 +80,6 @@ typedef NS_ENUM(NSInteger, ItemType) { ...@@ -81,7 +80,6 @@ typedef NS_ENUM(NSInteger, ItemType) {
ItemTypeLinkHeader = kItemTypeEnumZero, ItemTypeLinkHeader = kItemTypeEnumZero,
ItemTypeHeader, ItemTypeHeader,
ItemTypeSavePasswordsSwitch, ItemTypeSavePasswordsSwitch,
ItemTypePasswordLeakCheckSwitch,
ItemTypeSavedPassword, // This is a repeated item type. ItemTypeSavedPassword, // This is a repeated item type.
ItemTypeBlacklisted, // This is a repeated item type. ItemTypeBlacklisted, // This is a repeated item type.
ItemTypeExportPasswordsButton, ItemTypeExportPasswordsButton,
...@@ -167,16 +165,10 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf( ...@@ -167,16 +165,10 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf(
// The observable boolean that binds to the password manager setting state. // The observable boolean that binds to the password manager setting state.
// Saved passwords are only on if the password manager is enabled. // Saved passwords are only on if the password manager is enabled.
PrefBackedBoolean* passwordManagerEnabled_; PrefBackedBoolean* passwordManagerEnabled_;
// The observable boolean that binds to the password leak check settings
// state.
PrefBackedBoolean* passwordLeakCheckEnabled_;
// The header for save passwords switch section. // The header for save passwords switch section.
TableViewLinkHeaderFooterItem* manageAccountLinkItem_; TableViewLinkHeaderFooterItem* manageAccountLinkItem_;
// The item related to the switch for the password manager setting. // The item related to the switch for the password manager setting.
SettingsSwitchItem* savePasswordsItem_; SettingsSwitchItem* savePasswordsItem_;
// The item related to the switch for the automatic password leak detection
// setting.
SettingsSwitchItem* leakCheckItem_;
// The item related to the button for exporting passwords. // The item related to the button for exporting passwords.
TableViewTextItem* exportPasswordsItem_; TableViewTextItem* exportPasswordsItem_;
// The interface for getting and manipulating a user's saved passwords. // The interface for getting and manipulating a user's saved passwords.
...@@ -257,16 +249,6 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf( ...@@ -257,16 +249,6 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf(
initWithPrefService:browserState_->GetPrefs() initWithPrefService:browserState_->GetPrefs()
prefName:password_manager::prefs::kCredentialsEnableService]; prefName:password_manager::prefs::kCredentialsEnableService];
[passwordManagerEnabled_ setObserver:self]; [passwordManagerEnabled_ setObserver:self];
if (base::FeatureList::IsEnabled(
password_manager::features::kLeakDetection)) {
passwordLeakCheckEnabled_ = [[PrefBackedBoolean alloc]
initWithPrefService:browserState_->GetPrefs()
prefName:password_manager::prefs::
kPasswordLeakDetectionEnabled];
[passwordLeakCheckEnabled_ setObserver:self];
identityServiceObserver_.reset(
new ChromeIdentityServiceObserverBridge(self));
}
[self getLoginsFromPasswordStore]; [self getLoginsFromPasswordStore];
[self updateUIForEditState]; [self updateUIForEditState];
[self updateExportPasswordsButton]; [self updateExportPasswordsButton];
...@@ -346,12 +328,10 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf( ...@@ -346,12 +328,10 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf(
[super setEditing:editing animated:animated]; [super setEditing:editing animated:animated];
if (editing) { if (editing) {
[self setSavePasswordsSwitchItemEnabled:NO]; [self setSavePasswordsSwitchItemEnabled:NO];
[self setLeakCheckSwitchItemEnabled:NO];
[self setExportPasswordsButtonEnabled:NO]; [self setExportPasswordsButtonEnabled:NO];
[self setSearchBarEnabled:NO]; [self setSearchBarEnabled:NO];
} else { } else {
[self setSavePasswordsSwitchItemEnabled:YES]; [self setSavePasswordsSwitchItemEnabled:YES];
[self setLeakCheckSwitchItemEnabled:YES];
if (exportReady_) { if (exportReady_) {
[self setExportPasswordsButtonEnabled:YES]; [self setExportPasswordsButtonEnabled:YES];
} }
...@@ -372,13 +352,6 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf( ...@@ -372,13 +352,6 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf(
savePasswordsItem_ = [self savePasswordsItem]; savePasswordsItem_ = [self savePasswordsItem];
[model addItem:savePasswordsItem_ [model addItem:savePasswordsItem_
toSectionWithIdentifier:SectionIdentifierSavePasswordsSwitch]; toSectionWithIdentifier:SectionIdentifierSavePasswordsSwitch];
if (base::FeatureList::IsEnabled(
password_manager::features::kLeakDetection)) {
leakCheckItem_ = [self leakCheckItem];
[self updateDetailTextLeakCheckItem];
[model addItem:leakCheckItem_
toSectionWithIdentifier:SectionIdentifierSavePasswordsSwitch];
}
manageAccountLinkItem_ = [self manageAccountLinkItem]; manageAccountLinkItem_ = [self manageAccountLinkItem];
[model setHeader:manageAccountLinkItem_ [model setHeader:manageAccountLinkItem_
forSectionWithIdentifier:SectionIdentifierSavePasswordsSwitch]; forSectionWithIdentifier:SectionIdentifierSavePasswordsSwitch];
...@@ -467,20 +440,6 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf( ...@@ -467,20 +440,6 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf(
return savePasswordsItem; return savePasswordsItem;
} }
- (SettingsSwitchItem*)leakCheckItem {
SettingsSwitchItem* leakCheckItem =
[[SettingsSwitchItem alloc] initWithType:ItemTypePasswordLeakCheckSwitch];
leakCheckItem.text = l10n_util::GetNSString(IDS_IOS_LEAK_CHECK_SWITCH);
leakCheckItem.on = [self leakCheckItemOnState];
leakCheckItem.accessibilityIdentifier = @"leakCheckItem_switch";
AuthenticationService* authService =
AuthenticationServiceFactory::GetForBrowserState(browserState_);
leakCheckItem.enabled = authService->IsAuthenticated();
return leakCheckItem;
}
- (TableViewTextItem*)exportPasswordsItem { - (TableViewTextItem*)exportPasswordsItem {
TableViewTextItem* exportPasswordsItem = TableViewTextItem* exportPasswordsItem =
[[TableViewTextItem alloc] initWithType:ItemTypeExportPasswordsButton]; [[TableViewTextItem alloc] initWithType:ItemTypeExportPasswordsButton];
...@@ -529,19 +488,6 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf( ...@@ -529,19 +488,6 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf(
sectionIdentifier:SectionIdentifierSavePasswordsSwitch]) { sectionIdentifier:SectionIdentifierSavePasswordsSwitch]) {
[self reconfigureCellsForItems:@[ savePasswordsItem_ ]]; [self reconfigureCellsForItems:@[ savePasswordsItem_ ]];
} }
} else if (observableBoolean == passwordLeakCheckEnabled_) {
DCHECK(base::FeatureList::IsEnabled(
password_manager::features::kLeakDetection));
// Update the item.
leakCheckItem_.on = [self leakCheckItemOnState];
// Update the cell if it's not removed by presenting search controller.
if ([self.tableViewModel
hasItemForItemType:ItemTypePasswordLeakCheckSwitch
sectionIdentifier:SectionIdentifierSavePasswordsSwitch]) {
[self updateDetailTextLeakCheckItem];
[self reconfigureCellsForItems:@[ leakCheckItem_ ]];
}
} else { } else {
NOTREACHED(); NOTREACHED();
} }
...@@ -557,16 +503,6 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf( ...@@ -557,16 +503,6 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf(
savePasswordsItem_.on = [passwordManagerEnabled_ value]; savePasswordsItem_.on = [passwordManagerEnabled_ value];
} }
- (void)passwordLeakCheckSwitchChanged:(UISwitch*)switchView {
// Update the setting.
[passwordLeakCheckEnabled_ setValue:switchView.on];
// Update the item.
leakCheckItem_.on = [self leakCheckItemOnState];
[self updateDetailTextLeakCheckItem];
[self reconfigureCellsForItems:@[ leakCheckItem_ ]];
}
#pragma mark - SavePasswordsConsumerDelegate #pragma mark - SavePasswordsConsumerDelegate
- (void)onGetPasswordStoreResults: - (void)onGetPasswordStoreResults:
...@@ -657,11 +593,6 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf( ...@@ -657,11 +593,6 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf(
withRowAnimation:UITableViewRowAnimationTop]; withRowAnimation:UITableViewRowAnimationTop];
[model addItem:savePasswordsItem_ [model addItem:savePasswordsItem_
toSectionWithIdentifier:SectionIdentifierSavePasswordsSwitch]; toSectionWithIdentifier:SectionIdentifierSavePasswordsSwitch];
if (base::FeatureList::IsEnabled(
password_manager::features::kLeakDetection)) {
[model addItem:leakCheckItem_
toSectionWithIdentifier:SectionIdentifierSavePasswordsSwitch];
}
[self.tableView [self.tableView
insertRowsAtIndexPaths:@[ [NSIndexPath indexPathForRow:0 insertRowsAtIndexPaths:@[ [NSIndexPath indexPathForRow:0
inSection:0] ] inSection:0] ]
...@@ -987,7 +918,6 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf( ...@@ -987,7 +918,6 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf(
case ItemTypeLinkHeader: case ItemTypeLinkHeader:
case ItemTypeHeader: case ItemTypeHeader:
case ItemTypeSavePasswordsSwitch: case ItemTypeSavePasswordsSwitch:
case ItemTypePasswordLeakCheckSwitch:
break; break;
case ItemTypeSavedPassword: { case ItemTypeSavedPassword: {
DCHECK_EQ(SectionIdentifierSavedPasswords, DCHECK_EQ(SectionIdentifierSavedPasswords,
...@@ -1067,17 +997,6 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf( ...@@ -1067,17 +997,6 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf(
forControlEvents:UIControlEventValueChanged]; forControlEvents:UIControlEventValueChanged];
break; break;
} }
case ItemTypePasswordLeakCheckSwitch: {
DCHECK(base::FeatureList::IsEnabled(
password_manager::features::kLeakDetection));
SettingsSwitchCell* switchCell =
base::mac::ObjCCastStrict<SettingsSwitchCell>(cell);
[switchCell.switchView
addTarget:self
action:@selector(passwordLeakCheckSwitchChanged:)
forControlEvents:UIControlEventValueChanged];
break;
}
} }
return cell; return cell;
} }
...@@ -1259,27 +1178,6 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf( ...@@ -1259,27 +1178,6 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf(
[self reconfigureCellsForItems:@[ savePasswordsItem_ ]]; [self reconfigureCellsForItems:@[ savePasswordsItem_ ]];
} }
// Returns a boolean indicating if the switch should appear as "On" or "Off"
// based on the sync preference and the sign in status.
- (BOOL)leakCheckItemOnState {
AuthenticationService* authService =
AuthenticationServiceFactory::GetForBrowserState(browserState_);
return [passwordLeakCheckEnabled_ value] && authService->IsAuthenticated();
}
// Sets the leak check switch item's enabled status to |enabled| and
// reconfigures the corresponding cell. If the user is not signed in, |enabled|
// is overriden with |NO|.
- (void)setLeakCheckSwitchItemEnabled:(BOOL)enabled {
if (!base::FeatureList::IsEnabled(password_manager::features::kLeakDetection))
return;
AuthenticationService* authService =
AuthenticationServiceFactory::GetForBrowserState(browserState_);
[leakCheckItem_ setEnabled:enabled && authService->IsAuthenticated()];
[self updateDetailTextLeakCheckItem];
[self reconfigureCellsForItems:@[ leakCheckItem_ ]];
}
// Enables/disables search bar. // Enables/disables search bar.
- (void)setSearchBarEnabled:(BOOL)enabled { - (void)setSearchBarEnabled:(BOOL)enabled {
if (enabled) { if (enabled) {
...@@ -1292,27 +1190,6 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf( ...@@ -1292,27 +1190,6 @@ std::vector<std::unique_ptr<autofill::PasswordForm>> CopyOf(
} }
} }
// Updates the detail text of the leak check item based on the state.
- (void)updateDetailTextLeakCheckItem {
if (!leakCheckItem_) {
return;
}
if (self.editing) {
// When editing keep the current detail text.
return;
}
AuthenticationService* authService =
AuthenticationServiceFactory::GetForBrowserState(browserState_);
if (!authService->IsAuthenticated() && [passwordLeakCheckEnabled_ value]) {
// If the user is signed out and the sync preference is enabled, this
// informs that it will be turned on on sign in.
leakCheckItem_.detailText =
l10n_util::GetNSString(IDS_IOS_LEAK_CHECK_SIGNED_OUT_ENABLED_DESC);
return;
}
leakCheckItem_.detailText = nil;
}
#pragma mark - Testing #pragma mark - Testing
- (void)setReauthenticationModuleForExporter: - (void)setReauthenticationModuleForExporter:
......
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