[iOS] Refactor Safety Check Manager for Multi-Profile Support (Phase 1)
Currently, the IOSChromeSafetyCheckManager maintains a reference to the IOSChromePasswordCheckManager throughout its lifecycle. However, the password check functionality is only used infrequently, making this continuous reference unnecessary. This change is the first step in refactoring IOSChromeSafetyCheckManager to support multi-profile functionality (crbug.com/349805178). In this initial phase: - Remove Persistent Reference: We remove the PasswordCheckManager instance variable from IOSChromeSafetyCheckManager. - Dynamic Retrieval: When a password check is initiated, the SafetyCheckManager now fetches the relevant PasswordCheckManager instance from the last used browser state. Benefits: - Reduced Memory Overhead: Avoids storing an unused reference in memory. Preparation for Multi-Profile: This refactor makes it easier to support multiple password check managers in the future when users have multiple profiles. Future Work: Subsequent changes will focus on extending this class to fully handle multiple browser profiles and their associated password managers. Change-Id: Id513311033168c37ce319d2353f794230cb64d2a Bug: 349805178 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5660275 Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com> Reviewed-by: Gauthier Ambard <gambard@chromium.org> Commit-Queue: Benjamin Williams <bwwilliams@google.com> Cr-Commit-Position: refs/heads/main@{#1329698}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
f1372cc5a6
commit
9de720cb96
ios/chrome/browser
browser_view
passwords
safety_check
model
ui
content_suggestions
magic_stack
safety_check
ntp
@ -26,6 +26,7 @@
|
||||
#import "ios/chrome/browser/shared/coordinator/scene/scene_state.h"
|
||||
#import "ios/chrome/browser/shared/model/browser/test/test_browser.h"
|
||||
#import "ios/chrome/browser/shared/model/browser_state/test_chrome_browser_state.h"
|
||||
#import "ios/chrome/browser/shared/model/browser_state/test_chrome_browser_state_manager.h"
|
||||
#import "ios/chrome/browser/shared/model/web_state_list/web_state_opener.h"
|
||||
#import "ios/chrome/browser/shared/public/commands/activity_service_commands.h"
|
||||
#import "ios/chrome/browser/shared/public/commands/application_commands.h"
|
||||
@ -57,7 +58,7 @@
|
||||
#import "ios/chrome/browser/web/model/web_state_delegate_browser_agent.h"
|
||||
#import "ios/chrome/browser/web_state_list/model/web_usage_enabler/web_usage_enabler_browser_agent.h"
|
||||
#import "ios/chrome/common/ui/reauthentication/reauthentication_module.h"
|
||||
#import "ios/chrome/test/ios_chrome_scoped_testing_local_state.h"
|
||||
#import "ios/chrome/test/testing_application_context.h"
|
||||
#import "ios/web/public/test/fakes/fake_navigation_context.h"
|
||||
#import "ios/web/public/test/web_task_environment.h"
|
||||
#import "ios/web/public/web_state_observer.h"
|
||||
@ -112,9 +113,13 @@ class BrowserCoordinatorTest : public PlatformTest {
|
||||
return std::make_unique<commerce::MockShoppingService>();
|
||||
}));
|
||||
|
||||
chrome_browser_state_ = test_cbs_builder.Build();
|
||||
browser_ = std::make_unique<TestBrowser>(chrome_browser_state_.get(),
|
||||
scene_state_);
|
||||
browser_state_manager_ = std::make_unique<TestChromeBrowserStateManager>(
|
||||
test_cbs_builder.Build());
|
||||
|
||||
TestingApplicationContext::GetGlobal()->SetChromeBrowserStateManager(
|
||||
browser_state_manager_.get());
|
||||
|
||||
browser_ = std::make_unique<TestBrowser>(GetBrowserState(), scene_state_);
|
||||
UrlLoadingNotifierBrowserAgent::CreateForBrowser(browser_.get());
|
||||
UrlLoadingBrowserAgent::CreateForBrowser(browser_.get());
|
||||
LensBrowserAgent::CreateForBrowser(browser_.get());
|
||||
@ -131,7 +136,7 @@ class BrowserCoordinatorTest : public PlatformTest {
|
||||
enabler->SetWebUsageEnabled(true);
|
||||
|
||||
AuthenticationServiceFactory::CreateAndInitializeForBrowserState(
|
||||
chrome_browser_state_.get(),
|
||||
GetBrowserState(),
|
||||
std::make_unique<FakeAuthenticationServiceDelegate>());
|
||||
|
||||
IncognitoReauthSceneAgent* reauthAgent = [[IncognitoReauthSceneAgent alloc]
|
||||
@ -161,9 +166,13 @@ class BrowserCoordinatorTest : public PlatformTest {
|
||||
browser:browser_.get()];
|
||||
}
|
||||
|
||||
ChromeBrowserState* GetBrowserState() {
|
||||
return browser_state_manager_->GetLastUsedBrowserStateForTesting();
|
||||
}
|
||||
|
||||
// Creates and inserts a new WebState.
|
||||
int InsertWebState() {
|
||||
web::WebState::CreateParams params(chrome_browser_state_.get());
|
||||
web::WebState::CreateParams params(GetBrowserState());
|
||||
std::unique_ptr<web::WebState> web_state = web::WebState::Create(params);
|
||||
AttachTabHelpers(web_state.get());
|
||||
|
||||
@ -198,10 +207,9 @@ class BrowserCoordinatorTest : public PlatformTest {
|
||||
ntpHelper->PageLoaded(web_state, web::PageLoadCompletionStatus::SUCCESS);
|
||||
}
|
||||
|
||||
IOSChromeScopedTestingLocalState local_state_;
|
||||
web::WebTaskEnvironment task_environment_;
|
||||
UIViewController* base_view_controller_;
|
||||
std::unique_ptr<TestChromeBrowserState> chrome_browser_state_;
|
||||
std::unique_ptr<TestChromeBrowserStateManager> browser_state_manager_;
|
||||
std::unique_ptr<TestBrowser> browser_;
|
||||
SceneState* scene_state_;
|
||||
};
|
||||
|
@ -39,6 +39,7 @@
|
||||
#import "ios/chrome/browser/shared/coordinator/scene/scene_state.h"
|
||||
#import "ios/chrome/browser/shared/model/browser/test/test_browser.h"
|
||||
#import "ios/chrome/browser/shared/model/browser_state/test_chrome_browser_state.h"
|
||||
#import "ios/chrome/browser/shared/model/browser_state/test_chrome_browser_state_manager.h"
|
||||
#import "ios/chrome/browser/shared/model/web_state_list/web_state_list.h"
|
||||
#import "ios/chrome/browser/shared/model/web_state_list/web_state_opener.h"
|
||||
#import "ios/chrome/browser/shared/public/commands/activity_service_commands.h"
|
||||
@ -76,6 +77,7 @@
|
||||
#import "ios/chrome/browser/web_state_list/model/web_usage_enabler/web_usage_enabler_browser_agent.h"
|
||||
#import "ios/chrome/test/block_cleanup_test.h"
|
||||
#import "ios/chrome/test/ios_chrome_scoped_testing_local_state.h"
|
||||
#import "ios/chrome/test/testing_application_context.h"
|
||||
#import "ios/web/public/test/fakes/fake_web_state.h"
|
||||
#import "ios/web/public/test/web_task_environment.h"
|
||||
#import "ios/web/public/web_state.h"
|
||||
@ -128,13 +130,17 @@ class BrowserViewControllerTest : public BlockCleanupTest {
|
||||
segmentation_platform::SegmentationPlatformServiceFactory::
|
||||
GetDefaultFactory());
|
||||
|
||||
chrome_browser_state_ = test_cbs_builder.Build();
|
||||
browser_state_manager_ = std::make_unique<TestChromeBrowserStateManager>(
|
||||
test_cbs_builder.Build());
|
||||
|
||||
TestingApplicationContext::GetGlobal()->SetChromeBrowserStateManager(
|
||||
browser_state_manager_.get());
|
||||
|
||||
AuthenticationServiceFactory::CreateAndInitializeForBrowserState(
|
||||
chrome_browser_state_.get(),
|
||||
GetBrowserState(),
|
||||
std::make_unique<FakeAuthenticationServiceDelegate>());
|
||||
|
||||
browser_ = std::make_unique<TestBrowser>(chrome_browser_state_.get(),
|
||||
scene_state_);
|
||||
browser_ = std::make_unique<TestBrowser>(GetBrowserState(), scene_state_);
|
||||
WebUsageEnablerBrowserAgent::CreateForBrowser(browser_.get());
|
||||
UrlLoadingNotifierBrowserAgent::CreateForBrowser(browser_.get());
|
||||
LensBrowserAgent::CreateForBrowser(browser_.get());
|
||||
@ -198,7 +204,7 @@ class BrowserViewControllerTest : public BlockCleanupTest {
|
||||
|
||||
// Create three web states.
|
||||
for (int i = 0; i < 3; i++) {
|
||||
web::WebState::CreateParams params(chrome_browser_state_.get());
|
||||
web::WebState::CreateParams params(GetBrowserState());
|
||||
std::unique_ptr<web::WebState> webState = web::WebState::Create(params);
|
||||
AttachTabHelpers(webState.get());
|
||||
browser_->GetWebStateList()->InsertWebState(std::move(webState));
|
||||
@ -207,8 +213,7 @@ class BrowserViewControllerTest : public BlockCleanupTest {
|
||||
|
||||
// Load TemplateURLService.
|
||||
TemplateURLService* template_url_service =
|
||||
ios::TemplateURLServiceFactory::GetForBrowserState(
|
||||
chrome_browser_state_.get());
|
||||
ios::TemplateURLServiceFactory::GetForBrowserState(GetBrowserState());
|
||||
template_url_service->Load();
|
||||
|
||||
ClipboardRecentContent::SetInstance(
|
||||
@ -226,10 +231,10 @@ class BrowserViewControllerTest : public BlockCleanupTest {
|
||||
|
||||
feature_engagement::Tracker* tracker =
|
||||
feature_engagement::TrackerFactory::GetForBrowserState(
|
||||
chrome_browser_state_.get());
|
||||
GetBrowserState());
|
||||
HostContentSettingsMap* settings_map =
|
||||
ios::HostContentSettingsMapFactory::GetForBrowserState(
|
||||
chrome_browser_state_.get());
|
||||
GetBrowserState());
|
||||
|
||||
bubble_presenter_ = [[BubblePresenter alloc]
|
||||
initWithDeviceSwitcherResultDispatcher:nullptr
|
||||
@ -303,7 +308,7 @@ class BrowserViewControllerTest : public BlockCleanupTest {
|
||||
tab_events_mediator_ = [[TabEventsMediator alloc]
|
||||
initWithWebStateList:browser_.get()->GetWebStateList()
|
||||
ntpCoordinator:NTPCoordinator_
|
||||
browserState:chrome_browser_state_.get()
|
||||
browserState:GetBrowserState()
|
||||
loadingNotifier:url_loading_notifier];
|
||||
tab_events_mediator_.consumer = bvc_;
|
||||
|
||||
@ -330,6 +335,18 @@ class BrowserViewControllerTest : public BlockCleanupTest {
|
||||
BlockCleanupTest::TearDown();
|
||||
}
|
||||
|
||||
ChromeBrowserState* GetBrowserState() {
|
||||
return browser_state_manager_->GetLastUsedBrowserStateForTesting();
|
||||
}
|
||||
|
||||
TestChromeBrowserState* GetTestBrowserState() {
|
||||
TestChromeBrowserState* test_chrome_browser_state =
|
||||
static_cast<TestChromeBrowserState*>(GetBrowserState());
|
||||
EXPECT_NE(test_chrome_browser_state, nullptr);
|
||||
|
||||
return test_chrome_browser_state;
|
||||
}
|
||||
|
||||
web::WebState* ActiveWebState() {
|
||||
return browser_->GetWebStateList()->GetActiveWebState();
|
||||
}
|
||||
@ -342,7 +359,7 @@ class BrowserViewControllerTest : public BlockCleanupTest {
|
||||
}
|
||||
|
||||
std::unique_ptr<web::WebState> CreateWebState() {
|
||||
web::WebState::CreateParams params(chrome_browser_state_.get());
|
||||
web::WebState::CreateParams params(GetBrowserState());
|
||||
auto web_state = web::WebState::Create(params);
|
||||
AttachTabHelpers(web_state.get());
|
||||
return web_state;
|
||||
@ -350,7 +367,7 @@ class BrowserViewControllerTest : public BlockCleanupTest {
|
||||
|
||||
std::unique_ptr<web::WebState> CreateOffTheRecordWebState() {
|
||||
web::WebState::CreateParams params(
|
||||
chrome_browser_state_
|
||||
GetTestBrowserState()
|
||||
->CreateOffTheRecordBrowserStateWithTestingFactories());
|
||||
auto web_state = web::WebState::Create(params);
|
||||
AttachTabHelpers(web_state.get());
|
||||
@ -397,8 +414,7 @@ class BrowserViewControllerTest : public BlockCleanupTest {
|
||||
MOCK_METHOD0(OnCompletionCalled, void());
|
||||
|
||||
web::WebTaskEnvironment task_environment_;
|
||||
IOSChromeScopedTestingLocalState local_state_;
|
||||
std::unique_ptr<TestChromeBrowserState> chrome_browser_state_;
|
||||
std::unique_ptr<TestChromeBrowserStateManager> browser_state_manager_;
|
||||
std::unique_ptr<Browser> browser_;
|
||||
KeyCommandsProvider* key_commands_provider_;
|
||||
BubblePresenter* bubble_presenter_;
|
||||
|
@ -104,6 +104,10 @@ IOSChromePasswordCheckManager::IOSChromePasswordCheckManager(
|
||||
}
|
||||
|
||||
IOSChromePasswordCheckManager::~IOSChromePasswordCheckManager() {
|
||||
for (auto& observer : observers_) {
|
||||
observer.ManagerWillShutdown(this);
|
||||
}
|
||||
|
||||
DCHECK(observers_.empty());
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,8 @@ source_set("model") {
|
||||
"//components/version_info",
|
||||
"//ios/chrome/browser/omaha/model",
|
||||
"//ios/chrome/browser/passwords/model:password_checkup_utils",
|
||||
"//ios/chrome/browser/shared/model/application_context",
|
||||
"//ios/chrome/browser/shared/model/browser_state",
|
||||
"//ios/chrome/browser/shared/model/prefs:pref_names",
|
||||
"//ios/chrome/browser/ui/content_suggestions:constants",
|
||||
"//ios/chrome/browser/ui/ntp/metrics:home_metrics",
|
||||
@ -90,6 +92,7 @@ source_set("unit_tests") {
|
||||
"//components/prefs",
|
||||
"//components/prefs:test_support",
|
||||
"//components/safe_browsing/core/common:safe_browsing_prefs",
|
||||
"//ios/chrome/browser/browser_state/model",
|
||||
"//ios/chrome/browser/passwords/model",
|
||||
"//ios/chrome/browser/passwords/model:password_checkup_utils",
|
||||
"//ios/chrome/browser/shared/model/browser_state:test_support",
|
||||
|
@ -9,7 +9,6 @@
|
||||
#import "base/memory/weak_ptr.h"
|
||||
#import "base/observer_list.h"
|
||||
#import "base/observer_list_types.h"
|
||||
#import "base/scoped_observation.h"
|
||||
#import "base/sequence_checker.h"
|
||||
#import "base/task/sequenced_task_runner.h"
|
||||
#import "components/keyed_service/core/keyed_service.h"
|
||||
@ -68,7 +67,6 @@ class IOSChromeSafetyCheckManager
|
||||
explicit IOSChromeSafetyCheckManager(
|
||||
PrefService* pref_service,
|
||||
PrefService* local_pref_service,
|
||||
scoped_refptr<IOSChromePasswordCheckManager> password_check_manager,
|
||||
const scoped_refptr<base::SequencedTaskRunner> task_runner);
|
||||
|
||||
IOSChromeSafetyCheckManager(const IOSChromeSafetyCheckManager&) = delete;
|
||||
@ -346,14 +344,6 @@ class IOSChromeSafetyCheckManager
|
||||
// Registrar for pref changes notifications.
|
||||
PrefChangeRegistrar pref_change_registrar_;
|
||||
|
||||
// Owning, smart pointer to the Password Check Manager, which checks the
|
||||
// user's Passwords (e.g. insecure credentials) state.
|
||||
const scoped_refptr<IOSChromePasswordCheckManager> password_check_manager_;
|
||||
|
||||
base::ScopedObservation<IOSChromePasswordCheckManager,
|
||||
IOSChromePasswordCheckManager::Observer>
|
||||
password_check_manager_observation_{this};
|
||||
|
||||
// Validates IOSChromeSafetyCheckManager::Observer events are evaluated on the
|
||||
// same sequence that IOSChromeSafetyCheckManager was created on.
|
||||
SEQUENCE_CHECKER(sequence_checker_);
|
||||
|
@ -17,7 +17,11 @@
|
||||
#import "components/safe_browsing/core/common/safe_browsing_prefs.h"
|
||||
#import "components/version_info/version_info.h"
|
||||
#import "ios/chrome/browser/omaha/model/omaha_service.h"
|
||||
#import "ios/chrome/browser/passwords/model/ios_chrome_password_check_manager_factory.h"
|
||||
#import "ios/chrome/browser/safety_check/model/ios_chrome_safety_check_manager_utils.h"
|
||||
#import "ios/chrome/browser/shared/model/application_context/application_context.h"
|
||||
#import "ios/chrome/browser/shared/model/browser_state/chrome_browser_state.h"
|
||||
#import "ios/chrome/browser/shared/model/browser_state/chrome_browser_state_manager.h"
|
||||
#import "ios/chrome/browser/shared/model/prefs/pref_names.h"
|
||||
#import "ios/chrome/browser/ui/content_suggestions/content_suggestions_constants.h"
|
||||
#import "ios/chrome/browser/ui/ntp/metrics/home_metrics.h"
|
||||
@ -25,21 +29,41 @@
|
||||
#import "ios/chrome/browser/upgrade/model/upgrade_utils.h"
|
||||
#import "ios/chrome/common/channel_info.h"
|
||||
|
||||
namespace {
|
||||
|
||||
// Returns the `IOSChromePasswordCheckManager` for the last used browser state.
|
||||
|
||||
// TODO(crbug.com/349805178): When multi-profile support is added to
|
||||
// Safety Check and Password Check views, refactor to iterate over all
|
||||
// profiles and aggregate results.
|
||||
scoped_refptr<IOSChromePasswordCheckManager>
|
||||
GetPasswordCheckManagerForLastUsedBrowserState() {
|
||||
ChromeBrowserState* last_used_browser_state =
|
||||
GetApplicationContext()
|
||||
->GetChromeBrowserStateManager()
|
||||
->GetLastUsedBrowserStateDeprecatedDoNotUse();
|
||||
|
||||
return IOSChromePasswordCheckManagerFactory::GetForBrowserState(
|
||||
last_used_browser_state);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
IOSChromeSafetyCheckManager::IOSChromeSafetyCheckManager(
|
||||
PrefService* pref_service,
|
||||
PrefService* local_pref_service,
|
||||
scoped_refptr<IOSChromePasswordCheckManager> password_check_manager,
|
||||
const scoped_refptr<base::SequencedTaskRunner> task_runner)
|
||||
: pref_service_(pref_service),
|
||||
local_pref_service_(local_pref_service),
|
||||
password_check_manager_(password_check_manager),
|
||||
task_runner_(task_runner) {
|
||||
CHECK(pref_service_);
|
||||
CHECK(local_pref_service_);
|
||||
CHECK(password_check_manager_);
|
||||
CHECK(task_runner_);
|
||||
|
||||
password_check_manager_observation_.Observe(password_check_manager.get());
|
||||
scoped_refptr<IOSChromePasswordCheckManager> password_check_manager =
|
||||
GetPasswordCheckManagerForLastUsedBrowserState();
|
||||
|
||||
password_check_manager->AddObserver(this);
|
||||
|
||||
pref_change_registrar_.Init(pref_service);
|
||||
|
||||
@ -74,7 +98,11 @@ void IOSChromeSafetyCheckManager::Shutdown() {
|
||||
pref_change_registrar_.RemoveAll();
|
||||
pref_service_ = nullptr;
|
||||
local_pref_service_ = nullptr;
|
||||
password_check_manager_observation_.Reset();
|
||||
|
||||
// Confirm that `IOSChromeSafetyCheckManager` is not observing any other
|
||||
// services, particularly `IOSChromePasswordCheckManager`. This ensures safe
|
||||
// destruction of `IOSChromeSafetyCheckManager`.
|
||||
CHECK(!IsInObserverList());
|
||||
}
|
||||
|
||||
void IOSChromeSafetyCheckManager::StartSafetyCheck() {
|
||||
@ -163,7 +191,10 @@ void IOSChromeSafetyCheckManager::StartPasswordCheck() {
|
||||
|
||||
previous_insecure_password_counts_ = insecure_password_counts_;
|
||||
|
||||
password_check_manager_->StartPasswordCheck(
|
||||
scoped_refptr<IOSChromePasswordCheckManager> password_check_manager =
|
||||
GetPasswordCheckManagerForLastUsedBrowserState();
|
||||
|
||||
password_check_manager->StartPasswordCheck(
|
||||
password_manager::LeakDetectionInitiator::kIosProactivePasswordCheckup);
|
||||
|
||||
// NOTE: There's no need to explicitly set `password_check_state_` to
|
||||
@ -187,7 +218,10 @@ void IOSChromeSafetyCheckManager::StopPasswordCheck() {
|
||||
|
||||
ignore_password_check_changes_ = true;
|
||||
|
||||
password_check_manager_->StopPasswordCheck();
|
||||
scoped_refptr<IOSChromePasswordCheckManager> password_check_manager =
|
||||
GetPasswordCheckManagerForLastUsedBrowserState();
|
||||
|
||||
password_check_manager->StopPasswordCheck();
|
||||
}
|
||||
|
||||
void IOSChromeSafetyCheckManager::StartUpdateChromeCheck() {
|
||||
@ -238,7 +272,6 @@ void IOSChromeSafetyCheckManager::InsecureCredentialsChanged() {
|
||||
|
||||
void IOSChromeSafetyCheckManager::ManagerWillShutdown(
|
||||
IOSChromePasswordCheckManager* password_check_manager) {
|
||||
password_check_manager_observation_.Reset();
|
||||
password_check_manager->RemoveObserver(this);
|
||||
}
|
||||
|
||||
@ -275,7 +308,11 @@ const GURL& IOSChromeSafetyCheckManager::GetChromeAppUpgradeUrl() const {
|
||||
std::vector<password_manager::CredentialUIEntry>
|
||||
IOSChromeSafetyCheckManager::GetInsecureCredentials() const {
|
||||
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
|
||||
return password_check_manager_->GetInsecureCredentials();
|
||||
|
||||
scoped_refptr<IOSChromePasswordCheckManager> password_check_manager =
|
||||
GetPasswordCheckManagerForLastUsedBrowserState();
|
||||
|
||||
return password_check_manager->GetInsecureCredentials();
|
||||
}
|
||||
|
||||
base::Time IOSChromeSafetyCheckManager::GetLastSafetyCheckRunTime() const {
|
||||
@ -327,8 +364,11 @@ void IOSChromeSafetyCheckManager::ConvertAndSetPasswordCheckState(
|
||||
SetUpdateChromeCheckState(UpdateChromeSafetyCheckState::kNetError);
|
||||
}
|
||||
|
||||
scoped_refptr<IOSChromePasswordCheckManager> password_check_manager =
|
||||
GetPasswordCheckManagerForLastUsedBrowserState();
|
||||
|
||||
const std::vector<password_manager::CredentialUIEntry> insecure_credentials =
|
||||
password_check_manager_->GetInsecureCredentials();
|
||||
password_check_manager->GetInsecureCredentials();
|
||||
|
||||
password_manager::InsecurePasswordCounts counts =
|
||||
password_manager::CountInsecurePasswordsPerInsecureType(
|
||||
@ -346,7 +386,10 @@ void IOSChromeSafetyCheckManager::ConvertAndSetPasswordCheckState(
|
||||
void IOSChromeSafetyCheckManager::RefreshOutdatedPasswordCheckState() {
|
||||
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
|
||||
|
||||
PasswordCheckState state = password_check_manager_->GetPasswordCheckState();
|
||||
scoped_refptr<IOSChromePasswordCheckManager> password_check_manager =
|
||||
GetPasswordCheckManagerForLastUsedBrowserState();
|
||||
|
||||
PasswordCheckState state = password_check_manager->GetPasswordCheckState();
|
||||
|
||||
// If the Password check reports the device is offline, propogate this
|
||||
// information to the Update Chrome check.
|
||||
@ -355,7 +398,7 @@ void IOSChromeSafetyCheckManager::RefreshOutdatedPasswordCheckState() {
|
||||
}
|
||||
|
||||
const std::vector<password_manager::CredentialUIEntry> insecure_credentials =
|
||||
password_check_manager_->GetInsecureCredentials();
|
||||
password_check_manager->GetInsecureCredentials();
|
||||
|
||||
password_manager::InsecurePasswordCounts counts =
|
||||
password_manager::CountInsecurePasswordsPerInsecureType(
|
||||
|
@ -9,8 +9,6 @@
|
||||
#import "components/keyed_service/core/keyed_service.h"
|
||||
#import "components/keyed_service/ios/browser_state_dependency_manager.h"
|
||||
#import "components/prefs/pref_service.h"
|
||||
#import "ios/chrome/browser/passwords/model/ios_chrome_password_check_manager.h"
|
||||
#import "ios/chrome/browser/passwords/model/ios_chrome_password_check_manager_factory.h"
|
||||
#import "ios/chrome/browser/safety_check/model/ios_chrome_safety_check_manager.h"
|
||||
#import "ios/chrome/browser/shared/model/application_context/application_context.h"
|
||||
#import "ios/chrome/browser/shared/model/browser_state/browser_state_otr_helper.h"
|
||||
@ -30,7 +28,6 @@ std::unique_ptr<KeyedService> BuildServiceInstance(web::BrowserState* context) {
|
||||
|
||||
return std::make_unique<IOSChromeSafetyCheckManager>(
|
||||
browser_state->GetPrefs(), GetApplicationContext()->GetLocalState(),
|
||||
IOSChromePasswordCheckManagerFactory::GetForBrowserState(browser_state),
|
||||
task_runner);
|
||||
}
|
||||
|
||||
@ -61,7 +58,6 @@ IOSChromeSafetyCheckManagerFactory::IOSChromeSafetyCheckManagerFactory()
|
||||
: BrowserStateKeyedServiceFactory(
|
||||
"SafetyCheckManager",
|
||||
BrowserStateDependencyManager::GetInstance()) {
|
||||
DependsOn(IOSChromePasswordCheckManagerFactory::GetInstance());
|
||||
}
|
||||
|
||||
IOSChromeSafetyCheckManagerFactory::~IOSChromeSafetyCheckManagerFactory() =
|
||||
|
@ -18,12 +18,12 @@
|
||||
#import "components/prefs/pref_service.h"
|
||||
#import "components/prefs/testing_pref_service.h"
|
||||
#import "components/safe_browsing/core/common/safe_browsing_prefs.h"
|
||||
#import "ios/chrome/browser/passwords/model/ios_chrome_password_check_manager_factory.h"
|
||||
#import "ios/chrome/browser/passwords/model/ios_chrome_profile_password_store_factory.h"
|
||||
#import "ios/chrome/browser/passwords/model/password_checkup_utils.h"
|
||||
#import "ios/chrome/browser/safety_check/model/ios_chrome_safety_check_manager_constants.h"
|
||||
#import "ios/chrome/browser/safety_check/model/ios_chrome_safety_check_manager_utils.h"
|
||||
#import "ios/chrome/browser/shared/model/browser_state/test_chrome_browser_state.h"
|
||||
#import "ios/chrome/browser/shared/model/browser_state/test_chrome_browser_state_manager.h"
|
||||
#import "ios/chrome/browser/shared/model/prefs/pref_names.h"
|
||||
#import "ios/chrome/browser/shared/public/features/features.h"
|
||||
#import "ios/chrome/browser/upgrade/model/upgrade_recommended_details.h"
|
||||
@ -37,36 +37,6 @@ namespace {
|
||||
class IOSChromeSafetyCheckManagerTest : public PlatformTest {
|
||||
public:
|
||||
void SetUp() override {
|
||||
pref_service_ = std::make_unique<TestingPrefServiceSimple>();
|
||||
PrefRegistrySimple* registry = pref_service_->registry();
|
||||
|
||||
registry->RegisterBooleanPref(prefs::kSafeBrowsingEnabled, false);
|
||||
registry->RegisterBooleanPref(prefs::kSafeBrowsingEnhanced, false);
|
||||
registry->RegisterStringPref(
|
||||
prefs::kIosSafetyCheckManagerPasswordCheckResult,
|
||||
NameForSafetyCheckState(PasswordSafetyCheckState::kDefault),
|
||||
PrefRegistry::LOSSY_PREF);
|
||||
registry->RegisterDictionaryPref(
|
||||
prefs::kIosSafetyCheckManagerInsecurePasswordCounts,
|
||||
PrefRegistry::LOSSY_PREF);
|
||||
|
||||
local_pref_service_ = std::make_unique<TestingPrefServiceSimple>();
|
||||
PrefRegistrySimple* local_registry = local_pref_service_->registry();
|
||||
|
||||
local_registry->RegisterTimePref(prefs::kIosSafetyCheckManagerLastRunTime,
|
||||
base::Time(), PrefRegistry::LOSSY_PREF);
|
||||
local_registry->RegisterStringPref(
|
||||
prefs::kIosSafetyCheckManagerUpdateCheckResult,
|
||||
NameForSafetyCheckState(UpdateChromeSafetyCheckState::kDefault),
|
||||
PrefRegistry::LOSSY_PREF);
|
||||
local_registry->RegisterStringPref(
|
||||
prefs::kIosSafetyCheckManagerSafeBrowsingCheckResult,
|
||||
NameForSafetyCheckState(SafeBrowsingSafetyCheckState::kDefault),
|
||||
PrefRegistry::LOSSY_PREF);
|
||||
local_registry->RegisterIntegerPref(
|
||||
prefs::kIosMagicStackSegmentationSafetyCheckImpressionsSinceFreshness,
|
||||
-1);
|
||||
|
||||
TestChromeBrowserState::Builder builder;
|
||||
|
||||
builder.AddTestingFactory(
|
||||
@ -75,34 +45,38 @@ class IOSChromeSafetyCheckManagerTest : public PlatformTest {
|
||||
&password_manager::BuildPasswordStore<
|
||||
web::BrowserState, password_manager::TestPasswordStore>));
|
||||
|
||||
browser_state_ = builder.Build();
|
||||
TestingApplicationContext::GetGlobal()->SetLocalState(
|
||||
local_pref_service_.get());
|
||||
browser_state_manager_ =
|
||||
std::make_unique<TestChromeBrowserStateManager>(builder.Build());
|
||||
|
||||
password_check_manager_ =
|
||||
IOSChromePasswordCheckManagerFactory::GetForBrowserState(
|
||||
browser_state_.get());
|
||||
TestingApplicationContext::GetGlobal()->SetChromeBrowserStateManager(
|
||||
browser_state_manager_.get());
|
||||
|
||||
ChromeBrowserState* browser_state =
|
||||
browser_state_manager_->GetLastUsedBrowserStateForTesting();
|
||||
|
||||
pref_service_ = browser_state->GetPrefs();
|
||||
|
||||
local_pref_service_ =
|
||||
TestingApplicationContext::GetGlobal()->GetLocalState();
|
||||
|
||||
safety_check_manager_ = std::make_unique<IOSChromeSafetyCheckManager>(
|
||||
pref_service_.get(), local_pref_service_.get(), password_check_manager_,
|
||||
pref_service_.get(), local_pref_service_.get(),
|
||||
base::SequencedTaskRunner::GetCurrentDefault());
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
safety_check_manager_->StopSafetyCheck();
|
||||
safety_check_manager_->Shutdown();
|
||||
TestingApplicationContext::GetGlobal()->SetLocalState(nullptr);
|
||||
}
|
||||
|
||||
protected:
|
||||
web::WebTaskEnvironment task_environment_{
|
||||
base::test::TaskEnvironment::TimeSource::MOCK_TIME};
|
||||
base::test::ScopedFeatureList feature_list_;
|
||||
std::unique_ptr<TestChromeBrowserState> browser_state_;
|
||||
std::unique_ptr<TestChromeBrowserStateManager> browser_state_manager_;
|
||||
std::unique_ptr<IOSChromeSafetyCheckManager> safety_check_manager_;
|
||||
scoped_refptr<IOSChromePasswordCheckManager> password_check_manager_;
|
||||
std::unique_ptr<TestingPrefServiceSimple> pref_service_;
|
||||
std::unique_ptr<TestingPrefServiceSimple> local_pref_service_;
|
||||
raw_ptr<PrefService> pref_service_;
|
||||
raw_ptr<PrefService> local_pref_service_;
|
||||
};
|
||||
|
||||
std::vector<password_manager::CredentialUIEntry>
|
||||
@ -191,27 +165,6 @@ TEST_F(IOSChromeSafetyCheckManagerTest,
|
||||
SafeBrowsingSafetyCheckState::kUnsafe);
|
||||
}
|
||||
|
||||
// Tests the Safe Browsing Check state is `kManaged` when Safe Browsing is
|
||||
// enabled, and managed.
|
||||
TEST_F(IOSChromeSafetyCheckManagerTest,
|
||||
SafeBrowsingManagedAndEnabledReturnsManagedState) {
|
||||
pref_service_->SetManagedPref(prefs::kSafeBrowsingEnabled, base::Value(true));
|
||||
|
||||
EXPECT_EQ(safety_check_manager_->GetSafeBrowsingCheckState(),
|
||||
SafeBrowsingSafetyCheckState::kManaged);
|
||||
}
|
||||
|
||||
// Tests the Safe Browsing Check state is `kManaged` when Safe Browsing is
|
||||
// disabled, and managed.
|
||||
TEST_F(IOSChromeSafetyCheckManagerTest,
|
||||
SafeBrowsingManagedAndDisabledReturnsManagedState) {
|
||||
pref_service_->SetManagedPref(prefs::kSafeBrowsingEnabled,
|
||||
base::Value(false));
|
||||
|
||||
EXPECT_EQ(safety_check_manager_->GetSafeBrowsingCheckState(),
|
||||
SafeBrowsingSafetyCheckState::kManaged);
|
||||
}
|
||||
|
||||
// Tests `CalculatePasswordSafetyCheckState()` correctly converts
|
||||
// PasswordCheckState::kRunning.
|
||||
TEST_F(IOSChromeSafetyCheckManagerTest, ConvertsPasswordCheckStateRunning) {
|
||||
@ -494,7 +447,7 @@ TEST_F(IOSChromeSafetyCheckManagerTest,
|
||||
EXPECT_EQ(safety_check_manager_->GetUpdateChromeCheckState(),
|
||||
UpdateChromeSafetyCheckState::kDefault);
|
||||
EXPECT_EQ(safety_check_manager_->GetPasswordCheckState(),
|
||||
PasswordSafetyCheckState::kDisabled);
|
||||
PasswordSafetyCheckState::kDefault);
|
||||
EXPECT_EQ(safety_check_manager_->GetSafeBrowsingCheckState(),
|
||||
SafeBrowsingSafetyCheckState::kSafe);
|
||||
EXPECT_EQ(safety_check_manager_->GetRunningCheckStateForTesting(),
|
||||
|
@ -31,6 +31,7 @@
|
||||
#import "ios/chrome/browser/shared/coordinator/scene/test/fake_scene_state.h"
|
||||
#import "ios/chrome/browser/shared/model/browser/test/test_browser.h"
|
||||
#import "ios/chrome/browser/shared/model/browser_state/test_chrome_browser_state.h"
|
||||
#import "ios/chrome/browser/shared/model/browser_state/test_chrome_browser_state_manager.h"
|
||||
#import "ios/chrome/browser/shared/public/features/features.h"
|
||||
#import "ios/chrome/browser/signin/model/authentication_service.h"
|
||||
#import "ios/chrome/browser/signin/model/authentication_service_factory.h"
|
||||
@ -62,6 +63,7 @@
|
||||
#import "ios/chrome/browser/url_loading/model/url_loading_notifier_browser_agent.h"
|
||||
#import "ios/chrome/test/ios_chrome_scoped_testing_local_state.h"
|
||||
#import "ios/chrome/test/ios_chrome_scoped_testing_variations_service.h"
|
||||
#import "ios/chrome/test/testing_application_context.h"
|
||||
#import "ios/web/public/test/web_task_environment.h"
|
||||
#import "testing/platform_test.h"
|
||||
#import "third_party/ocmock/OCMock/OCMock.h"
|
||||
@ -225,27 +227,36 @@ class MagicStackRankingModelTest : public PlatformTest {
|
||||
test_cbs_builder.AddTestingFactory(
|
||||
IOSChromeLargeIconServiceFactory::GetInstance(),
|
||||
IOSChromeLargeIconServiceFactory::GetDefaultFactory());
|
||||
chrome_browser_state_ = test_cbs_builder.Build();
|
||||
browser_ = std::make_unique<TestBrowser>(chrome_browser_state_.get());
|
||||
|
||||
browser_state_manager_ = std::make_unique<TestChromeBrowserStateManager>(
|
||||
test_cbs_builder.Build());
|
||||
|
||||
TestingApplicationContext::GetGlobal()->SetChromeBrowserStateManager(
|
||||
browser_state_manager_.get());
|
||||
|
||||
browser_ = std::make_unique<TestBrowser>(GetBrowserState());
|
||||
|
||||
local_state_ = TestingApplicationContext::GetGlobal()->GetLocalState();
|
||||
|
||||
// Necessary set up for kIOSSetUpList.
|
||||
local_state_.Get()->ClearPref(set_up_list_prefs::kDisabled);
|
||||
GetLocalState()->ClearPref(set_up_list_prefs::kDisabled);
|
||||
ClearDefaultBrowserPromoData();
|
||||
WriteFirstRunSentinel();
|
||||
|
||||
// Necessary set up for parcel tracking.
|
||||
scoped_variations_service_.Get()->OverrideStoredPermanentCountry("us");
|
||||
scoped_variations_service_ =
|
||||
std::make_unique<IOSChromeScopedTestingVariationsService>();
|
||||
scoped_variations_service_->Get()->OverrideStoredPermanentCountry("us");
|
||||
|
||||
AuthenticationServiceFactory::CreateAndInitializeForBrowserState(
|
||||
chrome_browser_state_.get(),
|
||||
GetBrowserState(),
|
||||
std::make_unique<FakeAuthenticationServiceDelegate>());
|
||||
syncer::SyncService* syncService =
|
||||
SyncServiceFactory::GetForBrowserState(chrome_browser_state_.get());
|
||||
SyncServiceFactory::GetForBrowserState(GetBrowserState());
|
||||
AuthenticationService* authenticationService =
|
||||
AuthenticationServiceFactory::GetForBrowserState(
|
||||
chrome_browser_state_.get());
|
||||
AuthenticationServiceFactory::GetForBrowserState(GetBrowserState());
|
||||
signin::IdentityManager* identityManager =
|
||||
IdentityManagerFactory::GetForBrowserState(chrome_browser_state_.get());
|
||||
IdentityManagerFactory::GetForBrowserState(GetBrowserState());
|
||||
|
||||
shopping_service_ = std::make_unique<commerce::MockShoppingService>();
|
||||
UrlLoadingNotifierBrowserAgent::CreateForBrowser(browser_.get());
|
||||
@ -255,20 +266,18 @@ class MagicStackRankingModelTest : public PlatformTest {
|
||||
StartSurfaceRecentTabBrowserAgent::CreateForBrowser(browser_.get());
|
||||
|
||||
ReadingListModel* readingListModel =
|
||||
ReadingListModelFactory::GetForBrowserState(
|
||||
chrome_browser_state_.get());
|
||||
ReadingListModelFactory::GetForBrowserState(GetBrowserState());
|
||||
feature_engagement::Tracker* tracker =
|
||||
feature_engagement::TrackerFactory::GetForBrowserState(
|
||||
chrome_browser_state_.get());
|
||||
GetBrowserState());
|
||||
AuthenticationService* authentication_service =
|
||||
AuthenticationServiceFactory::GetForBrowserState(
|
||||
chrome_browser_state_.get());
|
||||
AuthenticationServiceFactory::GetForBrowserState(GetBrowserState());
|
||||
_shortcutsMediator = [[ShortcutsMediator alloc]
|
||||
initWithReadingListModel:readingListModel
|
||||
featureEngagementTracker:(feature_engagement::Tracker*)tracker
|
||||
authService:authentication_service];
|
||||
_setUpListMediator = [[FakeSetUpListMediator alloc]
|
||||
initWithPrefService:chrome_browser_state_.get()->GetPrefs()
|
||||
initWithPrefService:GetBrowserState()->GetPrefs()
|
||||
syncService:syncService
|
||||
identityManager:identityManager
|
||||
authenticationService:authenticationService
|
||||
@ -279,15 +288,14 @@ class MagicStackRankingModelTest : public PlatformTest {
|
||||
initWithShoppingService:shopping_service_.get()
|
||||
URLLoadingBrowserAgent:url_loader_];
|
||||
_tabResumptionMediator = [[FakeTabResumptionMediator alloc]
|
||||
initWithLocalState:local_state_.Get()
|
||||
prefService:chrome_browser_state_.get()->GetPrefs()
|
||||
initWithLocalState:GetLocalState()
|
||||
prefService:GetBrowserState()->GetPrefs()
|
||||
identityManager:identityManager
|
||||
browser:browser_.get()];
|
||||
favicon::LargeIconService* large_icon_service =
|
||||
IOSChromeLargeIconServiceFactory::GetForBrowserState(
|
||||
chrome_browser_state_.get());
|
||||
LargeIconCache* cache = IOSChromeLargeIconCacheFactory::GetForBrowserState(
|
||||
chrome_browser_state_.get());
|
||||
IOSChromeLargeIconServiceFactory::GetForBrowserState(GetBrowserState());
|
||||
LargeIconCache* cache =
|
||||
IOSChromeLargeIconCacheFactory::GetForBrowserState(GetBrowserState());
|
||||
std::unique_ptr<ntp_tiles::MostVisitedSites> most_visited_sites =
|
||||
std::make_unique<ntp_tiles::MostVisitedSites>(
|
||||
&pref_service_, /*top_sites*/ nullptr, /*popular_sites*/ nullptr,
|
||||
@ -295,7 +303,7 @@ class MagicStackRankingModelTest : public PlatformTest {
|
||||
/*supervisor=*/nullptr, true);
|
||||
_mostVisitedTilesMediator = [[FakeMostVisitedTilesMediator alloc]
|
||||
initWithMostVisitedSite:std::move(most_visited_sites)
|
||||
prefService:chrome_browser_state_.get()->GetPrefs()
|
||||
prefService:GetBrowserState()->GetPrefs()
|
||||
largeIconService:large_icon_service
|
||||
largeIconCache:cache
|
||||
URLLoadingBrowserAgent:url_loader_];
|
||||
@ -304,17 +312,16 @@ class MagicStackRankingModelTest : public PlatformTest {
|
||||
|
||||
_safetyCheckMediator = [[SafetyCheckMagicStackMediator alloc]
|
||||
initWithSafetyCheckManager:IOSChromeSafetyCheckManagerFactory::
|
||||
GetForBrowserState(
|
||||
chrome_browser_state_.get())
|
||||
localState:local_state_.Get()
|
||||
GetForBrowserState(GetBrowserState())
|
||||
localState:GetLocalState()
|
||||
appState:mockAppState];
|
||||
|
||||
_magicStackRankingModel = [[MagicStackRankingModel alloc]
|
||||
initWithSegmentationService:
|
||||
segmentation_platform::SegmentationPlatformServiceFactory::
|
||||
GetForBrowserState(chrome_browser_state_.get())
|
||||
prefService:chrome_browser_state_.get()->GetPrefs()
|
||||
localState:local_state_.Get()
|
||||
GetForBrowserState(GetBrowserState())
|
||||
prefService:GetBrowserState()->GetPrefs()
|
||||
localState:GetLocalState()
|
||||
moduleMediators:@[
|
||||
_shortcutsMediator,
|
||||
_setUpListMediator,
|
||||
@ -325,7 +332,7 @@ class MagicStackRankingModelTest : public PlatformTest {
|
||||
]];
|
||||
|
||||
metrics_recorder_ = [[ContentSuggestionsMetricsRecorder alloc]
|
||||
initWithLocalState:local_state_.Get()];
|
||||
initWithLocalState:GetLocalState()];
|
||||
_magicStackRankingModel.contentSuggestionsMetricsRecorder =
|
||||
metrics_recorder_;
|
||||
_setUpListMediator.contentSuggestionsMetricsRecorder = metrics_recorder_;
|
||||
@ -333,6 +340,12 @@ class MagicStackRankingModelTest : public PlatformTest {
|
||||
histogram_tester_ = std::make_unique<base::HistogramTester>();
|
||||
}
|
||||
|
||||
ChromeBrowserState* GetBrowserState() {
|
||||
return browser_state_manager_->GetLastUsedBrowserStateForTesting();
|
||||
}
|
||||
|
||||
PrefService* GetLocalState() { return local_state_; }
|
||||
|
||||
~MagicStackRankingModelTest() override {
|
||||
[_setUpListMediator disconnect];
|
||||
[_tabResumptionMediator disconnect];
|
||||
@ -356,20 +369,22 @@ class MagicStackRankingModelTest : public PlatformTest {
|
||||
<< base::File::ErrorToString(file_error);
|
||||
FirstRun::LoadSentinelInfo();
|
||||
FirstRun::ClearStateForTesting();
|
||||
EXPECT_FALSE(set_up_list_prefs::IsSetUpListDisabled(local_state_.Get()));
|
||||
EXPECT_FALSE(set_up_list_prefs::IsSetUpListDisabled(GetLocalState()));
|
||||
EXPECT_FALSE(FirstRun::IsChromeFirstRun());
|
||||
EXPECT_TRUE(set_up_list_utils::IsSetUpListActive(local_state_.Get()));
|
||||
EXPECT_TRUE(set_up_list_utils::IsSetUpListActive(GetLocalState()));
|
||||
}
|
||||
|
||||
web::WebTaskEnvironment task_environment_;
|
||||
base::test::ScopedFeatureList scoped_feature_list_;
|
||||
std::unique_ptr<TestChromeBrowserStateManager> browser_state_manager_;
|
||||
sync_preferences::TestingPrefServiceSyncable pref_service_;
|
||||
IOSChromeScopedTestingLocalState local_state_;
|
||||
raw_ptr<PrefService> local_state_;
|
||||
FakeSceneState* scene_state_;
|
||||
std::unique_ptr<TestChromeBrowserState> chrome_browser_state_;
|
||||
std::unique_ptr<Browser> browser_;
|
||||
FakeUrlLoadingBrowserAgent* url_loader_;
|
||||
IOSChromeScopedTestingVariationsService scoped_variations_service_;
|
||||
std::unique_ptr<IOSChromeScopedTestingVariationsService>
|
||||
scoped_variations_service_;
|
||||
std::unique_ptr<commerce::MockShoppingService> shopping_service_;
|
||||
FakeSetUpListMediator* _setUpListMediator;
|
||||
FakeParcelTrackingMediator* _parcelTrackingMediator;
|
||||
@ -391,17 +406,17 @@ TEST_F(MagicStackRankingModelTest, TestSetUpListConsumerCall) {
|
||||
OCMExpect([setUpListConsumer_ setUpListItemDidComplete:[OCMArg any]
|
||||
allItemsCompleted:NO
|
||||
completion:[OCMArg any]]);
|
||||
set_up_list_prefs::MarkItemComplete(local_state_.Get(),
|
||||
set_up_list_prefs::MarkItemComplete(GetLocalState(),
|
||||
SetUpListItemType::kSignInSync);
|
||||
OCMExpect([setUpListConsumer_ setUpListItemDidComplete:[OCMArg any]
|
||||
allItemsCompleted:NO
|
||||
completion:[OCMArg any]]);
|
||||
set_up_list_prefs::MarkItemComplete(local_state_.Get(),
|
||||
set_up_list_prefs::MarkItemComplete(GetLocalState(),
|
||||
SetUpListItemType::kDefaultBrowser);
|
||||
OCMExpect([setUpListConsumer_ setUpListItemDidComplete:[OCMArg any]
|
||||
allItemsCompleted:YES
|
||||
completion:[OCMArg any]]);
|
||||
set_up_list_prefs::MarkItemComplete(local_state_.Get(),
|
||||
set_up_list_prefs::MarkItemComplete(GetLocalState(),
|
||||
SetUpListItemType::kAutofill);
|
||||
EXPECT_OCMOCK_VERIFY(setUpListConsumer_);
|
||||
}
|
||||
@ -441,14 +456,13 @@ TEST_F(MagicStackRankingModelTest, TestMetricsWithoutSetUpList) {
|
||||
TEST_F(MagicStackRankingModelTest, TestOnServiceStatusChanged) {
|
||||
// Verify the initial state.
|
||||
SetUpListItemState item_state = set_up_list_prefs::GetItemState(
|
||||
local_state_.Get(), SetUpListItemType::kSignInSync);
|
||||
GetLocalState(), SetUpListItemType::kSignInSync);
|
||||
EXPECT_EQ(item_state, SetUpListItemState::kNotComplete);
|
||||
|
||||
// Simulate the user disabling signin.
|
||||
chrome_browser_state_.get()->GetPrefs()->SetBoolean(prefs::kSigninAllowed,
|
||||
false);
|
||||
GetBrowserState()->GetPrefs()->SetBoolean(prefs::kSigninAllowed, false);
|
||||
// Verify that the signin item is complete.
|
||||
item_state = set_up_list_prefs::GetItemState(local_state_.Get(),
|
||||
item_state = set_up_list_prefs::GetItemState(GetLocalState(),
|
||||
SetUpListItemType::kSignInSync);
|
||||
EXPECT_EQ(item_state, SetUpListItemState::kCompleteInList);
|
||||
}
|
||||
|
@ -117,10 +117,6 @@ source_set("eg2_tests") {
|
||||
"//ios/chrome/browser/shared/public/features",
|
||||
"//ios/chrome/browser/ui/content_suggestions:constants",
|
||||
"//ios/chrome/browser/ui/content_suggestions:eg_test_support+eg2",
|
||||
"//ios/chrome/browser/ui/settings/password:eg_test_support",
|
||||
"//ios/chrome/browser/ui/settings/password:eg_test_support+eg2",
|
||||
"//ios/chrome/browser/ui/settings/password:features",
|
||||
"//ios/chrome/browser/ui/settings/password/password_checkup:password_checkup_constants",
|
||||
"//ios/chrome/test/earl_grey:eg_test_support+eg2",
|
||||
"//ios/testing/earl_grey:eg_test_support+eg2",
|
||||
"//ui/base",
|
||||
|
64
ios/chrome/browser/ui/content_suggestions/safety_check/safety_check_magic_stack_mediator_unittest.mm
64
ios/chrome/browser/ui/content_suggestions/safety_check/safety_check_magic_stack_mediator_unittest.mm
@ -16,6 +16,7 @@
|
||||
#import "ios/chrome/browser/safety_check/model/ios_chrome_safety_check_manager.h"
|
||||
#import "ios/chrome/browser/safety_check/model/ios_chrome_safety_check_manager_constants.h"
|
||||
#import "ios/chrome/browser/shared/model/browser_state/test_chrome_browser_state.h"
|
||||
#import "ios/chrome/browser/shared/model/browser_state/test_chrome_browser_state_manager.h"
|
||||
#import "ios/chrome/browser/shared/model/prefs/pref_names.h"
|
||||
#import "ios/chrome/browser/ui/content_suggestions/content_suggestions_consumer.h"
|
||||
#import "ios/chrome/browser/ui/content_suggestions/safety_check/safety_check_magic_stack_consumer.h"
|
||||
@ -39,40 +40,6 @@
|
||||
class SafetyCheckMagicStackMediatorTest : public PlatformTest {
|
||||
public:
|
||||
void SetUp() override {
|
||||
pref_service_ = std::make_unique<TestingPrefServiceSimple>();
|
||||
PrefRegistrySimple* registry = pref_service_->registry();
|
||||
|
||||
registry->RegisterBooleanPref(prefs::kSafeBrowsingEnabled, false);
|
||||
registry->RegisterBooleanPref(prefs::kSafeBrowsingEnhanced, false);
|
||||
registry->RegisterStringPref(
|
||||
prefs::kIosSafetyCheckManagerPasswordCheckResult,
|
||||
NameForSafetyCheckState(PasswordSafetyCheckState::kDefault),
|
||||
PrefRegistry::LOSSY_PREF);
|
||||
registry->RegisterDictionaryPref(
|
||||
prefs::kIosSafetyCheckManagerInsecurePasswordCounts,
|
||||
PrefRegistry::LOSSY_PREF);
|
||||
|
||||
local_pref_service_ = std::make_unique<TestingPrefServiceSimple>();
|
||||
PrefRegistrySimple* local_registry = local_pref_service_->registry();
|
||||
|
||||
local_registry->RegisterTimePref(prefs::kIosSafetyCheckManagerLastRunTime,
|
||||
base::Time(), PrefRegistry::LOSSY_PREF);
|
||||
local_registry->RegisterStringPref(
|
||||
prefs::kIosSafetyCheckManagerUpdateCheckResult,
|
||||
NameForSafetyCheckState(UpdateChromeSafetyCheckState::kDefault),
|
||||
PrefRegistry::LOSSY_PREF);
|
||||
local_registry->RegisterStringPref(
|
||||
prefs::kIosSafetyCheckManagerSafeBrowsingCheckResult,
|
||||
NameForSafetyCheckState(SafeBrowsingSafetyCheckState::kDefault),
|
||||
PrefRegistry::LOSSY_PREF);
|
||||
local_registry->RegisterIntegerPref(
|
||||
prefs::kIosMagicStackSegmentationSafetyCheckImpressionsSinceFreshness,
|
||||
-1);
|
||||
local_registry->RegisterBooleanPref(
|
||||
safety_check_prefs::kSafetyCheckInMagicStackDisabledPref, false);
|
||||
local_registry->RegisterTimePref(prefs::kIosSettingsSafetyCheckLastRunTime,
|
||||
base::Time());
|
||||
|
||||
TestChromeBrowserState::Builder builder;
|
||||
|
||||
builder.AddTestingFactory(
|
||||
@ -81,17 +48,22 @@ class SafetyCheckMagicStackMediatorTest : public PlatformTest {
|
||||
&password_manager::BuildPasswordStore<
|
||||
web::BrowserState, password_manager::TestPasswordStore>));
|
||||
|
||||
browser_state_ = builder.Build();
|
||||
browser_state_manager_ =
|
||||
std::make_unique<TestChromeBrowserStateManager>(builder.Build());
|
||||
|
||||
TestingApplicationContext::GetGlobal()->SetLocalState(
|
||||
local_pref_service_.get());
|
||||
TestingApplicationContext::GetGlobal()->SetChromeBrowserStateManager(
|
||||
browser_state_manager_.get());
|
||||
|
||||
password_check_manager_ =
|
||||
IOSChromePasswordCheckManagerFactory::GetForBrowserState(
|
||||
browser_state_.get());
|
||||
ChromeBrowserState* browser_state =
|
||||
browser_state_manager_->GetLastUsedBrowserStateForTesting();
|
||||
|
||||
pref_service_ = browser_state->GetPrefs();
|
||||
|
||||
local_pref_service_ =
|
||||
TestingApplicationContext::GetGlobal()->GetLocalState();
|
||||
|
||||
safety_check_manager_ = std::make_unique<IOSChromeSafetyCheckManager>(
|
||||
pref_service_.get(), local_pref_service_.get(), password_check_manager_,
|
||||
pref_service_.get(), local_pref_service_.get(),
|
||||
base::SequencedTaskRunner::GetCurrentDefault());
|
||||
|
||||
mock_app_state_ = OCMClassMock([AppState class]);
|
||||
@ -109,19 +81,17 @@ class SafetyCheckMagicStackMediatorTest : public PlatformTest {
|
||||
void TearDown() override {
|
||||
safety_check_manager_->StopSafetyCheck();
|
||||
safety_check_manager_->Shutdown();
|
||||
TestingApplicationContext::GetGlobal()->SetLocalState(nullptr);
|
||||
}
|
||||
|
||||
protected:
|
||||
web::WebTaskEnvironment task_environment_{
|
||||
base::test::TaskEnvironment::TimeSource::MOCK_TIME};
|
||||
id mock_app_state_;
|
||||
std::unique_ptr<TestChromeBrowserState> browser_state_;
|
||||
std::unique_ptr<TestingPrefServiceSimple> pref_service_;
|
||||
std::unique_ptr<TestingPrefServiceSimple> local_pref_service_;
|
||||
std::unique_ptr<TestChromeBrowserStateManager> browser_state_manager_;
|
||||
raw_ptr<PrefService> pref_service_;
|
||||
raw_ptr<PrefService> local_pref_service_;
|
||||
SafetyCheckMagicStackMediator* mediator_;
|
||||
id safety_check_magic_stack_consumer_;
|
||||
scoped_refptr<IOSChromePasswordCheckManager> password_check_manager_;
|
||||
std::unique_ptr<IOSChromeSafetyCheckManager> safety_check_manager_;
|
||||
};
|
||||
|
||||
@ -131,7 +101,7 @@ TEST_F(SafetyCheckMagicStackMediatorTest, CallsConsumerWithRunningState) {
|
||||
SafetyCheckState* expected = [[SafetyCheckState alloc]
|
||||
initWithUpdateChromeState:UpdateChromeSafetyCheckState::kRunning
|
||||
passwordState:PasswordSafetyCheckState::kDefault
|
||||
safeBrowsingState:SafeBrowsingSafetyCheckState::kUnsafe
|
||||
safeBrowsingState:SafeBrowsingSafetyCheckState::kSafe
|
||||
runningState:RunningSafetyCheckState::kRunning];
|
||||
|
||||
OCMExpect([safety_check_magic_stack_consumer_
|
||||
|
@ -9,10 +9,6 @@
|
||||
#import "ios/chrome/browser/ui/content_suggestions/new_tab_page_app_interface.h"
|
||||
#import "ios/chrome/browser/ui/content_suggestions/safety_check/constants.h"
|
||||
#import "ios/chrome/browser/ui/content_suggestions/safety_check/safety_check_prefs.h"
|
||||
#import "ios/chrome/browser/ui/settings/password/password_checkup/password_checkup_constants.h"
|
||||
#import "ios/chrome/browser/ui/settings/password/password_manager_egtest_utils.h"
|
||||
#import "ios/chrome/browser/ui/settings/password/password_manager_ui_features.h"
|
||||
#import "ios/chrome/browser/ui/settings/password/password_settings_app_interface.h"
|
||||
#import "ios/chrome/grit/ios_strings.h"
|
||||
#import "ios/chrome/test/earl_grey/chrome_earl_grey.h"
|
||||
#import "ios/chrome/test/earl_grey/chrome_matchers.h"
|
||||
@ -23,9 +19,6 @@
|
||||
|
||||
namespace {
|
||||
|
||||
// The accessibility identifier of the Safety Check collection view.
|
||||
NSString* const kSafetyCheckTableViewId = @"kSafetyCheckTableViewId";
|
||||
|
||||
// Checks that the visibility of the Safety Check module matches `should_show`.
|
||||
void WaitUntilSafetyCheckModuleVisibleOrTimeout(bool should_show) {
|
||||
id<GREYMatcher> matcher =
|
||||
@ -65,10 +58,6 @@ void WaitUntilSafetyCheckModuleVisibleOrTimeout(bool should_show) {
|
||||
- (void)setUp {
|
||||
[super setUp];
|
||||
|
||||
// Mock local authentication for opening Password Checkup.
|
||||
[PasswordSettingsAppInterface setUpMockReauthenticationModule];
|
||||
[PasswordSettingsAppInterface mockReauthenticationModuleExpectedResult:
|
||||
ReauthenticationResult::kSuccess];
|
||||
[ChromeEarlGrey resetDataForLocalStatePref:
|
||||
safety_check_prefs::kSafetyCheckInMagicStackDisabledPref];
|
||||
[NewTabPageAppInterface disableSetUpList];
|
||||
@ -77,7 +66,6 @@ void WaitUntilSafetyCheckModuleVisibleOrTimeout(bool should_show) {
|
||||
}
|
||||
|
||||
- (void)tearDown {
|
||||
[PasswordSettingsAppInterface removeMockReauthenticationModule];
|
||||
[ChromeEarlGrey resetDataForLocalStatePref:
|
||||
safety_check_prefs::kSafetyCheckInMagicStackDisabledPref];
|
||||
[super tearDown];
|
||||
@ -86,8 +74,6 @@ void WaitUntilSafetyCheckModuleVisibleOrTimeout(bool should_show) {
|
||||
- (AppLaunchConfiguration)appConfigurationForTestCase {
|
||||
AppLaunchConfiguration config;
|
||||
config.features_enabled.push_back(kSafetyCheckMagicStack);
|
||||
config.features_enabled.push_back(
|
||||
password_manager::features::kIOSPasswordAuthOnEntryV2);
|
||||
config.additional_args.push_back("--test-ios-module-ranker=safety_check");
|
||||
|
||||
return config;
|
||||
@ -112,127 +98,4 @@ void WaitUntilSafetyCheckModuleVisibleOrTimeout(bool should_show) {
|
||||
WaitUntilSafetyCheckModuleVisibleOrTimeout(false);
|
||||
}
|
||||
|
||||
// Tests that the Password Checkup view is dismissed when there are no saved
|
||||
// passwords.
|
||||
- (void)testPasswordCheckupDismissedAfterAllPasswordsGone {
|
||||
password_manager_test_utils::SavePasswordFormToProfileStore();
|
||||
|
||||
WaitUntilSafetyCheckModuleVisibleOrTimeout(true);
|
||||
[[EarlGrey
|
||||
selectElementWithMatcher:grey_allOf(grey_accessibilityID(
|
||||
safety_check::kSafetyCheckViewID),
|
||||
grey_sufficientlyVisible(), nil)]
|
||||
performAction:grey_tap()];
|
||||
|
||||
ConditionBlock condition = ^{
|
||||
NSError* error = nil;
|
||||
|
||||
[[[EarlGrey
|
||||
selectElementWithMatcher:grey_allOf(
|
||||
grey_text(l10n_util::GetNSString(
|
||||
IDS_IOS_CHECK_PASSWORDS_NOW_BUTTON)),
|
||||
grey_sufficientlyVisible(), nil)]
|
||||
usingSearchAction:grey_scrollInDirection(kGREYDirectionDown, 350)
|
||||
onElementWithMatcher:grey_allOf(
|
||||
grey_accessibilityID(kSafetyCheckTableViewId),
|
||||
grey_sufficientlyVisible(), nil)]
|
||||
assertWithMatcher:grey_sufficientlyVisible()
|
||||
error:&error];
|
||||
|
||||
return error == nil;
|
||||
};
|
||||
|
||||
GREYAssert(base::test::ios::WaitUntilConditionOrTimeout(base::Seconds(10),
|
||||
condition),
|
||||
@"Timeout waiting for the Safety Check to complete its run.");
|
||||
|
||||
[[EarlGrey selectElementWithMatcher:
|
||||
grey_text(l10n_util::GetNSString(
|
||||
IDS_IOS_SETTINGS_SAFETY_CHECK_PASSWORDS_TITLE))]
|
||||
performAction:grey_tap()];
|
||||
|
||||
// Verify that the Password Checkup Homepage is displayed.
|
||||
[[EarlGrey
|
||||
selectElementWithMatcher:
|
||||
grey_accessibilityID(password_manager::kPasswordCheckupTableViewId)]
|
||||
assertWithMatcher:grey_notNil()];
|
||||
|
||||
[PasswordSettingsAppInterface clearProfilePasswordStore];
|
||||
|
||||
// Verify that the Password Checkup Homepage is not displayed.
|
||||
[[EarlGrey
|
||||
selectElementWithMatcher:
|
||||
grey_accessibilityID(password_manager::kPasswordCheckupTableViewId)]
|
||||
assertWithMatcher:grey_nil()];
|
||||
}
|
||||
|
||||
// Tests that the Password Checkup view is dismissed when the user doesn't pass
|
||||
// Local Authentication.
|
||||
- (void)testPasswordCheckupDismissedAfterFailedAuthentication {
|
||||
password_manager_test_utils::SavePasswordFormToProfileStore();
|
||||
|
||||
WaitUntilSafetyCheckModuleVisibleOrTimeout(true);
|
||||
[[EarlGrey
|
||||
selectElementWithMatcher:grey_allOf(grey_accessibilityID(
|
||||
safety_check::kSafetyCheckViewID),
|
||||
grey_sufficientlyVisible(), nil)]
|
||||
performAction:grey_tap()];
|
||||
|
||||
ConditionBlock condition = ^{
|
||||
NSError* error = nil;
|
||||
|
||||
[[[EarlGrey
|
||||
selectElementWithMatcher:grey_allOf(
|
||||
grey_text(l10n_util::GetNSString(
|
||||
IDS_IOS_CHECK_PASSWORDS_NOW_BUTTON)),
|
||||
grey_sufficientlyVisible(), nil)]
|
||||
usingSearchAction:grey_scrollInDirection(kGREYDirectionDown, 350)
|
||||
onElementWithMatcher:grey_allOf(
|
||||
grey_accessibilityID(kSafetyCheckTableViewId),
|
||||
grey_sufficientlyVisible(), nil)]
|
||||
assertWithMatcher:grey_sufficientlyVisible()
|
||||
error:&error];
|
||||
|
||||
return error == nil;
|
||||
};
|
||||
|
||||
GREYAssert(base::test::ios::WaitUntilConditionOrTimeout(base::Seconds(10),
|
||||
condition),
|
||||
@"Timeout waiting for the Safety Check to complete its run.");
|
||||
|
||||
[PasswordSettingsAppInterface mockReauthenticationModuleExpectedResult:
|
||||
ReauthenticationResult::kFailure];
|
||||
// Delay the auth result to be able to validate that the passwords are not
|
||||
// visible until the result is emitted.
|
||||
[PasswordSettingsAppInterface
|
||||
mockReauthenticationModuleShouldReturnSynchronously:NO];
|
||||
|
||||
[[EarlGrey selectElementWithMatcher:
|
||||
grey_text(l10n_util::GetNSString(
|
||||
IDS_IOS_SETTINGS_SAFETY_CHECK_PASSWORDS_TITLE))]
|
||||
performAction:grey_tap()];
|
||||
|
||||
// Verify that the Password Checkup Homepage is not displayed.
|
||||
[[EarlGrey
|
||||
selectElementWithMatcher:
|
||||
grey_accessibilityID(password_manager::kPasswordCheckupTableViewId)]
|
||||
assertWithMatcher:grey_notVisible()];
|
||||
[[EarlGrey selectElementWithMatcher:password_manager_test_utils::
|
||||
ReauthenticationController()]
|
||||
assertWithMatcher:grey_sufficientlyVisible()];
|
||||
|
||||
[PasswordSettingsAppInterface mockReauthenticationModuleReturnMockedResult];
|
||||
|
||||
// Password Checkup and reauthentication UI should be gone, leaving Safety
|
||||
// Check visible.
|
||||
[[EarlGrey
|
||||
selectElementWithMatcher:
|
||||
grey_accessibilityID(password_manager::kPasswordCheckupTableViewId)]
|
||||
assertWithMatcher:grey_notVisible()];
|
||||
[[EarlGrey
|
||||
selectElementWithMatcher:chrome_test_util::SafetyCheckTableViewMatcher()]
|
||||
assertWithMatcher:grey_sufficientlyVisible()];
|
||||
;
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -334,6 +334,7 @@ source_set("unit_tests") {
|
||||
"//ios/chrome/browser/discover_feed/model:discover_feed_factory",
|
||||
"//ios/chrome/browser/favicon/model",
|
||||
"//ios/chrome/browser/ntp/model",
|
||||
"//ios/chrome/browser/safety_check/model:factory",
|
||||
"//ios/chrome/browser/search_engines/model:template_url_service_factory",
|
||||
"//ios/chrome/browser/segmentation_platform/model",
|
||||
"//ios/chrome/browser/shared/coordinator/scene:scene_state_header",
|
||||
|
@ -15,6 +15,7 @@
|
||||
#import "ios/chrome/browser/commerce/model/shopping_service_factory.h"
|
||||
#import "ios/chrome/browser/favicon/model/ios_chrome_large_icon_service_factory.h"
|
||||
#import "ios/chrome/browser/ntp/model/new_tab_page_tab_helper.h"
|
||||
#import "ios/chrome/browser/safety_check/model/ios_chrome_safety_check_manager_factory.h"
|
||||
#import "ios/chrome/browser/search_engines/model/template_url_service_factory.h"
|
||||
#import "ios/chrome/browser/segmentation_platform/model/segmentation_platform_service_factory.h"
|
||||
#import "ios/chrome/browser/shared/model/application_context/application_context.h"
|
||||
@ -146,9 +147,7 @@ class ScopedVariationsService {
|
||||
class NewTabPageCoordinatorTest : public PlatformTest {
|
||||
protected:
|
||||
NewTabPageCoordinatorTest()
|
||||
: scoped_browser_state_manager_(
|
||||
std::make_unique<TestChromeBrowserStateManager>(base::FilePath())),
|
||||
base_view_controller_([[UIViewController alloc] init]) {
|
||||
: base_view_controller_([[UIViewController alloc] init]) {
|
||||
TestChromeBrowserState::Builder test_cbs_builder;
|
||||
test_cbs_builder.AddTestingFactory(
|
||||
ios::TemplateURLServiceFactory::GetInstance(),
|
||||
@ -170,9 +169,18 @@ class NewTabPageCoordinatorTest : public PlatformTest {
|
||||
GetInstance(),
|
||||
segmentation_platform::SegmentationPlatformServiceFactory::
|
||||
GetDefaultFactory());
|
||||
browser_state_ = test_cbs_builder.Build();
|
||||
test_cbs_builder.AddTestingFactory(
|
||||
IOSChromeSafetyCheckManagerFactory::GetInstance(),
|
||||
IOSChromeSafetyCheckManagerFactory::GetDefaultFactory());
|
||||
|
||||
browser_state_manager_ = std::make_unique<TestChromeBrowserStateManager>(
|
||||
test_cbs_builder.Build());
|
||||
|
||||
TestingApplicationContext::GetGlobal()->SetChromeBrowserStateManager(
|
||||
browser_state_manager_.get());
|
||||
|
||||
AuthenticationServiceFactory::CreateAndInitializeForBrowserState(
|
||||
browser_state_.get(),
|
||||
GetBrowserState(),
|
||||
std::make_unique<FakeAuthenticationServiceDelegate>());
|
||||
toolbar_delegate_ =
|
||||
OCMProtocolMock(@protocol(NewTabPageControllerDelegate));
|
||||
@ -184,9 +192,13 @@ class NewTabPageCoordinatorTest : public PlatformTest {
|
||||
scoped_feature_list_.InitWithFeatures(enabled, disabled);
|
||||
}
|
||||
|
||||
ChromeBrowserState* GetBrowserState() {
|
||||
return browser_state_manager_->GetLastUsedBrowserStateForTesting();
|
||||
}
|
||||
|
||||
std::unique_ptr<web::FakeWebState> CreateWebState(const char* url) {
|
||||
auto test_web_state = std::make_unique<web::FakeWebState>();
|
||||
test_web_state->SetBrowserState(browser_state_.get());
|
||||
test_web_state->SetBrowserState(GetBrowserState());
|
||||
NewTabPageTabHelper::CreateForWebState(test_web_state.get());
|
||||
test_web_state->SetCurrentURL(GURL(url));
|
||||
test_web_state->SetNavigationManager(
|
||||
@ -197,10 +209,10 @@ class NewTabPageCoordinatorTest : public PlatformTest {
|
||||
void CreateCoordinator(bool off_the_record) {
|
||||
if (off_the_record) {
|
||||
ChromeBrowserState* otr_state =
|
||||
browser_state_->GetOffTheRecordChromeBrowserState();
|
||||
GetBrowserState()->GetOffTheRecordChromeBrowserState();
|
||||
browser_ = std::make_unique<TestBrowser>(otr_state);
|
||||
} else {
|
||||
browser_ = std::make_unique<TestBrowser>(browser_state_.get());
|
||||
browser_ = std::make_unique<TestBrowser>(GetBrowserState());
|
||||
StartSurfaceRecentTabBrowserAgent::CreateForBrowser(browser_.get());
|
||||
// Create non-NTP WebState
|
||||
browser_.get()->GetWebStateList()->InsertWebState(
|
||||
@ -263,7 +275,7 @@ class NewTabPageCoordinatorTest : public PlatformTest {
|
||||
std::unique_ptr<web::WebState> CreateWebStateWithURL(const GURL& url) {
|
||||
std::unique_ptr<web::FakeWebState> web_state =
|
||||
std::make_unique<web::FakeWebState>();
|
||||
web_state->SetBrowserState(browser_state_.get());
|
||||
web_state->SetBrowserState(GetBrowserState());
|
||||
NewTabPageTabHelper::CreateForWebState(web_state.get());
|
||||
web_state->SetVisibleURL(url);
|
||||
auto navigation_manager = std::make_unique<web::FakeNavigationManager>();
|
||||
@ -349,7 +361,7 @@ class NewTabPageCoordinatorTest : public PlatformTest {
|
||||
FakeSystemIdentityManager::FromSystemIdentityManager(
|
||||
GetApplicationContext()->GetSystemIdentityManager());
|
||||
system_identity_manager->AddIdentity(fake_identity);
|
||||
AuthenticationServiceFactory::GetForBrowserState(browser_state_.get())
|
||||
AuthenticationServiceFactory::GetForBrowserState(GetBrowserState())
|
||||
->SignIn(fake_identity,
|
||||
signin_metrics::AccessPoint::ACCESS_POINT_UNKNOWN);
|
||||
}
|
||||
@ -358,8 +370,7 @@ class NewTabPageCoordinatorTest : public PlatformTest {
|
||||
raw_ptr<web::WebState> web_state_;
|
||||
id toolbar_delegate_;
|
||||
id delegate_;
|
||||
IOSChromeScopedTestingChromeBrowserStateManager scoped_browser_state_manager_;
|
||||
std::unique_ptr<TestChromeBrowserState> browser_state_;
|
||||
std::unique_ptr<TestChromeBrowserStateManager> browser_state_manager_;
|
||||
std::unique_ptr<Browser> browser_;
|
||||
UIViewController* fake_feed_view_controller_;
|
||||
NewTabPageCoordinator* coordinator_;
|
||||
|
Reference in New Issue
Block a user