| OLD | NEW | 
|---|
| 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; | 
| 21 class PrefNotifier; | 22 class PrefNotifier; | 
| 22 class PrefStore; | 23 class PrefStore; | 
| 23 | 24 | 
| 24 // The PrefValueStore manages various sources of values for Preferences | 25 // The PrefValueStore manages various sources of values for Preferences | 
| 25 // (e.g., configuration policies, extensions, and user settings). It returns | 26 // (e.g., configuration policies, extensions, and user settings). It returns | 
| 26 // the value of a Preference from the source with the highest priority, and | 27 // the value of a Preference from the source with the highest priority, and | 
| 27 // allows setting user-defined values for preferences that are not managed. | 28 // allows setting user-defined values for preferences that are not managed. | 
| 28 // | 29 // | 
| 29 // Unless otherwise explicitly noted, all of the methods of this class must | 30 // Unless otherwise explicitly noted, all of the methods of this class must | 
| 30 // be called on the UI thread. | 31 // be called on the UI thread. | 
| (...skipping 18 matching lines...) Expand all  Loading... | 
| 49   // |pref_notifier| facilitates broadcasting preference change notifications | 50   // |pref_notifier| facilitates broadcasting preference change notifications | 
| 50   // to the world. | 51   // to the world. | 
| 51   PrefValueStore(PrefStore* managed_platform_prefs, | 52   PrefValueStore(PrefStore* managed_platform_prefs, | 
| 52                  PrefStore* managed_cloud_prefs, | 53                  PrefStore* managed_cloud_prefs, | 
| 53                  PrefStore* extension_prefs, | 54                  PrefStore* extension_prefs, | 
| 54                  PrefStore* command_line_prefs, | 55                  PrefStore* command_line_prefs, | 
| 55                  PrefStore* user_prefs, | 56                  PrefStore* user_prefs, | 
| 56                  PrefStore* recommended_platform_prefs, | 57                  PrefStore* recommended_platform_prefs, | 
| 57                  PrefStore* recommended_cloud_prefs, | 58                  PrefStore* recommended_cloud_prefs, | 
| 58                  PrefStore* default_prefs, | 59                  PrefStore* default_prefs, | 
|  | 60                  PrefModelAssociator* pref_sync_associator, | 
| 59                  PrefNotifier* pref_notifier); | 61                  PrefNotifier* pref_notifier); | 
| 60   virtual ~PrefValueStore(); | 62   virtual ~PrefValueStore(); | 
| 61 | 63 | 
| 62   // Creates a clone of this PrefValueStore with PrefStores overwritten | 64   // Creates a clone of this PrefValueStore with PrefStores overwritten | 
| 63   // by the parameters passed, if unequal NULL. | 65   // by the parameters passed, if unequal NULL. | 
| 64   PrefValueStore* CloneAndSpecialize(PrefStore* managed_platform_prefs, | 66   PrefValueStore* CloneAndSpecialize(PrefStore* managed_platform_prefs, | 
| 65                                      PrefStore* managed_cloud_prefs, | 67                                      PrefStore* managed_cloud_prefs, | 
| 66                                      PrefStore* extension_prefs, | 68                                      PrefStore* extension_prefs, | 
| 67                                      PrefStore* command_line_prefs, | 69                                      PrefStore* command_line_prefs, | 
| 68                                      PrefStore* user_prefs, | 70                                      PrefStore* user_prefs, | 
| 69                                      PrefStore* recommended_platform_prefs, | 71                                      PrefStore* recommended_platform_prefs, | 
| 70                                      PrefStore* recommended_cloud_prefs, | 72                                      PrefStore* recommended_cloud_prefs, | 
| 71                                      PrefStore* default_prefs, | 73                                      PrefStore* default_prefs, | 
|  | 74                                      PrefModelAssociator* pref_sync_associator, | 
| 72                                      PrefNotifier* pref_notifier); | 75                                      PrefNotifier* pref_notifier); | 
| 73 | 76 | 
| 74   // Gets the value for the given preference name that has the specified value | 77   // Gets the value for the given preference name that has the specified value | 
| 75   // type. Values stored in a PrefStore that have the matching |name| but | 78   // type. Values stored in a PrefStore that have the matching |name| but | 
| 76   // a non-matching |type| are silently skipped. Returns true if a valid value | 79   // a non-matching |type| are silently skipped. Returns true if a valid value | 
| 77   // was found in any of the available PrefStores. Most callers should use | 80   // was found in any of the available PrefStores. Most callers should use | 
| 78   // Preference::GetValue() instead of calling this method directly. | 81   // Preference::GetValue() instead of calling this method directly. | 
| 79   bool GetValue(const std::string& name, | 82   bool GetValue(const std::string& name, | 
| 80                 Value::ValueType type, | 83                 Value::ValueType type, | 
| 81                 const Value** out_value) const; | 84                 const Value** out_value) const; | 
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 226   PrefStore* GetPrefStore(PrefStoreType type) { | 229   PrefStore* GetPrefStore(PrefStoreType type) { | 
| 227     return pref_stores_[type].store(); | 230     return pref_stores_[type].store(); | 
| 228   } | 231   } | 
| 229   const PrefStore* GetPrefStore(PrefStoreType type) const { | 232   const PrefStore* GetPrefStore(PrefStoreType type) const { | 
| 230     return pref_stores_[type].store(); | 233     return pref_stores_[type].store(); | 
| 231   } | 234   } | 
| 232 | 235 | 
| 233   // Keeps the PrefStore references in order of precedence. | 236   // Keeps the PrefStore references in order of precedence. | 
| 234   PrefStoreKeeper pref_stores_[PREF_STORE_TYPE_MAX + 1]; | 237   PrefStoreKeeper pref_stores_[PREF_STORE_TYPE_MAX + 1]; | 
| 235 | 238 | 
|  | 239   // The associator for syncing preferences. | 
|  | 240   PrefModelAssociator* pref_sync_associator_; | 
|  | 241 | 
| 236   // Used for generating PREF_CHANGED and PREF_INITIALIZATION_COMPLETED | 242   // Used for generating PREF_CHANGED and PREF_INITIALIZATION_COMPLETED | 
| 237   // notifications. This is a weak reference, since the notifier is owned by the | 243   // notifications. This is a weak reference, since the notifier is owned by the | 
| 238   // corresponding PrefService. | 244   // corresponding PrefService. | 
| 239   PrefNotifier* pref_notifier_; | 245   PrefNotifier* pref_notifier_; | 
| 240 | 246 | 
| 241   // A mapping of preference names to their registered types. | 247   // A mapping of preference names to their registered types. | 
| 242   PrefTypeMap pref_types_; | 248   PrefTypeMap pref_types_; | 
| 243 | 249 | 
| 244   DISALLOW_COPY_AND_ASSIGN(PrefValueStore); | 250   DISALLOW_COPY_AND_ASSIGN(PrefValueStore); | 
| 245 }; | 251 }; | 
| 246 | 252 | 
| 247 #endif  // CHROME_BROWSER_PREFS_PREF_VALUE_STORE_H_ | 253 #endif  // CHROME_BROWSER_PREFS_PREF_VALUE_STORE_H_ | 
| OLD | NEW | 
|---|