| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 // GetExtensionSpecialStoragePolicy(). | 77 // GetExtensionSpecialStoragePolicy(). |
| 78 void SetExtensionSpecialStoragePolicy( | 78 void SetExtensionSpecialStoragePolicy( |
| 79 scoped_refptr<ExtensionSpecialStoragePolicy> policy); | 79 scoped_refptr<ExtensionSpecialStoragePolicy> policy); |
| 80 | 80 |
| 81 // Sets the path to the directory to be used to hold profile data. | 81 // Sets the path to the directory to be used to hold profile data. |
| 82 void SetPath(const FilePath& path); | 82 void SetPath(const FilePath& path); |
| 83 | 83 |
| 84 // Sets the PrefService to be used by this profile. | 84 // Sets the PrefService to be used by this profile. |
| 85 void SetPrefService(scoped_ptr<PrefService> prefs); | 85 void SetPrefService(scoped_ptr<PrefService> prefs); |
| 86 | 86 |
| 87 // Sets the UserCloudPolicyManager to be used by this profile. | |
| 88 void SetUserCloudPolicyManager( | |
| 89 scoped_ptr<policy::UserCloudPolicyManager> manager); | |
| 90 | |
| 91 // Creates the TestingProfile using previously-set settings. | 87 // Creates the TestingProfile using previously-set settings. |
| 92 scoped_ptr<TestingProfile> Build(); | 88 scoped_ptr<TestingProfile> Build(); |
| 93 | 89 |
| 94 private: | 90 private: |
| 95 // If true, Build() has already been called. | 91 // If true, Build() has already been called. |
| 96 bool build_called_; | 92 bool build_called_; |
| 97 | 93 |
| 98 // Various staging variables where values are held until Build() is invoked. | 94 // Various staging variables where values are held until Build() is invoked. |
| 99 scoped_ptr<policy::UserCloudPolicyManager> user_cloud_policy_manager_; | |
| 100 scoped_ptr<PrefService> pref_service_; | 95 scoped_ptr<PrefService> pref_service_; |
| 101 scoped_refptr<ExtensionSpecialStoragePolicy> extension_policy_; | 96 scoped_refptr<ExtensionSpecialStoragePolicy> extension_policy_; |
| 102 FilePath path_; | 97 FilePath path_; |
| 103 Delegate* delegate_; | 98 Delegate* delegate_; |
| 104 | 99 |
| 105 DISALLOW_COPY_AND_ASSIGN(Builder); | 100 DISALLOW_COPY_AND_ASSIGN(Builder); |
| 106 }; | 101 }; |
| 107 | 102 |
| 108 // Multi-profile aware constructor that takes the path to a directory managed | 103 // Multi-profile aware constructor that takes the path to a directory managed |
| 109 // for this profile. This constructor is meant to be used by | 104 // for this profile. This constructor is meant to be used by |
| 110 // TestingProfileManager::CreateTestingProfile. If you need to create multi- | 105 // TestingProfileManager::CreateTestingProfile. If you need to create multi- |
| 111 // profile profiles, use that factory method instead of this directly. | 106 // profile profiles, use that factory method instead of this directly. |
| 112 // Exception: if you need to create multi-profile profiles for testing the | 107 // Exception: if you need to create multi-profile profiles for testing the |
| 113 // ProfileManager, then use the constructor below instead. | 108 // ProfileManager, then use the constructor below instead. |
| 114 explicit TestingProfile(const FilePath& path); | 109 explicit TestingProfile(const FilePath& path); |
| 115 | 110 |
| 116 // Multi-profile aware constructor that takes the path to a directory managed | 111 // Multi-profile aware constructor that takes the path to a directory managed |
| 117 // for this profile and a delegate. This constructor is meant to be used | 112 // for this profile and a delegate. This constructor is meant to be used |
| 118 // for unittesting the ProfileManager. | 113 // for unittesting the ProfileManager. |
| 119 TestingProfile(const FilePath& path, Delegate* delegate); | 114 TestingProfile(const FilePath& path, Delegate* delegate); |
| 120 | 115 |
| 121 // Full constructor allowing the setting of all possible instance data. | 116 // Full constructor allowing the setting of all possible instance data. |
| 122 // Callers should use Builder::Build() instead of invoking this constructor. | 117 // Callers should use Builder::Build() instead of invoking this constructor. |
| 123 TestingProfile(const FilePath& path, | 118 TestingProfile(const FilePath& path, |
| 124 Delegate* delegate, | 119 Delegate* delegate, |
| 125 scoped_refptr<ExtensionSpecialStoragePolicy> extension_policy, | 120 scoped_refptr<ExtensionSpecialStoragePolicy> extension_policy, |
| 126 scoped_ptr<PrefService> prefs, | 121 scoped_ptr<PrefService> prefs); |
| 127 scoped_ptr<policy::UserCloudPolicyManager> manager); | |
| 128 | 122 |
| 129 virtual ~TestingProfile(); | 123 virtual ~TestingProfile(); |
| 130 | 124 |
| 131 // Creates the favicon service. Consequent calls would recreate the service. | 125 // Creates the favicon service. Consequent calls would recreate the service. |
| 132 void CreateFaviconService(); | 126 void CreateFaviconService(); |
| 133 | 127 |
| 134 // Creates the history service. If |delete_file| is true, the history file is | 128 // Creates the history service. If |delete_file| is true, the history file is |
| 135 // deleted first, then the HistoryService is created. As TestingProfile | 129 // deleted first, then the HistoryService is created. As TestingProfile |
| 136 // deletes the directory containing the files used by HistoryService, this | 130 // deletes the directory containing the files used by HistoryService, this |
| 137 // only matters if you're recreating the HistoryService. If |no_db| is true, | 131 // only matters if you're recreating the HistoryService. If |no_db| is true, |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 virtual ExtensionService* GetExtensionService() OVERRIDE; | 207 virtual ExtensionService* GetExtensionService() OVERRIDE; |
| 214 void SetExtensionSpecialStoragePolicy( | 208 void SetExtensionSpecialStoragePolicy( |
| 215 ExtensionSpecialStoragePolicy* extension_special_storage_policy); | 209 ExtensionSpecialStoragePolicy* extension_special_storage_policy); |
| 216 virtual ExtensionSpecialStoragePolicy* | 210 virtual ExtensionSpecialStoragePolicy* |
| 217 GetExtensionSpecialStoragePolicy() OVERRIDE; | 211 GetExtensionSpecialStoragePolicy() OVERRIDE; |
| 218 // The CookieMonster will only be returned if a Context has been created. Do | 212 // The CookieMonster will only be returned if a Context has been created. Do |
| 219 // this by calling CreateRequestContext(). See the note at GetRequestContext | 213 // this by calling CreateRequestContext(). See the note at GetRequestContext |
| 220 // for more information. | 214 // for more information. |
| 221 net::CookieMonster* GetCookieMonster(); | 215 net::CookieMonster* GetCookieMonster(); |
| 222 | 216 |
| 223 virtual policy::UserCloudPolicyManager* GetUserCloudPolicyManager() OVERRIDE; | |
| 224 virtual policy::ManagedModePolicyProvider* | 217 virtual policy::ManagedModePolicyProvider* |
| 225 GetManagedModePolicyProvider() OVERRIDE; | 218 GetManagedModePolicyProvider() OVERRIDE; |
| 226 virtual policy::PolicyService* GetPolicyService() OVERRIDE; | 219 virtual policy::PolicyService* GetPolicyService() OVERRIDE; |
| 227 // Sets the profile's PrefService. If a pref service hasn't been explicitly | 220 // Sets the profile's PrefService. If a pref service hasn't been explicitly |
| 228 // set GetPrefs creates one, so normally you need not invoke this. If you need | 221 // set GetPrefs creates one, so normally you need not invoke this. If you need |
| 229 // to set a pref service you must invoke this before GetPrefs. | 222 // to set a pref service you must invoke this before GetPrefs. |
| 230 // TestingPrefService takes ownership of |prefs|. | 223 // TestingPrefService takes ownership of |prefs|. |
| 231 void SetPrefService(PrefService* prefs); | 224 void SetPrefService(PrefService* prefs); |
| 232 virtual PrefService* GetPrefs() OVERRIDE; | 225 virtual PrefService* GetPrefs() OVERRIDE; |
| 233 virtual history::TopSites* GetTopSites() OVERRIDE; | 226 virtual history::TopSites* GetTopSites() OVERRIDE; |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 | 337 |
| 345 FilePath last_selected_directory_; | 338 FilePath last_selected_directory_; |
| 346 scoped_refptr<history::TopSites> top_sites_; // For history and thumbnails. | 339 scoped_refptr<history::TopSites> top_sites_; // For history and thumbnails. |
| 347 | 340 |
| 348 scoped_refptr<ExtensionSpecialStoragePolicy> | 341 scoped_refptr<ExtensionSpecialStoragePolicy> |
| 349 extension_special_storage_policy_; | 342 extension_special_storage_policy_; |
| 350 | 343 |
| 351 // The proxy prefs tracker. | 344 // The proxy prefs tracker. |
| 352 scoped_ptr<PrefProxyConfigTracker> pref_proxy_config_tracker_; | 345 scoped_ptr<PrefProxyConfigTracker> pref_proxy_config_tracker_; |
| 353 | 346 |
| 354 // UserCloudPolicyManager returned by GetUserCloudPolicyManager(). | |
| 355 scoped_ptr<policy::UserCloudPolicyManager> user_cloud_policy_manager_; | |
| 356 | |
| 357 // We use a temporary directory to store testing profile data. In a multi- | 347 // We use a temporary directory to store testing profile data. In a multi- |
| 358 // profile environment, this is invalid and the directory is managed by the | 348 // profile environment, this is invalid and the directory is managed by the |
| 359 // TestingProfileManager. | 349 // TestingProfileManager. |
| 360 base::ScopedTempDir temp_dir_; | 350 base::ScopedTempDir temp_dir_; |
| 361 // The path to this profile. This will be valid in either of the two above | 351 // The path to this profile. This will be valid in either of the two above |
| 362 // cases. | 352 // cases. |
| 363 FilePath profile_path_; | 353 FilePath profile_path_; |
| 364 | 354 |
| 365 // We keep a weak pointer to the dependency manager we want to notify on our | 355 // We keep a weak pointer to the dependency manager we want to notify on our |
| 366 // death. Defaults to the Singleton implementation but overridable for | 356 // death. Defaults to the Singleton implementation but overridable for |
| 367 // testing. | 357 // testing. |
| 368 ProfileDependencyManager* profile_dependency_manager_; | 358 ProfileDependencyManager* profile_dependency_manager_; |
| 369 | 359 |
| 370 scoped_ptr<content::MockResourceContext> resource_context_; | 360 scoped_ptr<content::MockResourceContext> resource_context_; |
| 371 | 361 |
| 372 // Weak pointer to a delegate for indicating that a profile was created. | 362 // Weak pointer to a delegate for indicating that a profile was created. |
| 373 Delegate* delegate_; | 363 Delegate* delegate_; |
| 374 }; | 364 }; |
| 375 | 365 |
| 376 #endif // CHROME_TEST_BASE_TESTING_PROFILE_H_ | 366 #endif // CHROME_TEST_BASE_TESTING_PROFILE_H_ |
| OLD | NEW |