From 6e3502301e8d50c5ddc7fb1a71dc840f0e8f2c23 Mon Sep 17 00:00:00 2001 From: Chris Thompson Date: Tue, 21 Nov 2023 23:21:08 +0000 Subject: [PATCH] Convert GeneratedHttpsFirstModePref into a tri-state enum GeneratedHttpsFirstModePref is used for managing the HTTPS-First Mode setting in the Security settings page. This updates it to match the HttpsFirstModeSettings enum that adds new states besides "disabled" and "fully enabled", and hooks it up to the two HTTPS-First Mode prefs kHttpsOnlyModeEnabled and kHttpsFIrstModeIncognito. This is an initial step towards adding a new Settings UI (when the HttpsFirstModeIcnognito feature flag is enabled) to control the tri-state of HFM (EnabledFull, EnabledIncognito, Disabled). Having the SettingsToggleButton control the underlying numeric setting will make it easier to have both versions of the Settings control use the same underlying generated pref logic. Bug: 1494186 Change-Id: Iae8dc496f786a60fb5d89bcd6f973eafbd5f7739 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5041962 Reviewed-by: Demetrios Papadopoulos Code-Coverage: findit-for-me@appspot.gserviceaccount.com Reviewed-by: Mustafa Emre Acer Commit-Queue: Chris Thompson Reviewed-by: Rainhard Findling Cr-Commit-Position: refs/heads/main@{#1227664} --- .../api/settings_private/prefs_util.cc | 2 +- .../settings/privacy_page/security_page.html | 5 +- .../settings/privacy_page/security_page.ts | 23 +++ .../ssl/generated_https_first_mode_pref.cc | 104 ++++++++++-- .../ssl/generated_https_first_mode_pref.h | 6 +- ...enerated_https_first_mode_pref_unittest.cc | 154 ++++++++++++++++-- .../ssl/https_first_mode_settings_tracker.h | 3 + 7 files changed, 262 insertions(+), 35 deletions(-) diff --git a/chrome/browser/extensions/api/settings_private/prefs_util.cc b/chrome/browser/extensions/api/settings_private/prefs_util.cc index 0c36d4a558eb39..6eea7035c37485 100644 --- a/chrome/browser/extensions/api/settings_private/prefs_util.cc +++ b/chrome/browser/extensions/api/settings_private/prefs_util.cc @@ -339,7 +339,7 @@ const PrefsUtil::TypedPrefMap& PrefsUtil::GetAllowlistedKeys() { (*s_allowlist)[::prefs::kHttpsOnlyModeEnabled] = settings_api::PrefType::kBoolean; (*s_allowlist)[::kGeneratedHttpsFirstModePref] = - settings_api::PrefType::kBoolean; + settings_api::PrefType::kNumber; // Cookies page (*s_allowlist)[::prefs::kCookieControlsMode] = diff --git a/chrome/browser/resources/settings/privacy_page/security_page.html b/chrome/browser/resources/settings/privacy_page/security_page.html index 4dd4a5cfd9e47b..043c0a4a32328b 100644 --- a/chrome/browser/resources/settings/privacy_page/security_page.html +++ b/chrome/browser/resources/settings/privacy_page/security_page.html @@ -69,7 +69,7 @@ } #safeBrowsingEnhanced { - --cr-radio-button-unchecked-ripple-color: + --cr-radio-button-unchecked-ripple-color: var(--cr-radio-button-checked-ripple-color); } @@ -260,7 +260,8 @@

$i18n{advancedPageTitle}

pref="{{prefs.generated.https_first_mode_enabled}}" label="$i18n{httpsOnlyModeTitle}" sub-label="[[getHttpsFirstModeSubLabel_( - prefs.generated.https_first_mode_enabled.*)]]"> + prefs.generated.https_first_mode_enabled.*)]]" + numeric-checked-value="[[httpsFirstModeSettingEnum_.ENABLED_FULL]]">