From 4537a79c55aa39704631ed2e7f8acda751931a7f Mon Sep 17 00:00:00 2001 From: Anthony Tseng Date: Wed, 17 Mar 2021 14:21:23 -0700 Subject: [PATCH] Only specify net::HostResolverSource::DNS when DoH is enabled --- .../brave_ad_block_tp_network_delegate_helper.cc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/browser/net/brave_ad_block_tp_network_delegate_helper.cc b/browser/net/brave_ad_block_tp_network_delegate_helper.cc index b0e1618a8561..e916a9f6de51 100644 --- a/browser/net/brave_ad_block_tp_network_delegate_helper.cc +++ b/browser/net/brave_ad_block_tp_network_delegate_helper.cc @@ -23,6 +23,8 @@ #include "brave/components/brave_shields/common/brave_shield_constants.h" #include "brave/components/brave_shields/common/features.h" #include "brave/grit/brave_generated_resources.h" +#include "chrome/browser/net/secure_dns_config.h" +#include "chrome/browser/net/system_network_context_manager.h" #include "content/public/browser/browser_context.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/render_frame_host.h" @@ -144,10 +146,15 @@ class AdblockCnameResolveHostClient : public network::mojom::ResolveHostClient { network::mojom::ResolveHostParametersPtr optional_parameters = network::mojom::ResolveHostParameters::New(); optional_parameters->include_canonical_name = true; - // Explicitly specify source to avoid using `HostResolverProc` - // which will be handled by system resolver + + SecureDnsConfig secure_dns_config = + SystemNetworkContextManager::GetStubResolverConfigReader() + ->GetSecureDnsConfiguration(false); + // Explicitly specify source when DNS over HTTPS is enabled to avoid + // using `HostResolverProc` which will be handled by system resolver // See https://crbug.com/872665 - optional_parameters->source = net::HostResolverSource::DNS; + if (secure_dns_config.mode() == net::SecureDnsMode::kSecure) + optional_parameters->source = net::HostResolverSource::DNS; network::mojom::NetworkContext* network_context = content::BrowserContext::GetDefaultStoragePartition(context)