#include "chrome/browser/ssl/https_first_mode_settings_tracker.h"
#include "base/json/values_util.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/simple_test_clock.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/safe_browsing/advanced_protection_status_manager.h"
#include "chrome/browser/safe_browsing/advanced_protection_status_manager_factory.h"
#include "chrome/browser/signin/identity_test_environment_profile_adaptor.h"
#include "chrome/browser/ssl/stateful_ssl_host_state_delegate_factory.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_profile.h"
#include "components/prefs/pref_test_utils.h"
#include "components/security_interstitials/content/stateful_ssl_host_state_delegate.h"
#include "components/security_interstitials/core/https_only_mode_metrics.h"
#include "components/site_engagement/content/site_engagement_score.h"
#include "components/site_engagement/content/site_engagement_service.h"
#include "components/site_engagement/core/pref_names.h"
#include "components/user_prefs/user_prefs.h"
#include "content/public/test/browser_task_environment.h"
#include "testing/gtest/include/gtest/gtest.h"
kSiteEngagementHeuristicAccumulatedHostCountHistogram;
kSiteEngagementHeuristicEnforcementDurationHistogram;
kSiteEngagementHeuristicHostCountHistogram;
kSiteEngagementHeuristicStateHistogram;
SiteEngagementHeuristicState;
class HttpsFirstModeSettingsTrackerTest : public testing::Test { … };
void MaybeEnableHttpsFirstModeForEngagedSitesAndWait(
HttpsFirstModeService* hfm_service) { … }
TEST_F(HttpsFirstModeSettingsTrackerTest,
SiteEngagementHeuristic_ShouldNotEnableIfPrefIsSet) { … }
TEST_F(
HttpsFirstModeSettingsTrackerTest,
SiteEngagementHeuristic_ShouldIgnoreEngagementScoreOfUrlWithNonDefaultPort) { … }
TEST_F(HttpsFirstModeSettingsTrackerTest,
SiteEngagementHeuristic_ShouldEnforceHttps) { … }
TEST_F(HttpsFirstModeSettingsTrackerTest,
SiteEngagementHeuristic_NoEngagementScoreShouldUnenforceHttps) { … }
TEST_F(HttpsFirstModeSettingsTrackerTest,
TypicallySecureUser_DisabledByDefault) { … }
HttpsFirstModeService*
CreateHttpsFirstModeServiceAndWaitForTypicallySecureUserPrefInitialized(
Profile* profile,
base::SimpleTestClock* clock) { … }
TEST_F(HttpsFirstModeSettingsTrackerTest, TypicallySecureUser_NewProfile) { … }
TEST_F(HttpsFirstModeSettingsTrackerTest, TypicallySecureUser_OldVersion) { … }
class TypicallySecureUserTest : public HttpsFirstModeSettingsTrackerTest { … };
TEST_F(TypicallySecureUserTest, ProfileOldEnough) { … }
TEST_F(TypicallySecureUserTest, EnablePrefWhenObservedForLongEnough) { … }
TEST_F(TypicallySecureUserTest,
DontEnablePrefWhenObservedForLongEnoughWithManyWarnings) { … }
TEST_F(TypicallySecureUserTest, HFMEnabled) { … }
TEST_F(HttpsFirstModeSettingsTrackerTest, PrefUpdated_ShouldClearAllowlist) { … }
TEST_F(TypicallySecureUserTest,
PrefUpdatedByHeuristic_ShouldNotClearAllowlist) { … }
TEST_F(HttpsFirstModeSettingsTrackerTest, StartupBalancedModeAvailable) { … }
TEST_F(HttpsFirstModeSettingsTrackerTest, StartupBalancedModeAutoEnabled) { … }