1 // Copyright 2014 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.
5 #ifndef COMPONENTS_SEARCH_ENGINES_DEFAULT_SEARCH_POLICY_HANDLER_H_
6 #define COMPONENTS_SEARCH_ENGINES_DEFAULT_SEARCH_POLICY_HANDLER_H_
11 #include "base/macros.h"
12 #include "components/policy/core/browser/configuration_policy_handler.h"
16 // ConfigurationPolicyHandler for the default search policies.
17 class DefaultSearchPolicyHandler : public ConfigurationPolicyHandler {
19 DefaultSearchPolicyHandler();
20 ~DefaultSearchPolicyHandler() override;
22 // ConfigurationPolicyHandler methods:
23 bool CheckPolicySettings(const PolicyMap& policies,
24 PolicyErrorMap* errors) override;
25 void ApplyPolicySettings(const PolicyMap& policies,
26 PrefValueMap* prefs) override;
29 // Checks that value type is valid for each policy and returns whether all of
30 // the policies are valid.
31 bool CheckIndividualPolicies(const PolicyMap& policies,
32 PolicyErrorMap* errors);
34 // Returns whether there is a value for |policy_name| in |policies|.
35 bool HasDefaultSearchPolicy(const PolicyMap& policies,
36 const char* policy_name);
38 // Returns whether any default search policies are specified in |policies|.
39 bool AnyDefaultSearchPoliciesSpecified(const PolicyMap& policies);
41 // Returns whether the default search provider policy has a value.
42 bool DefaultSearchProviderPolicyIsSet(const PolicyMap& policies);
44 // Returns whether the default search provider is disabled.
45 bool DefaultSearchProviderIsDisabled(const PolicyMap& policies);
47 // Returns whether the default search URL is set and valid. On success, both
48 // outparams (which must be non-NULL) are filled with the search URL.
49 bool DefaultSearchURLIsValid(const PolicyMap& policies,
50 const base::Value** url_value,
51 std::string* url_string);
53 // Make sure that the |path| is present in |prefs_|. If not, set it to
55 void EnsureStringPrefExists(PrefValueMap* prefs, const std::string& path);
57 // Make sure that the |path| is present in |prefs_| and is a ListValue. If
58 // not, set it to an empty list.
59 void EnsureListPrefExists(PrefValueMap* prefs, const std::string& path);
61 DISALLOW_COPY_AND_ASSIGN(DefaultSearchPolicyHandler);
66 #endif // COMPONENTS_SEARCH_ENGINES_DEFAULT_SEARCH_POLICY_HANDLER_H_