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

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

Issue 2529083002: Make extensions developer mode adhere to policy (Closed)
Patch Set: Reviewers' comments Created 4 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_EXTENSION_SERVICE_TEST_BASE_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_TEST_BASE_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_TEST_BASE_H_ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_TEST_BASE_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 17 matching lines...) Expand all
28 #endif 28 #endif
29 29
30 class ExtensionService; 30 class ExtensionService;
31 class Profile; 31 class Profile;
32 class TestingProfile; 32 class TestingProfile;
33 33
34 namespace content { 34 namespace content {
35 class BrowserContext; 35 class BrowserContext;
36 } 36 }
37 37
38 namespace sync_preferences {
39 class TestingPrefServiceSyncable;
40 }
41
38 namespace extensions { 42 namespace extensions {
39 43
40 class ExtensionRegistry; 44 class ExtensionRegistry;
41 class ManagementPolicy; 45 class ManagementPolicy;
42 46
43 // A unittest infrastructure which creates an ExtensionService. Whenever 47 // A unittest infrastructure which creates an ExtensionService. Whenever
44 // possible, use this instead of creating a browsertest. 48 // possible, use this instead of creating a browsertest.
45 // Note: Before adding methods to this class, please, please, please think about 49 // Note: Before adding methods to this class, please, please, please think about
46 // whether they should go here or in a more specific subclass. Lots of things 50 // whether they should go here or in a more specific subclass. Lots of things
47 // need an ExtensionService, but they don't all need to know how you want yours 51 // need an ExtensionService, but they don't all need to know how you want yours
48 // to be initialized. 52 // to be initialized.
49 class ExtensionServiceTestBase : public testing::Test { 53 class ExtensionServiceTestBase : public testing::Test {
50 public: 54 public:
51 struct ExtensionServiceInitParams { 55 struct ExtensionServiceInitParams {
52 base::FilePath profile_path; 56 base::FilePath profile_path;
53 base::FilePath pref_file; 57 base::FilePath pref_file;
54 base::FilePath extensions_install_dir; 58 base::FilePath extensions_install_dir;
55 bool autoupdate_enabled; // defaults to false. 59 bool autoupdate_enabled; // defaults to false.
56 bool is_first_run; // defaults to true. 60 bool is_first_run; // defaults to true.
57 bool profile_is_supervised; // defaults to false. 61 bool profile_is_supervised; // defaults to false.
Andrew T Wilson (Slow) 2016/12/04 14:54:54 I think intent is for comments to line up, so can
pmarko 2016/12/07 16:12:11 Done.
58 62
59 // Though you could use this constructor, you probably want to use 63 // Though you could use this constructor, you probably want to use
60 // CreateDefaultInitParams(), and then make a change or two. 64 // CreateDefaultInitParams(), and then make a change or two.
61 ExtensionServiceInitParams(); 65 ExtensionServiceInitParams();
62 ExtensionServiceInitParams(const ExtensionServiceInitParams& other); 66 ExtensionServiceInitParams(const ExtensionServiceInitParams& other);
63 }; 67 };
64 68
65 // Public because parameterized test cases need it to be, or else the compiler 69 // Public because parameterized test cases need it to be, or else the compiler
66 // barfs. 70 // barfs.
67 static void SetUpTestCase(); // faux-verride (static override). 71 static void SetUpTestCase(); // faux-verride (static override).
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 void ValidateStringPref(const std::string& extension_id, 115 void ValidateStringPref(const std::string& extension_id,
112 const std::string& pref_path, 116 const std::string& pref_path,
113 const std::string& expected_val); 117 const std::string& expected_val);
114 118
115 // TODO(rdevlin.cronin): Pull out more methods from ExtensionServiceTest that 119 // TODO(rdevlin.cronin): Pull out more methods from ExtensionServiceTest that
116 // are commonly used and/or reimplemented. For instance, methods to install 120 // are commonly used and/or reimplemented. For instance, methods to install
117 // extensions from various locations, etc. 121 // extensions from various locations, etc.
118 122
119 content::BrowserContext* browser_context(); 123 content::BrowserContext* browser_context();
120 Profile* profile(); 124 Profile* profile();
125 sync_preferences::TestingPrefServiceSyncable* testing_pref_service();
121 ExtensionService* service() { return service_; } 126 ExtensionService* service() { return service_; }
122 ExtensionRegistry* registry() { return registry_; } 127 ExtensionRegistry* registry() { return registry_; }
123 const base::FilePath& extensions_install_dir() const { 128 const base::FilePath& extensions_install_dir() const {
124 return extensions_install_dir_; 129 return extensions_install_dir_;
125 } 130 }
126 const base::FilePath& data_dir() const { return data_dir_; } 131 const base::FilePath& data_dir() const { return data_dir_; }
127 const base::ScopedTempDir& temp_dir() const { return temp_dir_; } 132 const base::ScopedTempDir& temp_dir() const { return temp_dir_; }
128 133
129 private: 134 private:
130 // Must be declared before anything that may make use of the 135 // Must be declared before anything that may make use of the
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 chromeos::ScopedTestCrosSettings test_cros_settings_; 180 chromeos::ScopedTestCrosSettings test_cros_settings_;
176 chromeos::ScopedTestUserManager test_user_manager_; 181 chromeos::ScopedTestUserManager test_user_manager_;
177 #endif 182 #endif
178 183
179 DISALLOW_COPY_AND_ASSIGN(ExtensionServiceTestBase); 184 DISALLOW_COPY_AND_ASSIGN(ExtensionServiceTestBase);
180 }; 185 };
181 186
182 } // namespace extensions 187 } // namespace extensions
183 188
184 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_TEST_BASE_H_ 189 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SERVICE_TEST_BASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698