#include "chrome/browser/safe_browsing/tailored_security/chrome_tailored_security_service.h"
#include "base/files/scoped_temp_dir.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/scoped_refptr.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "chrome/browser/prefs/browser_prefs.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/safe_browsing/safe_browsing_service.h"
#include "chrome/browser/signin/chrome_signin_client_factory.h"
#include "chrome/browser/signin/chrome_signin_client_test_util.h"
#include "chrome/browser/signin/identity_test_environment_profile_adaptor.h"
#include "chrome/browser/sync/sync_service_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/test/base/test_browser_window.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "chrome/test/base/testing_profile_manager.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/testing_pref_service.h"
#include "components/prefs/testing_pref_store.h"
#include "components/safe_browsing/core/browser/tailored_security_service/tailored_security_notification_result.h"
#include "components/safe_browsing/core/common/features.h"
#include "components/safe_browsing/core/common/safe_browsing_prefs.h"
#include "components/sync/test/test_sync_service.h"
#include "components/sync_preferences/pref_model_associator_client.h"
#include "components/sync_preferences/pref_service_syncable.h"
#include "components/sync_preferences/testing_pref_service_syncable.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/browser/storage_partition_config.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/browser_task_environment.h"
#include "content/public/test/navigation_simulator.h"
#include "content/public/test/test_renderer_host.h"
#include "content/public/test/web_contents_tester.h"
#include "services/network/test/test_url_loader_factory.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
class Profile;
namespace safe_browsing {
const bool kTailoredSecurityEnabled = …;
const bool kTailoredSecurityDisabled = …;
namespace {
class TestChromeTailoredSecurityService : public ChromeTailoredSecurityService { … };
}
class ChromeTailoredSecurityServiceTest : public testing::Test { … };
class ChromeTailoredSecurityServiceRetryForSyncUsersDisabledTest
: public ChromeTailoredSecurityServiceTest { … };
TEST_F(ChromeTailoredSecurityServiceTest,
TailoredSecurityEnabledShowsEnableDialog) { … }
TEST_F(ChromeTailoredSecurityServiceTest,
TailoredSecurityEnabledButHistorySyncDisabledDoesNotShowEnableDialog) { … }
TEST_F(ChromeTailoredSecurityServiceTest,
TailoredSecurityEnabledButHistorySyncDisabledLogsHistoryNotSynced) { … }
TEST_F(ChromeTailoredSecurityServiceTest,
TailoredSecurityEnabledButHistorySyncEnabledDoesNotLogHistoryNotSynced) { … }
TEST_F(ChromeTailoredSecurityServiceTest, TsEnabledEnablesEp) { … }
TEST_F(ChromeTailoredSecurityServiceTest, EpAlreadyEnabledDoesNotShowDialog) { … }
TEST_F(ChromeTailoredSecurityServiceTest, EpAlreadyEnabledLeavesEpEnabled) { … }
TEST_F(ChromeTailoredSecurityServiceTest,
EpWasEnabledByTsAndTsNowDisabledShowsDialog) { … }
TEST_F(ChromeTailoredSecurityServiceTest,
EpEnabledByTsAndTsNowDisabledDisablesEp) { … }
TEST_F(ChromeTailoredSecurityServiceTest,
SpEnabledAndTsNowDisabledDoesNotShowDialog) { … }
TEST_F(ChromeTailoredSecurityServiceTest,
SpEnabledAndTsNowDisabledDoesNotChangeSb) { … }
TEST_F(ChromeTailoredSecurityServiceTest,
EpEnabledByUserTsDisabledDoesNotShowDialog) { … }
TEST_F(ChromeTailoredSecurityServiceTest,
EpEnabledByUserTsDisabledDoesNotChangeSb) { … }
TEST_F(ChromeTailoredSecurityServiceTest,
WhenRetryEnabledOnSuccessStoresNoRetryNeeded) { … }
TEST_F(ChromeTailoredSecurityServiceTest,
WhenRetryEnabledButHistorySyncDisabledSetsNoRetryNeeded) { … }
TEST_F(ChromeTailoredSecurityServiceTest,
WhenRetryEnabledAndSbControlledByPolicySetsNoRetryNeeded) { … }
TEST_F(ChromeTailoredSecurityServiceTest,
WhenRetryEnabledAndEpAlreadyEnabledSetsNoRetryNeeded) { … }
TEST_F(ChromeTailoredSecurityServiceTest,
HistorySyncAndSbNotControlledByPolicyRunsRetryLogicAfterStartupDelay) { … }
TEST_F(ChromeTailoredSecurityServiceTest, HistorySyncNotSetDoesNotRetry) { … }
TEST_F(ChromeTailoredSecurityServiceTest, SbControlledByPolicyDoesNotRetry) { … }
TEST_F(ChromeTailoredSecurityServiceTest,
TailoredSecurityUpdateTimeNotSetDoesNotRetry) { … }
TEST_F(ChromeTailoredSecurityServiceTest,
WhenRetryNeededButNotEnoughTimeHasPassedDoesNotRetry) { … }
TEST_F(ChromeTailoredSecurityServiceTest,
WhenRetryNeededAndEnoughTimeHasPassedRetries) { … }
TEST_F(
ChromeTailoredSecurityServiceTest,
WhenRetryNeededAndEnoughTimeHasPassedUpdatesNextSyncFlowTimestampByNextAttemptDelay) { … }
TEST_F(
ChromeTailoredSecurityServiceTest,
WhenRetryNotSetAndEnhancedProtectionEnabledViaTailoredSecurityDoesNotSetNextSyncFlowTimestamp) { … }
TEST_F(
ChromeTailoredSecurityServiceTest,
WhenRetryNotSetAndNextSyncFlowNotSetSetsNextSyncFlowToWaitingIntervalFromNow) { … }
TEST_F(ChromeTailoredSecurityServiceTest,
WhenRetryNotSetAndNextSyncFlowHasPassedRunsRetry) { … }
TEST_F(ChromeTailoredSecurityServiceTest,
WhenRetryNotSetAndNextSyncFlowHasPassedSetsNextSyncFlowToTomorrow) { … }
TEST_F(ChromeTailoredSecurityServiceTest,
WhenRetryNotSetAndNextSyncFlowHasNotPassedDoesNotRunRetryLogic) { … }
TEST_F(ChromeTailoredSecurityServiceTest, WhenNoRetryNeededDoesNotRetry) { … }
TEST_F(ChromeTailoredSecurityServiceRetryForSyncUsersDisabledTest,
OnSuccessDoesNotUpdateRetryStatePref) { … }
TEST_F(ChromeTailoredSecurityServiceRetryForSyncUsersDisabledTest,
WhenRetryForSyncUsersIsDisabledDoesNotRunRetryLogicAfterStartupDelay) { … }
}