1 // Copyright 2013 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 CHROME_BROWSER_SEARCH_ENGINES_DEFAULT_SEARCH_POLICY_HANDLER_H_
6 #define CHROME_BROWSER_SEARCH_ENGINES_DEFAULT_SEARCH_POLICY_HANDLER_H_
10 #include "components/policy/core/browser/configuration_policy_handler.h"
14 // ConfigurationPolicyHandler for the DefaultSearchEncodings policy.
15 class DefaultSearchEncodingsPolicyHandler
16 : public TypeCheckingPolicyHandler
{
18 DefaultSearchEncodingsPolicyHandler();
19 virtual ~DefaultSearchEncodingsPolicyHandler();
21 // ConfigurationPolicyHandler methods:
22 virtual void ApplyPolicySettings(const PolicyMap
& policies
,
23 PrefValueMap
* prefs
) OVERRIDE
;
26 DISALLOW_COPY_AND_ASSIGN(DefaultSearchEncodingsPolicyHandler
);
29 // ConfigurationPolicyHandler for the default search policies.
30 class DefaultSearchPolicyHandler
: public ConfigurationPolicyHandler
{
32 DefaultSearchPolicyHandler();
33 virtual ~DefaultSearchPolicyHandler();
35 // ConfigurationPolicyHandler methods:
36 virtual bool CheckPolicySettings(const PolicyMap
& policies
,
37 PolicyErrorMap
* errors
) OVERRIDE
;
38 virtual void ApplyPolicySettings(const PolicyMap
& policies
,
39 PrefValueMap
* prefs
) OVERRIDE
;
42 // Calls |CheckPolicySettings()| on each of the handlers in |handlers_|
43 // and returns whether all of the calls succeeded.
44 bool CheckIndividualPolicies(const PolicyMap
& policies
,
45 PolicyErrorMap
* errors
);
47 // Returns whether there is a value for |policy_name| in |policies|.
48 bool HasDefaultSearchPolicy(const PolicyMap
& policies
,
49 const char* policy_name
);
51 // Returns whether any default search policies are specified in |policies|.
52 bool AnyDefaultSearchPoliciesSpecified(const PolicyMap
& policies
);
54 // Returns whether the default search provider is disabled.
55 bool DefaultSearchProviderIsDisabled(const PolicyMap
& policies
);
57 // Returns whether the default search URL is set and valid. On success, both
58 // outparams (which must be non-NULL) are filled with the search URL.
59 bool DefaultSearchURLIsValid(const PolicyMap
& policies
,
60 const base::Value
** url_value
,
61 std::string
* url_string
);
63 // Make sure that the |path| is present in |prefs_|. If not, set it to
65 void EnsureStringPrefExists(PrefValueMap
* prefs
, const std::string
& path
);
67 // Make sure that the |path| is present in |prefs_| and is a ListValue. If
68 // not, set it to an empty list.
69 void EnsureListPrefExists(PrefValueMap
* prefs
, const std::string
& path
);
71 // The ConfigurationPolicyHandler handlers for each default search policy.
72 std::vector
<TypeCheckingPolicyHandler
*> handlers_
;
74 DISALLOW_COPY_AND_ASSIGN(DefaultSearchPolicyHandler
);
79 #endif // CHROME_BROWSER_SEARCH_ENGINES_DEFAULT_SEARCH_POLICY_HANDLER_H_