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

Side by Side Diff: chrome/browser/extensions/test_extension_prefs.h

Issue 11570009: Split PrefService into PrefService, PrefServiceSimple and PrefServiceSyncable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head again, previous had unrelated broken win_rel test. Created 8 years 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) 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/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "chrome/common/extensions/extension.h" 12 #include "chrome/common/extensions/extension.h"
13 13
14 class ExtensionPrefValueMap; 14 class ExtensionPrefValueMap;
15 class PrefService; 15 class PrefServiceSyncable;
16 16
17 namespace base { 17 namespace base {
18 class DictionaryValue; 18 class DictionaryValue;
19 class SequencedTaskRunner; 19 class SequencedTaskRunner;
20 } 20 }
21 21
22 namespace extensions { 22 namespace extensions {
23 class ExtensionPrefs; 23 class ExtensionPrefs;
24 24
25 // This is a test class intended to make it easier to work with ExtensionPrefs 25 // This is a test class intended to make it easier to work with ExtensionPrefs
26 // in tests. 26 // in tests.
27 class TestExtensionPrefs { 27 class TestExtensionPrefs {
28 public: 28 public:
29 explicit TestExtensionPrefs(base::SequencedTaskRunner* task_runner); 29 explicit TestExtensionPrefs(base::SequencedTaskRunner* task_runner);
30 virtual ~TestExtensionPrefs(); 30 virtual ~TestExtensionPrefs();
31 31
32 ExtensionPrefs* prefs() { return prefs_.get(); } 32 ExtensionPrefs* prefs() { return prefs_.get(); }
33 const ExtensionPrefs& const_prefs() const { 33 const ExtensionPrefs& const_prefs() const {
34 return *prefs_.get(); 34 return *prefs_.get();
35 } 35 }
36 PrefService* pref_service() { return pref_service_.get(); } 36 PrefServiceSyncable* pref_service() { return pref_service_.get(); }
37 const FilePath& temp_dir() const { return temp_dir_.path(); } 37 const FilePath& temp_dir() const { return temp_dir_.path(); }
38 const FilePath& extensions_dir() const { return extensions_dir_; } 38 const FilePath& extensions_dir() const { return extensions_dir_; }
39 39
40 // This will cause the ExtensionPrefs to be deleted and recreated, based on 40 // This will cause the ExtensionPrefs to be deleted and recreated, based on
41 // any existing backing file we had previously created. 41 // any existing backing file we had previously created.
42 void RecreateExtensionPrefs(); 42 void RecreateExtensionPrefs();
43 43
44 // Creates a new Extension with the given name in our temp dir, adds it to 44 // Creates a new Extension with the given name in our temp dir, adds it to
45 // our ExtensionPrefs, and returns it. 45 // our ExtensionPrefs, and returns it.
46 scoped_refptr<Extension> AddExtension(std::string name); 46 scoped_refptr<Extension> AddExtension(std::string name);
(...skipping 11 matching lines...) Expand all
58 scoped_refptr<Extension> AddExtensionWithManifestAndFlags( 58 scoped_refptr<Extension> AddExtensionWithManifestAndFlags(
59 const base::DictionaryValue& manifest, 59 const base::DictionaryValue& manifest,
60 Extension::Location location, 60 Extension::Location location,
61 int extra_flags); 61 int extra_flags);
62 62
63 // Similar to AddExtension, this adds a new test Extension. This is useful for 63 // Similar to AddExtension, this adds a new test Extension. This is useful for
64 // cases when you don't need the Extension object, but just the id it was 64 // cases when you don't need the Extension object, but just the id it was
65 // assigned. 65 // assigned.
66 std::string AddExtensionAndReturnId(std::string name); 66 std::string AddExtensionAndReturnId(std::string name);
67 67
68 PrefService* CreateIncognitoPrefService() const; 68 PrefServiceSyncable* CreateIncognitoPrefService() const;
69 69
70 // Allows disabling the loading of preferences of extensions. Becomes 70 // Allows disabling the loading of preferences of extensions. Becomes
71 // active after calling RecreateExtensionPrefs(). Defaults to false. 71 // active after calling RecreateExtensionPrefs(). Defaults to false.
72 void set_extensions_disabled(bool extensions_disabled); 72 void set_extensions_disabled(bool extensions_disabled);
73 73
74 protected: 74 protected:
75 base::ScopedTempDir temp_dir_; 75 base::ScopedTempDir temp_dir_;
76 FilePath preferences_file_; 76 FilePath preferences_file_;
77 FilePath extensions_dir_; 77 FilePath extensions_dir_;
78 scoped_ptr<PrefService> pref_service_; 78 scoped_ptr<PrefServiceSyncable> pref_service_;
79 scoped_ptr<ExtensionPrefs> prefs_; 79 scoped_ptr<ExtensionPrefs> prefs_;
80 scoped_ptr<ExtensionPrefValueMap> extension_pref_value_map_; 80 scoped_ptr<ExtensionPrefValueMap> extension_pref_value_map_;
81 const scoped_refptr<base::SequencedTaskRunner> task_runner_; 81 const scoped_refptr<base::SequencedTaskRunner> task_runner_;
82 82
83 private: 83 private:
84 bool extensions_disabled_; 84 bool extensions_disabled_;
85 DISALLOW_COPY_AND_ASSIGN(TestExtensionPrefs); 85 DISALLOW_COPY_AND_ASSIGN(TestExtensionPrefs);
86 }; 86 };
87 87
88 } // namespace extensions 88 } // namespace extensions
89 89
90 #endif // CHROME_BROWSER_EXTENSIONS_TEST_EXTENSION_PREFS_H_ 90 #endif // CHROME_BROWSER_EXTENSIONS_TEST_EXTENSION_PREFS_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/platform_app_browsertest.cc ('k') | chrome/browser/extensions/test_extension_prefs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698