1 // Copyright 2014 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_SEARCH_ENGINES_DEFAULT_SEARCH_POLICY_HANDLER_H_
6 #define COMPONENTS_SEARCH_ENGINES_DEFAULT_SEARCH_POLICY_HANDLER_H_
10 #include "components/policy/core/browser/configuration_policy_handler.h"
14 // ConfigurationPolicyHandler for the default search policies.
15 class DefaultSearchPolicyHandler : public ConfigurationPolicyHandler {
17 DefaultSearchPolicyHandler();
19 DefaultSearchPolicyHandler(const DefaultSearchPolicyHandler&) = delete;
20 DefaultSearchPolicyHandler& operator=(const DefaultSearchPolicyHandler&) =
23 ~DefaultSearchPolicyHandler() override;
25 // ConfigurationPolicyHandler methods:
26 bool CheckPolicySettings(const PolicyMap& policies,
27 PolicyErrorMap* errors) override;
28 void ApplyPolicySettings(const PolicyMap& policies,
29 PrefValueMap* prefs) override;
32 // Checks that value type is valid for each policy and returns whether all of
33 // the policies are valid.
34 bool CheckIndividualPolicies(const PolicyMap& policies,
35 PolicyErrorMap* errors);
37 // Returns whether there is a value for |policy_name| in |policies|.
38 bool HasDefaultSearchPolicy(const PolicyMap& policies,
39 const char* policy_name);
41 // Returns whether any default search policies are specified in |policies|.
42 bool AnyDefaultSearchPoliciesSpecified(const PolicyMap& policies);
44 // Returns whether the default search provider policy has a value.
45 bool DefaultSearchProviderPolicyIsSet(const PolicyMap& policies);
47 // Returns whether the default search provider is disabled.
48 bool DefaultSearchProviderIsDisabled(const PolicyMap& policies);
50 // Returns whether the default search URL is set and valid. On success, both
51 // outparams (which must be non-NULL) are filled with the search URL.
52 bool DefaultSearchURLIsValid(const PolicyMap& policies,
53 const base::Value** url_value,
54 std::string* url_string);
56 // Make sure that the |path| is present in |prefs_|. If not, set it to
58 void EnsureStringPrefExists(PrefValueMap* prefs, const std::string& path);
60 // Make sure that the |path| is present in |prefs_| and is a List. If
61 // not, set it to an empty list.
62 void EnsureListPrefExists(PrefValueMap* prefs, const std::string& path);
67 #endif // COMPONENTS_SEARCH_ENGINES_DEFAULT_SEARCH_POLICY_HANDLER_H_