| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_EXTENSIONS_TEST_EXTENSION_PREFS_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_TEST_EXTENSION_PREFS_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_TEST_EXTENSION_PREFS_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_TEST_EXTENSION_PREFS_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "chrome/test/base/testing_profile.h" |
| 13 #include "extensions/common/manifest.h" | 14 #include "extensions/common/manifest.h" |
| 14 | 15 |
| 15 class ExtensionPrefValueMap; | 16 class ExtensionPrefValueMap; |
| 16 class PrefService; | 17 class PrefService; |
| 17 class PrefServiceSyncable; | 18 class PrefServiceSyncable; |
| 18 | 19 |
| 19 namespace base { | 20 namespace base { |
| 20 class DictionaryValue; | 21 class DictionaryValue; |
| 21 class SequencedTaskRunner; | 22 class SequencedTaskRunner; |
| 22 } | 23 } |
| 23 | 24 |
| 24 namespace user_prefs { | 25 namespace user_prefs { |
| 25 class PrefRegistrySyncable; | 26 class PrefRegistrySyncable; |
| 26 } | 27 } |
| 27 | 28 |
| 28 namespace extensions { | 29 namespace extensions { |
| 30 class ChromeAppSorting; |
| 29 class Extension; | 31 class Extension; |
| 30 class ExtensionPrefs; | 32 class ExtensionPrefs; |
| 31 | 33 |
| 32 // This is a test class intended to make it easier to work with ExtensionPrefs | 34 // This is a test class intended to make it easier to work with ExtensionPrefs |
| 33 // in tests. | 35 // in tests. |
| 34 class TestExtensionPrefs { | 36 class TestExtensionPrefs { |
| 35 public: | 37 public: |
| 36 explicit TestExtensionPrefs( | 38 explicit TestExtensionPrefs( |
| 37 const scoped_refptr<base::SequencedTaskRunner>& task_runner); | 39 const scoped_refptr<base::SequencedTaskRunner>& task_runner); |
| 38 virtual ~TestExtensionPrefs(); | 40 virtual ~TestExtensionPrefs(); |
| 39 | 41 |
| 40 ExtensionPrefs* prefs() { return prefs_.get(); } | 42 ExtensionPrefs* prefs(); |
| 41 const ExtensionPrefs& const_prefs() const { | 43 const ExtensionPrefs& const_prefs() const; |
| 42 return *prefs_.get(); | 44 |
| 43 } | |
| 44 PrefService* pref_service(); | 45 PrefService* pref_service(); |
| 45 const scoped_refptr<user_prefs::PrefRegistrySyncable>& pref_registry(); | 46 const scoped_refptr<user_prefs::PrefRegistrySyncable>& pref_registry(); |
| 46 void ResetPrefRegistry(); | 47 void ResetPrefRegistry(); |
| 47 const base::FilePath& temp_dir() const { return temp_dir_.path(); } | 48 const base::FilePath& temp_dir() const { return temp_dir_.path(); } |
| 48 const base::FilePath& extensions_dir() const { return extensions_dir_; } | 49 const base::FilePath& extensions_dir() const { return extensions_dir_; } |
| 49 ExtensionPrefValueMap* extension_pref_value_map() { | 50 ExtensionPrefValueMap* extension_pref_value_map() { |
| 50 return extension_pref_value_map_.get(); | 51 return extension_pref_value_map_.get(); |
| 51 } | 52 } |
| 52 | 53 |
| 53 // This will cause the ExtensionPrefs to be deleted and recreated, based on | 54 // This will cause the ExtensionPrefs to be deleted and recreated, based on |
| (...skipping 26 matching lines...) Expand all Loading... |
| 80 | 81 |
| 81 // This will add extension in our ExtensionPrefs. | 82 // This will add extension in our ExtensionPrefs. |
| 82 void AddExtension(Extension* extension); | 83 void AddExtension(Extension* extension); |
| 83 | 84 |
| 84 PrefService* CreateIncognitoPrefService() const; | 85 PrefService* CreateIncognitoPrefService() const; |
| 85 | 86 |
| 86 // Allows disabling the loading of preferences of extensions. Becomes | 87 // Allows disabling the loading of preferences of extensions. Becomes |
| 87 // active after calling RecreateExtensionPrefs(). Defaults to false. | 88 // active after calling RecreateExtensionPrefs(). Defaults to false. |
| 88 void set_extensions_disabled(bool extensions_disabled); | 89 void set_extensions_disabled(bool extensions_disabled); |
| 89 | 90 |
| 91 ChromeAppSorting* app_sorting(); |
| 92 |
| 90 protected: | 93 protected: |
| 91 base::ScopedTempDir temp_dir_; | 94 base::ScopedTempDir temp_dir_; |
| 92 base::FilePath preferences_file_; | 95 base::FilePath preferences_file_; |
| 93 base::FilePath extensions_dir_; | 96 base::FilePath extensions_dir_; |
| 94 scoped_refptr<user_prefs::PrefRegistrySyncable> pref_registry_; | 97 scoped_refptr<user_prefs::PrefRegistrySyncable> pref_registry_; |
| 95 scoped_ptr<PrefServiceSyncable> pref_service_; | 98 scoped_ptr<PrefServiceSyncable> pref_service_; |
| 96 scoped_ptr<ExtensionPrefs> prefs_; | |
| 97 scoped_ptr<ExtensionPrefValueMap> extension_pref_value_map_; | 99 scoped_ptr<ExtensionPrefValueMap> extension_pref_value_map_; |
| 98 const scoped_refptr<base::SequencedTaskRunner> task_runner_; | 100 const scoped_refptr<base::SequencedTaskRunner> task_runner_; |
| 99 | 101 |
| 100 private: | 102 private: |
| 103 TestingProfile profile_; |
| 101 bool extensions_disabled_; | 104 bool extensions_disabled_; |
| 102 DISALLOW_COPY_AND_ASSIGN(TestExtensionPrefs); | 105 DISALLOW_COPY_AND_ASSIGN(TestExtensionPrefs); |
| 103 }; | 106 }; |
| 104 | 107 |
| 105 } // namespace extensions | 108 } // namespace extensions |
| 106 | 109 |
| 107 #endif // CHROME_BROWSER_EXTENSIONS_TEST_EXTENSION_PREFS_H_ | 110 #endif // CHROME_BROWSER_EXTENSIONS_TEST_EXTENSION_PREFS_H_ |
| OLD | NEW |