Only grant permissions to new extensions from sync if they have the expected version
[chromium-blink-merge.git] / components / search_engines / default_search_policy_handler.h
blob5b1a88a0f6caa5dd30fec4e83d32267578661d2b
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_
8 #include <vector>
10 #include "components/policy/core/browser/configuration_policy_handler.h"
12 namespace policy {
14 // ConfigurationPolicyHandler for the DefaultSearchEncodings policy.
15 class DefaultSearchEncodingsPolicyHandler
16 : public TypeCheckingPolicyHandler {
17 public:
18 DefaultSearchEncodingsPolicyHandler();
19 ~DefaultSearchEncodingsPolicyHandler() override;
21 // ConfigurationPolicyHandler methods:
22 void ApplyPolicySettings(const PolicyMap& policies,
23 PrefValueMap* prefs) override;
25 private:
26 DISALLOW_COPY_AND_ASSIGN(DefaultSearchEncodingsPolicyHandler);
29 // ConfigurationPolicyHandler for the default search policies.
30 class DefaultSearchPolicyHandler : public ConfigurationPolicyHandler {
31 public:
32 DefaultSearchPolicyHandler();
33 ~DefaultSearchPolicyHandler() override;
35 // ConfigurationPolicyHandler methods:
36 bool CheckPolicySettings(const PolicyMap& policies,
37 PolicyErrorMap* errors) override;
38 void ApplyPolicySettings(const PolicyMap& policies,
39 PrefValueMap* prefs) override;
41 private:
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
64 // a blank string.
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);
77 } // namespace policy
79 #endif // COMPONENTS_SEARCH_ENGINES_DEFAULT_SEARCH_POLICY_HANDLER_H_