Commit fab87547 authored by Viktor Semeniuk's avatar Viktor Semeniuk Committed by Commit Bot

[iOS] Clean up after enabling Password Check feature

Bug: 1096986
Change-Id: Ic4d55f8b041a09db22baea5ae49a0d5c3afe78d4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2505753Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Commit-Queue: Viktor Semeniuk <vsemeniuk@google.com>
Cr-Commit-Position: refs/heads/master@{#822193}
parent d3660dd3
......@@ -549,9 +549,6 @@ const flags_ui::FeatureEntry kFeatureEntries[] = {
flags_ui::kOsIos,
FEATURE_VALUE_TYPE(
autofill::features::kAutofillEnableCardNicknameManagement)},
{"password-check", flag_descriptions::kPasswordCheckName,
flag_descriptions::kPasswordCheckDescription, flags_ui::kOsIos,
FEATURE_VALUE_TYPE(password_manager::features::kPasswordCheck)},
{"enable-ios-managed-settings-ui",
flag_descriptions::kEnableIOSManagedSettingsUIName,
flag_descriptions::kEnableIOSManagedSettingsUIDescription,
......
......@@ -397,10 +397,6 @@ const char kOpenDownloadsInFilesAppDescription[] =
"the tools menu or after pressing the 'Open in downloads' button invoked "
"by pressing 'Open In...' after download completes.";
const char kPasswordCheckName[] = "Bulk Password Check";
const char kPasswordCheckDescription[] =
"Enables the Bulk Password Check feature for signed-in users.";
const char kPageInfoRefactoringName[] = "New design of the page info";
const char kPageInfoRefactoringDescription[] =
"Uses the new design for the page security info.";
......
......@@ -347,11 +347,6 @@ extern const char kOmniboxOnFocusSuggestionsDescription[];
extern const char kOpenDownloadsInFilesAppName[];
extern const char kOpenDownloadsInFilesAppDescription[];
// Title and description for the flag to provide user with Password Check
// feature in Settings.
extern const char kPasswordCheckName[];
extern const char kPasswordCheckDescription[];
// Title and description for the flag to enable the new design of the page info.
extern const char kPageInfoRefactoringName[];
extern const char kPageInfoRefactoringDescription[];
......
......@@ -63,12 +63,9 @@ using password_manager::CredentialLeakType;
if (@available(iOS 13, *)) {
self.viewController.modalInPresentation = YES;
}
id<ApplicationCommands> handler = HandlerForProtocol(
self.browser->GetCommandDispatcher(), ApplicationCommands);
self.mediator =
[[PasswordBreachMediator alloc] initWithConsumer:self.viewController
presenter:self
handler:handler
URL:_url
leakType:self.leakType];
self.viewController.actionHandler = self.mediator;
......
......@@ -63,11 +63,6 @@ id<GREYMatcher> CheckPasswordButton() {
// Tests that Check password button redirects to the Passwords List.
- (void)testPasswordBreachRedirectToPasswords {
// TODO(crbug.com/1096986): Remove it once feature is enabled by default.
AppLaunchConfiguration config;
config.features_enabled.push_back(password_manager::features::kPasswordCheck);
[[AppLaunchManager sharedManager] ensureAppLaunchedWithConfiguration:config];
[PasswordBreachAppInterface showPasswordBreachWithCheckButton:YES];
[[EarlGrey selectElementWithMatcher:PasswordBreachMatcher()]
assertWithMatcher:grey_notNil()];
......
......@@ -21,7 +21,6 @@ class GURL;
- (instancetype)initWithConsumer:(id<PasswordBreachConsumer>)consumer
presenter:(id<PasswordBreachPresenter>)presenter
handler:(id<ApplicationCommands>)handler
URL:(const GURL&)URL
leakType:(password_manager::CredentialLeakType)leakType;
......
......@@ -42,22 +42,17 @@ using password_manager::metrics_util::LogLeakDialogTypeAndDismissalReason;
// The presenter of the feature.
@property(nonatomic, weak) id<PasswordBreachPresenter> presenter;
// Dispatcher.
@property(nonatomic, weak) id<ApplicationCommands> handler;
@end
@implementation PasswordBreachMediator
- (instancetype)initWithConsumer:(id<PasswordBreachConsumer>)consumer
presenter:(id<PasswordBreachPresenter>)presenter
handler:(id<ApplicationCommands>)handler
URL:(const GURL&)URL
leakType:(CredentialLeakType)leakType {
self = [super init];
if (self) {
_presenter = presenter;
_handler = handler;
_leakType = GetLeakDialogType(leakType);
_dismissReason = LeakDialogDismissalReason::kNoDirectInteraction;
......@@ -85,18 +80,9 @@ using password_manager::metrics_util::LogLeakDialogTypeAndDismissalReason;
- (void)confirmationAlertPrimaryAction {
self.dismissReason = LeakDialogDismissalReason::kClickedCheckPasswords;
if (base::FeatureList::IsEnabled(
password_manager::features::kPasswordCheck)) {
// Opening Password page will stop the presentation in the presenter.
// No need to send |stop|.
[self.presenter startPasswordCheck];
} else {
// Opening a new tab already stops the presentation in the presenter.
// No need to send |stop|.
OpenNewTabCommand* newTabCommand =
[OpenNewTabCommand commandWithURLFromChrome:GetPasswordCheckupURL()];
[self.handler openURLInNewTab:newTabCommand];
}
// Opening Password page will stop the presentation in the presenter.
// No need to send |stop|.
[self.presenter startPasswordCheck];
}
- (void)confirmationAlertSecondaryAction {
......
......@@ -44,9 +44,6 @@ source_set("password") {
source_set("password_ui") {
configs += [ "//build/config/compiler:enable_arc" ]
sources = [
"legacy_password_details_table_view_controller.h",
"legacy_password_details_table_view_controller.mm",
"legacy_password_details_table_view_controller_delegate.h",
"password_exporter.h",
"password_exporter.mm",
"password_issue.h",
......@@ -116,10 +113,7 @@ source_set("password_constants") {
source_set("test_support") {
configs += [ "//build/config/compiler:enable_arc" ]
testonly = true
sources = [
"legacy_password_details_table_view_controller+testing.h",
"password_exporter_for_testing.h",
]
sources = [ "password_exporter_for_testing.h" ]
deps = [ ":password_ui" ]
}
......@@ -127,7 +121,6 @@ source_set("unit_tests") {
configs += [ "//build/config/compiler:enable_arc" ]
testonly = true
sources = [
"legacy_password_details_table_view_controller_unittest.mm",
"password_exporter_unittest.mm",
"password_issues_mediator_unittest.mm",
"password_issues_table_view_controller_unittest.mm",
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_CHROME_BROWSER_UI_SETTINGS_PASSWORD_LEGACY_PASSWORD_DETAILS_TABLE_VIEW_CONTROLLER_TESTING_H_
#define IOS_CHROME_BROWSER_UI_SETTINGS_PASSWORD_LEGACY_PASSWORD_DETAILS_TABLE_VIEW_CONTROLLER_TESTING_H_
#import "ios/chrome/browser/ui/settings/password/legacy_password_details_table_view_controller.h"
// TODO(crbug.com/943523): Refactor the PasswordTableViewController and
// PasswordsSettingsTestCase to remove this Category file.
@interface LegacyPasswordDetailsTableViewController (Testing)
// Allows to replace a |reauthenticationModule| for a fake one in integration
// tests, where the testing code cannot control the creation of the
// controller.
- (void)setReauthenticationModule:
(id<ReauthenticationProtocol>)reauthenticationModule;
@end
#endif // IOS_CHROME_BROWSER_UI_SETTINGS_PASSWORD_LEGACY_PASSWORD_DETAILS_TABLE_VIEW_CONTROLLER_TESTING_H_
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_CHROME_BROWSER_UI_SETTINGS_PASSWORD_LEGACY_PASSWORD_DETAILS_TABLE_VIEW_CONTROLLER_H_
#define IOS_CHROME_BROWSER_UI_SETTINGS_PASSWORD_LEGACY_PASSWORD_DETAILS_TABLE_VIEW_CONTROLLER_H_
#include "components/password_manager/core/browser/password_form_forward.h"
#import "ios/chrome/browser/ui/settings/password/legacy_password_details_table_view_controller_delegate.h"
#import "ios/chrome/browser/ui/settings/settings_root_table_view_controller.h"
@protocol ReauthenticationProtocol;
// TODO(crbug.com/1096986): Delete this view controller after Password Check
// launch.
// Displays details of a password item, including URL of the site, username and
// password in masked state as default. User can copy the URL and username,
// pass the iOS security check to see and copy the password , or delete the
// password item.
@interface LegacyPasswordDetailsTableViewController
: SettingsRootTableViewController
// The designated initializer.
- (nullable instancetype)
initWithPasswordForm:(const password_manager::PasswordForm&)passwordForm
delegate:
(nonnull
id<LegacyPasswordDetailsTableViewControllerDelegate>)
delegate
reauthenticationModule:
(nonnull id<ReauthenticationProtocol>)reauthenticationModule
NS_DESIGNATED_INITIALIZER;
- (nullable instancetype)initWithStyle:(UITableViewStyle)style NS_UNAVAILABLE;
@end
#endif // IOS_CHROME_BROWSER_UI_SETTINGS_PASSWORD_LEGACY_PASSWORD_DETAILS_TABLE_VIEW_CONTROLLER_H_
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_CHROME_BROWSER_UI_SETTINGS_PASSWORD_LEGACY_PASSWORD_DETAILS_TABLE_VIEW_CONTROLLER_DELEGATE_H_
#define IOS_CHROME_BROWSER_UI_SETTINGS_PASSWORD_LEGACY_PASSWORD_DETAILS_TABLE_VIEW_CONTROLLER_DELEGATE_H_
#import <Foundation/Foundation.h>
#include "components/password_manager/core/browser/password_form_forward.h"
@class LegacyPasswordDetailsTableViewController;
// PasswordDetailsTableViewController uses this protocol to interact with higher
// level password controller.
@protocol LegacyPasswordDetailsTableViewControllerDelegate
- (void)passwordDetailsTableViewController:
(LegacyPasswordDetailsTableViewController*)controller
deletePassword:
(const password_manager::PasswordForm&)
passwordForm;
@end
#endif // IOS_CHROME_BROWSER_UI_SETTINGS_PASSWORD_LEGACY_PASSWORD_DETAILS_TABLE_VIEW_CONTROLLER_DELEGATE_H_
......@@ -17,8 +17,6 @@
#include "ios/chrome/browser/sync/sync_setup_service_factory.h"
#import "ios/chrome/browser/ui/commands/application_commands.h"
#import "ios/chrome/browser/ui/commands/command_dispatcher.h"
#import "ios/chrome/browser/ui/settings/password/legacy_password_details_table_view_controller.h"
#import "ios/chrome/browser/ui/settings/password/legacy_password_details_table_view_controller_delegate.h"
#import "ios/chrome/browser/ui/settings/password/password_details/password_details_coordinator.h"
#import "ios/chrome/browser/ui/settings/password/password_details/password_details_coordinator_delegate.h"
#import "ios/chrome/browser/ui/settings/password/password_issues_coordinator.h"
......@@ -35,7 +33,6 @@
#endif
@interface PasswordsCoordinator () <
LegacyPasswordDetailsTableViewControllerDelegate,
PasswordDetailsCoordinatorDelegate,
PasswordIssuesCoordinatorDelegate,
PasswordsSettingsCommands,
......@@ -152,26 +149,15 @@
}
- (void)showDetailedViewForForm:(const password_manager::PasswordForm&)form {
if (base::FeatureList::IsEnabled(
password_manager::features::kPasswordCheck)) {
DCHECK(!self.passwordDetailsCoordinator);
self.passwordDetailsCoordinator = [[PasswordDetailsCoordinator alloc]
initWithBaseNavigationController:self.baseNavigationController
browser:self.browser
password:form
reauthModule:self.reauthModule
passwordCheckManager:[self passwordCheckManager].get()];
self.passwordDetailsCoordinator.delegate = self;
[self.passwordDetailsCoordinator start];
} else {
LegacyPasswordDetailsTableViewController* controller =
[[LegacyPasswordDetailsTableViewController alloc]
initWithPasswordForm:form
delegate:self
reauthenticationModule:self.reauthModule];
controller.dispatcher = self.dispatcher;
[self.baseNavigationController pushViewController:controller animated:YES];
}
DCHECK(!self.passwordDetailsCoordinator);
self.passwordDetailsCoordinator = [[PasswordDetailsCoordinator alloc]
initWithBaseNavigationController:self.baseNavigationController
browser:self.browser
password:form
reauthModule:self.reauthModule
passwordCheckManager:[self passwordCheckManager].get()];
self.passwordDetailsCoordinator.delegate = self;
[self.passwordDetailsCoordinator start];
}
#pragma mark - PasswordsTableViewControllerPresentationDelegate
......@@ -213,15 +199,6 @@
[self.passwordsViewController deletePasswordForm:password];
}
#pragma mark LegacyPasswordDetailsTableViewControllerDelegate
- (void)passwordDetailsTableViewController:
(LegacyPasswordDetailsTableViewController*)controller
deletePassword:
(const password_manager::PasswordForm&)form {
[self.passwordsViewController deletePasswordForm:form];
}
#pragma mark Private
- (scoped_refptr<IOSChromePasswordCheckManager>)passwordCheckManager {
......
......@@ -93,13 +93,9 @@ constexpr base::TimeDelta kJustCheckedTimeThresholdInMinutes =
_passwordStoreObserver =
std::make_unique<PasswordStoreObserverBridge>(self);
_passwordStore->AddObserver(_passwordStoreObserver.get());
if (base::FeatureList::IsEnabled(
password_manager::features::kPasswordCheck)) {
_passwordCheckManager = passwordCheckManager;
_passwordCheckObserver = std::make_unique<PasswordCheckObserverBridge>(
self, _passwordCheckManager.get());
}
_passwordCheckManager = passwordCheckManager;
_passwordCheckObserver = std::make_unique<PasswordCheckObserverBridge>(
self, _passwordCheckManager.get());
}
return self;
}
......@@ -108,6 +104,9 @@ constexpr base::TimeDelta kJustCheckedTimeThresholdInMinutes =
if (_passwordStoreObserver) {
_passwordStore->RemoveObserver(_passwordStoreObserver.get());
}
if (_passwordCheckObserver) {
_passwordCheckManager->RemoveObserver(_passwordCheckObserver.get());
}
}
- (void)setConsumer:(id<PasswordsConsumer>)consumer {
......@@ -116,15 +115,12 @@ constexpr base::TimeDelta kJustCheckedTimeThresholdInMinutes =
_consumer = consumer;
[self loginsDidChange];
if (base::FeatureList::IsEnabled(
password_manager::features::kPasswordCheck)) {
_currentState = _passwordCheckManager->GetPasswordCheckState();
[self.consumer setPasswordCheckUIState:
[self computePasswordCheckUIStateWith:_currentState]
compromisedPasswordsCount:_passwordCheckManager
->GetCompromisedCredentials()
.size()];
}
_currentState = _passwordCheckManager->GetPasswordCheckState();
[self.consumer setPasswordCheckUIState:
[self computePasswordCheckUIStateWith:_currentState]
compromisedPasswordsCount:_passwordCheckManager
->GetCompromisedCredentials()
.size()];
}
#pragma mark - PasswordsTableViewControllerDelegate
......
......@@ -87,8 +87,6 @@ class PasswordsMediatorTest : public BlockCleanupTest {
protected:
void SetUp() override {
BlockCleanupTest::SetUp();
scoped_feature_list_.InitAndEnableFeature(
password_manager::features::kPasswordCheck);
TestChromeBrowserState::Builder builder;
builder.AddTestingFactory(
......@@ -134,7 +132,6 @@ class PasswordsMediatorTest : public BlockCleanupTest {
scoped_refptr<IOSChromePasswordCheckManager> password_check_;
FakePasswordsConsumer* consumer_;
PasswordsMediator* mediator_;
base::test::ScopedFeatureList scoped_feature_list_;
};
TEST_F(PasswordsMediatorTest, ElapsedTimeSinceLastCheck) {
......
......@@ -312,12 +312,9 @@ void CopyPasswordDetailWithID(int detail_id) {
- (AppLaunchConfiguration)appConfigurationForTestCase {
AppLaunchConfiguration config;
// Password Check Feature is enabled for all tests. This is done because it
// Password Editing Feature is enabled by test name. This is done because it
// is inefficient to use ensureAppLaunchedWithConfiguration for each test.
// This should be removed once test config is modified.
// TODO(crbug.com/1075494): Remove this once feature is launched.
config.features_enabled.push_back(password_manager::features::kPasswordCheck);
if ([self isRunningTest:@selector(testEditUsername)] ||
[self isRunningTest:@selector(testEditUsernameFails)]) {
config.features_enabled.push_back(
......
......@@ -414,30 +414,27 @@ std::vector<std::unique_ptr<password_manager::PasswordForm>> CopyOf(
forSectionWithIdentifier:SectionIdentifierSavePasswordsSwitch];
}
if (base::FeatureList::IsEnabled(
password_manager::features::kPasswordCheck)) {
// Password check.
[model addSectionWithIdentifier:SectionIdentifierPasswordCheck];
if (!_passwordProblemsItem) {
_passwordProblemsItem = [self passwordProblemsItem];
}
// Password check.
[model addSectionWithIdentifier:SectionIdentifierPasswordCheck];
if (!_passwordProblemsItem) {
_passwordProblemsItem = [self passwordProblemsItem];
}
[self updatePasswordCheckStatusLabelWithState:_passwordCheckState];
[model addItem:_passwordProblemsItem
toSectionWithIdentifier:SectionIdentifierPasswordCheck];
[self updatePasswordCheckStatusLabelWithState:_passwordCheckState];
[model addItem:_passwordProblemsItem
toSectionWithIdentifier:SectionIdentifierPasswordCheck];
if (!_checkForProblemsItem) {
_checkForProblemsItem = [self checkForProblemsItem];
}
if (!_checkForProblemsItem) {
_checkForProblemsItem = [self checkForProblemsItem];
}
[self updatePasswordCheckButtonWithState:_passwordCheckState];
[model addItem:_checkForProblemsItem
toSectionWithIdentifier:SectionIdentifierPasswordCheck];
[self updatePasswordCheckButtonWithState:_passwordCheckState];
[model addItem:_checkForProblemsItem
toSectionWithIdentifier:SectionIdentifierPasswordCheck];
[self updateLastCheckTimestampWithState:_passwordCheckState
fromState:_passwordCheckState
update:NO];
}
[self updateLastCheckTimestampWithState:_passwordCheckState
fromState:_passwordCheckState
update:NO];
// Saved passwords.
if (!_savedForms.empty()) {
......@@ -724,13 +721,11 @@ std::vector<std::unique_ptr<password_manager::PasswordForm>> CopyOf(
- (void)setPasswordsForms:
(std::vector<std::unique_ptr<password_manager::PasswordForm>>)results {
if (base::FeatureList::IsEnabled(
password_manager::features::kPasswordCheck)) {
_blockedForms.clear();
_savedForms.clear();
_savedPasswordDuplicates.clear();
_blockedPasswordDuplicates.clear();
}
_blockedForms.clear();
_savedForms.clear();
_savedPasswordDuplicates.clear();
_blockedPasswordDuplicates.clear();
_didReceiveSavedForms = YES;
[self hideLoadingSpinnerBackground];
if (results.empty()) {
......@@ -799,11 +794,8 @@ std::vector<std::unique_ptr<password_manager::PasswordForm>> CopyOf(
// Remove save passwords switch section and password check section.
[self
performBatchTableViewUpdates:^{
if (base::FeatureList::IsEnabled(
password_manager::features::kPasswordCheck)) {
[self clearSectionWithIdentifier:SectionIdentifierPasswordCheck
withRowAnimation:UITableViewRowAnimationTop];
}
[self clearSectionWithIdentifier:SectionIdentifierPasswordCheck
withRowAnimation:UITableViewRowAnimationTop];
[self clearSectionWithIdentifier:SectionIdentifierSavePasswordsSwitch
withRowAnimation:UITableViewRowAnimationTop];
......@@ -837,25 +829,21 @@ std::vector<std::unique_ptr<password_manager::PasswordForm>> CopyOf(
arrayWithObjects:[NSIndexPath indexPathForRow:0
inSection:switchSection],
nil];
[model insertSectionWithIdentifier:SectionIdentifierPasswordCheck
atIndex:1];
NSInteger checkSection =
[model sectionForSectionIdentifier:SectionIdentifierPasswordCheck];
if (base::FeatureList::IsEnabled(
password_manager::features::kPasswordCheck)) {
[model insertSectionWithIdentifier:SectionIdentifierPasswordCheck
atIndex:1];
NSInteger checkSection = [model
sectionForSectionIdentifier:SectionIdentifierPasswordCheck];
[self.tableView insertSections:[NSIndexSet indexSetWithIndex:1]
withRowAnimation:UITableViewRowAnimationTop];
[model addItem:_passwordProblemsItem
toSectionWithIdentifier:SectionIdentifierPasswordCheck];
[model addItem:_checkForProblemsItem
toSectionWithIdentifier:SectionIdentifierPasswordCheck];
[rowsIndexPaths addObject:[NSIndexPath indexPathForRow:0
inSection:checkSection]];
[rowsIndexPaths addObject:[NSIndexPath indexPathForRow:1
inSection:checkSection]];
}
[self.tableView insertSections:[NSIndexSet indexSetWithIndex:1]
withRowAnimation:UITableViewRowAnimationTop];
[model addItem:_passwordProblemsItem
toSectionWithIdentifier:SectionIdentifierPasswordCheck];
[model addItem:_checkForProblemsItem
toSectionWithIdentifier:SectionIdentifierPasswordCheck];
[rowsIndexPaths addObject:[NSIndexPath indexPathForRow:0
inSection:checkSection]];
[rowsIndexPaths addObject:[NSIndexPath indexPathForRow:1
inSection:checkSection]];
[self.tableView insertRowsAtIndexPaths:rowsIndexPaths
withRowAnimation:UITableViewRowAnimationTop];
......
......@@ -5,7 +5,6 @@
#include "ios/chrome/test/app/password_test_util.h"
#include "base/mac/foundation_util.h"
#import "ios/chrome/browser/ui/settings/password/legacy_password_details_table_view_controller+testing.h"
#import "ios/chrome/browser/ui/settings/password/password_details/password_details_table_view_controller.h"
#import "ios/chrome/browser/ui/settings/password/passwords_table_view_controller.h"
#import "ios/chrome/browser/ui/settings/settings_navigation_controller.h"
......
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