OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_BASE_TESTING_PROFILE_H_ | 5 #ifndef CHROME_TEST_BASE_TESTING_PROFILE_H_ |
6 #define CHROME_TEST_BASE_TESTING_PROFILE_H_ | 6 #define CHROME_TEST_BASE_TESTING_PROFILE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 | 52 |
53 class TestingProfile : public Profile { | 53 class TestingProfile : public Profile { |
54 public: | 54 public: |
55 // Default constructor that cannot be used with multi-profiles. | 55 // Default constructor that cannot be used with multi-profiles. |
56 TestingProfile(); | 56 TestingProfile(); |
57 | 57 |
58 // Multi-profile aware constructor that takes the path to a directory managed | 58 // Multi-profile aware constructor that takes the path to a directory managed |
59 // for this profile. This constructor is meant to be used by | 59 // for this profile. This constructor is meant to be used by |
60 // TestingProfileManager::CreateTestingProfile. If you need to create multi- | 60 // TestingProfileManager::CreateTestingProfile. If you need to create multi- |
61 // profile profiles, use that factory method instead of this directly. | 61 // profile profiles, use that factory method instead of this directly. |
| 62 // Exception: if you need to create multi-profile profiles for testing the |
| 63 // ProfileManager, then use the constructor below instead. |
62 explicit TestingProfile(const FilePath& path); | 64 explicit TestingProfile(const FilePath& path); |
63 | 65 |
| 66 // Multi-profile aware constructor that takes the path to a directory managed |
| 67 // for this profile and a delegate. This constructor is meant to be used |
| 68 // for unittesting the ProfileManager. |
| 69 TestingProfile(const FilePath& path, Delegate* delegate); |
| 70 |
64 virtual ~TestingProfile(); | 71 virtual ~TestingProfile(); |
65 | 72 |
66 // Creates the favicon service. Consequent calls would recreate the service. | 73 // Creates the favicon service. Consequent calls would recreate the service. |
67 void CreateFaviconService(); | 74 void CreateFaviconService(); |
68 | 75 |
69 // Creates the history service. If |delete_file| is true, the history file is | 76 // Creates the history service. If |delete_file| is true, the history file is |
70 // deleted first, then the HistoryService is created. As TestingProfile | 77 // deleted first, then the HistoryService is created. As TestingProfile |
71 // deletes the directory containing the files used by HistoryService, this | 78 // deletes the directory containing the files used by HistoryService, this |
72 // only matters if you're recreating the HistoryService. If |no_db| is true, | 79 // only matters if you're recreating the HistoryService. If |no_db| is true, |
73 // the history backend will fail to initialize its database; this is useful | 80 // the history backend will fail to initialize its database; this is useful |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 virtual SpeechInputPreferences* GetSpeechInputPreferences(); | 228 virtual SpeechInputPreferences* GetSpeechInputPreferences(); |
222 virtual HostZoomMap* GetHostZoomMap(); | 229 virtual HostZoomMap* GetHostZoomMap(); |
223 virtual bool HasProfileSyncService() const; | 230 virtual bool HasProfileSyncService() const; |
224 virtual std::wstring GetName(); | 231 virtual std::wstring GetName(); |
225 virtual void SetName(const std::wstring& name) {} | 232 virtual void SetName(const std::wstring& name) {} |
226 virtual std::wstring GetID(); | 233 virtual std::wstring GetID(); |
227 virtual void SetID(const std::wstring& id); | 234 virtual void SetID(const std::wstring& id); |
228 void set_last_session_exited_cleanly(bool value) { | 235 void set_last_session_exited_cleanly(bool value) { |
229 last_session_exited_cleanly_ = value; | 236 last_session_exited_cleanly_ = value; |
230 } | 237 } |
| 238 void set_enable_lazy_service_initialization(bool value) { |
| 239 enable_lazy_service_initialization_ = value; |
| 240 } |
231 virtual bool DidLastSessionExitCleanly(); | 241 virtual bool DidLastSessionExitCleanly(); |
232 virtual void MergeResourceString(int message_id, | 242 virtual void MergeResourceString(int message_id, |
233 std::wstring* output_string) {} | 243 std::wstring* output_string) {} |
234 virtual void MergeResourceInteger(int message_id, int* output_value) {} | 244 virtual void MergeResourceInteger(int message_id, int* output_value) {} |
235 virtual void MergeResourceBoolean(int message_id, bool* output_value) {} | 245 virtual void MergeResourceBoolean(int message_id, bool* output_value) {} |
236 virtual BookmarkModel* GetBookmarkModel(); | 246 virtual BookmarkModel* GetBookmarkModel(); |
237 virtual bool IsSameProfile(Profile *p); | 247 virtual bool IsSameProfile(Profile *p); |
238 virtual base::Time GetStartTime() const; | 248 virtual base::Time GetStartTime() const; |
239 virtual ProtocolHandlerRegistry* GetProtocolHandlerRegistry(); | 249 virtual ProtocolHandlerRegistry* GetProtocolHandlerRegistry(); |
240 virtual SpellCheckHost* GetSpellCheckHost(); | 250 virtual SpellCheckHost* GetSpellCheckHost(); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 protected: | 300 protected: |
291 base::Time start_time_; | 301 base::Time start_time_; |
292 scoped_ptr<PrefService> prefs_; | 302 scoped_ptr<PrefService> prefs_; |
293 // ref only for right type, lifecycle is managed by prefs_ | 303 // ref only for right type, lifecycle is managed by prefs_ |
294 TestingPrefService* testing_prefs_; | 304 TestingPrefService* testing_prefs_; |
295 | 305 |
296 private: | 306 private: |
297 // Common initialization between the two constructors. | 307 // Common initialization between the two constructors. |
298 void Init(); | 308 void Init(); |
299 | 309 |
| 310 // Finishes initialization when a profile is created asynchronously. |
| 311 void FinishInit(); |
| 312 |
300 // Destroys favicon service if it has been created. | 313 // Destroys favicon service if it has been created. |
301 void DestroyFaviconService(); | 314 void DestroyFaviconService(); |
302 | 315 |
303 // If the webdata service has been created, it is destroyed. This is invoked | 316 // If the webdata service has been created, it is destroyed. This is invoked |
304 // from the destructor. | 317 // from the destructor. |
305 void DestroyWebDataService(); | 318 void DestroyWebDataService(); |
306 | 319 |
307 // Creates a TestingPrefService and associates it with the TestingProfile. | 320 // Creates a TestingPrefService and associates it with the TestingProfile. |
308 void CreateTestingPrefService(); | 321 void CreateTestingPrefService(); |
309 | 322 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 scoped_refptr<net::URLRequestContextGetter> extensions_request_context_; | 356 scoped_refptr<net::URLRequestContextGetter> extensions_request_context_; |
344 | 357 |
345 std::wstring id_; | 358 std::wstring id_; |
346 | 359 |
347 bool incognito_; | 360 bool incognito_; |
348 scoped_ptr<Profile> incognito_profile_; | 361 scoped_ptr<Profile> incognito_profile_; |
349 | 362 |
350 // Did the last session exit cleanly? Default is true. | 363 // Did the last session exit cleanly? Default is true. |
351 bool last_session_exited_cleanly_; | 364 bool last_session_exited_cleanly_; |
352 | 365 |
| 366 // Do we create services if they do not exist? Default is false. |
| 367 bool enable_lazy_service_initialization_; |
| 368 |
353 // FileSystemContext. Created lazily by GetFileSystemContext(). | 369 // FileSystemContext. Created lazily by GetFileSystemContext(). |
354 scoped_refptr<fileapi::FileSystemContext> file_system_context_; | 370 scoped_refptr<fileapi::FileSystemContext> file_system_context_; |
355 | 371 |
356 // WebKitContext, lazily initialized by GetWebKitContext(). | 372 // WebKitContext, lazily initialized by GetWebKitContext(). |
357 scoped_refptr<WebKitContext> webkit_context_; | 373 scoped_refptr<WebKitContext> webkit_context_; |
358 | 374 |
359 // The main database tracker for this profile. | 375 // The main database tracker for this profile. |
360 // Should be used only on the file thread. | 376 // Should be used only on the file thread. |
361 scoped_refptr<webkit_database::DatabaseTracker> db_tracker_; | 377 scoped_refptr<webkit_database::DatabaseTracker> db_tracker_; |
362 | 378 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 | 415 |
400 // We keep a weak pointer to the dependency manager we want to notify on our | 416 // We keep a weak pointer to the dependency manager we want to notify on our |
401 // death. Defaults to the Singleton implementation but overridable for | 417 // death. Defaults to the Singleton implementation but overridable for |
402 // testing. | 418 // testing. |
403 ProfileDependencyManager* profile_dependency_manager_; | 419 ProfileDependencyManager* profile_dependency_manager_; |
404 | 420 |
405 scoped_refptr<ChromeAppCacheService> appcache_service_; | 421 scoped_refptr<ChromeAppCacheService> appcache_service_; |
406 | 422 |
407 // The QuotaManager, only available if set explicitly via SetQuotaManager. | 423 // The QuotaManager, only available if set explicitly via SetQuotaManager. |
408 scoped_refptr<quota::QuotaManager> quota_manager_; | 424 scoped_refptr<quota::QuotaManager> quota_manager_; |
| 425 |
| 426 // Weak pointer to a delegate for indicating that a profile was created. |
| 427 Delegate* delegate_; |
409 }; | 428 }; |
410 | 429 |
411 #endif // CHROME_TEST_BASE_TESTING_PROFILE_H_ | 430 #endif // CHROME_TEST_BASE_TESTING_PROFILE_H_ |
OLD | NEW |