diff options
Diffstat (limited to 'chromium/components/security_interstitials')
56 files changed, 616 insertions, 900 deletions
diff --git a/chromium/components/security_interstitials/BUILD.gn b/chromium/components/security_interstitials/BUILD.gn index 05c13899231..c1b13e56c68 100644 --- a/chromium/components/security_interstitials/BUILD.gn +++ b/chromium/components/security_interstitials/BUILD.gn @@ -7,8 +7,5 @@ import("//third_party/closure_compiler/compile_js.gni") assert(enable_js_type_check) group("closure_compile") { - deps = [ - "content/resources:closure_compile", - "core/common/resources:closure_compile", - ] + deps = [ "core/common/resources:closure_compile" ] } diff --git a/chromium/components/security_interstitials/DEPS b/chromium/components/security_interstitials/DEPS index 66cf58139c0..02c972f27b8 100644 --- a/chromium/components/security_interstitials/DEPS +++ b/chromium/components/security_interstitials/DEPS @@ -3,6 +3,7 @@ include_rules = [ "+components/google/core", "+components/history/core/browser", "+components/metrics", + "+components/policy", "+components/prefs", "+components/safe_browsing/core/common", "+components/safe_browsing/core/browser/db", diff --git a/chromium/components/security_interstitials/content/BUILD.gn b/chromium/components/security_interstitials/content/BUILD.gn index 2f66e25f6e4..8ddc5e8f661 100644 --- a/chromium/components/security_interstitials/content/BUILD.gn +++ b/chromium/components/security_interstitials/content/BUILD.gn @@ -35,10 +35,6 @@ static_library("security_interstitial_page") { "known_interception_disclosure_ui.h", "mitm_software_blocking_page.cc", "mitm_software_blocking_page.h", - "origin_policy_interstitial_page.cc", - "origin_policy_interstitial_page.h", - "origin_policy_ui.cc", - "origin_policy_ui.h", "security_blocking_page_factory.h", "security_interstitial_controller_client.cc", "security_interstitial_controller_client.h", diff --git a/chromium/components/security_interstitials/content/bad_clock_blocking_page.cc b/chromium/components/security_interstitials/content/bad_clock_blocking_page.cc index a54ac865d57..ec44bd7fbc5 100644 --- a/chromium/components/security_interstitials/content/bad_clock_blocking_page.cc +++ b/chromium/components/security_interstitials/content/bad_clock_blocking_page.cc @@ -71,7 +71,7 @@ BadClockBlockingPage::GetTypeForTesting() { } void BadClockBlockingPage::PopulateInterstitialStrings( - base::Value* load_time_data) { + base::Value::Dict& load_time_data) { bad_clock_ui_->PopulateStringsForHTML(load_time_data); cert_report_helper()->PopulateExtendedReportingOption(load_time_data); cert_report_helper()->PopulateEnhancedProtectionMessage(load_time_data); diff --git a/chromium/components/security_interstitials/content/bad_clock_blocking_page.h b/chromium/components/security_interstitials/content/bad_clock_blocking_page.h index 9b45d0120e5..e4318bcd939 100644 --- a/chromium/components/security_interstitials/content/bad_clock_blocking_page.h +++ b/chromium/components/security_interstitials/content/bad_clock_blocking_page.h @@ -60,7 +60,7 @@ class BadClockBlockingPage : public SSLBlockingPageBase { protected: // SecurityInterstitialPage implementation: void CommandReceived(const std::string& command) override; - void PopulateInterstitialStrings(base::Value* load_time_data) override; + void PopulateInterstitialStrings(base::Value::Dict& load_time_data) override; private: const net::SSLInfo ssl_info_; diff --git a/chromium/components/security_interstitials/content/blocked_interception_blocking_page.cc b/chromium/components/security_interstitials/content/blocked_interception_blocking_page.cc index 4eba1b09067..4532811fb27 100644 --- a/chromium/components/security_interstitials/content/blocked_interception_blocking_page.cc +++ b/chromium/components/security_interstitials/content/blocked_interception_blocking_page.cc @@ -66,7 +66,7 @@ BlockedInterceptionBlockingPage::GetTypeForTesting() { } void BlockedInterceptionBlockingPage::PopulateInterstitialStrings( - base::Value* load_time_data) { + base::Value::Dict& load_time_data) { blocked_interception_ui_->PopulateStringsForHTML(load_time_data); cert_report_helper()->PopulateExtendedReportingOption(load_time_data); cert_report_helper()->PopulateEnhancedProtectionMessage(load_time_data); diff --git a/chromium/components/security_interstitials/content/blocked_interception_blocking_page.h b/chromium/components/security_interstitials/content/blocked_interception_blocking_page.h index a8f5298d4cf..31edd4ae04e 100644 --- a/chromium/components/security_interstitials/content/blocked_interception_blocking_page.h +++ b/chromium/components/security_interstitials/content/blocked_interception_blocking_page.h @@ -41,7 +41,7 @@ class BlockedInterceptionBlockingPage : public SSLBlockingPageBase { protected: // SecurityInterstitialPage implementation: void CommandReceived(const std::string& command) override; - void PopulateInterstitialStrings(base::Value* load_time_data) override; + void PopulateInterstitialStrings(base::Value::Dict& load_time_data) override; private: const net::SSLInfo ssl_info_; diff --git a/chromium/components/security_interstitials/content/captive_portal_blocking_page.cc b/chromium/components/security_interstitials/content/captive_portal_blocking_page.cc index 6e968b8acdd..d96ea9ed9f4 100644 --- a/chromium/components/security_interstitials/content/captive_portal_blocking_page.cc +++ b/chromium/components/security_interstitials/content/captive_portal_blocking_page.cc @@ -120,26 +120,26 @@ std::string CaptivePortalBlockingPage::GetWiFiSSID() const { } void CaptivePortalBlockingPage::PopulateInterstitialStrings( - base::Value* load_time_data) { - load_time_data->SetStringKey("iconClass", "icon-offline"); - load_time_data->SetStringKey("type", "CAPTIVE_PORTAL"); - load_time_data->SetBoolKey("overridable", false); - load_time_data->SetBoolKey("hide_primary_button", false); + base::Value::Dict& load_time_data) { + load_time_data.Set("iconClass", "icon-offline"); + load_time_data.Set("type", "CAPTIVE_PORTAL"); + load_time_data.Set("overridable", false); + load_time_data.Set("hide_primary_button", false); // |IsWifiConnection| isn't accurate on some platforms, so always try to get // the Wi-Fi SSID even if |IsWifiConnection| is false. std::string wifi_ssid = GetWiFiSSID(); bool is_wifi = !wifi_ssid.empty() || IsWifiConnection(); - load_time_data->SetStringKey( + load_time_data.Set( "primaryButtonText", l10n_util::GetStringUTF16(IDS_CAPTIVE_PORTAL_BUTTON_OPEN_LOGIN_PAGE)); std::u16string tab_title = l10n_util::GetStringUTF16(is_wifi ? IDS_CAPTIVE_PORTAL_HEADING_WIFI : IDS_CAPTIVE_PORTAL_HEADING_WIRED); - load_time_data->SetStringKey("tabTitle", tab_title); - load_time_data->SetStringKey("heading", tab_title); + load_time_data.Set("tabTitle", tab_title); + load_time_data.Set("heading", tab_title); std::u16string paragraph; if (login_url_.is_empty() || @@ -178,27 +178,26 @@ void CaptivePortalBlockingPage::PopulateInterstitialStrings( base::EscapeForHTML(base::UTF8ToUTF16(wifi_ssid)), login_host); } } - load_time_data->SetStringKey("primaryParagraph", paragraph); - load_time_data->SetStringKey( - "optInLink", - l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_SCOUT_REPORTING_AGREE)); - load_time_data->SetStringKey( + load_time_data.Set("primaryParagraph", std::move(paragraph)); + load_time_data.Set("optInLink", l10n_util::GetStringUTF16( + IDS_SAFE_BROWSING_SCOUT_REPORTING_AGREE)); + load_time_data.Set( "enhancedProtectionMessage", l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_ENHANCED_PROTECTION_MESSAGE)); // Explicitly specify other expected fields to empty. - load_time_data->SetStringKey("openDetails", ""); - load_time_data->SetStringKey("closeDetails", ""); - load_time_data->SetStringKey("explanationParagraph", ""); - load_time_data->SetStringKey("finalParagraph", ""); - load_time_data->SetStringKey("recurrentErrorParagraph", ""); - load_time_data->SetBoolKey("show_recurrent_error_paragraph", false); + load_time_data.Set("openDetails", ""); + load_time_data.Set("closeDetails", ""); + load_time_data.Set("explanationParagraph", ""); + load_time_data.Set("finalParagraph", ""); + load_time_data.Set("recurrentErrorParagraph", ""); + load_time_data.Set("show_recurrent_error_paragraph", false); if (cert_report_helper()) { cert_report_helper()->PopulateExtendedReportingOption(load_time_data); cert_report_helper()->PopulateEnhancedProtectionMessage(load_time_data); } else { - load_time_data->SetBoolKey(security_interstitials::kDisplayCheckBox, false); - load_time_data->SetBoolKey( + load_time_data.Set(security_interstitials::kDisplayCheckBox, false); + load_time_data.Set( security_interstitials::kDisplayEnhancedProtectionMessage, false); } } diff --git a/chromium/components/security_interstitials/content/captive_portal_blocking_page.h b/chromium/components/security_interstitials/content/captive_portal_blocking_page.h index 3e1051411ab..624de81ca44 100644 --- a/chromium/components/security_interstitials/content/captive_portal_blocking_page.h +++ b/chromium/components/security_interstitials/content/captive_portal_blocking_page.h @@ -72,7 +72,7 @@ class CaptivePortalBlockingPage : public SSLBlockingPageBase { std::string GetWiFiSSID() const; // SecurityInterstitialPage methods: - void PopulateInterstitialStrings(base::Value* load_time_data) override; + void PopulateInterstitialStrings(base::Value::Dict& load_time_data) override; // SecurityInterstitialPage method: void CommandReceived(const std::string& command) override; diff --git a/chromium/components/security_interstitials/content/cert_logger.proto b/chromium/components/security_interstitials/content/cert_logger.proto index 25cb78ae954..750f7a8b94b 100644 --- a/chromium/components/security_interstitials/content/cert_logger.proto +++ b/chromium/components/security_interstitials/content/cert_logger.proto @@ -245,6 +245,11 @@ message WinPlatformDebugInfo { optional bytes authroot_sequence_number = 2; } +message ChromeRootStoreDebugInfo { + // The version of the Chrome root store used. + optional int64 chrome_root_store_version = 1; +} + // Contains the results of verification by the trial verifier. All fields // have the same meaning as those of the same name in CertLoggerRequest. message TrialVerificationInfo { @@ -299,6 +304,7 @@ message TrialVerificationInfo { MAC_TRUST_IMPL_DOMAIN_CACHE = 1; MAC_TRUST_IMPL_SIMPLE = 2; MAC_TRUST_IMPL_MRU_CACHE = 3; + MAC_TRUST_IMPL_DOMAIN_CACHE_FULL_CERTS = 4; }; optional MacTrustImplType mac_trust_impl = 13; @@ -322,4 +328,7 @@ message TrialVerificationInfo { // Debug information from CertVerifyProcWin (if it was the primary verifier). optional WinPlatformDebugInfo win_platform_debug_info = 14; + + // Debug information pertaining to the Chrome Root Store (if it was used). + optional ChromeRootStoreDebugInfo chrome_root_store_debug_info = 15; } diff --git a/chromium/components/security_interstitials/content/cert_report_helper.cc b/chromium/components/security_interstitials/content/cert_report_helper.cc index da1876ef237..4cc8a6cf7ad 100644 --- a/chromium/components/security_interstitials/content/cert_report_helper.cc +++ b/chromium/components/security_interstitials/content/cert_report_helper.cc @@ -74,32 +74,32 @@ void CertReportHelper::SetFakeOfficialBuildForTesting() { } void CertReportHelper::PopulateExtendedReportingOption( - base::Value* load_time_data) { + base::Value::Dict& load_time_data) { // Only show the checkbox if not off-the-record and if this client is // part of the respective Finch group, and the feature is not disabled // by policy. const bool show = ShouldShowCertificateReporterCheckbox() && !ShouldShowEnhancedProtectionMessage(); - load_time_data->SetBoolKey(security_interstitials::kDisplayCheckBox, show); + load_time_data.Set(security_interstitials::kDisplayCheckBox, show); if (!show) return; - load_time_data->SetBoolKey( + load_time_data.Set( security_interstitials::kBoxChecked, safe_browsing::IsExtendedReportingEnabled(*GetPrefs(web_contents_))); - load_time_data->SetStringKey( + load_time_data.Set( security_interstitials::kOptInLink, l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_SCOUT_REPORTING_AGREE)); } void CertReportHelper::PopulateEnhancedProtectionMessage( - base::Value* load_time_data) { + base::Value::Dict& load_time_data) { const bool show = ShouldShowEnhancedProtectionMessage(); - load_time_data->SetBoolKey( - security_interstitials::kDisplayEnhancedProtectionMessage, show); + load_time_data.Set(security_interstitials::kDisplayEnhancedProtectionMessage, + show); if (!show) return; @@ -109,7 +109,7 @@ void CertReportHelper::PopulateEnhancedProtectionMessage( security_interstitials::MetricsHelper::SHOW_ENHANCED_PROTECTION); } - load_time_data->SetStringKey( + load_time_data.Set( security_interstitials::kEnhancedProtectionMessage, l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_ENHANCED_PROTECTION_MESSAGE)); } diff --git a/chromium/components/security_interstitials/content/cert_report_helper.h b/chromium/components/security_interstitials/content/cert_report_helper.h index 52e611aae39..250fc38bced 100644 --- a/chromium/components/security_interstitials/content/cert_report_helper.h +++ b/chromium/components/security_interstitials/content/cert_report_helper.h @@ -7,15 +7,12 @@ #include "base/memory/raw_ptr.h" #include "base/time/time.h" +#include "base/values.h" #include "components/security_interstitials/content/certificate_error_report.h" #include "components/security_interstitials/core/controller_client.h" #include "net/ssl/ssl_info.h" #include "url/gurl.h" -namespace base { -class Value; -} - namespace content { class WebContents; } @@ -63,11 +60,11 @@ class CertReportHelper { // Populates data that JavaScript code on the interstitial uses to show // the checkbox. - void PopulateExtendedReportingOption(base::Value* load_time_data); + void PopulateExtendedReportingOption(base::Value::Dict& load_time_data); // Populates data that JavaScript code on the interstitial uses to show // the enhanced protection message. - void PopulateEnhancedProtectionMessage(base::Value* load_time_data); + void PopulateEnhancedProtectionMessage(base::Value::Dict& load_time_data); // Allows tests to inject a mock reporter. void SetSSLCertReporterForTesting( diff --git a/chromium/components/security_interstitials/content/certificate_error_report.cc b/chromium/components/security_interstitials/content/certificate_error_report.cc index d52129b7a99..d73084a3aed 100644 --- a/chromium/components/security_interstitials/content/certificate_error_report.cc +++ b/chromium/components/security_interstitials/content/certificate_error_report.cc @@ -151,20 +151,20 @@ void AddMacPlatformDebugInfoToReport( chrome_browser_ssl::TrialVerificationInfo::MacTrustImplType TrustImplTypeFromMojom( cert_verifier::mojom::CertVerifierDebugInfo::MacTrustImplType input) { + using mojom_MacTrustImplType = + cert_verifier::mojom::CertVerifierDebugInfo::MacTrustImplType; + using chrome_browser_ssl::TrialVerificationInfo; switch (input) { - case cert_verifier::mojom::CertVerifierDebugInfo::MacTrustImplType:: - kUnknown: - return chrome_browser_ssl::TrialVerificationInfo::MAC_TRUST_IMPL_UNKNOWN; - case cert_verifier::mojom::CertVerifierDebugInfo::MacTrustImplType:: - kDomainCache: - return chrome_browser_ssl::TrialVerificationInfo:: - MAC_TRUST_IMPL_DOMAIN_CACHE; - case cert_verifier::mojom::CertVerifierDebugInfo::MacTrustImplType::kSimple: - return chrome_browser_ssl::TrialVerificationInfo::MAC_TRUST_IMPL_SIMPLE; - case cert_verifier::mojom::CertVerifierDebugInfo::MacTrustImplType:: - kLruCache: - return chrome_browser_ssl::TrialVerificationInfo:: - MAC_TRUST_IMPL_MRU_CACHE; + case mojom_MacTrustImplType::kUnknown: + return TrialVerificationInfo::MAC_TRUST_IMPL_UNKNOWN; + case mojom_MacTrustImplType::kDomainCache: + return TrialVerificationInfo::MAC_TRUST_IMPL_DOMAIN_CACHE; + case mojom_MacTrustImplType::kSimple: + return TrialVerificationInfo::MAC_TRUST_IMPL_SIMPLE; + case mojom_MacTrustImplType::kLruCache: + return TrialVerificationInfo::MAC_TRUST_IMPL_MRU_CACHE; + case mojom_MacTrustImplType::kDomainCacheFullCerts: + return TrialVerificationInfo::MAC_TRUST_IMPL_DOMAIN_CACHE_FULL_CERTS; } } #endif // BUILDFLAG(IS_APPLE) @@ -187,6 +187,21 @@ void AddWinPlatformDebugInfoToReport( } #endif // BUILDFLAG(IS_WIN) +#if BUILDFLAG(CHROME_ROOT_STORE_SUPPORTED) +void AddChromeRootStoreDebugInfoToReport( + const cert_verifier::mojom::ChromeRootStoreDebugInfoPtr& + chrome_root_store_debug_info, + chrome_browser_ssl::TrialVerificationInfo* trial_report) { + if (!chrome_root_store_debug_info) { + return; + } + + chrome_browser_ssl::ChromeRootStoreDebugInfo* report_info = + trial_report->mutable_chrome_root_store_debug_info(); + report_info->set_chrome_root_store_version( + chrome_root_store_debug_info->chrome_root_store_version); +} +#endif #endif // BUILDFLAG(TRIAL_COMPARISON_CERT_VERIFIER_SUPPORTED) bool CertificateChainToString(const net::X509Certificate& cert, @@ -269,6 +284,10 @@ CertificateErrorReport::CertificateErrorReport( AddWinPlatformDebugInfoToReport(debug_info->win_platform_debug_info, trial_report); #endif +#if BUILDFLAG(CHROME_ROOT_STORE_SUPPORTED) + AddChromeRootStoreDebugInfoToReport(debug_info->chrome_root_store_debug_info, + trial_report); +#endif if (!debug_info->trial_verification_time.is_null()) { trial_report->set_trial_verification_time_usec( debug_info->trial_verification_time.ToDeltaSinceWindowsEpoch() diff --git a/chromium/components/security_interstitials/content/certificate_error_report_unittest.cc b/chromium/components/security_interstitials/content/certificate_error_report_unittest.cc index b54ad3d580e..022d28d4bf8 100644 --- a/chromium/components/security_interstitials/content/certificate_error_report_unittest.cc +++ b/chromium/components/security_interstitials/content/certificate_error_report_unittest.cc @@ -23,6 +23,7 @@ #include "components/security_interstitials/content/cert_logger.pb.h" #include "components/version_info/version_info.h" #include "net/cert/cert_status_flags.h" +#include "net/net_buildflags.h" #include "net/ssl/ssl_info.h" #include "net/test/cert_test_util.h" #include "net/test/test_data_directory.h" @@ -347,6 +348,10 @@ TEST(ErrorReportTest, AndroidAIAFetchingFeatureEnabled) { #endif #if BUILDFLAG(TRIAL_COMPARISON_CERT_VERIFIER_SUPPORTED) +#if BUILDFLAG(CHROME_ROOT_STORE_SUPPORTED) +const int64_t kTestChromeRootVersion = 24601; +#endif + TEST(ErrorReportTest, TrialDebugInfo) { scoped_refptr<net::X509Certificate> unverified_cert = net::ImportCertFromFile(net::GetTestCertsDirectory(), "ok_cert.pem"); @@ -398,6 +403,13 @@ TEST(ErrorReportTest, TrialDebugInfo) { debug_info->win_platform_debug_info->authroot_sequence_number = { 'J', 'E', 'N', 'N', 'Y'}; #endif +#if BUILDFLAG(CHROME_ROOT_STORE_SUPPORTED) + debug_info->chrome_root_store_debug_info = + cert_verifier::mojom::ChromeRootStoreDebugInfo::New(); + debug_info->chrome_root_store_debug_info->chrome_root_store_version = + kTestChromeRootVersion; +#endif + base::Time time = base::Time::Now(); debug_info->trial_verification_time = time; debug_info->trial_der_verification_time = "it's just a string"; @@ -478,6 +490,15 @@ TEST(ErrorReportTest, TrialDebugInfo) { EXPECT_FALSE(trial_info.has_win_platform_debug_info()); #endif +#if BUILDFLAG(CHROME_ROOT_STORE_SUPPORTED) + ASSERT_TRUE(trial_info.has_chrome_root_store_debug_info()); + EXPECT_EQ( + kTestChromeRootVersion, + trial_info.chrome_root_store_debug_info().chrome_root_store_version()); +#else + EXPECT_FALSE(trial_info.has_chrome_root_store_debug_info()); +#endif + ASSERT_TRUE(trial_info.has_trial_verification_time_usec()); EXPECT_EQ(time.ToDeltaSinceWindowsEpoch().InMicroseconds(), trial_info.trial_verification_time_usec()); diff --git a/chromium/components/security_interstitials/content/https_only_mode_blocking_page.cc b/chromium/components/security_interstitials/content/https_only_mode_blocking_page.cc index 3328297c8de..1cc7125b317 100644 --- a/chromium/components/security_interstitials/content/https_only_mode_blocking_page.cc +++ b/chromium/components/security_interstitials/content/https_only_mode_blocking_page.cc @@ -107,7 +107,7 @@ void HttpsOnlyModeBlockingPage::CommandReceived(const std::string& command) { } void HttpsOnlyModeBlockingPage::PopulateInterstitialStrings( - base::Value* load_time_data) { + base::Value::Dict& load_time_data) { PopulateHttpsOnlyModeStringsForSharedHTML(load_time_data); PopulateHttpsOnlyModeStringsForBlockingPage(load_time_data, request_url()); } diff --git a/chromium/components/security_interstitials/content/https_only_mode_blocking_page.h b/chromium/components/security_interstitials/content/https_only_mode_blocking_page.h index 9d6daa1ce7f..7147c496185 100644 --- a/chromium/components/security_interstitials/content/https_only_mode_blocking_page.h +++ b/chromium/components/security_interstitials/content/https_only_mode_blocking_page.h @@ -28,7 +28,7 @@ class HttpsOnlyModeBlockingPage : public SecurityInterstitialPage { protected: // SecurityInterstitialPage: void CommandReceived(const std::string& command) override; - void PopulateInterstitialStrings(base::Value* load_time_data) override; + void PopulateInterstitialStrings(base::Value::Dict& load_time_data) override; private: bool user_made_decision_ = false; diff --git a/chromium/components/security_interstitials/content/insecure_form_blocking_page.cc b/chromium/components/security_interstitials/content/insecure_form_blocking_page.cc index e551705e448..4a127e5c8f2 100644 --- a/chromium/components/security_interstitials/content/insecure_form_blocking_page.cc +++ b/chromium/components/security_interstitials/content/insecure_form_blocking_page.cc @@ -78,39 +78,36 @@ void InsecureFormBlockingPage::CommandReceived(const std::string& command) { } void InsecureFormBlockingPage::PopulateInterstitialStrings( - base::Value* load_time_data) { + base::Value::Dict& load_time_data) { PopulateValuesForSharedHTML(load_time_data); - load_time_data->SetStringKey( - "tabTitle", l10n_util::GetStringUTF16(IDS_INSECURE_FORM_TITLE)); - load_time_data->SetStringKey( - "heading", l10n_util::GetStringUTF16(IDS_INSECURE_FORM_HEADING)); - load_time_data->SetStringKey( + load_time_data.Set("tabTitle", + l10n_util::GetStringUTF16(IDS_INSECURE_FORM_TITLE)); + load_time_data.Set("heading", + l10n_util::GetStringUTF16(IDS_INSECURE_FORM_HEADING)); + load_time_data.Set( "primaryParagraph", l10n_util::GetStringUTF16(IDS_INSECURE_FORM_PRIMARY_PARAGRAPH)); - load_time_data->SetStringKey( - "proceedButtonText", - l10n_util::GetStringUTF16(IDS_INSECURE_FORM_SUBMIT_BUTTON)); - load_time_data->SetStringKey( - "primaryButtonText", - l10n_util::GetStringUTF16(IDS_INSECURE_FORM_BACK_BUTTON)); - load_time_data->SetStringKey( - "optInLink", - l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_SCOUT_REPORTING_AGREE)); - load_time_data->SetStringKey( + load_time_data.Set("proceedButtonText", l10n_util::GetStringUTF16( + IDS_INSECURE_FORM_SUBMIT_BUTTON)); + load_time_data.Set("primaryButtonText", + l10n_util::GetStringUTF16(IDS_INSECURE_FORM_BACK_BUTTON)); + load_time_data.Set("optInLink", l10n_util::GetStringUTF16( + IDS_SAFE_BROWSING_SCOUT_REPORTING_AGREE)); + load_time_data.Set( "enhancedProtectionMessage", l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_ENHANCED_PROTECTION_MESSAGE)); } void InsecureFormBlockingPage::PopulateValuesForSharedHTML( - base::Value* load_time_data) { - load_time_data->SetStringKey("type", "INSECURE_FORM"); - load_time_data->SetBoolKey("overridable", false); - load_time_data->SetBoolKey("hide_primary_button", false); - load_time_data->SetBoolKey("show_recurrent_error_paragraph", false); - load_time_data->SetStringKey("recurrentErrorParagraph", ""); - load_time_data->SetStringKey("openDetails", ""); - load_time_data->SetStringKey("explanationParagraph", ""); - load_time_data->SetStringKey("finalParagraph", ""); + base::Value::Dict& load_time_data) { + load_time_data.Set("type", "INSECURE_FORM"); + load_time_data.Set("overridable", false); + load_time_data.Set("hide_primary_button", false); + load_time_data.Set("show_recurrent_error_paragraph", false); + load_time_data.Set("recurrentErrorParagraph", ""); + load_time_data.Set("openDetails", ""); + load_time_data.Set("explanationParagraph", ""); + load_time_data.Set("finalParagraph", ""); } } // namespace security_interstitials diff --git a/chromium/components/security_interstitials/content/insecure_form_blocking_page.h b/chromium/components/security_interstitials/content/insecure_form_blocking_page.h index c055662bac3..b79ba7224f6 100644 --- a/chromium/components/security_interstitials/content/insecure_form_blocking_page.h +++ b/chromium/components/security_interstitials/content/insecure_form_blocking_page.h @@ -33,11 +33,11 @@ class InsecureFormBlockingPage : public SecurityInterstitialPage { protected: // SecurityInterstitialPage:: void CommandReceived(const std::string& command) override; - void PopulateInterstitialStrings(base::Value* load_time_data) override; + void PopulateInterstitialStrings(base::Value::Dict& load_time_data) override; private: // Adds values required for shared interstitial HTML to |load_time_data|. - void PopulateValuesForSharedHTML(base::Value* load_time_data); + void PopulateValuesForSharedHTML(base::Value::Dict& load_time_data); }; } // namespace security_interstitials diff --git a/chromium/components/security_interstitials/content/mitm_software_blocking_page.cc b/chromium/components/security_interstitials/content/mitm_software_blocking_page.cc index 6e8142d2489..dc55b0c6cae 100644 --- a/chromium/components/security_interstitials/content/mitm_software_blocking_page.cc +++ b/chromium/components/security_interstitials/content/mitm_software_blocking_page.cc @@ -73,7 +73,7 @@ MITMSoftwareBlockingPage::GetTypeForTesting() { } void MITMSoftwareBlockingPage::PopulateInterstitialStrings( - base::Value* load_time_data) { + base::Value::Dict& load_time_data) { mitm_software_ui_->PopulateStringsForHTML(load_time_data); cert_report_helper()->PopulateExtendedReportingOption(load_time_data); cert_report_helper()->PopulateEnhancedProtectionMessage(load_time_data); diff --git a/chromium/components/security_interstitials/content/mitm_software_blocking_page.h b/chromium/components/security_interstitials/content/mitm_software_blocking_page.h index 535f0c5e3d1..c4348a13b73 100644 --- a/chromium/components/security_interstitials/content/mitm_software_blocking_page.h +++ b/chromium/components/security_interstitials/content/mitm_software_blocking_page.h @@ -57,7 +57,7 @@ class MITMSoftwareBlockingPage : public SSLBlockingPageBase { protected: // SecurityInterstitialPage implementation: void CommandReceived(const std::string& command) override; - void PopulateInterstitialStrings(base::Value* load_time_data) override; + void PopulateInterstitialStrings(base::Value::Dict& load_time_data) override; private: const net::SSLInfo ssl_info_; diff --git a/chromium/components/security_interstitials/content/origin_policy_interstitial_page.cc b/chromium/components/security_interstitials/content/origin_policy_interstitial_page.cc deleted file mode 100644 index dc74b84f0df..00000000000 --- a/chromium/components/security_interstitials/content/origin_policy_interstitial_page.cc +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright 2019 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. - -#include "components/security_interstitials/content/origin_policy_interstitial_page.h" - -#include <string> -#include <utility> -#include <vector> - -#include "base/strings/utf_string_conversions.h" -#include "base/values.h" -#include "components/strings/grit/components_strings.h" -#include "content/public/browser/navigation_controller.h" -#include "content/public/browser/origin_policy_commands.h" -#include "content/public/browser/web_contents.h" -#include "ui/base/l10n/l10n_util.h" -#include "url/gurl.h" -#include "url/origin.h" - -namespace security_interstitials { - -OriginPolicyInterstitialPage::OriginPolicyInterstitialPage( - content::WebContents* web_contents, - content::StoragePartition* storage_partition, - const GURL& request_url, - std::unique_ptr<SecurityInterstitialControllerClient> controller, - network::OriginPolicyState error_reason) - : SecurityInterstitialPage(web_contents, - request_url, - std::move(controller)), - storage_partition_(storage_partition), - error_reason_(error_reason) {} - -OriginPolicyInterstitialPage::~OriginPolicyInterstitialPage() = default; - -void OriginPolicyInterstitialPage::OnInterstitialClosing() {} - -void OriginPolicyInterstitialPage::PopulateInterstitialStrings( - base::Value* load_time_data) { - load_time_data->SetStringKey("type", "ORIGIN_POLICY"); - - // User may choose to ignore the warning & proceed to the site. - load_time_data->SetBoolKey("overridable", true); - - // Custom messages depending on the OriginPolicyState: - int explanation_paragraph_id = 0; - switch (error_reason_) { - case network::OriginPolicyState::kCannotLoadPolicy: - explanation_paragraph_id = IDS_ORIGIN_POLICY_EXPLANATION_CANNOT_LOAD; - break; - case network::OriginPolicyState::kCannotParseHeader: - explanation_paragraph_id = - IDS_ORIGIN_POLICY_EXPLANATION_CANNOT_PARSE_HEADER; - break; - default: - NOTREACHED(); - break; - } - - // Variables in IDR_SECURITY_INTERSTITIAL_HTML / interstitial_large.html, - // resources defined in security_interstitials_strings.grdp. - const struct { - const char* name; - int id; - } messages[] = { - {"closeDetails", IDS_ORIGIN_POLICY_CLOSE}, - {"explanationParagraph", explanation_paragraph_id}, - {"finalParagraph", IDS_ORIGIN_POLICY_FINAL_PARAGRAPH}, - {"heading", IDS_ORIGIN_POLICY_HEADING}, - {"openDetails", IDS_ORIGIN_POLICY_DETAILS}, - {"optInLink", IDS_SAFE_BROWSING_SCOUT_REPORTING_AGREE}, - {"enhancedProtectionMessage", - IDS_SAFE_BROWSING_ENHANCED_PROTECTION_MESSAGE}, - {"primaryButtonText", IDS_ORIGIN_POLICY_BUTTON}, - {"primaryParagraph", IDS_ORIGIN_POLICY_INFO}, - {"recurrentErrorParagraph", IDS_ORIGIN_POLICY_INFO2}, - {"tabTitle", IDS_ORIGIN_POLICY_TITLE}, - }; - // We interpolate _all_ strings with URL ($1) and origin ($2). - const std::vector<std::u16string> message_params = { - base::ASCIIToUTF16(request_url().spec()), - base::ASCIIToUTF16(url::Origin::Create(request_url()).Serialize()), - }; - for (const auto& message : messages) { - load_time_data->SetStringKey( - message.name, - base::ReplaceStringPlaceholders(l10n_util::GetStringUTF16(message.id), - message_params, nullptr)); - }; - - // Selectively enable certain UI elements. - load_time_data->SetBoolKey( - "hide_primary_button", - !web_contents()->GetController().CanGoBack() || - load_time_data->FindStringKey("primaryButtonText")->empty()); - load_time_data->SetBoolKey( - "show_recurrent_error_paragraph", - !load_time_data->FindStringKey("recurrentErrorParagraph")->empty()); -} - -void OriginPolicyInterstitialPage::CommandReceived(const std::string& command) { - // The command string we get passed in is interstitial_commands.mojom turned - // into a number turned into a string. - // - // TODO(carlosil): After non-committed insterstitials have been removed this - // should be cleaned up to use enum values (or somesuch). - if (command == "0") { - DontProceed(); - } else if (command == "1") { - Proceed(); - } else if (command == "2") { - // "Advanced" button, which shows extra text. This is handled within - // the page. - } else { - NOTREACHED(); - } -} - -void OriginPolicyInterstitialPage::Proceed() { - content::OriginPolicyAddExceptionFor(storage_partition_, request_url()); - web_contents()->GetController().Reload(content::ReloadType::NORMAL, true); -} - -void OriginPolicyInterstitialPage::DontProceed() { - // "Go Back" / "Don't Proceed" button should be disabled if we can't go back. - DCHECK(web_contents()->GetController().CanGoBack()); - web_contents()->GetController().GoBack(); -} - -} // namespace security_interstitials diff --git a/chromium/components/security_interstitials/content/origin_policy_interstitial_page.h b/chromium/components/security_interstitials/content/origin_policy_interstitial_page.h deleted file mode 100644 index 69448750c1b..00000000000 --- a/chromium/components/security_interstitials/content/origin_policy_interstitial_page.h +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright 2019 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 COMPONENTS_SECURITY_INTERSTITIALS_CONTENT_ORIGIN_POLICY_INTERSTITIAL_PAGE_H_ -#define COMPONENTS_SECURITY_INTERSTITIALS_CONTENT_ORIGIN_POLICY_INTERSTITIAL_PAGE_H_ - -#include <memory> -#include <string> - -#include "base/memory/raw_ptr.h" -#include "components/security_interstitials/content/security_interstitial_controller_client.h" -#include "components/security_interstitials/content/security_interstitial_page.h" -#include "services/network/public/cpp/origin_policy.h" - -#include "url/gurl.h" - -namespace content { -class StoragePartition; -class WebContents; -} // namespace content - -namespace security_interstitials { -class SecurityInterstitialControllerClient; - -class OriginPolicyInterstitialPage : public SecurityInterstitialPage { - public: - OriginPolicyInterstitialPage( - content::WebContents* web_contents, - content::StoragePartition* storage_partition, - const GURL& request_url, - std::unique_ptr<SecurityInterstitialControllerClient> controller, - network::OriginPolicyState error_reason); - - OriginPolicyInterstitialPage(const OriginPolicyInterstitialPage&) = delete; - OriginPolicyInterstitialPage& operator=(const OriginPolicyInterstitialPage&) = - delete; - - ~OriginPolicyInterstitialPage() override; - - void OnInterstitialClosing() override; - - void CommandReceived(const std::string& command) override; - - protected: - void PopulateInterstitialStrings(base::Value*) override; - - private: - raw_ptr<content::StoragePartition> storage_partition_; - network::OriginPolicyState error_reason_; - - void Proceed(); - void DontProceed(); -}; - -} // namespace security_interstitials - -#endif // COMPONENTS_SECURITY_INTERSTITIALS_CONTENT_ORIGIN_POLICY_INTERSTITIAL_PAGE_H_ diff --git a/chromium/components/security_interstitials/content/origin_policy_ui.cc b/chromium/components/security_interstitials/content/origin_policy_ui.cc deleted file mode 100644 index 343fd88d5e5..00000000000 --- a/chromium/components/security_interstitials/content/origin_policy_ui.cc +++ /dev/null @@ -1,74 +0,0 @@ -// 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. - -#include "components/security_interstitials/content/origin_policy_ui.h" - -#include <string> -#include <utility> - -#include "base/check.h" -#include "components/security_interstitials/content/origin_policy_interstitial_page.h" -#include "components/security_interstitials/content/security_interstitial_tab_helper.h" -#include "components/security_interstitials/content/settings_page_helper.h" -#include "components/security_interstitials/core/metrics_helper.h" -#include "content/public/browser/browser_context.h" -#include "content/public/browser/navigation_handle.h" -#include "content/public/browser/storage_partition.h" -#include "services/network/public/cpp/origin_policy.h" -#include "third_party/abseil-cpp/absl/types/optional.h" -#include "url/gurl.h" - -namespace security_interstitials { - -namespace { - -std::unique_ptr<SecurityInterstitialPage> GetErrorPageImpl( - network::OriginPolicyState error_reason, - content::WebContents* web_contents, - content::StoragePartition* storage_partition, - const GURL& url) { - MetricsHelper::ReportDetails report_details; - report_details.metric_prefix = "origin_policy"; - std::unique_ptr<SecurityInterstitialControllerClient> controller = - std::make_unique<SecurityInterstitialControllerClient>( - web_contents, - std::make_unique<MetricsHelper>(url, report_details, nullptr), - nullptr, /* pref service: can be null */ - "", GURL(), /* settings_page_helper: not used */ nullptr); - return std::make_unique<security_interstitials::OriginPolicyInterstitialPage>( - web_contents, storage_partition, url, std::move(controller), - error_reason); -} - -} // namespace - -absl::optional<std::string> OriginPolicyUI::GetErrorPageAsHTML( - network::OriginPolicyState error_reason, - content::NavigationHandle* handle) { - DCHECK(handle); - std::unique_ptr<SecurityInterstitialPage> page(GetErrorPageImpl( - error_reason, handle->GetWebContents(), - handle->GetRenderFrameHost()->GetStoragePartition(), handle->GetURL())); - std::string html = page->GetHTMLContents(); - - // The page object is "associated" with the web contents, and this is how - // the interstitial infrastructure will find this instance again. - security_interstitials::SecurityInterstitialTabHelper::AssociateBlockingPage( - handle, std::move(page)); - - return html; -} - -SecurityInterstitialPage* OriginPolicyUI::GetBlockingPage( - network::OriginPolicyState error_reason, - content::WebContents* web_contents, - const GURL& url) { - return GetErrorPageImpl( - error_reason, web_contents, - web_contents->GetBrowserContext()->GetDefaultStoragePartition(), - url) - .release(); -} - -} // namespace security_interstitials diff --git a/chromium/components/security_interstitials/content/origin_policy_ui.h b/chromium/components/security_interstitials/content/origin_policy_ui.h deleted file mode 100644 index d5ffb534d4c..00000000000 --- a/chromium/components/security_interstitials/content/origin_policy_ui.h +++ /dev/null @@ -1,47 +0,0 @@ -// 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 COMPONENTS_SECURITY_INTERSTITIALS_CONTENT_ORIGIN_POLICY_UI_H_ -#define COMPONENTS_SECURITY_INTERSTITIALS_CONTENT_ORIGIN_POLICY_UI_H_ - -#include <memory> -#include <string> - -#include <string> -#include "third_party/abseil-cpp/absl/types/optional.h" - -class GURL; - -namespace content { -class NavigationHandle; -class WebContents; -} // namespace content - -namespace network { -enum class OriginPolicyState; -} - -namespace security_interstitials { -class SecurityInterstitialPage; - -// A helper class to build the error page for Origin Policy errors. -class OriginPolicyUI { - public: - // Create the error page for the given NavigationHandle. - // This is intended to implement the ContentBrowserClient interface. - static absl::optional<std::string> GetErrorPageAsHTML( - network::OriginPolicyState error_reason, - content::NavigationHandle* handle); - - // Create the error page instance for the given WebContents + URL. - // This is intended for use by debug functions (like chrome:://interstitials). - static SecurityInterstitialPage* GetBlockingPage( - network::OriginPolicyState error_reason, - content::WebContents* web_contents, - const GURL& url); -}; - -} // namespace security_interstitials - -#endif // COMPONENTS_SECURITY_INTERSTITIALS_CONTENT_ORIGIN_POLICY_UI_H_ diff --git a/chromium/components/security_interstitials/content/resources/BUILD.gn b/chromium/components/security_interstitials/content/resources/BUILD.gn index a812d3548f7..655d9b44081 100644 --- a/chromium/components/security_interstitials/content/resources/BUILD.gn +++ b/chromium/components/security_interstitials/content/resources/BUILD.gn @@ -2,17 +2,11 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -import("//third_party/closure_compiler/compile_js.gni") +import("//tools/typescript/ts_library.gni") -assert(enable_js_type_check) - -js_type_check("closure_compile") { - deps = [ ":connection_help" ] -} - -js_library("connection_help") { - deps = [ - "//ui/webui/resources/js:load_time_data.m", - "//ui/webui/resources/js:util.m", - ] +ts_library("build_ts") { + root_dir = "." + out_dir = "$target_gen_dir/tsc" + in_files = [ "connection_help.ts" ] + deps = [ "//ui/webui/resources:library" ] } diff --git a/chromium/components/security_interstitials/content/resources/connection_help.js b/chromium/components/security_interstitials/content/resources/connection_help.ts index 8a6eba1dad8..b24f9cc8ef4 100644 --- a/chromium/components/security_interstitials/content/resources/connection_help.js +++ b/chromium/components/security_interstitials/content/resources/connection_help.ts @@ -7,23 +7,25 @@ import './strings.m.js'; import {loadTimeData} from 'chrome://resources/js/load_time_data.m.js'; import {$} from 'chrome://resources/js/util.m.js'; -const HIDDEN_CLASS = 'hidden'; +const HIDDEN_CLASS: string = 'hidden'; function setupEvents() { - $('details-certerror-button').addEventListener('click', function(event) { + $('details-certerror-button').addEventListener('click', function(_event) { toggleHidden('details-certerror', 'details-certerror-button'); }); - $('details-connectnetwork-button').addEventListener('click', function(event) { - toggleHidden('details-connectnetwork', 'details-connectnetwork-button'); - }); - $('details-clock-button').addEventListener('click', function(event) { + $('details-connectnetwork-button') + .addEventListener('click', function(_event) { + toggleHidden('details-connectnetwork', 'details-connectnetwork-button'); + }); + $('details-clock-button').addEventListener('click', function(_event) { toggleHidden('details-clock', 'details-clock-button'); }); if (loadTimeData.getBoolean('isWindows')) { $('windows-only').classList.remove(HIDDEN_CLASS); - $('details-mitmsoftware-button').addEventListener('click', function(event) { - toggleHidden('details-mitmsoftware', 'details-mitmsoftware-button'); - }); + $('details-mitmsoftware-button') + .addEventListener('click', function(_event) { + toggleHidden('details-mitmsoftware', 'details-mitmsoftware-button'); + }); } switch (window.location.hash) { case '#' + loadTimeData.getInteger('certCommonNameInvalid'): @@ -38,11 +40,10 @@ function setupEvents() { } } -function toggleHidden(className, buttonName) { +function toggleHidden(className: string, buttonName: string) { const hiddenDetails = $(className).classList.toggle(HIDDEN_CLASS); - $(buttonName).innerText = hiddenDetails ? - loadTimeData.getString('connectionHelpShowMore') : - loadTimeData.getString('connectionHelpShowLess'); + $(buttonName).innerText = loadTimeData.getString( + hiddenDetails ? 'connectionHelpShowMore' : 'connectionHelpShowLess'); } document.addEventListener('DOMContentLoaded', setupEvents); diff --git a/chromium/components/security_interstitials/content/security_interstitial_page.cc b/chromium/components/security_interstitials/content/security_interstitial_page.cc index 95da22e94bc..53b00133e62 100644 --- a/chromium/components/security_interstitials/content/security_interstitial_page.cc +++ b/chromium/components/security_interstitials/content/security_interstitial_page.cc @@ -68,10 +68,8 @@ SecurityInterstitialPage::TypeID SecurityInterstitialPage::GetTypeForTesting() { } std::string SecurityInterstitialPage::GetHTMLContents() { - // TODO(crbug.com/1187061): Change to base::Value once webui functions have - // been converted to take base::Value* instead of base::DictionaryValue*. - base::DictionaryValue load_time_data; - PopulateInterstitialStrings(&load_time_data); + base::Value::Dict load_time_data; + PopulateInterstitialStrings(load_time_data); webui::SetLoadTimeDataDefaults(controller()->GetApplicationLocale(), &load_time_data); std::string html = @@ -79,7 +77,7 @@ std::string SecurityInterstitialPage::GetHTMLContents() { GetHTMLTemplateId()); webui::AppendWebUiCssTextDefaults(&html); - return webui::GetI18nTemplateHtml(html, &load_time_data); + return webui::GetI18nTemplateHtml(html, load_time_data); } SecurityInterstitialControllerClient* SecurityInterstitialPage::controller() diff --git a/chromium/components/security_interstitials/content/security_interstitial_page.h b/chromium/components/security_interstitials/content/security_interstitial_page.h index 7dd18cb17ba..66633a504d3 100644 --- a/chromium/components/security_interstitials/content/security_interstitial_page.h +++ b/chromium/components/security_interstitials/content/security_interstitial_page.h @@ -9,12 +9,9 @@ #include <string> #include "base/memory/raw_ptr.h" +#include "base/values.h" #include "url/gurl.h" -namespace base { -class Value; -} - namespace content { class WebContents; } @@ -62,7 +59,8 @@ class SecurityInterstitialPage { protected: // Populates the strings used to generate the HTML from the template. - virtual void PopulateInterstitialStrings(base::Value* load_time_data) = 0; + virtual void PopulateInterstitialStrings( + base::Value::Dict& load_time_data) = 0; virtual int GetHTMLTemplateId(); diff --git a/chromium/components/security_interstitials/content/security_interstitial_tab_helper_unittest.cc b/chromium/components/security_interstitials/content/security_interstitial_tab_helper_unittest.cc index 8643b7ff236..ae73fb7b724 100644 --- a/chromium/components/security_interstitials/content/security_interstitial_tab_helper_unittest.cc +++ b/chromium/components/security_interstitials/content/security_interstitial_tab_helper_unittest.cc @@ -62,7 +62,8 @@ class TestInterstitialPage : public SecurityInterstitialPage { void OnInterstitialClosing() override {} protected: - void PopulateInterstitialStrings(base::Value* load_time_data) override {} + void PopulateInterstitialStrings(base::Value::Dict& load_time_data) override { + } private: raw_ptr<bool> destroyed_tracker_; diff --git a/chromium/components/security_interstitials/content/ssl_blocking_page.cc b/chromium/components/security_interstitials/content/ssl_blocking_page.cc index 4c7dec2764b..79d7e43428e 100644 --- a/chromium/components/security_interstitials/content/ssl_blocking_page.cc +++ b/chromium/components/security_interstitials/content/ssl_blocking_page.cc @@ -42,7 +42,8 @@ SSLBlockingPage::GetTypeForTesting() { SSLBlockingPage::~SSLBlockingPage() = default; -void SSLBlockingPage::PopulateInterstitialStrings(base::Value* load_time_data) { +void SSLBlockingPage::PopulateInterstitialStrings( + base::Value::Dict& load_time_data) { ssl_error_ui_->PopulateStringsForHTML(load_time_data); cert_report_helper()->PopulateExtendedReportingOption(load_time_data); cert_report_helper()->PopulateEnhancedProtectionMessage(load_time_data); diff --git a/chromium/components/security_interstitials/content/ssl_blocking_page.h b/chromium/components/security_interstitials/content/ssl_blocking_page.h index 7c39783e735..1193e12075e 100644 --- a/chromium/components/security_interstitials/content/ssl_blocking_page.h +++ b/chromium/components/security_interstitials/content/ssl_blocking_page.h @@ -71,7 +71,7 @@ class SSLBlockingPage : public SSLBlockingPageBase { protected: // SecurityInterstitialPage implementation: void CommandReceived(const std::string& command) override; - void PopulateInterstitialStrings(base::Value* load_time_data) override; + void PopulateInterstitialStrings(base::Value::Dict& load_time_data) override; private: friend class policy::PolicyTest_SSLErrorOverridingDisallowed_Test; diff --git a/chromium/components/security_interstitials/content/ssl_error_navigation_throttle_unittest.cc b/chromium/components/security_interstitials/content/ssl_error_navigation_throttle_unittest.cc index 238518fbca7..cea9753758b 100644 --- a/chromium/components/security_interstitials/content/ssl_error_navigation_throttle_unittest.cc +++ b/chromium/components/security_interstitials/content/ssl_error_navigation_throttle_unittest.cc @@ -74,7 +74,7 @@ class FakeSSLBlockingPage // SecurityInterstitialPage: void OnInterstitialClosing() override {} - void PopulateInterstitialStrings(base::Value* load_time_data) override { + void PopulateInterstitialStrings(base::Value::Dict& load_time_data) override { ssl_error_ui_.PopulateStringsForHTML(load_time_data); } diff --git a/chromium/components/security_interstitials/content/stateful_ssl_host_state_delegate.cc b/chromium/components/security_interstitials/content/stateful_ssl_host_state_delegate.cc index be2729fbffe..d744ffb62cd 100644 --- a/chromium/components/security_interstitials/content/stateful_ssl_host_state_delegate.cc +++ b/chromium/components/security_interstitials/content/stateful_ssl_host_state_delegate.cc @@ -16,13 +16,9 @@ #include "base/bind.h" #include "base/callback.h" #include "base/callback_helpers.h" -#include "base/command_line.h" #include "base/containers/contains.h" -#include "base/feature_list.h" #include "base/json/values_util.h" #include "base/logging.h" -#include "base/metrics/field_trial.h" -#include "base/metrics/field_trial_params.h" #include "base/strings/string_number_conversions.h" #include "base/time/clock.h" #include "base/time/default_clock.h" @@ -35,15 +31,10 @@ #include "components/prefs/pref_service.h" #include "components/prefs/scoped_user_pref_update.h" #include "components/security_interstitials/core/pref_names.h" -#include "components/variations/variations_associated_data.h" #include "content/public/browser/browser_context.h" #include "content/public/browser/storage_partition.h" -#include "content/public/browser/web_contents.h" -#include "content/public/common/content_switches.h" #include "net/base/hash_value.h" -#include "net/base/url_util.h" #include "net/cert/x509_certificate.h" -#include "services/network/public/cpp/features.h" #include "services/network/public/mojom/network_context.mojom.h" #include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" @@ -97,40 +88,39 @@ void UpdateRecurrentInterstitialPref(PrefService* pref_service, DictionaryPrefUpdate pref_update(pref_service, prefs::kRecurrentSSLInterstitial); - base::Value* list_value = - pref_update->FindListKey(net::ErrorToShortString(error)); - if (list_value) { + base::Value::Dict& dict = pref_update->GetDict(); + base::Value::List* list = dict.FindList(net::ErrorToShortString(error)); + if (list) { // Check that the values are in increasing order and wipe out the list if // not (presumably because the clock changed). double previous = 0; - for (const auto& error_instance : list_value->GetListDeprecated()) { + for (const auto& error_instance : *list) { double error_time = error_instance.GetDouble(); if (error_time < previous) { - list_value = nullptr; + list = nullptr; break; } previous = error_time; } if (now < previous) - list_value = nullptr; + list = nullptr; } - if (!list_value) { + if (!list) { // Either there was no list of occurrences of this error, or it was corrupt // (i.e. out of order). Save a new list composed of just this one error // instance. - base::Value error_list(base::Value::Type::LIST); + base::Value::List error_list; error_list.Append(now); - pref_update->SetKey(net::ErrorToShortString(error), std::move(error_list)); + dict.Set(net::ErrorToShortString(error), std::move(error_list)); } else { // Only up to |threshold| values need to be stored. If the list already // contains |threshold| values, pop one off the front and append the new one // at the end; otherwise just append the new one. - while (base::MakeStrictNum(list_value->GetListDeprecated().size()) >= - threshold) { - list_value->EraseListIter(list_value->GetListDeprecated().begin()); + while (base::MakeStrictNum(list->size()) >= threshold) { + list->erase(list->begin()); } - list_value->Append(now); + list->Append(now); } } @@ -139,10 +129,10 @@ bool DoesRecurrentInterstitialPrefMeetThreshold(PrefService* pref_service, int error, int threshold, int error_reset_time) { - const base::Value* pref = - pref_service->GetDictionary(prefs::kRecurrentSSLInterstitial); - const base::Value* list_value = - pref->FindListKey(net::ErrorToShortString(error)); + const base::Value::Dict& pref = + pref_service->GetValueDict(prefs::kRecurrentSSLInterstitial); + const base::Value::List* list_value = + pref.FindList(net::ErrorToShortString(error)); if (!list_value) return false; @@ -152,7 +142,7 @@ bool DoesRecurrentInterstitialPrefMeetThreshold(PrefService* pref_service, // Assume that the values in the list are in increasing order; // UpdateRecurrentInterstitialPref() maintains this ordering. Check if there // are more than |threshold| values after the cutoff time. - base::Value::ConstListView error_list = list_value->GetListDeprecated(); + const base::Value::List& error_list = *list_value; for (size_t i = 0; i < error_list.size(); i++) { if (base::Time::FromJsTime(error_list[i].GetDouble()) >= cutoff_time) return base::MakeStrictNum(error_list.size() - i) >= threshold; @@ -222,12 +212,7 @@ void StatefulSSLHostStateDelegate::AllowCert( const std::string& host, const net::X509Certificate& cert, int error, - content::WebContents* web_contents) { - DCHECK(web_contents); - content::StoragePartition* storage_partition = - browser_context_->GetStoragePartition( - web_contents->GetPrimaryMainFrame()->GetSiteInstance(), - false /* can_create */); + content::StoragePartition* storage_partition) { if (!storage_partition || storage_partition != browser_context_->GetDefaultStoragePartition()) { // Decisions for non-default storage partitions are stored in memory only; @@ -247,17 +232,17 @@ void StatefulSSLHostStateDelegate::AllowCert( if (!value.is_dict()) value = base::Value(base::Value::Type::DICTIONARY); - base::Value* cert_dict = - GetValidCertDecisionsDict(CREATE_DICTIONARY_ENTRIES, value); + base::Value::Dict* cert_dict = + GetValidCertDecisionsDict(CREATE_DICTIONARY_ENTRIES, value.GetDict()); // If a a valid certificate dictionary cannot be extracted from the content // setting, that means it's in an unknown format. Unfortunately, there's // nothing to be done in that case, so a silent fail is the only option. if (!cert_dict) return; - value.SetKey(kSSLCertDecisionVersionKey, - base::Value(kDefaultSSLCertDecisionVersion)); - cert_dict->SetKey(GetKey(cert, error), base::Value(ALLOWED)); + value.GetDict().Set(kSSLCertDecisionVersionKey, + kDefaultSSLCertDecisionVersion); + cert_dict->Set(GetKey(cert, error), ALLOWED); // The map takes ownership of the value, so it is released in the call to // SetWebsiteSettingDefaultScope. @@ -284,16 +269,11 @@ void StatefulSSLHostStateDelegate::Clear( } content::SSLHostStateDelegate::CertJudgment -StatefulSSLHostStateDelegate::QueryPolicy(const std::string& host, - const net::X509Certificate& cert, - int error, - content::WebContents* web_contents) { - DCHECK(web_contents); - - content::StoragePartition* storage_partition = - browser_context_->GetStoragePartition( - web_contents->GetPrimaryMainFrame()->GetSiteInstance(), - false /* can_create */); +StatefulSSLHostStateDelegate::QueryPolicy( + const std::string& host, + const net::X509Certificate& cert, + int error, + content::StoragePartition* storage_partition) { if (!storage_partition || storage_partition != browser_context_->GetDefaultStoragePartition()) { if (allowed_certs_for_non_default_storage_partitions_.find(host) == @@ -316,8 +296,8 @@ StatefulSSLHostStateDelegate::QueryPolicy(const std::string& host, if (!value.is_dict()) return DENIED; - base::Value* cert_error_dict = - GetValidCertDecisionsDict(DO_NOT_CREATE_DICTIONARY_ENTRIES, value); + base::Value::Dict* cert_error_dict = GetValidCertDecisionsDict( + DO_NOT_CREATE_DICTIONARY_ENTRIES, value.GetDict()); if (!cert_error_dict) { // This revoke is necessary to clear any old expired setting that may be // lingering in the case that an old decision expried. @@ -326,7 +306,7 @@ StatefulSSLHostStateDelegate::QueryPolicy(const std::string& host, } absl::optional<int> policy_decision = - cert_error_dict->FindIntKey(GetKey(cert, error)); + cert_error_dict->FindInt(GetKey(cert, error)); // If a policy decision was successfully retrieved and it's a valid value of // ALLOWED, return the valid value. Otherwise, return DENIED. @@ -368,13 +348,7 @@ bool StatefulSSLHostStateDelegate::DidHostRunInsecureContent( void StatefulSSLHostStateDelegate::AllowHttpForHost( const std::string& host, - content::WebContents* web_contents) { - DCHECK(web_contents); - - content::StoragePartition* storage_partition = - browser_context_->GetStoragePartition( - web_contents->GetPrimaryMainFrame()->GetSiteInstance(), - /*can_create=*/false); + content::StoragePartition* storage_partition) { bool is_nondefault_storage = !storage_partition || storage_partition != browser_context_->GetDefaultStoragePartition(); @@ -383,11 +357,7 @@ void StatefulSSLHostStateDelegate::AllowHttpForHost( bool StatefulSSLHostStateDelegate::IsHttpAllowedForHost( const std::string& host, - content::WebContents* web_contents) { - content::StoragePartition* storage_partition = - browser_context_->GetStoragePartition( - web_contents->GetPrimaryMainFrame()->GetSiteInstance(), - /*can_create=*/false); + content::StoragePartition* storage_partition) { bool is_nondefault_storage = !storage_partition || storage_partition != browser_context_->GetDefaultStoragePartition(); @@ -409,10 +379,9 @@ void StatefulSSLHostStateDelegate::RevokeUserAllowExceptions( bool StatefulSSLHostStateDelegate::HasAllowException( const std::string& host, - content::WebContents* web_contents) { - DCHECK(web_contents); - return HasCertAllowException(host, web_contents) || - IsHttpAllowedForHost(host, web_contents); + content::StoragePartition* storage_partition) { + return HasCertAllowException(host, storage_partition) || + IsHttpAllowedForHost(host, storage_partition); } // TODO(jww): This will revoke all of the decisions in the browser context. @@ -487,7 +456,7 @@ void StatefulSSLHostStateDelegate::ResetRecurrentErrorCountForTesting() { recurrent_errors_.clear(); DictionaryPrefUpdate pref_update(pref_service_, prefs::kRecurrentSSLInterstitial); - pref_update->DictClear(); + pref_update->GetDict().clear(); } void StatefulSSLHostStateDelegate::SetClockForTesting( @@ -538,11 +507,7 @@ StatefulSSLHostStateDelegate::GetRecurrentInterstitialMode() const { bool StatefulSSLHostStateDelegate::HasCertAllowException( const std::string& host, - content::WebContents* web_contents) { - content::StoragePartition* storage_partition = - browser_context_->GetStoragePartition( - web_contents->GetPrimaryMainFrame()->GetSiteInstance(), - false /* can_create */); + content::StoragePartition* storage_partition) { if (!storage_partition || storage_partition != browser_context_->GetDefaultStoragePartition()) { return base::Contains(allowed_certs_for_non_default_storage_partitions_, @@ -581,17 +546,17 @@ bool StatefulSSLHostStateDelegate::HasCertAllowException( // addition to there not being any values in the dictionary). If create_entries // is set to |CREATE_DICTIONARY_ENTRIES|, if no dictionary is found or the // decisions are expired, a new dictionary will be created. -base::Value* StatefulSSLHostStateDelegate::GetValidCertDecisionsDict( +base::Value::Dict* StatefulSSLHostStateDelegate::GetValidCertDecisionsDict( CreateDictionaryEntriesDisposition create_entries, - base::Value& dict) { + base::Value::Dict& dict) { // Extract the version of the certificate decision structure from the content // setting. - absl::optional<int> version = dict.FindIntKey(kSSLCertDecisionVersionKey); + absl::optional<int> version = dict.FindInt(kSSLCertDecisionVersionKey); if (!version) { if (create_entries == DO_NOT_CREATE_DICTIONARY_ENTRIES) return nullptr; - dict.SetIntKey(kSSLCertDecisionVersionKey, kDefaultSSLCertDecisionVersion); + dict.Set(kSSLCertDecisionVersionKey, kDefaultSSLCertDecisionVersion); version = absl::make_optional<int>(kDefaultSSLCertDecisionVersion); } @@ -612,7 +577,7 @@ base::Value* StatefulSSLHostStateDelegate::GetValidCertDecisionsDict( bool expired = false; base::Time now = clock_->Now(); auto* decision_expiration_value = - dict.FindKey(kSSLCertDecisionExpirationTimeKey); + dict.Find(kSSLCertDecisionExpirationTimeKey); auto decision_expiration = base::ValueToTime(decision_expiration_value); // Check to see if the user's certificate decision has expired. @@ -630,19 +595,19 @@ base::Value* StatefulSSLHostStateDelegate::GetValidCertDecisionsDict( // Unfortunately, JSON (and thus content settings) doesn't support int64_t // values, only doubles. Since this mildly depends on precision, it is // better to store the value as a string. - dict.SetKey(kSSLCertDecisionExpirationTimeKey, - base::TimeToValue(expiration_time)); + dict.Set(kSSLCertDecisionExpirationTimeKey, + base::TimeToValue(expiration_time)); } // Extract the map of certificate fingerprints to errors from the setting. - base::Value* cert_error_dict = - dict.FindDictKey(kSSLCertDecisionCertErrorMapKey); + base::Value::Dict* cert_error_dict = + dict.FindDict(kSSLCertDecisionCertErrorMapKey); if (expired || !cert_error_dict) { if (create_entries == DO_NOT_CREATE_DICTIONARY_ENTRIES) return nullptr; - cert_error_dict = dict.SetKey(kSSLCertDecisionCertErrorMapKey, - base::Value(base::Value::Type::DICTIONARY)); + cert_error_dict = dict.EnsureDict(kSSLCertDecisionCertErrorMapKey); + cert_error_dict->clear(); } return cert_error_dict; diff --git a/chromium/components/security_interstitials/content/stateful_ssl_host_state_delegate.h b/chromium/components/security_interstitials/content/stateful_ssl_host_state_delegate.h index db1dc5a8cda..642b5771897 100644 --- a/chromium/components/security_interstitials/content/stateful_ssl_host_state_delegate.h +++ b/chromium/components/security_interstitials/content/stateful_ssl_host_state_delegate.h @@ -8,7 +8,6 @@ #include <memory> #include <set> -#include "base/feature_list.h" #include "base/memory/raw_ptr.h" #include "components/keyed_service/core/keyed_service.h" #include "components/security_interstitials/core/https_only_mode_allowlist.h" @@ -25,6 +24,7 @@ class FilePath; namespace content { class BrowserContext; +class StoragePartition; } namespace user_prefs { @@ -58,13 +58,14 @@ class StatefulSSLHostStateDelegate : public content::SSLHostStateDelegate, void AllowCert(const std::string& host, const net::X509Certificate& cert, int error, - content::WebContents* web_contents) override; + content::StoragePartition* storage_partition) override; void Clear( base::RepeatingCallback<bool(const std::string&)> host_filter) override; - CertJudgment QueryPolicy(const std::string& host, - const net::X509Certificate& cert, - int error, - content::WebContents* web_contents) override; + CertJudgment QueryPolicy( + const std::string& host, + const net::X509Certificate& cert, + int error, + content::StoragePartition* storage_partition) override; void HostRanInsecureContent(const std::string& host, int child_id, InsecureContentType content_type) override; @@ -72,12 +73,13 @@ class StatefulSSLHostStateDelegate : public content::SSLHostStateDelegate, int child_id, InsecureContentType content_type) override; void AllowHttpForHost(const std::string& host, - content::WebContents* web_contents) override; - bool IsHttpAllowedForHost(const std::string& host, - content::WebContents* web_contents) override; + content::StoragePartition* storage_partition) override; + bool IsHttpAllowedForHost( + const std::string& host, + content::StoragePartition* storage_partition) override; void RevokeUserAllowExceptions(const std::string& host) override; bool HasAllowException(const std::string& host, - content::WebContents* web_contents) override; + content::StoragePartition* storage_partition) override; // RevokeUserAllowExceptionsHard is the same as RevokeUserAllowExceptions but // additionally may close idle connections in the process. This should be used @@ -122,7 +124,7 @@ class StatefulSSLHostStateDelegate : public content::SSLHostStateDelegate, // Returns whether the user has allowed a certificate error exception for // |host|. bool HasCertAllowException(const std::string& host, - content::WebContents* web_contents); + content::StoragePartition* storage_partition); // Returns a dictionary of certificate fingerprints and errors that have been // allowed as exceptions by the user. @@ -135,9 +137,9 @@ class StatefulSSLHostStateDelegate : public content::SSLHostStateDelegate, // GetValidCertDecisionsDict will create a new set of entries within the // dictionary if they do not already exist. Otherwise will fail and return if // NULL if they do not exist. - base::Value* GetValidCertDecisionsDict( + base::Value::Dict* GetValidCertDecisionsDict( CreateDictionaryEntriesDisposition create_entries, - base::Value& dict); + base::Value::Dict& dict); std::unique_ptr<base::Clock> clock_; raw_ptr<content::BrowserContext> browser_context_; diff --git a/chromium/components/security_interstitials/core/BUILD.gn b/chromium/components/security_interstitials/core/BUILD.gn index 2f073cfabcb..939869eb31a 100644 --- a/chromium/components/security_interstitials/core/BUILD.gn +++ b/chromium/components/security_interstitials/core/BUILD.gn @@ -8,8 +8,6 @@ static_library("core") { "bad_clock_ui.h", "base_safe_browsing_error_ui.cc", "base_safe_browsing_error_ui.h", - "blocked_interception_ui.cc", - "blocked_interception_ui.h", "common_string_util.cc", "common_string_util.h", "controller_client.cc", @@ -22,8 +20,6 @@ static_library("core") { "https_only_mode_ui_util.h", "metrics_helper.cc", "metrics_helper.h", - "mitm_software_ui.cc", - "mitm_software_ui.h", "omnibox_https_upgrade_metrics.cc", "omnibox_https_upgrade_metrics.h", "pref_names.cc", @@ -40,10 +36,12 @@ static_library("core") { "urls.h", ] - if (is_ios) { - sources -= [ + if (!is_ios) { + sources += [ "blocked_interception_ui.cc", "blocked_interception_ui.h", + "https_only_mode_policy_handler.cc", + "https_only_mode_policy_handler.h", "mitm_software_ui.cc", "mitm_software_ui.h", ] @@ -56,6 +54,8 @@ static_library("core") { "//components/google/core/common", "//components/history/core/browser", "//components/metrics", + "//components/policy/core/browser", + "//components/policy/core/common", "//components/prefs", "//components/resources", "//components/ssl_errors", diff --git a/chromium/components/security_interstitials/core/bad_clock_ui.cc b/chromium/components/security_interstitials/core/bad_clock_ui.cc index d9fd6d0a765..100d83539d0 100644 --- a/chromium/components/security_interstitials/core/bad_clock_ui.cc +++ b/chromium/components/security_interstitials/core/bad_clock_ui.cc @@ -35,9 +35,7 @@ BadClockUI::~BadClockUI() { controller_->metrics_helper()->RecordShutdownMetrics(); } -void BadClockUI::PopulateStringsForHTML(base::Value* load_time_data) { - CHECK(load_time_data); - +void BadClockUI::PopulateStringsForHTML(base::Value::Dict& load_time_data) { // Shared with other SSL errors. common_string_util::PopulateSSLLayoutStrings(cert_error_, load_time_data); common_string_util::PopulateSSLDebuggingStrings(ssl_info_, time_triggered_, @@ -45,15 +43,14 @@ void BadClockUI::PopulateStringsForHTML(base::Value* load_time_data) { // Clock-specific strings. PopulateClockStrings(load_time_data); - load_time_data->SetStringKey("finalParagraph", - std::string()); // Placeholder. + load_time_data.Set("finalParagraph", ""); // Placeholder. } -void BadClockUI::PopulateClockStrings(base::Value* load_time_data) { - load_time_data->SetBoolKey("bad_clock", true); - load_time_data->SetBoolKey("overridable", false); - load_time_data->SetBoolKey("hide_primary_button", - !controller_->CanLaunchDateAndTimeSettings()); +void BadClockUI::PopulateClockStrings(base::Value::Dict& load_time_data) { + load_time_data.Set("bad_clock", true); + load_time_data.Set("overridable", false); + load_time_data.Set("hide_primary_button", + !controller_->CanLaunchDateAndTimeSettings()); int heading_string = 0; switch (clock_state_) { case ssl_errors::CLOCK_STATE_FUTURE: @@ -65,22 +62,19 @@ void BadClockUI::PopulateClockStrings(base::Value* load_time_data) { default: NOTREACHED(); } - load_time_data->SetStringKey( - "tabTitle", l10n_util::GetStringUTF16(IDS_CLOCK_ERROR_TITLE)); - load_time_data->SetStringKey("heading", - l10n_util::GetStringUTF16(heading_string)); - load_time_data->SetStringKey( - "primaryParagraph", - l10n_util::GetStringFUTF16( - IDS_CLOCK_ERROR_PRIMARY_PARAGRAPH, - common_string_util::GetFormattedHostName(request_url_), - base::TimeFormatFriendlyDateAndTime(time_triggered_))); - load_time_data->SetStringKey( + load_time_data.Set("tabTitle", + l10n_util::GetStringUTF16(IDS_CLOCK_ERROR_TITLE)); + load_time_data.Set("heading", l10n_util::GetStringUTF16(heading_string)); + load_time_data.Set("primaryParagraph", + l10n_util::GetStringFUTF16( + IDS_CLOCK_ERROR_PRIMARY_PARAGRAPH, + common_string_util::GetFormattedHostName(request_url_), + base::TimeFormatFriendlyDateAndTime(time_triggered_))); + load_time_data.Set( "primaryButtonText", l10n_util::GetStringUTF16(IDS_CLOCK_ERROR_UPDATE_DATE_AND_TIME)); - load_time_data->SetStringKey( - "explanationParagraph", - l10n_util::GetStringUTF16(IDS_CLOCK_ERROR_EXPLANATION)); + load_time_data.Set("explanationParagraph", + l10n_util::GetStringUTF16(IDS_CLOCK_ERROR_EXPLANATION)); } void BadClockUI::HandleCommand(SecurityInterstitialCommand command) { diff --git a/chromium/components/security_interstitials/core/bad_clock_ui.h b/chromium/components/security_interstitials/core/bad_clock_ui.h index 4b54e351d3b..c8622e9d1bb 100644 --- a/chromium/components/security_interstitials/core/bad_clock_ui.h +++ b/chromium/components/security_interstitials/core/bad_clock_ui.h @@ -30,11 +30,11 @@ class BadClockUI { ~BadClockUI(); - void PopulateStringsForHTML(base::Value* load_time_data); + void PopulateStringsForHTML(base::Value::Dict& load_time_data); void HandleCommand(SecurityInterstitialCommand command); private: - void PopulateClockStrings(base::Value* load_time_data); + void PopulateClockStrings(base::Value::Dict& load_time_data); const GURL request_url_; const int cert_error_; diff --git a/chromium/components/security_interstitials/core/base_safe_browsing_error_ui.h b/chromium/components/security_interstitials/core/base_safe_browsing_error_ui.h index bca786b801e..8e639931257 100644 --- a/chromium/components/security_interstitials/core/base_safe_browsing_error_ui.h +++ b/chromium/components/security_interstitials/core/base_safe_browsing_error_ui.h @@ -188,7 +188,7 @@ class BaseSafeBrowsingErrorUI { GURL request_url() const { return request_url_; } GURL main_frame_url() const { return main_frame_url_; } - virtual void PopulateStringsForHtml(base::Value* load_time_data) = 0; + virtual void PopulateStringsForHtml(base::Value::Dict& load_time_data) = 0; virtual void HandleCommand(SecurityInterstitialCommand command) = 0; virtual int GetHTMLTemplateId() const = 0; diff --git a/chromium/components/security_interstitials/core/blocked_interception_ui.cc b/chromium/components/security_interstitials/core/blocked_interception_ui.cc index d9934685908..092a6e2791d 100644 --- a/chromium/components/security_interstitials/core/blocked_interception_ui.cc +++ b/chromium/components/security_interstitials/core/blocked_interception_ui.cc @@ -40,46 +40,42 @@ BlockedInterceptionUI::~BlockedInterceptionUI() { } void BlockedInterceptionUI::PopulateStringsForHTML( - base::Value* load_time_data) { - CHECK(load_time_data); - + base::Value::Dict& load_time_data) { // Shared with other SSL errors. common_string_util::PopulateSSLLayoutStrings(cert_error_, load_time_data); common_string_util::PopulateSSLDebuggingStrings( ssl_info_, base::Time::NowFromSystemTime(), load_time_data); - load_time_data->SetBoolKey("overridable", true); - load_time_data->SetBoolKey("hide_primary_button", false); - load_time_data->SetBoolKey("bad_clock", false); - load_time_data->SetStringKey("type", "BLOCKED_INTERCEPTION"); + load_time_data.Set("overridable", true); + load_time_data.Set("hide_primary_button", false); + load_time_data.Set("bad_clock", false); + load_time_data.Set("type", "BLOCKED_INTERCEPTION"); const std::u16string hostname( common_string_util::GetFormattedHostName(request_url_)); // Set strings that are shared between enterprise and non-enterprise // interstitials. - load_time_data->SetStringKey( + load_time_data.Set( "tabTitle", l10n_util::GetStringFUTF16(IDS_BLOCKED_INTERCEPTION_HEADING, hostname)); - load_time_data->SetStringKey( + load_time_data.Set( "heading", l10n_util::GetStringFUTF16(IDS_BLOCKED_INTERCEPTION_HEADING, hostname)); - load_time_data->SetStringKey( + load_time_data.Set( "primaryButtonText", l10n_util::GetStringUTF16(IDS_SSL_OVERRIDABLE_SAFETY_BUTTON)); - load_time_data->SetStringKey("finalParagraph", std::string()); + load_time_data.Set("finalParagraph", ""); // Reuse the strings from the WebUI page. - load_time_data->SetStringKey( - "primaryParagraph", - l10n_util::GetStringUTF16(IDS_KNOWN_INTERCEPTION_BODY1)); - load_time_data->SetStringKey( - "explanationParagraph", - l10n_util::GetStringUTF16(IDS_KNOWN_INTERCEPTION_BODY2)); + load_time_data.Set("primaryParagraph", + l10n_util::GetStringUTF16(IDS_KNOWN_INTERCEPTION_BODY1)); + load_time_data.Set("explanationParagraph", + l10n_util::GetStringUTF16(IDS_KNOWN_INTERCEPTION_BODY2)); - load_time_data->SetStringKey( - "finalParagraph", l10n_util::GetStringFUTF16( - IDS_SSL_OVERRIDABLE_PROCEED_PARAGRAPH, hostname)); + load_time_data.Set("finalParagraph", + l10n_util::GetStringFUTF16( + IDS_SSL_OVERRIDABLE_PROCEED_PARAGRAPH, hostname)); } void BlockedInterceptionUI::HandleCommand(SecurityInterstitialCommand command) { diff --git a/chromium/components/security_interstitials/core/blocked_interception_ui.h b/chromium/components/security_interstitials/core/blocked_interception_ui.h index c0f8b0251de..5bc0ef1ce87 100644 --- a/chromium/components/security_interstitials/core/blocked_interception_ui.h +++ b/chromium/components/security_interstitials/core/blocked_interception_ui.h @@ -27,7 +27,7 @@ class BlockedInterceptionUI { ~BlockedInterceptionUI(); - void PopulateStringsForHTML(base::Value* load_time_data); + void PopulateStringsForHTML(base::Value::Dict& load_time_data); void HandleCommand(SecurityInterstitialCommand command); private: diff --git a/chromium/components/security_interstitials/core/browser/resources/interstitial_large.js b/chromium/components/security_interstitials/core/browser/resources/interstitial_large.js index 257f4ab6151..a73365037ba 100644 --- a/chromium/components/security_interstitials/core/browser/resources/interstitial_large.js +++ b/chromium/components/security_interstitials/core/browser/resources/interstitial_large.js @@ -72,7 +72,6 @@ function setupEvents() { const lookalike = interstitialType === 'LOOKALIKE'; const billing = interstitialType === 'SAFEBROWSING' && loadTimeData.getBoolean('billing'); - const originPolicy = interstitialType === 'ORIGIN_POLICY'; const blockedInterception = interstitialType === 'BLOCKED_INTERCEPTION'; const insecureForm = interstitialType == 'INSECURE_FORM'; const httpsOnly = interstitialType == 'HTTPS_ONLY'; @@ -80,7 +79,7 @@ function setupEvents() { const showRecurrentErrorParagraph = loadTimeData.getBoolean( 'show_recurrent_error_paragraph'); - if (ssl || originPolicy || blockedInterception) { + if (ssl || blockedInterception) { $('body').classList.add(badClock ? 'bad-clock' : 'ssl'); if (loadTimeData.valueExists('errorCode')) { $('error-code').textContent = loadTimeData.getString('errorCode'); diff --git a/chromium/components/security_interstitials/core/browser/resources/list_of_interstitials.html b/chromium/components/security_interstitials/core/browser/resources/list_of_interstitials.html index f9a07f198aa..1d7b4b53efb 100644 --- a/chromium/components/security_interstitials/core/browser/resources/list_of_interstitials.html +++ b/chromium/components/security_interstitials/core/browser/resources/list_of_interstitials.html @@ -40,27 +40,31 @@ example.com (HSTS, non-overridable) </a> </li> - <li> - <a href="clock?clock_manipulation=2">Clock is ahead</a> - </li> - <li> - <a href="clock?clock_manipulation=-2">Clock is behind</a> - </li> + <if expr="not is_ios"> + <li> + <a href="clock?clock_manipulation=2">Clock is ahead</a> + </li> + <li> + <a href="clock?clock_manipulation=-2">Clock is behind</a> + </li> + </if> <li> <a href="ssl?type=hpkp_failure">Pinned certificate error</a> </li> <li> <a href="ssl?type=ct_failure&overridable=1">Certificate Transparency error</a> </li> - <li> - <a href="mitm-software-ssl?enterprise=0">MITM software</a> - </li> - <li> - <a href="mitm-software-ssl?enterprise=1">MITM software on an enterprise-managed machine</a> - </li> - <li> - <a href="blocked-interception">Blocked interception</a> - </li> + <if expr="not is_ios"> + <li> + <a href="mitm-software-ssl?enterprise=0">MITM software</a> + </li> + <li> + <a href="mitm-software-ssl?enterprise=1">MITM software on an enterprise-managed machine</a> + </li> + <li> + <a href="blocked-interception">Blocked interception</a> + </li> + </if> </ul> <h3>SafeBrowsing</h3> <h4>Loud</h4> @@ -84,24 +88,26 @@ <a href="safebrowsing?type=billing">Billing</a> </li> </ul> - <h4>Quiet (WebView)</h4> - <ul> - <li> - <a href="quietsafebrowsing?type=malware">Malware</a> - </li> - <li> - <a href="quietsafebrowsing?type=phishing">Phishing</a> - </li> - <li> - <a href="quietsafebrowsing?type=unwanted">Malicious Unwanted Software</a> - </li> - <li> - <a href="quietsafebrowsing?type=billing">Billing</a> - </li> - <li> - <a href="quietsafebrowsing?type=giant">Giant</a> - </li> - </ul> + <if expr="not is_ios"> + <h4>Quiet (WebView)</h4> + <ul> + <li> + <a href="quietsafebrowsing?type=malware">Malware</a> + </li> + <li> + <a href="quietsafebrowsing?type=phishing">Phishing</a> + </li> + <li> + <a href="quietsafebrowsing?type=unwanted">Malicious Unwanted Software</a> + </li> + <li> + <a href="quietsafebrowsing?type=billing">Billing</a> + </li> + <li> + <a href="quietsafebrowsing?type=giant">Giant</a> + </li> + </ul> + </if> <h3>Captive Portal</h3> <ul> <li> @@ -118,40 +124,34 @@ </a> </li> </ul> - <h3>Origin Policy</h3> - <ul> - <li> - <a href="origin_policy"> - Origin Policy Error - </a> - </li> - </ul> - <h3>Lookalike URL Warnings</h3> - <ul> - <li> - <a href="lookalike">Lookalike URL</a> - </li> - <li> - <a href="lookalike?no-safe-url=1">Lookalike URL (no suggested URL)</a> - </li> - </ul> - <h3>Insecure (Mixed) Form Submission Warnings</h3> - <ul> - <li> - <a href="insecure_form">Insecure Form</a> - </li> - </ul> - <h3>HTTPS-Only Mode Warnings</h3> - <ul> - <li> - <a href="https_only">HTTPS-Only Mode</a> - </li> - </ul> - <h3>Supervised User</h3> - <ul> - <li> - <a href="supervised_user?allow-access-requests=1">Supervised User Blocked Site</a> - </li> - </ul> + <if expr="not is_ios"> + <h3>Lookalike URL Warnings</h3> + <ul> + <li> + <a href="lookalike">Lookalike URL</a> + </li> + <li> + <a href="lookalike?no-safe-url=1">Lookalike URL (no suggested URL)</a> + </li> + </ul> + <h3>Insecure (Mixed) Form Submission Warnings</h3> + <ul> + <li> + <a href="insecure_form">Insecure Form</a> + </li> + </ul> + <h3>HTTPS-Only Mode Warnings</h3> + <ul> + <li> + <a href="https_only">HTTPS-Only Mode</a> + </li> + </ul> + <h3>Supervised User</h3> + <ul> + <li> + <a href="supervised_user?allow-access-requests=1">Supervised User Blocked Site</a> + </li> + </ul> + </if> </body> </html> diff --git a/chromium/components/security_interstitials/core/common_string_util.cc b/chromium/components/security_interstitials/core/common_string_util.cc index a5d653120e7..e244dff7650 100644 --- a/chromium/components/security_interstitials/core/common_string_util.cc +++ b/chromium/components/security_interstitials/core/common_string_util.cc @@ -25,49 +25,44 @@ std::u16string GetFormattedHostName(const GURL& gurl) { return host; } -void PopulateSSLLayoutStrings(int cert_error, base::Value* load_time_data) { - load_time_data->SetStringKey("type", "SSL"); - load_time_data->SetStringKey("errorCode", net::ErrorToString(cert_error)); - load_time_data->SetStringKey( - "openDetails", l10n_util::GetStringUTF16(IDS_SSL_OPEN_DETAILS_BUTTON)); - load_time_data->SetStringKey( - "closeDetails", l10n_util::GetStringUTF16(IDS_SSL_CLOSE_DETAILS_BUTTON)); +void PopulateSSLLayoutStrings(int cert_error, + base::Value::Dict& load_time_data) { + load_time_data.Set("type", "SSL"); + load_time_data.Set("errorCode", net::ErrorToString(cert_error)); + load_time_data.Set("openDetails", + l10n_util::GetStringUTF16(IDS_SSL_OPEN_DETAILS_BUTTON)); + load_time_data.Set("closeDetails", + l10n_util::GetStringUTF16(IDS_SSL_CLOSE_DETAILS_BUTTON)); // Not used by most interstitials; can be overridden by individual // interstitials as needed. - load_time_data->SetStringKey("recurrentErrorParagraph", ""); - load_time_data->SetBoolKey("show_recurrent_error_paragraph", false); - load_time_data->SetStringKey( - "optInLink", - l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_SCOUT_REPORTING_AGREE)); - load_time_data->SetStringKey( + load_time_data.Set("recurrentErrorParagraph", ""); + load_time_data.Set("show_recurrent_error_paragraph", false); + load_time_data.Set("optInLink", l10n_util::GetStringUTF16( + IDS_SAFE_BROWSING_SCOUT_REPORTING_AGREE)); + load_time_data.Set( "enhancedProtectionMessage", l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_ENHANCED_PROTECTION_MESSAGE)); } void PopulateSSLDebuggingStrings(const net::SSLInfo ssl_info, const base::Time time_triggered, - base::Value* load_time_data) { - load_time_data->SetStringKey("subject", - ssl_info.cert->subject().GetDisplayName()); - load_time_data->SetStringKey("issuer", - ssl_info.cert->issuer().GetDisplayName()); - load_time_data->SetStringKey( - "expirationDate", - base::TimeFormatShortDate(ssl_info.cert->valid_expiry())); - load_time_data->SetStringKey("currentDate", - base::TimeFormatShortDate(time_triggered)); - std::vector<std::string> sct_list; + base::Value::Dict& load_time_data) { + load_time_data.Set("subject", ssl_info.cert->subject().GetDisplayName()); + load_time_data.Set("issuer", ssl_info.cert->issuer().GetDisplayName()); + load_time_data.Set("expirationDate", + base::TimeFormatShortDate(ssl_info.cert->valid_expiry())); + load_time_data.Set("currentDate", base::TimeFormatShortDate(time_triggered)); + std::string sct_list; for (const auto& sct_status : ssl_info.signed_certificate_timestamps) { - std::string sct_info = "\n\nSCT " + sct_status.sct->log_description + " (" + - net::ct::OriginToString(sct_status.sct->origin) + - ", " + net::ct::StatusToString(sct_status.status) + - ")"; - sct_list.push_back(sct_info); + base::StrAppend(&sct_list, + {"\n\nSCT ", sct_status.sct->log_description, " (", + net::ct::OriginToString(sct_status.sct->origin), ", ", + net::ct::StatusToString(sct_status.status), ")"}); } - load_time_data->SetStringKey("ct", base::StrCat(sct_list)); + load_time_data.Set("ct", std::move(sct_list)); std::vector<std::string> encoded_chain; ssl_info.cert->GetPEMEncodedChain(&encoded_chain); - load_time_data->SetStringKey("pem", base::StrCat(encoded_chain)); + load_time_data.Set("pem", base::StrCat(encoded_chain)); } void PopulateLegacyTLSStrings(base::Value* load_time_data, diff --git a/chromium/components/security_interstitials/core/common_string_util.h b/chromium/components/security_interstitials/core/common_string_util.h index 2bb72841b19..33971f5227d 100644 --- a/chromium/components/security_interstitials/core/common_string_util.h +++ b/chromium/components/security_interstitials/core/common_string_util.h @@ -20,12 +20,13 @@ namespace common_string_util { std::u16string GetFormattedHostName(const GURL& gurl); // For SSL-related errors that share a basic structure. -void PopulateSSLLayoutStrings(int cert_error, base::Value* load_time_data); +void PopulateSSLLayoutStrings(int cert_error, + base::Value::Dict& load_time_data); // For SSL-related errors that provide debugging information. void PopulateSSLDebuggingStrings(const net::SSLInfo ssl_info, const base::Time time_triggered, - base::Value* load_time_data); + base::Value::Dict& load_time_data); // Fills in the details for a legacy TLS error. Abstracts the strings for // access from ios/. diff --git a/chromium/components/security_interstitials/core/https_only_mode_policy_handler.cc b/chromium/components/security_interstitials/core/https_only_mode_policy_handler.cc new file mode 100644 index 00000000000..87ed18cf7a7 --- /dev/null +++ b/chromium/components/security_interstitials/core/https_only_mode_policy_handler.cc @@ -0,0 +1,30 @@ +// Copyright 2021 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. + +#include "components/security_interstitials/core/https_only_mode_policy_handler.h" + +#include "components/policy/core/common/policy_map.h" +#include "components/policy/policy_constants.h" +#include "components/prefs/pref_value_map.h" + +namespace policy { + +HttpsOnlyModePolicyHandler::HttpsOnlyModePolicyHandler( + const char* const pref_name) + : TypeCheckingPolicyHandler(key::kHttpsOnlyMode, base::Value::Type::STRING), + pref_name_(pref_name) {} + +HttpsOnlyModePolicyHandler::~HttpsOnlyModePolicyHandler() = default; + +void HttpsOnlyModePolicyHandler::ApplyPolicySettings(const PolicyMap& policies, + PrefValueMap* prefs) { + const base::Value* value = + policies.GetValue(key::kHttpsOnlyMode, base::Value::Type::STRING); + if (value && value->GetString() == "disallowed") { + // Only apply the policy to the pref if it is set to "disallowed". + prefs->SetBoolean(pref_name_, false); + } +} + +} // namespace policy diff --git a/chromium/components/security_interstitials/core/https_only_mode_policy_handler.h b/chromium/components/security_interstitials/core/https_only_mode_policy_handler.h new file mode 100644 index 00000000000..0660c2c5f15 --- /dev/null +++ b/chromium/components/security_interstitials/core/https_only_mode_policy_handler.h @@ -0,0 +1,35 @@ +// Copyright 2021 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 COMPONENTS_SECURITY_INTERSTITIALS_CORE_HTTPS_ONLY_MODE_POLICY_HANDLER_H_ +#define COMPONENTS_SECURITY_INTERSTITIALS_CORE_HTTPS_ONLY_MODE_POLICY_HANDLER_H_ + +#include "components/policy/core/browser/configuration_policy_handler.h" + +namespace policy { + +// Checks and converts the strings in policy::key::kHttpsOnlyMode to the boolean +// pref::kHttpsOnlyModeEnabled. This currently only sets the associated pref to +// `false` if the policy is set to "disallowed". Otherwise, the policy has no +// effect. +class HttpsOnlyModePolicyHandler : public TypeCheckingPolicyHandler { + public: + explicit HttpsOnlyModePolicyHandler(const char* const pref_name); + ~HttpsOnlyModePolicyHandler() override; + HttpsOnlyModePolicyHandler(const HttpsOnlyModePolicyHandler&) = delete; + HttpsOnlyModePolicyHandler& operator=(const HttpsOnlyModePolicyHandler&) = + delete; + + // ConfigurationPolicyHandler methods: + void ApplyPolicySettings(const PolicyMap& policies, + PrefValueMap* prefs) override; + + private: + // Name of the HTTPS-Only pref. + const char* const pref_name_; +}; + +} // namespace policy + +#endif // COMPONENTS_SECURITY_INTERSTITIALS_CORE_HTTPS_ONLY_MODE_POLICY_HANDLER_H_ diff --git a/chromium/components/security_interstitials/core/https_only_mode_ui_util.cc b/chromium/components/security_interstitials/core/https_only_mode_ui_util.cc index 4c815a8330b..dd3a40eccff 100644 --- a/chromium/components/security_interstitials/core/https_only_mode_ui_util.cc +++ b/chromium/components/security_interstitials/core/https_only_mode_ui_util.cc @@ -9,42 +9,42 @@ #include "ui/base/l10n/l10n_util.h" #include "url/gurl.h" -void PopulateHttpsOnlyModeStringsForBlockingPage(base::Value* load_time_data, - const GURL& url) { - load_time_data->SetStringKey( - "tabTitle", l10n_util::GetStringUTF16(IDS_HTTPS_ONLY_MODE_TITLE)); - load_time_data->SetStringKey( +void PopulateHttpsOnlyModeStringsForBlockingPage( + base::Value::Dict& load_time_data, + const GURL& url) { + load_time_data.Set("tabTitle", + l10n_util::GetStringUTF16(IDS_HTTPS_ONLY_MODE_TITLE)); + load_time_data.Set( "heading", l10n_util::GetStringFUTF16( IDS_HTTPS_ONLY_MODE_HEADING, security_interstitials::common_string_util::GetFormattedHostName( url))); - load_time_data->SetStringKey( + load_time_data.Set( "primaryParagraph", l10n_util::GetStringUTF16(IDS_HTTPS_ONLY_MODE_PRIMARY_PARAGRAPH)); // TODO(crbug.com/1302509): Change this button to "Close" when we can't go // back: - load_time_data->SetStringKey( + load_time_data.Set( "proceedButtonText", l10n_util::GetStringUTF16(IDS_HTTPS_ONLY_MODE_SUBMIT_BUTTON)); - load_time_data->SetStringKey( - "primaryButtonText", - l10n_util::GetStringUTF16(IDS_HTTPS_ONLY_MODE_BACK_BUTTON)); - load_time_data->SetStringKey( - "optInLink", - l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_SCOUT_REPORTING_AGREE)); - load_time_data->SetStringKey( + load_time_data.Set("primaryButtonText", l10n_util::GetStringUTF16( + IDS_HTTPS_ONLY_MODE_BACK_BUTTON)); + load_time_data.Set("optInLink", l10n_util::GetStringUTF16( + IDS_SAFE_BROWSING_SCOUT_REPORTING_AGREE)); + load_time_data.Set( "enhancedProtectionMessage", l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_ENHANCED_PROTECTION_MESSAGE)); } -void PopulateHttpsOnlyModeStringsForSharedHTML(base::Value* load_time_data) { - load_time_data->SetStringKey("type", "HTTPS_ONLY"); - load_time_data->SetBoolKey("overridable", false); - load_time_data->SetBoolKey("hide_primary_button", false); - load_time_data->SetBoolKey("show_recurrent_error_paragraph", false); - load_time_data->SetStringKey("recurrentErrorParagraph", ""); - load_time_data->SetStringKey("openDetails", ""); - load_time_data->SetStringKey("explanationParagraph", ""); - load_time_data->SetStringKey("finalParagraph", ""); +void PopulateHttpsOnlyModeStringsForSharedHTML( + base::Value::Dict& load_time_data) { + load_time_data.Set("type", "HTTPS_ONLY"); + load_time_data.Set("overridable", false); + load_time_data.Set("hide_primary_button", false); + load_time_data.Set("show_recurrent_error_paragraph", false); + load_time_data.Set("recurrentErrorParagraph", ""); + load_time_data.Set("openDetails", ""); + load_time_data.Set("explanationParagraph", ""); + load_time_data.Set("finalParagraph", ""); } diff --git a/chromium/components/security_interstitials/core/https_only_mode_ui_util.h b/chromium/components/security_interstitials/core/https_only_mode_ui_util.h index c4eb62b26a7..0ae5b3fcfed 100644 --- a/chromium/components/security_interstitials/core/https_only_mode_ui_util.h +++ b/chromium/components/security_interstitials/core/https_only_mode_ui_util.h @@ -5,17 +5,17 @@ #ifndef COMPONENTS_SECURITY_INTERSTITIALS_CORE_HTTPS_ONLY_MODE_UI_UTIL_H_ #define COMPONENTS_SECURITY_INTERSTITIALS_CORE_HTTPS_ONLY_MODE_UI_UTIL_H_ -namespace base { -class Value; -} // namespace base +#include "base/values.h" class GURL; // Populates |load_time_data| for interstitial HTML. -void PopulateHttpsOnlyModeStringsForBlockingPage(base::Value* load_time_data, - const GURL& url); +void PopulateHttpsOnlyModeStringsForBlockingPage( + base::Value::Dict& load_time_data, + const GURL& url); // Values added to get shared interstitial HTML to play nice. -void PopulateHttpsOnlyModeStringsForSharedHTML(base::Value* load_time_data); +void PopulateHttpsOnlyModeStringsForSharedHTML( + base::Value::Dict& load_time_data); #endif // COMPONENTS_SECURITY_INTERSTITIALS_CORE_HTTPS_ONLY_MODE_UI_UTIL_H_ diff --git a/chromium/components/security_interstitials/core/mitm_software_ui.cc b/chromium/components/security_interstitials/core/mitm_software_ui.cc index 6c12c861945..753ee0488f4 100644 --- a/chromium/components/security_interstitials/core/mitm_software_ui.cc +++ b/chromium/components/security_interstitials/core/mitm_software_ui.cc @@ -36,27 +36,24 @@ MITMSoftwareUI::~MITMSoftwareUI() { controller_->metrics_helper()->RecordShutdownMetrics(); } -void MITMSoftwareUI::PopulateStringsForHTML(base::Value* load_time_data) { - CHECK(load_time_data); - +void MITMSoftwareUI::PopulateStringsForHTML(base::Value::Dict& load_time_data) { // Shared with other SSL errors. common_string_util::PopulateSSLLayoutStrings(cert_error_, load_time_data); common_string_util::PopulateSSLDebuggingStrings( ssl_info_, base::Time::NowFromSystemTime(), load_time_data); // Set display booleans. - load_time_data->SetBoolKey("overridable", false); - load_time_data->SetBoolKey("hide_primary_button", true); - load_time_data->SetBoolKey("bad_clock", false); + load_time_data.Set("overridable", false); + load_time_data.Set("hide_primary_button", true); + load_time_data.Set("bad_clock", false); // Set strings that are shared between enterprise and non-enterprise // interstitials. - load_time_data->SetStringKey("tabTitle", - l10n_util::GetStringUTF16(IDS_SSL_V2_TITLE)); - load_time_data->SetStringKey( - "heading", l10n_util::GetStringUTF16(IDS_MITM_SOFTWARE_HEADING)); - load_time_data->SetStringKey("primaryButtonText", std::string()); - load_time_data->SetStringKey("finalParagraph", std::string()); + load_time_data.Set("tabTitle", l10n_util::GetStringUTF16(IDS_SSL_V2_TITLE)); + load_time_data.Set("heading", + l10n_util::GetStringUTF16(IDS_MITM_SOFTWARE_HEADING)); + load_time_data.Set("primaryButtonText", ""); + load_time_data.Set("finalParagraph", ""); if (is_enterprise_managed_) { MITMSoftwareUI::PopulateEnterpriseUserStringsForHTML(load_time_data); @@ -109,13 +106,13 @@ void MITMSoftwareUI::HandleCommand(SecurityInterstitialCommand command) { } void MITMSoftwareUI::PopulateEnterpriseUserStringsForHTML( - base::Value* load_time_data) { - load_time_data->SetStringKey( + base::Value::Dict& load_time_data) { + load_time_data.Set( "primaryParagraph", l10n_util::GetStringFUTF16( IDS_MITM_SOFTWARE_PRIMARY_PARAGRAPH_ENTERPRISE, base::EscapeForHTML(base::UTF8ToUTF16(mitm_software_name_)))); - load_time_data->SetStringKey( + load_time_data.Set( "explanationParagraph", l10n_util::GetStringFUTF16( IDS_MITM_SOFTWARE_EXPLANATION_ENTERPRISE, @@ -124,13 +121,13 @@ void MITMSoftwareUI::PopulateEnterpriseUserStringsForHTML( } void MITMSoftwareUI::PopulateAtHomeUserStringsForHTML( - base::Value* load_time_data) { - load_time_data->SetStringKey( + base::Value::Dict& load_time_data) { + load_time_data.Set( "primaryParagraph", l10n_util::GetStringFUTF16( IDS_MITM_SOFTWARE_PRIMARY_PARAGRAPH_NONENTERPRISE, base::EscapeForHTML(base::UTF8ToUTF16(mitm_software_name_)))); - load_time_data->SetStringKey( + load_time_data.Set( "explanationParagraph", l10n_util::GetStringFUTF16( IDS_MITM_SOFTWARE_EXPLANATION_NONENTERPRISE, diff --git a/chromium/components/security_interstitials/core/mitm_software_ui.h b/chromium/components/security_interstitials/core/mitm_software_ui.h index ef34920df66..193e0247498 100644 --- a/chromium/components/security_interstitials/core/mitm_software_ui.h +++ b/chromium/components/security_interstitials/core/mitm_software_ui.h @@ -29,12 +29,12 @@ class MITMSoftwareUI { ~MITMSoftwareUI(); - void PopulateStringsForHTML(base::Value* load_time_data); + void PopulateStringsForHTML(base::Value::Dict& load_time_data); void HandleCommand(SecurityInterstitialCommand command); protected: - void PopulateEnterpriseUserStringsForHTML(base::Value* load_time_data); - void PopulateAtHomeUserStringsForHTML(base::Value* load_time_data); + void PopulateEnterpriseUserStringsForHTML(base::Value::Dict& load_time_data); + void PopulateAtHomeUserStringsForHTML(base::Value::Dict& load_time_data); private: const GURL request_url_; diff --git a/chromium/components/security_interstitials/core/safe_browsing_loud_error_ui.cc b/chromium/components/security_interstitials/core/safe_browsing_loud_error_ui.cc index 34d5d9fa672..268483cb131 100644 --- a/chromium/components/security_interstitials/core/safe_browsing_loud_error_ui.cc +++ b/chromium/components/security_interstitials/core/safe_browsing_loud_error_ui.cc @@ -69,41 +69,38 @@ SafeBrowsingLoudErrorUI::~SafeBrowsingLoudErrorUI() { } void SafeBrowsingLoudErrorUI::PopulateStringsForHtml( - base::Value* load_time_data) { - DCHECK(load_time_data); - - load_time_data->SetStringKey("type", "SAFEBROWSING"); - load_time_data->SetStringKey( - "tabTitle", l10n_util::GetStringUTF16(IDS_SAFEBROWSING_V3_TITLE)); - load_time_data->SetStringKey( + base::Value::Dict& load_time_data) { + load_time_data.Set("type", "SAFEBROWSING"); + load_time_data.Set("tabTitle", + l10n_util::GetStringUTF16(IDS_SAFEBROWSING_V3_TITLE)); + load_time_data.Set( "openDetails", l10n_util::GetStringUTF16(IDS_SAFEBROWSING_V3_OPEN_DETAILS_BUTTON)); - load_time_data->SetStringKey( + load_time_data.Set( "closeDetails", l10n_util::GetStringUTF16(IDS_SAFEBROWSING_V3_CLOSE_DETAILS_BUTTON)); - load_time_data->SetStringKey( + load_time_data.Set( "primaryButtonText", l10n_util::GetStringUTF16(IDS_SAFEBROWSING_OVERRIDABLE_SAFETY_BUTTON)); - load_time_data->SetBoolKey("overridable", !is_proceed_anyway_disabled()); - load_time_data->SetStringKey( + load_time_data.Set("overridable", !is_proceed_anyway_disabled()); + load_time_data.Set( security_interstitials::kOptInLink, l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_SCOUT_REPORTING_AGREE)); - load_time_data->SetStringKey( + load_time_data.Set( security_interstitials::kEnhancedProtectionMessage, l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_ENHANCED_PROTECTION_MESSAGE)); if (always_show_back_to_safety()) { - load_time_data->SetBoolKey("hide_primary_button", false); + load_time_data.Set("hide_primary_button", false); } else { - load_time_data->SetBoolKey("hide_primary_button", - created_prior_to_navigation_ - ? !controller()->CanGoBackBeforeNavigation() - : !controller()->CanGoBack()); + load_time_data.Set("hide_primary_button", + created_prior_to_navigation_ + ? !controller()->CanGoBackBeforeNavigation() + : !controller()->CanGoBack()); } - load_time_data->SetBoolKey( - "billing", - interstitial_reason() == BaseSafeBrowsingErrorUI::SB_REASON_BILLING); + load_time_data.Set("billing", interstitial_reason() == + BaseSafeBrowsingErrorUI::SB_REASON_BILLING); switch (interstitial_reason()) { case BaseSafeBrowsingErrorUI::SB_REASON_MALWARE: @@ -121,8 +118,8 @@ void SafeBrowsingLoudErrorUI::PopulateStringsForHtml( } // Not used by this interstitial. - load_time_data->SetStringKey("recurrentErrorParagraph", ""); - load_time_data->SetBoolKey("show_recurrent_error_paragraph", false); + load_time_data.Set("recurrentErrorParagraph", ""); + load_time_data.Set("show_recurrent_error_paragraph", false); PopulateExtendedReportingOption(load_time_data); PopulateEnhancedProtectionMessage(load_time_data); @@ -247,16 +244,16 @@ void SafeBrowsingLoudErrorUI::HandleCommand( } void SafeBrowsingLoudErrorUI::PopulateMalwareLoadTimeData( - base::Value* load_time_data) { - load_time_data->SetBoolKey("phishing", false); - load_time_data->SetStringKey( - "heading", l10n_util::GetStringUTF16(IDS_MALWARE_V3_HEADING)); - load_time_data->SetStringKey( + base::Value::Dict& load_time_data) { + load_time_data.Set("phishing", false); + load_time_data.Set("heading", + l10n_util::GetStringUTF16(IDS_MALWARE_V3_HEADING)); + load_time_data.Set( "primaryParagraph", l10n_util::GetStringFUTF16( IDS_MALWARE_V3_PRIMARY_PARAGRAPH, common_string_util::GetFormattedHostName(request_url()))); - load_time_data->SetStringKey( + load_time_data.Set( "explanationParagraph", is_main_frame_load_blocked() ? l10n_util::GetStringFUTF16( @@ -266,104 +263,96 @@ void SafeBrowsingLoudErrorUI::PopulateMalwareLoadTimeData( IDS_MALWARE_V3_EXPLANATION_PARAGRAPH_SUBRESOURCE, base::UTF8ToUTF16(main_frame_url().host()), common_string_util::GetFormattedHostName(request_url()))); - load_time_data->SetStringKey( - "finalParagraph", - l10n_util::GetStringUTF16(IDS_MALWARE_V3_PROCEED_PARAGRAPH)); + load_time_data.Set("finalParagraph", l10n_util::GetStringUTF16( + IDS_MALWARE_V3_PROCEED_PARAGRAPH)); } void SafeBrowsingLoudErrorUI::PopulateHarmfulLoadTimeData( - base::Value* load_time_data) { - load_time_data->SetBoolKey("phishing", false); - load_time_data->SetStringKey( - "heading", l10n_util::GetStringUTF16(IDS_HARMFUL_V3_HEADING)); - load_time_data->SetStringKey( + base::Value::Dict& load_time_data) { + load_time_data.Set("phishing", false); + load_time_data.Set("heading", + l10n_util::GetStringUTF16(IDS_HARMFUL_V3_HEADING)); + load_time_data.Set( "primaryParagraph", l10n_util::GetStringFUTF16( IDS_HARMFUL_V3_PRIMARY_PARAGRAPH, common_string_util::GetFormattedHostName(request_url()))); - load_time_data->SetStringKey( + load_time_data.Set( "explanationParagraph", l10n_util::GetStringFUTF16( IDS_HARMFUL_V3_EXPLANATION_PARAGRAPH, common_string_util::GetFormattedHostName(request_url()))); - load_time_data->SetStringKey( - "finalParagraph", - l10n_util::GetStringUTF16(IDS_HARMFUL_V3_PROCEED_PARAGRAPH)); + load_time_data.Set("finalParagraph", l10n_util::GetStringUTF16( + IDS_HARMFUL_V3_PROCEED_PARAGRAPH)); } void SafeBrowsingLoudErrorUI::PopulatePhishingLoadTimeData( - base::Value* load_time_data) { - load_time_data->SetBoolKey("phishing", true); - load_time_data->SetStringKey( - "heading", l10n_util::GetStringUTF16(IDS_PHISHING_V4_HEADING)); - load_time_data->SetStringKey( + base::Value::Dict& load_time_data) { + load_time_data.Set("phishing", true); + load_time_data.Set("heading", + l10n_util::GetStringUTF16(IDS_PHISHING_V4_HEADING)); + load_time_data.Set( "primaryParagraph", l10n_util::GetStringFUTF16( IDS_PHISHING_V4_PRIMARY_PARAGRAPH, common_string_util::GetFormattedHostName(request_url()))); - load_time_data->SetStringKey( + load_time_data.Set( "explanationParagraph", l10n_util::GetStringFUTF16( IDS_PHISHING_V4_EXPLANATION_PARAGRAPH, common_string_util::GetFormattedHostName(request_url()))); - load_time_data->SetStringKey( + load_time_data.Set( "finalParagraph", l10n_util::GetStringUTF16(IDS_PHISHING_V4_PROCEED_AND_REPORT_PARAGRAPH)); } void SafeBrowsingLoudErrorUI::PopulateExtendedReportingOption( - base::Value* load_time_data) { + base::Value::Dict& load_time_data) { bool can_show_extended_reporting_option = CanShowExtendedReportingOption(); bool can_show_enhanced_protection_message = CanShowEnhancedProtectionMessage(); - load_time_data->SetBoolKey(security_interstitials::kDisplayCheckBox, - can_show_extended_reporting_option && - !can_show_enhanced_protection_message); + load_time_data.Set(security_interstitials::kDisplayCheckBox, + can_show_extended_reporting_option && + !can_show_enhanced_protection_message); if (!can_show_extended_reporting_option) { return; } - load_time_data->SetBoolKey(security_interstitials::kBoxChecked, - is_extended_reporting_enabled()); + load_time_data.Set(security_interstitials::kBoxChecked, + is_extended_reporting_enabled()); } void SafeBrowsingLoudErrorUI::PopulateEnhancedProtectionMessage( - base::Value* load_time_data) { + base::Value::Dict& load_time_data) { bool can_show_enhanced_protection_message = CanShowEnhancedProtectionMessage(); if (can_show_enhanced_protection_message) { controller()->metrics_helper()->RecordUserInteraction( security_interstitials::MetricsHelper::SHOW_ENHANCED_PROTECTION); } - load_time_data->SetBoolKey( - security_interstitials::kDisplayEnhancedProtectionMessage, - can_show_enhanced_protection_message); + load_time_data.Set(security_interstitials::kDisplayEnhancedProtectionMessage, + can_show_enhanced_protection_message); } void SafeBrowsingLoudErrorUI::PopulateBillingLoadTimeData( - base::Value* load_time_data) { - load_time_data->SetBoolKey("phishing", false); - load_time_data->SetBoolKey("overridable", true); + base::Value::Dict& load_time_data) { + load_time_data.Set("phishing", false); + load_time_data.Set("overridable", true); - load_time_data->SetStringKey("tabTitle", - l10n_util::GetStringUTF16(IDS_BILLING_TITLE)); - load_time_data->SetStringKey("heading", - l10n_util::GetStringUTF16(IDS_BILLING_HEADING)); - load_time_data->SetStringKey( - "primaryParagraph", - l10n_util::GetStringUTF16(IDS_BILLING_PRIMARY_PARAGRAPH)); + load_time_data.Set("tabTitle", l10n_util::GetStringUTF16(IDS_BILLING_TITLE)); + load_time_data.Set("heading", l10n_util::GetStringUTF16(IDS_BILLING_HEADING)); + load_time_data.Set("primaryParagraph", + l10n_util::GetStringUTF16(IDS_BILLING_PRIMARY_PARAGRAPH)); - load_time_data->SetStringKey( - "primaryButtonText", - l10n_util::GetStringUTF16(IDS_BILLING_PRIMARY_BUTTON)); - load_time_data->SetStringKey( - "proceedButtonText", - l10n_util::GetStringUTF16(IDS_BILLING_PROCEED_BUTTON)); + load_time_data.Set("primaryButtonText", + l10n_util::GetStringUTF16(IDS_BILLING_PRIMARY_BUTTON)); + load_time_data.Set("proceedButtonText", + l10n_util::GetStringUTF16(IDS_BILLING_PROCEED_BUTTON)); - load_time_data->SetStringKey("openDetails", ""); - load_time_data->SetStringKey("closeDetails", ""); - load_time_data->SetStringKey("explanationParagraph", ""); - load_time_data->SetStringKey("finalParagraph", ""); + load_time_data.Set("openDetails", ""); + load_time_data.Set("closeDetails", ""); + load_time_data.Set("explanationParagraph", ""); + load_time_data.Set("finalParagraph", ""); } int SafeBrowsingLoudErrorUI::GetHTMLTemplateId() const { diff --git a/chromium/components/security_interstitials/core/safe_browsing_loud_error_ui.h b/chromium/components/security_interstitials/core/safe_browsing_loud_error_ui.h index 8c8396e9116..be3c9a7bbb0 100644 --- a/chromium/components/security_interstitials/core/safe_browsing_loud_error_ui.h +++ b/chromium/components/security_interstitials/core/safe_browsing_loud_error_ui.h @@ -41,7 +41,7 @@ class SafeBrowsingLoudErrorUI ~SafeBrowsingLoudErrorUI() override; // Implement BaseSafeBrowsingErrorUI. - void PopulateStringsForHtml(base::Value* load_time_data) override; + void PopulateStringsForHtml(base::Value::Dict& load_time_data) override; void HandleCommand(SecurityInterstitialCommand command) override; int GetHTMLTemplateId() const override; @@ -49,12 +49,12 @@ class SafeBrowsingLoudErrorUI private: // Fills the passed dictionary with the values to be passed to the template // when creating the HTML. - void PopulateExtendedReportingOption(base::Value* load_time_data); - void PopulateMalwareLoadTimeData(base::Value* load_time_data); - void PopulateHarmfulLoadTimeData(base::Value* load_time_data); - void PopulatePhishingLoadTimeData(base::Value* load_time_data); - void PopulateBillingLoadTimeData(base::Value* load_time_data); - void PopulateEnhancedProtectionMessage(base::Value* load_time_data); + void PopulateExtendedReportingOption(base::Value::Dict& load_time_data); + void PopulateMalwareLoadTimeData(base::Value::Dict& load_time_data); + void PopulateHarmfulLoadTimeData(base::Value::Dict& load_time_data); + void PopulatePhishingLoadTimeData(base::Value::Dict& load_time_data); + void PopulateBillingLoadTimeData(base::Value::Dict& load_time_data); + void PopulateEnhancedProtectionMessage(base::Value::Dict& load_time_data); const bool created_prior_to_navigation_; }; diff --git a/chromium/components/security_interstitials/core/safe_browsing_quiet_error_ui.cc b/chromium/components/security_interstitials/core/safe_browsing_quiet_error_ui.cc index 02c9b58da49..d330a2c3a7b 100644 --- a/chromium/components/security_interstitials/core/safe_browsing_quiet_error_ui.cc +++ b/chromium/components/security_interstitials/core/safe_browsing_quiet_error_ui.cc @@ -48,17 +48,15 @@ SafeBrowsingQuietErrorUI::~SafeBrowsingQuietErrorUI() { } void SafeBrowsingQuietErrorUI::PopulateStringsForHtml( - base::Value* load_time_data) { - DCHECK(load_time_data); - - load_time_data->SetStringKey("type", "SAFEBROWSING"); - load_time_data->SetStringKey( - "tabTitle", l10n_util::GetStringUTF16(IDS_SAFEBROWSING_V3_TITLE)); - load_time_data->SetBoolKey("overridable", !is_proceed_anyway_disabled()); - load_time_data->SetStringKey( + base::Value::Dict& load_time_data) { + load_time_data.Set("type", "SAFEBROWSING"); + load_time_data.Set("tabTitle", + l10n_util::GetStringUTF16(IDS_SAFEBROWSING_V3_TITLE)); + load_time_data.Set("overridable", !is_proceed_anyway_disabled()); + load_time_data.Set( "openDetails", l10n_util::GetStringUTF16(IDS_SAFEBROWSING_V3_OPEN_DETAILS_BUTTON)); - load_time_data->SetBoolKey("is_giant", is_giant_webview_); + load_time_data.Set("is_giant", is_giant_webview_); switch (interstitial_reason()) { case BaseSafeBrowsingErrorUI::SB_REASON_MALWARE: @@ -76,8 +74,8 @@ void SafeBrowsingQuietErrorUI::PopulateStringsForHtml( } // Not used by this interstitial. - load_time_data->SetStringKey("recurrentErrorParagraph", ""); - load_time_data->SetBoolKey("show_recurrent_error_paragraph", false); + load_time_data.Set("recurrentErrorParagraph", ""); + load_time_data.Set("show_recurrent_error_paragraph", false); } void SafeBrowsingQuietErrorUI::SetGiantWebViewForTesting( @@ -119,43 +117,42 @@ void SafeBrowsingQuietErrorUI::HandleCommand( } void SafeBrowsingQuietErrorUI::PopulateMalwareLoadTimeData( - base::Value* load_time_data) { - load_time_data->SetBoolKey("phishing", false); - load_time_data->SetStringKey( - "heading", l10n_util::GetStringUTF16(IDS_MALWARE_WEBVIEW_HEADING)); - load_time_data->SetStringKey( + base::Value::Dict& load_time_data) { + load_time_data.Set("phishing", false); + load_time_data.Set("heading", + l10n_util::GetStringUTF16(IDS_MALWARE_WEBVIEW_HEADING)); + load_time_data.Set( "explanationParagraph", l10n_util::GetStringUTF16(IDS_MALWARE_WEBVIEW_EXPLANATION_PARAGRAPH)); } void SafeBrowsingQuietErrorUI::PopulateHarmfulLoadTimeData( - base::Value* load_time_data) { - load_time_data->SetBoolKey("phishing", false); - load_time_data->SetStringKey( - "heading", l10n_util::GetStringUTF16(IDS_HARMFUL_WEBVIEW_HEADING)); - load_time_data->SetStringKey( + base::Value::Dict& load_time_data) { + load_time_data.Set("phishing", false); + load_time_data.Set("heading", + l10n_util::GetStringUTF16(IDS_HARMFUL_WEBVIEW_HEADING)); + load_time_data.Set( "explanationParagraph", l10n_util::GetStringUTF16(IDS_HARMFUL_WEBVIEW_EXPLANATION_PARAGRAPH)); } void SafeBrowsingQuietErrorUI::PopulatePhishingLoadTimeData( - base::Value* load_time_data) { - load_time_data->SetBoolKey("phishing", true); - load_time_data->SetStringKey( - "heading", l10n_util::GetStringUTF16(IDS_PHISHING_WEBVIEW_HEADING)); - load_time_data->SetStringKey( + base::Value::Dict& load_time_data) { + load_time_data.Set("phishing", true); + load_time_data.Set("heading", + l10n_util::GetStringUTF16(IDS_PHISHING_WEBVIEW_HEADING)); + load_time_data.Set( "explanationParagraph", l10n_util::GetStringUTF16(IDS_PHISHING_WEBVIEW_EXPLANATION_PARAGRAPH)); } void SafeBrowsingQuietErrorUI::PopulateBillingLoadTimeData( - base::Value* load_time_data) { - load_time_data->SetBoolKey("phishing", false); - load_time_data->SetStringKey("tabTitle", - l10n_util::GetStringUTF16(IDS_BILLING_TITLE)); - load_time_data->SetStringKey( - "heading", l10n_util::GetStringUTF16(IDS_BILLING_WEBVIEW_HEADING)); - load_time_data->SetStringKey( + base::Value::Dict& load_time_data) { + load_time_data.Set("phishing", false); + load_time_data.Set("tabTitle", l10n_util::GetStringUTF16(IDS_BILLING_TITLE)); + load_time_data.Set("heading", + l10n_util::GetStringUTF16(IDS_BILLING_WEBVIEW_HEADING)); + load_time_data.Set( "explanationParagraph", l10n_util::GetStringUTF16(IDS_BILLING_WEBVIEW_EXPLANATION_PARAGRAPH)); } diff --git a/chromium/components/security_interstitials/core/safe_browsing_quiet_error_ui.h b/chromium/components/security_interstitials/core/safe_browsing_quiet_error_ui.h index ddb82ab3f11..ab22337f56e 100644 --- a/chromium/components/security_interstitials/core/safe_browsing_quiet_error_ui.h +++ b/chromium/components/security_interstitials/core/safe_browsing_quiet_error_ui.h @@ -39,7 +39,7 @@ class SafeBrowsingQuietErrorUI // Fills the passed dictionary with the values to be passed to the template // when creating the HTML. - void PopulateStringsForHtml(base::Value* load_time_data) override; + void PopulateStringsForHtml(base::Value::Dict& load_time_data) override; void HandleCommand(SecurityInterstitialCommand command) override; @@ -50,10 +50,10 @@ class SafeBrowsingQuietErrorUI int GetHTMLTemplateId() const override; private: - void PopulateMalwareLoadTimeData(base::Value* load_time_data); - void PopulateHarmfulLoadTimeData(base::Value* load_time_data); - void PopulatePhishingLoadTimeData(base::Value* load_time_data); - void PopulateBillingLoadTimeData(base::Value* load_time_data); + void PopulateMalwareLoadTimeData(base::Value::Dict& load_time_data); + void PopulateHarmfulLoadTimeData(base::Value::Dict& load_time_data); + void PopulatePhishingLoadTimeData(base::Value::Dict& load_time_data); + void PopulateBillingLoadTimeData(base::Value::Dict& load_time_data); bool is_giant_webview_; }; diff --git a/chromium/components/security_interstitials/core/ssl_error_ui.cc b/chromium/components/security_interstitials/core/ssl_error_ui.cc index c8485f0b84e..88c140790a7 100644 --- a/chromium/components/security_interstitials/core/ssl_error_ui.cc +++ b/chromium/components/security_interstitials/core/ssl_error_ui.cc @@ -63,31 +63,27 @@ SSLErrorUI::~SSLErrorUI() { controller_->metrics_helper()->RecordShutdownMetrics(); } -void SSLErrorUI::PopulateStringsForHTML(base::Value* load_time_data) { - DCHECK(load_time_data); - +void SSLErrorUI::PopulateStringsForHTML(base::Value::Dict& load_time_data) { // Shared with other errors. common_string_util::PopulateSSLLayoutStrings(cert_error_, load_time_data); common_string_util::PopulateSSLDebuggingStrings(ssl_info_, time_triggered_, load_time_data); // Shared values for both the overridable and non-overridable versions. - load_time_data->SetBoolKey("bad_clock", false); - load_time_data->SetBoolKey("hide_primary_button", false); - load_time_data->SetStringKey("tabTitle", - l10n_util::GetStringUTF16(IDS_SSL_V2_TITLE)); - load_time_data->SetStringKey("heading", - l10n_util::GetStringUTF16(IDS_SSL_V2_HEADING)); - load_time_data->SetStringKey( + load_time_data.Set("bad_clock", false); + load_time_data.Set("hide_primary_button", false); + load_time_data.Set("tabTitle", l10n_util::GetStringUTF16(IDS_SSL_V2_TITLE)); + load_time_data.Set("heading", l10n_util::GetStringUTF16(IDS_SSL_V2_HEADING)); + load_time_data.Set( "primaryParagraph", l10n_util::GetStringFUTF16( IDS_SSL_V2_PRIMARY_PARAGRAPH, common_string_util::GetFormattedHostName(request_url_))); - load_time_data->SetStringKey( + load_time_data.Set( "recurrentErrorParagraph", l10n_util::GetStringUTF16(IDS_SSL_V2_RECURRENT_ERROR_PARAGRAPH)); - load_time_data->SetBoolKey("show_recurrent_error_paragraph", - controller_->HasSeenRecurrentError()); + load_time_data.Set("show_recurrent_error_paragraph", + controller_->HasSeenRecurrentError()); if (soft_override_enabled_) PopulateOverridableStrings(load_time_data); @@ -111,7 +107,7 @@ int SSLErrorUI::cert_error() const { return cert_error_; } -void SSLErrorUI::PopulateOverridableStrings(base::Value* load_time_data) { +void SSLErrorUI::PopulateOverridableStrings(base::Value::Dict& load_time_data) { DCHECK(soft_override_enabled_); std::u16string url(common_string_util::GetFormattedHostName(request_url_)); @@ -119,10 +115,10 @@ void SSLErrorUI::PopulateOverridableStrings(base::Value* load_time_data) { ssl_errors::ErrorInfo::NetErrorToErrorType(cert_error_), ssl_info_.cert.get(), request_url_); - load_time_data->SetBoolKey("overridable", true); - load_time_data->SetBoolKey("hide_primary_button", false); - load_time_data->SetStringKey("explanationParagraph", error_info.details()); - load_time_data->SetStringKey( + load_time_data.Set("overridable", true); + load_time_data.Set("hide_primary_button", false); + load_time_data.Set("explanationParagraph", error_info.details()); + load_time_data.Set( "primaryButtonText", l10n_util::GetStringUTF16(IDS_SSL_OVERRIDABLE_SAFETY_BUTTON)); @@ -130,37 +126,38 @@ void SSLErrorUI::PopulateOverridableStrings(base::Value* load_time_data) { // go back. See crbug.com/1058476 for discussion. #if BUILDFLAG(IS_IOS) if (!controller()->CanGoBack()) { - load_time_data->SetStringKey( + load_time_data.Set( "primaryButtonText", l10n_util::GetStringUTF16(IDS_SSL_OVERRIDABLE_CLOSE_PAGE_BUTTON)); - load_time_data->SetBoolKey("primary_button_close_page", true); + load_time_data.Set("primary_button_close_page", true); } #endif - load_time_data->SetStringKey( + load_time_data.Set( "finalParagraph", l10n_util::GetStringFUTF16(IDS_SSL_OVERRIDABLE_PROCEED_PARAGRAPH, url)); } -void SSLErrorUI::PopulateNonOverridableStrings(base::Value* load_time_data) { +void SSLErrorUI::PopulateNonOverridableStrings( + base::Value::Dict& load_time_data) { DCHECK(!soft_override_enabled_); std::u16string url(common_string_util::GetFormattedHostName(request_url_)); ssl_errors::ErrorInfo::ErrorType type = ssl_errors::ErrorInfo::NetErrorToErrorType(cert_error_); - load_time_data->SetBoolKey("overridable", false); - load_time_data->SetBoolKey("hide_primary_button", false); - load_time_data->SetStringKey( + load_time_data.Set("overridable", false); + load_time_data.Set("hide_primary_button", false); + load_time_data.Set( "explanationParagraph", l10n_util::GetStringFUTF16(IDS_SSL_NONOVERRIDABLE_MORE, url)); - load_time_data->SetStringKey("primaryButtonText", - l10n_util::GetStringUTF16(IDS_SSL_RELOAD)); + load_time_data.Set("primaryButtonText", + l10n_util::GetStringUTF16(IDS_SSL_RELOAD)); // Customize the help link depending on the specific error type. // Only mark as HSTS if none of the more specific error types apply, // and use INVALID as a fallback if no other string is appropriate. - load_time_data->SetIntKey("errorType", type); + load_time_data.Set("errorType", type); int help_string = IDS_SSL_NONOVERRIDABLE_INVALID; switch (type) { case ssl_errors::ErrorInfo::CERT_REVOKED: @@ -176,8 +173,8 @@ void SSLErrorUI::PopulateNonOverridableStrings(base::Value* load_time_data) { if (requested_strict_enforcement_) help_string = IDS_SSL_NONOVERRIDABLE_HSTS; } - load_time_data->SetStringKey("finalParagraph", - l10n_util::GetStringFUTF16(help_string, url)); + load_time_data.Set("finalParagraph", + l10n_util::GetStringFUTF16(help_string, url)); } void SSLErrorUI::HandleCommand(SecurityInterstitialCommand command) { diff --git a/chromium/components/security_interstitials/core/ssl_error_ui.h b/chromium/components/security_interstitials/core/ssl_error_ui.h index 2478fa20ece..bf1d409f627 100644 --- a/chromium/components/security_interstitials/core/ssl_error_ui.h +++ b/chromium/components/security_interstitials/core/ssl_error_ui.h @@ -34,7 +34,7 @@ class SSLErrorUI { virtual ~SSLErrorUI(); - virtual void PopulateStringsForHTML(base::Value* load_time_data); + virtual void PopulateStringsForHTML(base::Value::Dict& load_time_data); virtual void HandleCommand(SecurityInterstitialCommand command); protected: @@ -44,8 +44,8 @@ class SSLErrorUI { int cert_error() const; private: - void PopulateOverridableStrings(base::Value* load_time_data); - void PopulateNonOverridableStrings(base::Value* load_time_data); + void PopulateOverridableStrings(base::Value::Dict& load_time_data); + void PopulateNonOverridableStrings(base::Value::Dict& load_time_data); const GURL request_url_; const int cert_error_; |