Chromium Code Reviews| Index: components/prefs/testing_pref_service.h |
| diff --git a/components/prefs/testing_pref_service.h b/components/prefs/testing_pref_service.h |
| index f29e506d853ae28a830a0ad68e49f1c30352f3ec..30e4f24dd659903500e63ca19b0705ad87a53ec5 100644 |
| --- a/components/prefs/testing_pref_service.h |
| +++ b/components/prefs/testing_pref_service.h |
| @@ -40,6 +40,13 @@ class TestingPrefServiceBase : public SuperPrefService { |
| // preference has been defined previously. |
| void RemoveManagedPref(const std::string& path); |
| + // Similar to the above, but for extension preferences. |
| + // Does not really know about extensions and their order of installation. |
| + // Useful in tests that only checks that preference is overriden by extension. |
|
Peter Kasting
2017/01/06 01:44:57
Nit: "...only check that a preference is overridde
Alexander Yashkin
2017/01/07 12:55:59
Done, thanks.
|
| + const base::Value* GetExtensionPref(const std::string& path) const; |
| + void SetExtensionPref(const std::string& path, base::Value* value); |
| + void RemoveExtensionPref(const std::string& path); |
| + |
| // Similar to the above, but for user preferences. |
| const base::Value* GetUserPref(const std::string& path) const; |
| void SetUserPref(const std::string& path, base::Value* value); |
| @@ -54,12 +61,12 @@ class TestingPrefServiceBase : public SuperPrefService { |
| static void HandleReadError(PersistentPrefStore::PrefReadError error) {} |
| protected: |
| - TestingPrefServiceBase( |
| - TestingPrefStore* managed_prefs, |
| - TestingPrefStore* user_prefs, |
| - TestingPrefStore* recommended_prefs, |
| - ConstructionPrefRegistry* pref_registry, |
| - PrefNotifierImpl* pref_notifier); |
| + TestingPrefServiceBase(TestingPrefStore* managed_prefs, |
| + TestingPrefStore* extension_prefs, |
| + TestingPrefStore* user_prefs, |
| + TestingPrefStore* recommended_prefs, |
| + ConstructionPrefRegistry* pref_registry, |
| + PrefNotifierImpl* pref_notifier); |
| private: |
| // Reads the value of the preference indicated by |path| from |pref_store|. |
| @@ -77,6 +84,7 @@ class TestingPrefServiceBase : public SuperPrefService { |
| // Pointers to the pref stores our value store uses. |
| scoped_refptr<TestingPrefStore> managed_prefs_; |
| + scoped_refptr<TestingPrefStore> extension_prefs_; |
| scoped_refptr<TestingPrefStore> user_prefs_; |
| scoped_refptr<TestingPrefStore> recommended_prefs_; |
| @@ -104,6 +112,7 @@ class TestingPrefServiceSimple |
| template<> |
| TestingPrefServiceBase<PrefService, PrefRegistry>::TestingPrefServiceBase( |
| TestingPrefStore* managed_prefs, |
| + TestingPrefStore* extension_prefs, |
| TestingPrefStore* user_prefs, |
| TestingPrefStore* recommended_prefs, |
| PrefRegistry* pref_registry, |
| @@ -134,6 +143,25 @@ void TestingPrefServiceBase<SuperPrefService, ConstructionPrefRegistry>:: |
| } |
| template <class SuperPrefService, class ConstructionPrefRegistry> |
| +const base::Value* TestingPrefServiceBase< |
| + SuperPrefService, |
| + ConstructionPrefRegistry>::GetExtensionPref(const std::string& path) const { |
| + return GetPref(extension_prefs_.get(), path); |
| +} |
| + |
| +template <class SuperPrefService, class ConstructionPrefRegistry> |
| +void TestingPrefServiceBase<SuperPrefService, ConstructionPrefRegistry>:: |
| + SetExtensionPref(const std::string& path, base::Value* value) { |
| + SetPref(extension_prefs_.get(), path, value); |
| +} |
| + |
| +template <class SuperPrefService, class ConstructionPrefRegistry> |
| +void TestingPrefServiceBase<SuperPrefService, ConstructionPrefRegistry>:: |
| + RemoveExtensionPref(const std::string& path) { |
| + RemovePref(extension_prefs_.get(), path); |
| +} |
| + |
| +template <class SuperPrefService, class ConstructionPrefRegistry> |
| const base::Value* |
| TestingPrefServiceBase<SuperPrefService, ConstructionPrefRegistry>::GetUserPref( |
| const std::string& path) const { |