blob: cfb1810d3d03e8052b776b9eb2a6d4ff01f532a8 [file] [log] [blame]
Avi Drissman4a8573c2022-09-09 19:35:541// Copyright 2019 The Chromium Authors
Steven Binglerace5fd22019-08-20 21:01:202// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CHROME_BROWSER_NET_SECURE_DNS_POLICY_HANDLER_H_
6#define CHROME_BROWSER_NET_SECURE_DNS_POLICY_HANDLER_H_
7
Helmut Januschka52aa13022024-03-19 00:29:198#include <string_view>
9
Andreea Costinas6a54f7a2022-11-23 11:23:1810#include "build/chromeos_buildflags.h"
Steven Binglerace5fd22019-08-20 21:01:2011#include "components/policy/core/browser/configuration_policy_handler.h"
12
13class PrefValueMap;
14
15namespace policy {
16
Andreea Costinas6a54f7a2022-11-23 11:23:1817// Handles DnsOverHttpsMode, DnsOverHttpsTemplates,
18// DnsOverHttpsTemplatesWithIdentifiers and DnsOverHttpsSalt policies.
Steven Binglerace5fd22019-08-20 21:01:2019class SecureDnsPolicyHandler : public ConfigurationPolicyHandler {
20 public:
21 SecureDnsPolicyHandler();
Peter Boström53c6c5952021-09-17 09:41:2622
23 SecureDnsPolicyHandler(const SecureDnsPolicyHandler&) = delete;
24 SecureDnsPolicyHandler& operator=(const SecureDnsPolicyHandler&) = delete;
25
Steven Binglerace5fd22019-08-20 21:01:2026 ~SecureDnsPolicyHandler() override;
27
28 // ConfigurationPolicyHandler methods:
29 bool CheckPolicySettings(const PolicyMap& policies,
30 PolicyErrorMap* errors) override;
31 void ApplyPolicySettings(const PolicyMap& policies,
32 PrefValueMap* prefs) override;
33
34 private:
Andreea Costinas6a54f7a2022-11-23 11:23:1835 // Returns true if templates must be specified (i.e. `mode_str` is secure),
36 // but they are not set or invalid (non-string).
37 bool IsTemplatesPolicyNotSpecified(bool is_templates_policy_valid,
Tom Sepezb55f2f12024-10-02 21:54:3338 std::string_view mode_str);
Andreea Costinas6a54f7a2022-11-23 11:23:1839 // Indicates whether the DnsOverHttpsTemplates policy is valid and can be
40 // applied. If not, the corresponding pref is not set. If the DNS mode is
41 // secure, either `is_templates_policy_valid_` or, on Chrome OS only,
42 // `is_templates_with_identifiers_policy_valid_` must be true, otherwise
43 // `CheckPolicySettings` will report a policy error. Set in
44 // `CheckPolicySettings`.
45 bool is_templates_policy_valid_ = false;
Steven Binglerbb471bc62019-10-30 16:11:0946
Andrew Williams41c8b0c2025-01-07 18:20:3047#if BUILDFLAG(IS_CHROMEOS)
Andreea Costinas6a54f7a2022-11-23 11:23:1848 // Indicates whether the DnsOverHttpsTemplatesWithIdentifiers policy is valid
49 // and can be applied. If not, the corresponding pref is not set. Set in
50 // `CheckPolicySettings`.
51 bool is_templates_with_identifiers_policy_valid_ = false;
52#endif
Steven Binglerace5fd22019-08-20 21:01:2053};
54
55} // namespace policy
56
57#endif // CHROME_BROWSER_NET_SECURE_DNS_POLICY_HANDLER_H_