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

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

Issue 7838030: WIP: Introduce per-TabContents PrefService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 3 months 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "base/gtest_prod_util.h" 14 #include "base/gtest_prod_util.h"
15 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
16 #include "base/values.h" 16 #include "base/values.h"
17 #include "chrome/common/pref_store.h" 17 #include "chrome/common/pref_store.h"
18 #include "content/browser/browser_thread.h" 18 #include "content/browser/browser_thread.h"
19 19
20 class FilePath; 20 class FilePath;
21 class PrefModelAssociator;
22 class PrefNotifier; 21 class PrefNotifier;
23 class PrefStore; 22 class PrefStore;
24 23
25 // The PrefValueStore manages various sources of values for Preferences 24 // The PrefValueStore manages various sources of values for Preferences
26 // (e.g., configuration policies, extensions, and user settings). It returns 25 // (e.g., configuration policies, extensions, and user settings). It returns
27 // the value of a Preference from the source with the highest priority, and 26 // the value of a Preference from the source with the highest priority, and
28 // allows setting user-defined values for preferences that are not managed. 27 // allows setting user-defined values for preferences that are not managed.
29 // 28 //
30 // Unless otherwise explicitly noted, all of the methods of this class must 29 // Unless otherwise explicitly noted, all of the methods of this class must
31 // be called on the UI thread. 30 // be called on the UI thread.
(...skipping 18 matching lines...) Expand all
50 // |pref_notifier| facilitates broadcasting preference change notifications 49 // |pref_notifier| facilitates broadcasting preference change notifications
51 // to the world. 50 // to the world.
52 PrefValueStore(PrefStore* managed_platform_prefs, 51 PrefValueStore(PrefStore* managed_platform_prefs,
53 PrefStore* managed_cloud_prefs, 52 PrefStore* managed_cloud_prefs,
54 PrefStore* extension_prefs, 53 PrefStore* extension_prefs,
55 PrefStore* command_line_prefs, 54 PrefStore* command_line_prefs,
56 PrefStore* user_prefs, 55 PrefStore* user_prefs,
57 PrefStore* recommended_platform_prefs, 56 PrefStore* recommended_platform_prefs,
58 PrefStore* recommended_cloud_prefs, 57 PrefStore* recommended_cloud_prefs,
59 PrefStore* default_prefs, 58 PrefStore* default_prefs,
60 PrefModelAssociator* pref_sync_associator,
61 PrefNotifier* pref_notifier); 59 PrefNotifier* pref_notifier);
62 virtual ~PrefValueStore(); 60 virtual ~PrefValueStore();
63 61
64 // Creates a clone of this PrefValueStore with PrefStores overwritten 62 // Creates a clone of this PrefValueStore with PrefStores overwritten
65 // by the parameters passed, if unequal NULL. 63 // by the parameters passed, if unequal NULL.
66 PrefValueStore* CloneAndSpecialize(PrefStore* managed_platform_prefs, 64 PrefValueStore* CloneAndSpecialize(PrefStore* managed_platform_prefs,
67 PrefStore* managed_cloud_prefs, 65 PrefStore* managed_cloud_prefs,
68 PrefStore* extension_prefs, 66 PrefStore* extension_prefs,
69 PrefStore* command_line_prefs, 67 PrefStore* command_line_prefs,
70 PrefStore* user_prefs, 68 PrefStore* user_prefs,
71 PrefStore* recommended_platform_prefs, 69 PrefStore* recommended_platform_prefs,
72 PrefStore* recommended_cloud_prefs, 70 PrefStore* recommended_cloud_prefs,
73 PrefStore* default_prefs, 71 PrefStore* default_prefs,
74 PrefModelAssociator* pref_sync_associator,
75 PrefNotifier* pref_notifier); 72 PrefNotifier* pref_notifier);
76 73
77 // Gets the value for the given preference name that has the specified value 74 // Gets the value for the given preference name that has the specified value
78 // type. Values stored in a PrefStore that have the matching |name| but 75 // type. Values stored in a PrefStore that have the matching |name| but
79 // a non-matching |type| are silently skipped. Returns true if a valid value 76 // a non-matching |type| are silently skipped. Returns true if a valid value
80 // was found in any of the available PrefStores. Most callers should use 77 // was found in any of the available PrefStores. Most callers should use
81 // Preference::GetValue() instead of calling this method directly. 78 // Preference::GetValue() instead of calling this method directly.
82 bool GetValue(const std::string& name, 79 bool GetValue(const std::string& name,
83 base::Value::Type type, 80 base::Value::Type type,
84 const Value** out_value) const; 81 const Value** out_value) const;
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 PrefStore* GetPrefStore(PrefStoreType type) { 226 PrefStore* GetPrefStore(PrefStoreType type) {
230 return pref_stores_[type].store(); 227 return pref_stores_[type].store();
231 } 228 }
232 const PrefStore* GetPrefStore(PrefStoreType type) const { 229 const PrefStore* GetPrefStore(PrefStoreType type) const {
233 return pref_stores_[type].store(); 230 return pref_stores_[type].store();
234 } 231 }
235 232
236 // Keeps the PrefStore references in order of precedence. 233 // Keeps the PrefStore references in order of precedence.
237 PrefStoreKeeper pref_stores_[PREF_STORE_TYPE_MAX + 1]; 234 PrefStoreKeeper pref_stores_[PREF_STORE_TYPE_MAX + 1];
238 235
239 // The associator for syncing preferences.
240 PrefModelAssociator* pref_sync_associator_;
241
242 // Used for generating PREF_CHANGED and PREF_INITIALIZATION_COMPLETED 236 // Used for generating PREF_CHANGED and PREF_INITIALIZATION_COMPLETED
243 // notifications. This is a weak reference, since the notifier is owned by the 237 // notifications. This is a weak reference, since the notifier is owned by the
244 // corresponding PrefService. 238 // corresponding PrefService.
245 PrefNotifier* pref_notifier_; 239 PrefNotifier* pref_notifier_;
246 240
247 // A mapping of preference names to their registered types. 241 // A mapping of preference names to their registered types.
248 PrefTypeMap pref_types_; 242 PrefTypeMap pref_types_;
249 243
250 // True if not all of the PrefStores were initialized successfully. 244 // True if not all of the PrefStores were initialized successfully.
251 bool initialization_failed_; 245 bool initialization_failed_;
252 246
253 DISALLOW_COPY_AND_ASSIGN(PrefValueStore); 247 DISALLOW_COPY_AND_ASSIGN(PrefValueStore);
254 }; 248 };
255 249
256 #endif // CHROME_BROWSER_PREFS_PREF_VALUE_STORE_H_ 250 #endif // CHROME_BROWSER_PREFS_PREF_VALUE_STORE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698