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

Side by Side Diff: chrome/test/testing_profile.h

Issue 3129007: FBTF: Forward declare everything possible in testing_profile.h (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: argh mac problems now Created 10 years, 4 months 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
« no previous file with comments | « chrome/browser/web_applications/web_app_unittest.cc ('k') | chrome/test/testing_profile.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_TEST_TESTING_PROFILE_H_ 5 #ifndef CHROME_TEST_TESTING_PROFILE_H_
6 #define CHROME_TEST_TESTING_PROFILE_H_ 6 #define CHROME_TEST_TESTING_PROFILE_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/base_paths.h"
10 #include "base/file_util.h"
11 #include "base/path_service.h"
12 #include "base/scoped_temp_dir.h" 9 #include "base/scoped_temp_dir.h"
13 #include "chrome/browser/autocomplete/autocomplete_classifier.h"
14 #include "chrome/browser/bookmarks/bookmark_model.h"
15 #include "chrome/browser/browser_prefs.h"
16 #include "chrome/browser/browser_theme_provider.h"
17 #include "chrome/browser/chrome_thread.h"
18 #include "chrome/browser/favicon_service.h"
19 #include "chrome/browser/find_bar_state.h"
20 #include "chrome/browser/geolocation/geolocation_content_settings_map.h"
21 #include "chrome/browser/geolocation/geolocation_permission_context.h"
22 #include "chrome/browser/host_content_settings_map.h"
23 #include "chrome/browser/history/history.h"
24 #include "chrome/browser/history/top_sites.h"
25 #include "chrome/browser/in_process_webkit/webkit_context.h"
26 #include "chrome/browser/notifications/desktop_notification_service.h"
27 #include "chrome/browser/pref_service.h"
28 #include "chrome/browser/pref_value_store.h"
29 #include "chrome/browser/profile.h" 10 #include "chrome/browser/profile.h"
30 #include "chrome/browser/search_engines/template_url_model.h"
31 #include "chrome/common/json_pref_store.h"
32 #include "chrome/common/net/url_request_context_getter.h"
33 #include "chrome/test/testing_pref_service.h"
34 #include "net/base/cookie_monster.h"
35 11
12 namespace history {
13 class TopSites;
14 }
15
16 namespace net {
17 class CookieMonster;
18 }
19
20 class AutocompleteClassifier;
21 class BookmarkModel;
22 class BrowserThemeProvider;
23 class DesktopNotificationService;
24 class FaviconService;
25 class FindBarState;
26 class GeolocationContentSettingsMap;
27 class GeolocationPermissionContext;
28 class HistoryService;
29 class HostContentSettingsMap;
30 class PrefService;
36 class ProfileSyncService; 31 class ProfileSyncService;
37 class SessionService; 32 class SessionService;
33 class TemplateURLModel;
34 class TestingPrefService;
35 class URLRequestContextGetter;
36 class WebKitContext;
38 37
39 class TestingProfile : public Profile { 38 class TestingProfile : public Profile {
40 public: 39 public:
41 TestingProfile(); 40 TestingProfile();
42 41
43 // Creates a new profile by adding |count| to the end of the path. Use this 42 // Creates a new profile by adding |count| to the end of the path. Use this
44 // when you need to have more than one TestingProfile running at the same 43 // when you need to have more than one TestingProfile running at the same
45 // time. 44 // time.
46 explicit TestingProfile(int count); 45 explicit TestingProfile(int count);
47 46
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 // CreateBookmarkModel. 87 // CreateBookmarkModel.
89 void BlockUntilBookmarkModelLoaded(); 88 void BlockUntilBookmarkModelLoaded();
90 89
91 // Creates a TemplateURLModel. If not invoked the TemplateURLModel is NULL. 90 // Creates a TemplateURLModel. If not invoked the TemplateURLModel is NULL.
92 void CreateTemplateURLModel(); 91 void CreateTemplateURLModel();
93 92
94 // Uses a specific theme provider for this profile. TestingProfile takes 93 // Uses a specific theme provider for this profile. TestingProfile takes
95 // ownership of |theme_provider|. 94 // ownership of |theme_provider|.
96 void UseThemeProvider(BrowserThemeProvider* theme_provider); 95 void UseThemeProvider(BrowserThemeProvider* theme_provider);
97 96
97 TestingPrefService* GetTestingPrefService();
98
98 virtual ProfileId GetRuntimeId() { 99 virtual ProfileId GetRuntimeId() {
99 return reinterpret_cast<ProfileId>(this); 100 return reinterpret_cast<ProfileId>(this);
100 } 101 }
101 102
102 virtual FilePath GetPath() { 103 virtual FilePath GetPath() {
103 return path_; 104 return path_;
104 } 105 }
105 // Sets whether we're off the record. Default is false. 106 // Sets whether we're off the record. Default is false.
106 void set_off_the_record(bool off_the_record) { 107 void set_off_the_record(bool off_the_record) {
107 off_the_record_ = off_the_record; 108 off_the_record_ = off_the_record;
(...skipping 28 matching lines...) Expand all
136 } 137 }
137 virtual HistoryService* GetHistoryServiceWithoutCreating() { 138 virtual HistoryService* GetHistoryServiceWithoutCreating() {
138 return history_service_.get(); 139 return history_service_.get();
139 } 140 }
140 void set_has_history_service(bool has_history_service) { 141 void set_has_history_service(bool has_history_service) {
141 has_history_service_ = has_history_service; 142 has_history_service_ = has_history_service;
142 } 143 }
143 // The CookieMonster will only be returned if a Context has been created. Do 144 // The CookieMonster will only be returned if a Context has been created. Do
144 // this by calling CreateRequestContext(). See the note at GetRequestContext 145 // this by calling CreateRequestContext(). See the note at GetRequestContext
145 // for more information. 146 // for more information.
146 net::CookieMonster* GetCookieMonster() { 147 net::CookieMonster* GetCookieMonster();
147 if (!GetRequestContext())
148 return NULL;
149 return GetRequestContext()->GetCookieStore()->GetCookieMonster();
150 }
151 virtual AutocompleteClassifier* GetAutocompleteClassifier() { 148 virtual AutocompleteClassifier* GetAutocompleteClassifier() {
152 return autocomplete_classifier_.get(); 149 return autocomplete_classifier_.get();
153 } 150 }
154 virtual WebDataService* GetWebDataService(ServiceAccessType access) { 151 virtual WebDataService* GetWebDataService(ServiceAccessType access) {
155 return web_data_service_.get(); 152 return web_data_service_.get();
156 } 153 }
157 virtual WebDataService* GetWebDataServiceWithoutCreating() { 154 virtual WebDataService* GetWebDataServiceWithoutCreating() {
158 return web_data_service_.get(); 155 return web_data_service_.get();
159 } 156 }
160 virtual PasswordStore* GetPasswordStore(ServiceAccessType access) { 157 virtual PasswordStore* GetPasswordStore(ServiceAccessType access) {
161 return NULL; 158 return NULL;
162 } 159 }
163 virtual TestingPrefService* GetPrefs() { 160 virtual PrefService* GetPrefs();
164 if (!prefs_.get()) {
165 prefs_.reset(new TestingPrefService());
166 Profile::RegisterUserPrefs(prefs_.get());
167 browser::RegisterAllPrefs(prefs_.get(), prefs_.get());
168 }
169 return prefs_.get();
170 }
171 virtual TemplateURLModel* GetTemplateURLModel() { 161 virtual TemplateURLModel* GetTemplateURLModel() {
172 return template_url_model_.get(); 162 return template_url_model_.get();
173 } 163 }
174 virtual TemplateURLFetcher* GetTemplateURLFetcher() { return NULL; } 164 virtual TemplateURLFetcher* GetTemplateURLFetcher() { return NULL; }
175 virtual history::TopSites* GetTopSites() { 165 virtual history::TopSites* GetTopSites();
176 if (!top_sites_.get()) {
177 top_sites_ = new history::TopSites(this);
178 if (!temp_dir_.CreateUniqueTempDir())
179 return NULL;
180 FilePath file_name = temp_dir_.path().AppendASCII("TopSites.db");
181 top_sites_->Init(file_name);
182 }
183 return top_sites_;
184 }
185 virtual DownloadManager* GetDownloadManager() { return NULL; } 166 virtual DownloadManager* GetDownloadManager() { return NULL; }
186 virtual PersonalDataManager* GetPersonalDataManager() { return NULL; } 167 virtual PersonalDataManager* GetPersonalDataManager() { return NULL; }
187 virtual bool HasCreatedDownloadManager() const { return false; } 168 virtual bool HasCreatedDownloadManager() const { return false; }
188 virtual void InitThemes(); 169 virtual void InitThemes();
189 virtual void SetTheme(Extension* extension) {} 170 virtual void SetTheme(Extension* extension) {}
190 virtual void SetNativeTheme() {} 171 virtual void SetNativeTheme() {}
191 virtual void ClearTheme() {} 172 virtual void ClearTheme() {}
192 virtual Extension* GetTheme() { return NULL; } 173 virtual Extension* GetTheme() { return NULL; }
193 virtual BrowserThemeProvider* GetThemeProvider() { 174 virtual BrowserThemeProvider* GetThemeProvider() {
194 InitThemes(); 175 InitThemes();
195 return theme_provider_.get(); 176 return theme_provider_.get();
196 } 177 }
197 178
198 // Returns a testing ContextGetter (if one has been created via 179 // Returns a testing ContextGetter (if one has been created via
199 // CreateRequestContext) or NULL. This is not done on-demand for two reasons: 180 // CreateRequestContext) or NULL. This is not done on-demand for two reasons:
200 // (1) Some tests depend on GetRequestContext() returning NULL. (2) Because 181 // (1) Some tests depend on GetRequestContext() returning NULL. (2) Because
201 // of the special memory management considerations for the 182 // of the special memory management considerations for the
202 // TestURLRequestContextGetter class, many tests would find themseleves 183 // TestURLRequestContextGetter class, many tests would find themseleves
203 // leaking if they called this method without the necessary IO thread. This 184 // leaking if they called this method without the necessary IO thread. This
204 // getter is currently only capable of returning a Context that helps test 185 // getter is currently only capable of returning a Context that helps test
205 // the CookieMonster. See implementation comments for more details. 186 // the CookieMonster. See implementation comments for more details.
206 virtual URLRequestContextGetter* GetRequestContext(); 187 virtual URLRequestContextGetter* GetRequestContext();
207 void CreateRequestContext(); 188 void CreateRequestContext();
208 189
209 virtual URLRequestContextGetter* GetRequestContextForMedia() { return NULL; } 190 virtual URLRequestContextGetter* GetRequestContextForMedia() { return NULL; }
210 virtual URLRequestContextGetter* GetRequestContextForExtensions(); 191 virtual URLRequestContextGetter* GetRequestContextForExtensions();
211 192
212 virtual net::SSLConfigService* GetSSLConfigService() { return NULL; } 193 virtual net::SSLConfigService* GetSSLConfigService() { return NULL; }
213 virtual UserStyleSheetWatcher* GetUserStyleSheetWatcher() { return NULL; } 194 virtual UserStyleSheetWatcher* GetUserStyleSheetWatcher() { return NULL; }
214 virtual FindBarState* GetFindBarState() { 195 virtual FindBarState* GetFindBarState();
215 if (!find_bar_state_.get()) 196 virtual HostContentSettingsMap* GetHostContentSettingsMap();
216 find_bar_state_.reset(new FindBarState()); 197 virtual GeolocationContentSettingsMap* GetGeolocationContentSettingsMap();
217 return find_bar_state_.get(); 198 virtual GeolocationPermissionContext* GetGeolocationPermissionContext();
218 }
219 virtual HostContentSettingsMap* GetHostContentSettingsMap() {
220 if (!host_content_settings_map_.get())
221 host_content_settings_map_ = new HostContentSettingsMap(this);
222 return host_content_settings_map_.get();
223 }
224 virtual GeolocationContentSettingsMap* GetGeolocationContentSettingsMap() {
225 if (!geolocation_content_settings_map_.get()) {
226 geolocation_content_settings_map_ =
227 new GeolocationContentSettingsMap(this);
228 }
229 return geolocation_content_settings_map_.get();
230 }
231 virtual GeolocationPermissionContext* GetGeolocationPermissionContext() {
232 if (!geolocation_permission_context_.get()) {
233 geolocation_permission_context_ =
234 new GeolocationPermissionContext(this);
235 }
236 return geolocation_permission_context_.get();
237 }
238 virtual HostZoomMap* GetHostZoomMap() { return NULL; } 199 virtual HostZoomMap* GetHostZoomMap() { return NULL; }
239 void set_session_service(SessionService* session_service); 200 void set_session_service(SessionService* session_service);
240 virtual SessionService* GetSessionService() { return session_service_.get(); } 201 virtual SessionService* GetSessionService() { return session_service_.get(); }
241 virtual void ShutdownSessionService() {} 202 virtual void ShutdownSessionService() {}
242 virtual bool HasSessionService() const { 203 virtual bool HasSessionService() const {
243 return (session_service_.get() != NULL); 204 return (session_service_.get() != NULL);
244 } 205 }
245 virtual std::wstring GetName() { return std::wstring(); } 206 virtual std::wstring GetName() { return std::wstring(); }
246 virtual void SetName(const std::wstring& name) {} 207 virtual void SetName(const std::wstring& name) {}
247 virtual std::wstring GetID() { return id_; } 208 virtual std::wstring GetID() { return id_; }
(...skipping 10 matching lines...) Expand all
258 virtual void MergeResourceBoolean(int message_id, bool* output_value) {} 219 virtual void MergeResourceBoolean(int message_id, bool* output_value) {}
259 virtual BookmarkModel* GetBookmarkModel() { 220 virtual BookmarkModel* GetBookmarkModel() {
260 return bookmark_bar_model_.get(); 221 return bookmark_bar_model_.get();
261 } 222 }
262 virtual bool IsSameProfile(Profile *p) { return this == p; } 223 virtual bool IsSameProfile(Profile *p) { return this == p; }
263 virtual base::Time GetStartTime() const { return start_time_; } 224 virtual base::Time GetStartTime() const { return start_time_; }
264 virtual TabRestoreService* GetTabRestoreService() { return NULL; } 225 virtual TabRestoreService* GetTabRestoreService() { return NULL; }
265 virtual void ResetTabRestoreService() {} 226 virtual void ResetTabRestoreService() {}
266 virtual SpellCheckHost* GetSpellCheckHost() { return NULL; } 227 virtual SpellCheckHost* GetSpellCheckHost() { return NULL; }
267 virtual void ReinitializeSpellCheckHost(bool force) { } 228 virtual void ReinitializeSpellCheckHost(bool force) { }
268 virtual WebKitContext* GetWebKitContext() { 229 virtual WebKitContext* GetWebKitContext();
269 if (webkit_context_ == NULL)
270 webkit_context_ = new WebKitContext(this);
271 return webkit_context_;
272 }
273 virtual WebKitContext* GetOffTheRecordWebKitContext() { return NULL; } 230 virtual WebKitContext* GetOffTheRecordWebKitContext() { return NULL; }
274 virtual void MarkAsCleanShutdown() {} 231 virtual void MarkAsCleanShutdown() {}
275 virtual void InitExtensions() {} 232 virtual void InitExtensions() {}
276 virtual void InitWebResources() {} 233 virtual void InitWebResources() {}
277 virtual NTPResourceCache* GetNTPResourceCache(); 234 virtual NTPResourceCache* GetNTPResourceCache();
278 virtual DesktopNotificationService* GetDesktopNotificationService() { 235 virtual DesktopNotificationService* GetDesktopNotificationService();
279 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
280 if (!desktop_notification_service_.get()) {
281 desktop_notification_service_.reset(new DesktopNotificationService(
282 this, NULL));
283 }
284 return desktop_notification_service_.get();
285 }
286 virtual BackgroundContentsService* GetBackgroundContentsService() { 236 virtual BackgroundContentsService* GetBackgroundContentsService() {
287 return NULL; 237 return NULL;
288 } 238 }
289 virtual FilePath last_selected_directory() { 239 virtual FilePath last_selected_directory() {
290 return last_selected_directory_; 240 return last_selected_directory_;
291 } 241 }
292 virtual void set_last_selected_directory(const FilePath& path) { 242 virtual void set_last_selected_directory(const FilePath& path) {
293 last_selected_directory_ = path; 243 last_selected_directory_ = path;
294 } 244 }
295 245
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 354
405 virtual ProfileId GetRuntimeId() { 355 virtual ProfileId GetRuntimeId() {
406 return original_profile_->GetRuntimeId(); 356 return original_profile_->GetRuntimeId();
407 } 357 }
408 358
409 protected: 359 protected:
410 Profile* original_profile_; 360 Profile* original_profile_;
411 }; 361 };
412 362
413 #endif // CHROME_TEST_TESTING_PROFILE_H_ 363 #endif // CHROME_TEST_TESTING_PROFILE_H_
OLDNEW
« no previous file with comments | « chrome/browser/web_applications/web_app_unittest.cc ('k') | chrome/test/testing_profile.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698