OLD | NEW |
1 // Copyright (c) 2009-2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009-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 | 7 |
8 #include "base/base_paths.h" | 8 #include "base/base_paths.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 // Creates the BookmkarBarModel. If not invoked the bookmark bar model is | 43 // Creates the BookmkarBarModel. If not invoked the bookmark bar model is |
44 // NULL. If |delete_file| is true, the bookmarks file is deleted first, then | 44 // NULL. If |delete_file| is true, the bookmarks file is deleted first, then |
45 // the model is created. As TestingProfile deletes the directory containing | 45 // the model is created. As TestingProfile deletes the directory containing |
46 // the files used by HistoryService, the boolean only matters if you're | 46 // the files used by HistoryService, the boolean only matters if you're |
47 // recreating the BookmarkModel. | 47 // recreating the BookmarkModel. |
48 // | 48 // |
49 // NOTE: this does not block until the bookmarks are loaded. For that use | 49 // NOTE: this does not block until the bookmarks are loaded. For that use |
50 // BlockUntilBookmarkModelLoaded. | 50 // BlockUntilBookmarkModelLoaded. |
51 void CreateBookmarkModel(bool delete_file); | 51 void CreateBookmarkModel(bool delete_file); |
52 | 52 |
| 53 // Creates the webdata service. If |delete_file| is true, the webdata file is |
| 54 // deleted first, then the WebDataService is created. As TestingProfile |
| 55 // deletes the directory containing the files used by WebDataService, this |
| 56 // only matters if you're recreating the WebDataService. |
| 57 void CreateWebDataService(bool delete_file); |
| 58 |
| 59 // Destroys |
| 60 |
53 // Blocks until the BookmarkModel finishes loaded. This is NOT invoked from | 61 // Blocks until the BookmarkModel finishes loaded. This is NOT invoked from |
54 // CreateBookmarkModel. | 62 // CreateBookmarkModel. |
55 void BlockUntilBookmarkModelLoaded(); | 63 void BlockUntilBookmarkModelLoaded(); |
56 | 64 |
57 // Creates a TemplateURLModel. If not invoked the TemplateURLModel is NULL. | 65 // Creates a TemplateURLModel. If not invoked the TemplateURLModel is NULL. |
58 void CreateTemplateURLModel(); | 66 void CreateTemplateURLModel(); |
59 | 67 |
60 // Uses a specific theme provider for this profile. TestingProfile takes | 68 // Uses a specific theme provider for this profile. TestingProfile takes |
61 // ownership of |theme_provider|. | 69 // ownership of |theme_provider|. |
62 void UseThemeProvider(BrowserThemeProvider* theme_provider); | 70 void UseThemeProvider(BrowserThemeProvider* theme_provider); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 // for more information. | 116 // for more information. |
109 net::CookieMonster* GetCookieMonster() { | 117 net::CookieMonster* GetCookieMonster() { |
110 if (!GetRequestContext()) | 118 if (!GetRequestContext()) |
111 return NULL; | 119 return NULL; |
112 return GetRequestContext()->GetCookieStore()->GetCookieMonster(); | 120 return GetRequestContext()->GetCookieStore()->GetCookieMonster(); |
113 } | 121 } |
114 virtual SearchVersusNavigateClassifier* GetSearchVersusNavigateClassifier() { | 122 virtual SearchVersusNavigateClassifier* GetSearchVersusNavigateClassifier() { |
115 return NULL; | 123 return NULL; |
116 } | 124 } |
117 virtual WebDataService* GetWebDataService(ServiceAccessType access) { | 125 virtual WebDataService* GetWebDataService(ServiceAccessType access) { |
118 return NULL; | 126 return web_data_service_.get(); |
119 } | 127 } |
120 virtual WebDataService* GetWebDataServiceWithoutCreating() { | 128 virtual WebDataService* GetWebDataServiceWithoutCreating() { |
121 return NULL; | 129 return web_data_service_.get(); |
122 } | 130 } |
123 virtual PasswordStore* GetPasswordStore(ServiceAccessType access) { | 131 virtual PasswordStore* GetPasswordStore(ServiceAccessType access) { |
124 return NULL; | 132 return NULL; |
125 } | 133 } |
126 virtual PrefService* GetPrefs() { | 134 virtual PrefService* GetPrefs() { |
127 if (!prefs_.get()) { | 135 if (!prefs_.get()) { |
128 FilePath prefs_filename = | 136 FilePath prefs_filename = |
129 path_.Append(FILE_PATH_LITERAL("TestPreferences")); | 137 path_.Append(FILE_PATH_LITERAL("TestPreferences")); |
130 prefs_.reset(new PrefService(prefs_filename)); | 138 prefs_.reset(new PrefService(prefs_filename)); |
131 Profile::RegisterUserPrefs(prefs_.get()); | 139 Profile::RegisterUserPrefs(prefs_.get()); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 // to this. | 237 // to this. |
230 FilePath path_; | 238 FilePath path_; |
231 base::Time start_time_; | 239 base::Time start_time_; |
232 scoped_ptr<PrefService> prefs_; | 240 scoped_ptr<PrefService> prefs_; |
233 | 241 |
234 private: | 242 private: |
235 // If the history service has been created, it is destroyed. This is invoked | 243 // If the history service has been created, it is destroyed. This is invoked |
236 // from the destructor. | 244 // from the destructor. |
237 void DestroyHistoryService(); | 245 void DestroyHistoryService(); |
238 | 246 |
| 247 // If the webdata service has been created, it is destroyed. This is invoked |
| 248 // from the destructor. |
| 249 void DestroyWebDataService(); |
| 250 |
239 // The history service. Only created if CreateHistoryService is invoked. | 251 // The history service. Only created if CreateHistoryService is invoked. |
240 scoped_refptr<HistoryService> history_service_; | 252 scoped_refptr<HistoryService> history_service_; |
241 | 253 |
242 // The BookmarkModel. Only created if CreateBookmarkModel is invoked. | 254 // The BookmarkModel. Only created if CreateBookmarkModel is invoked. |
243 scoped_ptr<BookmarkModel> bookmark_bar_model_; | 255 scoped_ptr<BookmarkModel> bookmark_bar_model_; |
244 | 256 |
245 // The ProfileSyncService. Created by CreateProfileSyncService. | 257 // The ProfileSyncService. Created by CreateProfileSyncService. |
246 scoped_ptr<ProfileSyncService> profile_sync_service_; | 258 scoped_ptr<ProfileSyncService> profile_sync_service_; |
247 | 259 |
| 260 // The WebDataService. Only created if CreateWebDataService is invoked. |
| 261 scoped_refptr<WebDataService> web_data_service_; |
| 262 |
248 // The TemplateURLFetcher. Only created if CreateTemplateURLModel is invoked. | 263 // The TemplateURLFetcher. Only created if CreateTemplateURLModel is invoked. |
249 scoped_ptr<TemplateURLModel> template_url_model_; | 264 scoped_ptr<TemplateURLModel> template_url_model_; |
250 | 265 |
251 scoped_ptr<NTPResourceCache> ntp_resource_cache_; | 266 scoped_ptr<NTPResourceCache> ntp_resource_cache_; |
252 | 267 |
253 // The SessionService. Defaults to NULL, but can be set using the setter. | 268 // The SessionService. Defaults to NULL, but can be set using the setter. |
254 scoped_refptr<SessionService> session_service_; | 269 scoped_refptr<SessionService> session_service_; |
255 | 270 |
256 // The theme provider. Created lazily by GetThemeProvider()/InitThemes(). | 271 // The theme provider. Created lazily by GetThemeProvider()/InitThemes(). |
257 scoped_ptr<BrowserThemeProvider> theme_provider_; | 272 scoped_ptr<BrowserThemeProvider> theme_provider_; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 | 305 |
291 virtual ProfileId GetRuntimeId() { | 306 virtual ProfileId GetRuntimeId() { |
292 return original_profile_->GetRuntimeId(); | 307 return original_profile_->GetRuntimeId(); |
293 } | 308 } |
294 | 309 |
295 protected: | 310 protected: |
296 Profile* original_profile_; | 311 Profile* original_profile_; |
297 }; | 312 }; |
298 | 313 |
299 #endif // CHROME_TEST_TESTING_PROFILE_H_ | 314 #endif // CHROME_TEST_TESTING_PROFILE_H_ |
OLD | NEW |