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_
10 #include "base/macros.h"
11 #include "components/policy/core/browser/configuration_policy_handler.h"
15 // ConfigurationPolicyHandler for the default search policies.
16 class DefaultSearchPolicyHandler : public ConfigurationPolicyHandler {
18 DefaultSearchPolicyHandler();
19 ~DefaultSearchPolicyHandler() override;
21 // ConfigurationPolicyHandler methods:
22 bool CheckPolicySettings(const PolicyMap& policies,
23 PolicyErrorMap* errors) override;
24 void ApplyPolicySettings(const PolicyMap& policies,
25 PrefValueMap* prefs) override;
28 // Checks that value type is valid for each policy and returns whether all of
29 // the policies are valid.
30 bool CheckIndividualPolicies(const PolicyMap& policies,
31 PolicyErrorMap* errors);
33 // Returns whether there is a value for |policy_name| in |policies|.
34 bool HasDefaultSearchPolicy(const PolicyMap& policies,
35 const char* policy_name);
37 // Returns whether any default search policies are specified in |policies|.
38 bool AnyDefaultSearchPoliciesSpecified(const PolicyMap& policies);
40 // Returns whether the default search provider policy has a value.
41 bool DefaultSearchProviderPolicyIsSet(const PolicyMap& policies);
43 // Returns whether the default search provider is disabled.
44 bool DefaultSearchProviderIsDisabled(const PolicyMap& policies);
46 // Returns whether the default search URL is set and valid. On success, both
47 // outparams (which must be non-NULL) are filled with the search URL.
48 bool DefaultSearchURLIsValid(const PolicyMap& policies,
49 const base::Value** url_value,
50 std::string* url_string);
52 // Make sure that the |path| is present in |prefs_|. If not, set it to
54 void EnsureStringPrefExists(PrefValueMap* prefs, const std::string& path);
56 // Make sure that the |path| is present in |prefs_| and is a ListValue. If
57 // not, set it to an empty list.
58 void EnsureListPrefExists(PrefValueMap* prefs, const std::string& path);
60 DISALLOW_COPY_AND_ASSIGN(DefaultSearchPolicyHandler);
65 #endif // COMPONENTS_SEARCH_ENGINES_DEFAULT_SEARCH_POLICY_HANDLER_H_