OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PREF_STORE_H_ | 5 #ifndef CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PREF_STORE_H_ |
6 #define CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PREF_STORE_H_ | 6 #define CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PREF_STORE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 static ConfigurationPolicyPrefStore* CreateDeviceManagementPolicyPrefStore( | 49 static ConfigurationPolicyPrefStore* CreateDeviceManagementPolicyPrefStore( |
50 Profile* profile); | 50 Profile* profile); |
51 | 51 |
52 // Creates a ConfigurationPolicyPrefStore that reads recommended policy. | 52 // Creates a ConfigurationPolicyPrefStore that reads recommended policy. |
53 static ConfigurationPolicyPrefStore* CreateRecommendedPolicyPrefStore(); | 53 static ConfigurationPolicyPrefStore* CreateRecommendedPolicyPrefStore(); |
54 | 54 |
55 // Returns the default policy definition list for Chrome. | 55 // Returns the default policy definition list for Chrome. |
56 static const ConfigurationPolicyProvider::PolicyDefinitionList* | 56 static const ConfigurationPolicyProvider::PolicyDefinitionList* |
57 GetChromePolicyDefinitionList(); | 57 GetChromePolicyDefinitionList(); |
58 | 58 |
59 // Returns the set of preference paths that can be affected by a proxy | |
60 // policy. | |
61 static void GetProxyPreferenceSet(ProxyPreferenceSet* proxy_pref_set); | |
62 | |
63 private: | 59 private: |
64 // Policies that map to a single preference are handled | 60 // Policies that map to a single preference are handled |
65 // by an automated converter. Each one of these policies | 61 // by an automated converter. Each one of these policies |
66 // has an entry in |simple_policy_map_| with the following type. | 62 // has an entry in |simple_policy_map_| with the following type. |
67 struct PolicyToPreferenceMapEntry { | 63 struct PolicyToPreferenceMapEntry { |
68 Value::ValueType value_type; | 64 Value::ValueType value_type; |
69 ConfigurationPolicyType policy_type; | 65 ConfigurationPolicyType policy_type; |
70 const char* preference_path; // A DictionaryValue path, not a file path. | 66 const char* preference_path; // A DictionaryValue path, not a file path. |
71 }; | 67 }; |
72 | 68 |
73 static const PolicyToPreferenceMapEntry kSimplePolicyMap[]; | 69 static const PolicyToPreferenceMapEntry kSimplePolicyMap[]; |
74 static const PolicyToPreferenceMapEntry kProxyPolicyMap[]; | 70 static const PolicyToPreferenceMapEntry kProxyPolicyMap[]; |
75 static const PolicyToPreferenceMapEntry kDefaultSearchPolicyMap[]; | 71 static const PolicyToPreferenceMapEntry kDefaultSearchPolicyMap[]; |
76 static const ConfigurationPolicyProvider::PolicyDefinitionList | 72 static const ConfigurationPolicyProvider::PolicyDefinitionList |
77 kPolicyDefinitionList; | 73 kPolicyDefinitionList; |
78 | 74 |
79 ConfigurationPolicyProvider* provider_; | 75 ConfigurationPolicyProvider* provider_; |
80 scoped_ptr<DictionaryValue> prefs_; | 76 scoped_ptr<DictionaryValue> prefs_; |
81 | 77 |
82 // Set to false until the first proxy-relevant policy is applied. At that | 78 // Temporary cache that stores values until FinalizeProxyPolicySettings() |
83 // time, default values are provided for all proxy-relevant prefs | 79 // is called. |
84 // to override any values set from stores with a lower priority. | 80 std::map<ConfigurationPolicyType, Value*> proxy_policies_; |
85 bool lower_priority_proxy_settings_overridden_; | |
86 | 81 |
87 // The following are used to track what proxy-relevant policy has been applied | 82 bool HasProxyPolicy(ConfigurationPolicyType policy) const; |
88 // accross calls to Apply to provide a warning if a policy specifies a | |
89 // contradictory proxy configuration. |proxy_disabled_| is set to true if and | |
90 // only if the kPolicyNoProxyServer has been applied, | |
91 // |proxy_configuration_specified_| is set to true if and only if any other | |
92 // proxy policy other than kPolicyNoProxyServer has been applied. | |
93 bool proxy_disabled_; | |
94 bool proxy_configuration_specified_; | |
95 | |
96 // Set to true if a the proxy mode policy has been set to force Chrome | |
97 // to use the system proxy. | |
98 bool use_system_proxy_; | |
99 | 83 |
100 // Returns the map entry that corresponds to |policy| in the map. | 84 // Returns the map entry that corresponds to |policy| in the map. |
101 const PolicyToPreferenceMapEntry* FindPolicyInMap( | 85 const PolicyToPreferenceMapEntry* FindPolicyInMap( |
102 ConfigurationPolicyType policy, | 86 ConfigurationPolicyType policy, |
103 const PolicyToPreferenceMapEntry* map, | 87 const PolicyToPreferenceMapEntry* map, |
104 int size) const; | 88 int size) const; |
105 | 89 |
106 // Remove the preferences found in the map from |prefs_|. Returns true if | 90 // Remove the preferences found in the map from |prefs_|. Returns true if |
107 // any such preferences were found and removed. | 91 // any such preferences were found and removed. |
108 bool RemovePreferencesOfMap(const PolicyToPreferenceMapEntry* map, | 92 bool RemovePreferencesOfMap(const PolicyToPreferenceMapEntry* map, |
(...skipping 20 matching lines...) Expand all Loading... |
129 // Make sure that the |path| if present in |prefs_|. If not, set it to | 113 // Make sure that the |path| if present in |prefs_|. If not, set it to |
130 // a blank string. | 114 // a blank string. |
131 void EnsureStringPrefExists(const std::string& path); | 115 void EnsureStringPrefExists(const std::string& path); |
132 | 116 |
133 // If the required entries for default search are specified and valid, | 117 // If the required entries for default search are specified and valid, |
134 // finalizes the policy-specified configuration by initializing the | 118 // finalizes the policy-specified configuration by initializing the |
135 // unspecified map entries. Otherwise wipes all default search related | 119 // unspecified map entries. Otherwise wipes all default search related |
136 // map entries from |prefs_|. | 120 // map entries from |prefs_|. |
137 void FinalizeDefaultSearchPolicySettings(); | 121 void FinalizeDefaultSearchPolicySettings(); |
138 | 122 |
| 123 // If the required entries for the proxy settings are specified and valid, |
| 124 // finalizes the policy-specified configuration by initializing the |
| 125 // respective values in |prefs_|. |
| 126 void FinalizeProxyPolicySettings(); |
| 127 |
| 128 // Returns true if the policy values stored in proxy_* represent a valid |
| 129 // proxy configuration. |
| 130 bool CheckProxySettings(); |
| 131 |
| 132 // Assumes CheckProxySettings returns true and applies the values stored |
| 133 // in proxy_*. |
| 134 void ApplyProxySettings(); |
| 135 |
139 DISALLOW_COPY_AND_ASSIGN(ConfigurationPolicyPrefStore); | 136 DISALLOW_COPY_AND_ASSIGN(ConfigurationPolicyPrefStore); |
140 }; | 137 }; |
141 | 138 |
142 } // namespace policy | 139 } // namespace policy |
143 | 140 |
144 #endif // CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PREF_STORE_H_ | 141 #endif // CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PREF_STORE_H_ |
OLD | NEW |