blob: 8e6509ffcafec789e0185b00c135a4dd673b2cb4 [file] [log] [blame]
dalyk272d4b02019-08-14 00:37:511// Copyright 2019 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Ben Schwartz135746c2020-05-14 04:37:035#ifndef CHROME_BROWSER_NET_SECURE_DNS_UTIL_H_
6#define CHROME_BROWSER_NET_SECURE_DNS_UTIL_H_
dalyk272d4b02019-08-14 00:37:517
Ben Schwartz4e1468612020-03-31 21:23:458#include <vector>
9
10#include "base/strings/string_piece.h"
Ben Schwartz35685c72020-06-03 04:53:1311#include "net/dns/public/doh_provider_entry.h"
Ben Schwartze91bdcfe42020-05-07 14:49:5012
13namespace net {
14struct DnsConfigOverrides;
15} // namespace net
dalyk272d4b02019-08-14 00:37:5116
Martin Šrámek5921f6312020-03-25 09:31:4717class PrefRegistrySimple;
18class PrefService;
19
Steven Binglerdd2307b2019-08-27 20:44:3620namespace chrome_browser_net {
21
Ben Schwartz135746c2020-05-14 04:37:0322namespace secure_dns {
23
Ben Schwartz35685c72020-06-03 04:53:1324// Returns the subset of |providers| that are marked for use in the specified
25// country.
26net::DohProviderEntry::List ProvidersForCountry(
27 const net::DohProviderEntry::List& providers,
28 int country_id);
29
30// Returns the names of providers that have been remotely disabled, for use with
31// RemoveDisabledProviders().
32std::vector<std::string> GetDisabledProviders();
33
34// Returns the subset of |providers| for which |DohProviderEntry::provider| is
35// not listed in |disabled_providers|.
36net::DohProviderEntry::List RemoveDisabledProviders(
37 const net::DohProviderEntry::List& providers,
38 const std::vector<std::string>& disabled_providers);
39
Ben Schwartz4e1468612020-03-31 21:23:4540// Implements the whitespace-delimited group syntax for DoH templates.
Ben Schwartz135746c2020-05-14 04:37:0341std::vector<base::StringPiece> SplitGroup(base::StringPiece group);
Ben Schwartz4e1468612020-03-31 21:23:4542
43// Returns true if a group of templates are all valid per
44// net::dns_util::IsValidDohTemplate(). This should be checked before updating
45// stored preferences.
Ben Schwartz135746c2020-05-14 04:37:0346bool IsValidGroup(base::StringPiece group);
Ben Schwartz4e1468612020-03-31 21:23:4547
Ben Schwartz35685c72020-06-03 04:53:1348// When the selected template changes, call this function to update the
49// Selected, Unselected, and Ignored histograms for all the included providers,
50// and also for the custom provider option. If the old or new selection is the
51// custom provider option, pass an empty string as the template.
52void UpdateDropdownHistograms(const net::DohProviderEntry::List& providers,
53 base::StringPiece old_template,
54 base::StringPiece new_template);
55void UpdateValidationHistogram(bool valid);
56void UpdateProbeHistogram(bool success);
57
Ben Schwartz78ff2568f2020-04-30 05:15:1858// Modifies |overrides| to use the DoH server specified by |server_template|.
Ben Schwartz135746c2020-05-14 04:37:0359void ApplyTemplate(net::DnsConfigOverrides* overrides,
60 base::StringPiece server_template);
Ben Schwartz78ff2568f2020-04-30 05:15:1861
Martin Šrámek5921f6312020-03-25 09:31:4762// Registers the backup preference required for the DNS probes setting reset.
63// TODO(crbug.com/1062698): Remove this once the privacy settings redesign
64// is fully launched.
Ben Schwartz135746c2020-05-14 04:37:0365void RegisterProbesSettingBackupPref(PrefRegistrySimple* registry);
Martin Šrámek5921f6312020-03-25 09:31:4766
67// Backs up the unneeded preference controlling DNS and captive portal probes
68// once the privacy settings redesign is enabled, or restores the backup
69// in case the feature is rolled back.
70// TODO(crbug.com/1062698): Remove this once the privacy settings redesign
71// is fully launched.
Ben Schwartz135746c2020-05-14 04:37:0372void MigrateProbesSettingToOrFromBackup(PrefService* prefs);
73
74} // namespace secure_dns
Martin Šrámek5921f6312020-03-25 09:31:4775
Steven Binglerdd2307b2019-08-27 20:44:3676} // namespace chrome_browser_net
77
Ben Schwartz135746c2020-05-14 04:37:0378#endif // CHROME_BROWSER_NET_SECURE_DNS_UTIL_H_