Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(279)

Side by Side Diff: chrome/browser/prefs/pref_value_store.h

Issue 5174006: Move DeviceManagementPolicyProvider into the profile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address thakis' comments. Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_PREFS_PREF_VALUE_STORE_H_ 5 #ifndef CHROME_BROWSER_PREFS_PREF_VALUE_STORE_H_
6 #define CHROME_BROWSER_PREFS_PREF_VALUE_STORE_H_ 6 #define CHROME_BROWSER_PREFS_PREF_VALUE_STORE_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 // |callback|. |callback| is called with the set of preferences changed by the 165 // |callback|. |callback| is called with the set of preferences changed by the
166 // policy refresh. |callback| is called on the caller's thread as a Task 166 // policy refresh. |callback| is called on the caller's thread as a Task
167 // after RefreshPolicyPrefs has returned. 167 // after RefreshPolicyPrefs has returned.
168 void RefreshPolicyPrefs(AfterRefreshCallback* callback); 168 void RefreshPolicyPrefs(AfterRefreshCallback* callback);
169 169
170 // Returns true if there are proxy preferences in user-modifiable 170 // Returns true if there are proxy preferences in user-modifiable
171 // preference stores (e.g. CommandLinePrefStore, ExtensionPrefStore) 171 // preference stores (e.g. CommandLinePrefStore, ExtensionPrefStore)
172 // that conflict with proxy settings specified by proxy policy. 172 // that conflict with proxy settings specified by proxy policy.
173 bool HasPolicyConflictingUserProxySettings(); 173 bool HasPolicyConflictingUserProxySettings();
174 174
175 protected: 175 protected:
176 // In decreasing order of precedence: 176 // In decreasing order of precedence:
177 // |managed_platform_prefs| contains all managed platform (non-cloud policy) 177 // |managed_platform_prefs| contains all managed platform (non-cloud policy)
178 // preference values. 178 // preference values.
179 // |device_management_prefs| contains all device management (cloud policy) 179 // |device_management_prefs| contains all device management (cloud policy)
180 // preference values. 180 // preference values.
181 // |extension_prefs| contains preference values set by extensions. 181 // |extension_prefs| contains preference values set by extensions.
182 // |command_line_prefs| contains preference values set by command-line 182 // |command_line_prefs| contains preference values set by command-line
183 // switches. 183 // switches.
184 // |user_prefs| contains all user-set preference values. 184 // |user_prefs| contains all user-set preference values.
185 // |recommended_prefs| contains all recommended (policy) preference values. 185 // |recommended_prefs| contains all recommended (policy) preference values.
186 // |default_prefs| contains application-default preference values. It must 186 // |default_prefs| contains application-default preference values. It must
187 // be non-null if any preferences are to be registered. 187 // be non-null if any preferences are to be registered.
188 // 188 //
189 // The |profile| parameter is used to construct a replacement device
190 // management pref store in case of policy refresh.
Nico 2010/11/18 14:34:24 get rid of the newline above this, and make the fo
Mattias Nissler (ping if slow) 2010/11/18 15:08:16 I disagree, the above comment talks about the pref
191 //
192 // TODO(mnissler, danno): Refactor the pref store interface and refresh logic
193 // so refreshes can be handled by the pref store itself and the profile
194 // parameter be removed her.
Nico 2010/11/18 14:34:24 can be removed here
Mattias Nissler (ping if slow) 2010/11/18 15:08:16 Done.
195 //
189 // This constructor should only be used internally, or by subclasses in 196 // This constructor should only be used internally, or by subclasses in
190 // testing. The usual way to create a PrefValueStore is by creating a 197 // testing. The usual way to create a PrefValueStore is by creating a
191 // PrefService. 198 // PrefService.
192 PrefValueStore(PrefStore* managed_platform_prefs, 199 PrefValueStore(PrefStore* managed_platform_prefs,
193 PrefStore* device_management_prefs, 200 PrefStore* device_management_prefs,
194 PrefStore* extension_prefs, 201 PrefStore* extension_prefs,
195 PrefStore* command_line_prefs, 202 PrefStore* command_line_prefs,
196 PrefStore* user_prefs, 203 PrefStore* user_prefs,
197 PrefStore* recommended_prefs, 204 PrefStore* recommended_prefs,
198 PrefStore* default_prefs); 205 PrefStore* default_prefs,
206 Profile* profile);
199 207
200 private: 208 private:
209 typedef std::map<std::string, Value::ValueType> PrefTypeMap;
210
201 friend class PrefValueStoreTest; 211 friend class PrefValueStoreTest;
202 FRIEND_TEST_ALL_PREFIXES(PrefValueStoreTest, 212 FRIEND_TEST_ALL_PREFIXES(PrefValueStoreTest,
203 TestRefreshPolicyPrefsCompletion); 213 TestRefreshPolicyPrefsCompletion);
204 214
205 scoped_ptr<PrefStore> pref_stores_[PrefNotifier::PREF_STORE_TYPE_MAX + 1];
206
207 // A mapping of preference names to their registered types.
208 typedef std::map<std::string, Value::ValueType> PrefTypeMap;
209 PrefTypeMap pref_types_;
210
211 // Returns true if the preference with the given name has a value in the 215 // Returns true if the preference with the given name has a value in the
212 // given PrefStoreType, of the same value type as the preference was 216 // given PrefStoreType, of the same value type as the preference was
213 // registered with. 217 // registered with.
214 bool PrefValueInStore(const char* name, 218 bool PrefValueInStore(const char* name,
215 PrefNotifier::PrefStoreType store) const; 219 PrefNotifier::PrefStoreType store) const;
216 220
217 // Get a value from the specified store type. 221 // Get a value from the specified store type.
218 bool GetValueFromStore(const char* name, 222 bool GetValueFromStore(const char* name,
219 PrefNotifier::PrefStoreType store, 223 PrefNotifier::PrefStoreType store,
220 Value** out_value) const; 224 Value** out_value) const;
221 225
222 // Called during policy refresh after ReadPrefs completes on the thread 226 // Called during policy refresh after ReadPrefs completes on the thread
223 // that initiated the policy refresh. RefreshPolicyPrefsCompletion takes 227 // that initiated the policy refresh. RefreshPolicyPrefsCompletion takes
224 // ownership of the |callback| object. 228 // ownership of the |callback| object.
225 void RefreshPolicyPrefsCompletion( 229 void RefreshPolicyPrefsCompletion(
226 PrefStore* new_managed_platform_pref_store, 230 PrefStore* new_managed_platform_pref_store,
227 PrefStore* new_device_management_pref_store, 231 PrefStore* new_device_management_pref_store,
228 PrefStore* new_recommended_pref_store, 232 PrefStore* new_recommended_pref_store,
229 AfterRefreshCallback* callback); 233 AfterRefreshCallback* callback);
230 234
231 // Called during policy refresh to do the ReadPrefs on the FILE thread. 235 // Called during policy refresh to do the ReadPrefs on the FILE thread.
232 // RefreshPolicyPrefsOnFileThread takes ownership of the |callback| object. 236 // RefreshPolicyPrefsOnFileThread takes ownership of the |callback| object.
233 void RefreshPolicyPrefsOnFileThread( 237 void RefreshPolicyPrefsOnFileThread(
234 BrowserThread::ID calling_thread_id, 238 BrowserThread::ID calling_thread_id,
235 PrefStore* new_managed_platform_pref_store, 239 PrefStore* new_managed_platform_pref_store,
236 PrefStore* new_device_management_pref_store, 240 PrefStore* new_device_management_pref_store,
237 PrefStore* new_recommended_pref_store, 241 PrefStore* new_recommended_pref_store,
238 AfterRefreshCallback* callback); 242 AfterRefreshCallback* callback);
239 243
244 scoped_ptr<PrefStore> pref_stores_[PrefNotifier::PREF_STORE_TYPE_MAX + 1];
245
246 // A mapping of preference names to their registered types.
247 PrefTypeMap pref_types_;
248
249 // The associated profile, if applicable.
250 Profile* profile_;
251
240 DISALLOW_COPY_AND_ASSIGN(PrefValueStore); 252 DISALLOW_COPY_AND_ASSIGN(PrefValueStore);
241 }; 253 };
242 254
243 #endif // CHROME_BROWSER_PREFS_PREF_VALUE_STORE_H_ 255 #endif // CHROME_BROWSER_PREFS_PREF_VALUE_STORE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698