| OLD | NEW |
| 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/ref_counted.h" | 9 #include "base/ref_counted.h" |
| 10 #include "base/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
| 11 #include "base/scoped_temp_dir.h" | 11 #include "base/scoped_temp_dir.h" |
| 12 #include "base/timer.h" | 12 #include "base/timer.h" |
| 13 #include "chrome/browser/profile.h" | 13 #include "chrome/browser/profile.h" |
| 14 | 14 |
| 15 namespace history { | 15 namespace history { |
| 16 class TopSites; | 16 class TopSites; |
| 17 } | 17 } |
| 18 | 18 |
| 19 namespace net { | 19 namespace net { |
| 20 class CookieMonster; | 20 class CookieMonster; |
| 21 } | 21 } |
| 22 | 22 |
| 23 class AutocompleteClassifier; | 23 class AutocompleteClassifier; |
| 24 class BookmarkModel; | 24 class BookmarkModel; |
| 25 class BrowserThemeProvider; | 25 class BrowserThemeProvider; |
| 26 class CommandLine; |
| 26 class DesktopNotificationService; | 27 class DesktopNotificationService; |
| 27 class FaviconService; | 28 class FaviconService; |
| 28 class FindBarState; | 29 class FindBarState; |
| 29 class GeolocationContentSettingsMap; | 30 class GeolocationContentSettingsMap; |
| 30 class GeolocationPermissionContext; | 31 class GeolocationPermissionContext; |
| 31 class HistoryService; | 32 class HistoryService; |
| 32 class HostContentSettingsMap; | 33 class HostContentSettingsMap; |
| 33 class PrefService; | 34 class PrefService; |
| 34 class ProfileSyncService; | 35 class ProfileSyncService; |
| 35 class SessionService; | 36 class SessionService; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 // CreateBookmarkModel. | 80 // CreateBookmarkModel. |
| 80 void BlockUntilBookmarkModelLoaded(); | 81 void BlockUntilBookmarkModelLoaded(); |
| 81 | 82 |
| 82 // Creates a TemplateURLModel. If not invoked the TemplateURLModel is NULL. | 83 // Creates a TemplateURLModel. If not invoked the TemplateURLModel is NULL. |
| 83 void CreateTemplateURLModel(); | 84 void CreateTemplateURLModel(); |
| 84 | 85 |
| 85 // Uses a specific theme provider for this profile. TestingProfile takes | 86 // Uses a specific theme provider for this profile. TestingProfile takes |
| 86 // ownership of |theme_provider|. | 87 // ownership of |theme_provider|. |
| 87 void UseThemeProvider(BrowserThemeProvider* theme_provider); | 88 void UseThemeProvider(BrowserThemeProvider* theme_provider); |
| 88 | 89 |
| 90 // Creates an ExtensionsService initialized with the testing profile and |
| 91 // returns it. The profile keeps its own copy of a scoped_refptr to the |
| 92 // ExtensionsService to make sure that is still alive to be notified when the |
| 93 // profile is destroyed. |
| 94 scoped_refptr<ExtensionsService> CreateExtensionsService( |
| 95 const CommandLine* command_line, |
| 96 const FilePath& install_directory); |
| 97 |
| 89 TestingPrefService* GetTestingPrefService(); | 98 TestingPrefService* GetTestingPrefService(); |
| 90 | 99 |
| 91 virtual ProfileId GetRuntimeId() { | 100 virtual ProfileId GetRuntimeId() { |
| 92 return reinterpret_cast<ProfileId>(this); | 101 return reinterpret_cast<ProfileId>(this); |
| 93 } | 102 } |
| 94 | 103 |
| 95 virtual FilePath GetPath(); | 104 virtual FilePath GetPath(); |
| 96 | 105 |
| 97 // Sets whether we're off the record. Default is false. | 106 // Sets whether we're off the record. Default is false. |
| 98 void set_off_the_record(bool off_the_record) { | 107 void set_off_the_record(bool off_the_record) { |
| 99 off_the_record_ = off_the_record; | 108 off_the_record_ = off_the_record; |
| 100 } | 109 } |
| 101 virtual bool IsOffTheRecord() { return off_the_record_; } | 110 virtual bool IsOffTheRecord() { return off_the_record_; } |
| 102 virtual Profile* GetOffTheRecordProfile() { return NULL; } | 111 virtual Profile* GetOffTheRecordProfile() { return NULL; } |
| 103 | 112 |
| 104 virtual void DestroyOffTheRecordProfile() {} | 113 virtual void DestroyOffTheRecordProfile() {} |
| 105 | 114 |
| 106 virtual bool HasOffTheRecordProfile() { return false; } | 115 virtual bool HasOffTheRecordProfile() { return false; } |
| 107 | 116 |
| 108 virtual Profile* GetOriginalProfile() { return this; } | 117 virtual Profile* GetOriginalProfile() { return this; } |
| 109 virtual ChromeAppCacheService* GetAppCacheService() { return NULL; } | 118 virtual ChromeAppCacheService* GetAppCacheService() { return NULL; } |
| 110 virtual webkit_database::DatabaseTracker* GetDatabaseTracker(); | 119 virtual webkit_database::DatabaseTracker* GetDatabaseTracker(); |
| 111 virtual VisitedLinkMaster* GetVisitedLinkMaster() { return NULL; } | 120 virtual VisitedLinkMaster* GetVisitedLinkMaster() { return NULL; } |
| 112 virtual ExtensionsService* GetExtensionsService() { return NULL; } | 121 virtual ExtensionsService* GetExtensionsService(); |
| 113 virtual UserScriptMaster* GetUserScriptMaster() { return NULL; } | 122 virtual UserScriptMaster* GetUserScriptMaster() { return NULL; } |
| 114 virtual ExtensionDevToolsManager* GetExtensionDevToolsManager() { | 123 virtual ExtensionDevToolsManager* GetExtensionDevToolsManager() { |
| 115 return NULL; | 124 return NULL; |
| 116 } | 125 } |
| 117 virtual ExtensionProcessManager* GetExtensionProcessManager() { return NULL; } | 126 virtual ExtensionProcessManager* GetExtensionProcessManager() { return NULL; } |
| 118 virtual ExtensionMessageService* GetExtensionMessageService() { return NULL; } | 127 virtual ExtensionMessageService* GetExtensionMessageService() { return NULL; } |
| 119 virtual SSLHostState* GetSSLHostState() { return NULL; } | 128 virtual SSLHostState* GetSSLHostState() { return NULL; } |
| 120 virtual net::TransportSecurityState* GetTransportSecurityState() { | 129 virtual net::TransportSecurityState* GetTransportSecurityState() { |
| 121 return NULL; | 130 return NULL; |
| 122 } | 131 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 141 } | 150 } |
| 142 virtual WebDataService* GetWebDataService(ServiceAccessType access) { | 151 virtual WebDataService* GetWebDataService(ServiceAccessType access) { |
| 143 return web_data_service_.get(); | 152 return web_data_service_.get(); |
| 144 } | 153 } |
| 145 virtual WebDataService* GetWebDataServiceWithoutCreating() { | 154 virtual WebDataService* GetWebDataServiceWithoutCreating() { |
| 146 return web_data_service_.get(); | 155 return web_data_service_.get(); |
| 147 } | 156 } |
| 148 virtual PasswordStore* GetPasswordStore(ServiceAccessType access) { | 157 virtual PasswordStore* GetPasswordStore(ServiceAccessType access) { |
| 149 return NULL; | 158 return NULL; |
| 150 } | 159 } |
| 160 // Initialized the profile's PrefService with an explicity specified |
| 161 // PrefService. Must be called before the TestingProfile. |
| 162 // The profile takes ownership of |pref|. |
| 163 void SetPrefService(PrefService* prefs); |
| 151 virtual PrefService* GetPrefs(); | 164 virtual PrefService* GetPrefs(); |
| 152 virtual TemplateURLModel* GetTemplateURLModel() { | 165 virtual TemplateURLModel* GetTemplateURLModel() { |
| 153 return template_url_model_.get(); | 166 return template_url_model_.get(); |
| 154 } | 167 } |
| 155 virtual TemplateURLFetcher* GetTemplateURLFetcher() { return NULL; } | 168 virtual TemplateURLFetcher* GetTemplateURLFetcher() { return NULL; } |
| 156 virtual history::TopSites* GetTopSites(); | 169 virtual history::TopSites* GetTopSites(); |
| 157 virtual DownloadManager* GetDownloadManager() { return NULL; } | 170 virtual DownloadManager* GetDownloadManager() { return NULL; } |
| 158 virtual PersonalDataManager* GetPersonalDataManager() { return NULL; } | 171 virtual PersonalDataManager* GetPersonalDataManager() { return NULL; } |
| 159 virtual FileSystemHostContext* GetFileSystemHostContext() { return NULL; } | 172 virtual FileSystemHostContext* GetFileSystemHostContext() { return NULL; } |
| 160 virtual bool HasCreatedDownloadManager() const { return false; } | 173 virtual bool HasCreatedDownloadManager() const { return false; } |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 virtual ProfileSyncService* GetProfileSyncService( | 269 virtual ProfileSyncService* GetProfileSyncService( |
| 257 const std::string& cros_notes); | 270 const std::string& cros_notes); |
| 258 virtual CloudPrintProxyService* GetCloudPrintProxyService() { return NULL; } | 271 virtual CloudPrintProxyService* GetCloudPrintProxyService() { return NULL; } |
| 259 | 272 |
| 260 virtual ChromeBlobStorageContext* GetBlobStorageContext() { | 273 virtual ChromeBlobStorageContext* GetBlobStorageContext() { |
| 261 return NULL; | 274 return NULL; |
| 262 } | 275 } |
| 263 | 276 |
| 264 protected: | 277 protected: |
| 265 base::Time start_time_; | 278 base::Time start_time_; |
| 266 scoped_ptr<TestingPrefService> prefs_; | 279 scoped_ptr<PrefService> prefs_; |
| 280 // ref only for right type, lifecycle is managed by prefs_ |
| 281 TestingPrefService* testing_prefs_; |
| 267 | 282 |
| 268 private: | 283 private: |
| 269 // Destroys favicon service if it has been created. | 284 // Destroys favicon service if it has been created. |
| 270 void DestroyFaviconService(); | 285 void DestroyFaviconService(); |
| 271 | 286 |
| 272 // If the history service has been created, it is destroyed. This is invoked | 287 // If the history service has been created, it is destroyed. This is invoked |
| 273 // from the destructor. | 288 // from the destructor. |
| 274 void DestroyHistoryService(); | 289 void DestroyHistoryService(); |
| 275 | 290 |
| 276 // If the webdata service has been created, it is destroyed. This is invoked | 291 // If the webdata service has been created, it is destroyed. This is invoked |
| 277 // from the destructor. | 292 // from the destructor. |
| 278 void DestroyWebDataService(); | 293 void DestroyWebDataService(); |
| 279 | 294 |
| 295 // Creates a TestingPrefService and associates it with the TestingProfile |
| 296 void CreateTestingPrefService(); |
| 297 |
| 280 // The favicon service. Only created if CreateFaviconService is invoked. | 298 // The favicon service. Only created if CreateFaviconService is invoked. |
| 281 scoped_refptr<FaviconService> favicon_service_; | 299 scoped_refptr<FaviconService> favicon_service_; |
| 282 | 300 |
| 283 // The history service. Only created if CreateHistoryService is invoked. | 301 // The history service. Only created if CreateHistoryService is invoked. |
| 284 scoped_refptr<HistoryService> history_service_; | 302 scoped_refptr<HistoryService> history_service_; |
| 285 | 303 |
| 286 // The BookmarkModel. Only created if CreateBookmarkModel is invoked. | 304 // The BookmarkModel. Only created if CreateBookmarkModel is invoked. |
| 287 scoped_ptr<BookmarkModel> bookmark_bar_model_; | 305 scoped_ptr<BookmarkModel> bookmark_bar_model_; |
| 288 | 306 |
| 289 // The TokenService. Created by CreateTokenService. Filled with dummy data. | 307 // The TokenService. Created by CreateTokenService. Filled with dummy data. |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 geolocation_content_settings_map_; | 357 geolocation_content_settings_map_; |
| 340 scoped_refptr<GeolocationPermissionContext> geolocation_permission_context_; | 358 scoped_refptr<GeolocationPermissionContext> geolocation_permission_context_; |
| 341 scoped_ptr<DesktopNotificationService> desktop_notification_service_; | 359 scoped_ptr<DesktopNotificationService> desktop_notification_service_; |
| 342 | 360 |
| 343 // Find bar state. Created lazily by GetFindBarState(). | 361 // Find bar state. Created lazily by GetFindBarState(). |
| 344 scoped_ptr<FindBarState> find_bar_state_; | 362 scoped_ptr<FindBarState> find_bar_state_; |
| 345 | 363 |
| 346 FilePath last_selected_directory_; | 364 FilePath last_selected_directory_; |
| 347 scoped_refptr<history::TopSites> top_sites_; // For history and thumbnails. | 365 scoped_refptr<history::TopSites> top_sites_; // For history and thumbnails. |
| 348 | 366 |
| 367 // For properly notifying the ExtensionsService when the profile |
| 368 // is disposed. |
| 369 scoped_refptr<ExtensionsService> extensions_service_; |
| 370 |
| 349 // We use a temporary directory to store testing profile data. | 371 // We use a temporary directory to store testing profile data. |
| 350 ScopedTempDir temp_dir_; | 372 ScopedTempDir temp_dir_; |
| 351 }; | 373 }; |
| 352 | 374 |
| 353 // A profile that derives from another profile. This does not actually | 375 // A profile that derives from another profile. This does not actually |
| 354 // override anything except the GetRuntimeId() in order to test sharing of | 376 // override anything except the GetRuntimeId() in order to test sharing of |
| 355 // site information. | 377 // site information. |
| 356 class DerivedTestingProfile : public TestingProfile { | 378 class DerivedTestingProfile : public TestingProfile { |
| 357 public: | 379 public: |
| 358 explicit DerivedTestingProfile(Profile* profile) | 380 explicit DerivedTestingProfile(Profile* profile) |
| 359 : original_profile_(profile) {} | 381 : original_profile_(profile) {} |
| 360 | 382 |
| 361 virtual ProfileId GetRuntimeId() { | 383 virtual ProfileId GetRuntimeId() { |
| 362 return original_profile_->GetRuntimeId(); | 384 return original_profile_->GetRuntimeId(); |
| 363 } | 385 } |
| 364 | 386 |
| 365 protected: | 387 protected: |
| 366 Profile* original_profile_; | 388 Profile* original_profile_; |
| 367 }; | 389 }; |
| 368 | 390 |
| 369 #endif // CHROME_TEST_TESTING_PROFILE_H_ | 391 #endif // CHROME_TEST_TESTING_PROFILE_H_ |
| OLD | NEW |