| Index: chrome/test/base/testing_profile.h
|
| diff --git a/chrome/test/base/testing_profile.h b/chrome/test/base/testing_profile.h
|
| index 0e34cddb1e3d742f89ca1eaa17635a43352bca0b..493f9032e7a647243c48d6aee2147b96a8f8f81e 100644
|
| --- a/chrome/test/base/testing_profile.h
|
| +++ b/chrome/test/base/testing_profile.h
|
| @@ -58,6 +58,54 @@ class TestingProfile : public Profile {
|
| // Default constructor that cannot be used with multi-profiles.
|
| TestingProfile();
|
|
|
| + // Helper class for building an instance of TestingProfile (allows injecting
|
| + // mocks for various services prior to profile initialization).
|
| + // TODO(atwilson): Remove non-default constructors and various setters in
|
| + // favor of using the Builder API.
|
| + class Builder {
|
| + public:
|
| + Builder();
|
| + ~Builder();
|
| +
|
| + // Sets a Delegate to be called back when the Profile is fully initialized.
|
| + // This causes the final initialization to be performed via a task so the
|
| + // caller must run a MessageLoop. Caller maintains ownership of the Delegate
|
| + // and must manage its lifetime so it continues to exist until profile
|
| + // initialization is complete.
|
| + void SetDelegate(Delegate* delegate);
|
| +
|
| + // Sets the ExtensionSpecialStoragePolicy to be returned by
|
| + // GetExtensionSpecialStoragePolicy().
|
| + void SetExtensionSpecialStoragePolicy(
|
| + scoped_refptr<ExtensionSpecialStoragePolicy> policy);
|
| +
|
| + // Sets the path to the directory to be used to hold profile data.
|
| + void SetPath(const FilePath& path);
|
| +
|
| + // Sets the PrefService to be used by this profile.
|
| + void SetPrefService(scoped_ptr<PrefService> prefs);
|
| +
|
| + // Sets the UserCloudPolicyManager to be used by this profile.
|
| + void SetUserCloudPolicyManager(
|
| + scoped_ptr<policy::UserCloudPolicyManager> manager);
|
| +
|
| + // Creates the TestingProfile using previously-set settings.
|
| + scoped_ptr<TestingProfile> Build();
|
| +
|
| + private:
|
| + // If true, Build() has already been called.
|
| + bool build_called_;
|
| +
|
| + // Various staging variables where values are held until Build() is invoked.
|
| + scoped_ptr<policy::UserCloudPolicyManager> user_cloud_policy_manager_;
|
| + scoped_ptr<PrefService> pref_service_;
|
| + scoped_refptr<ExtensionSpecialStoragePolicy> extension_policy_;
|
| + FilePath path_;
|
| + Delegate* delegate_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(Builder);
|
| + };
|
| +
|
| // Multi-profile aware constructor that takes the path to a directory managed
|
| // for this profile. This constructor is meant to be used by
|
| // TestingProfileManager::CreateTestingProfile. If you need to create multi-
|
| @@ -71,6 +119,14 @@ class TestingProfile : public Profile {
|
| // for unittesting the ProfileManager.
|
| TestingProfile(const FilePath& path, Delegate* delegate);
|
|
|
| + // Full constructor allowing the setting of all possible instance data.
|
| + // Callers should use Builder::Build() instead of invoking this constructor.
|
| + TestingProfile(const FilePath& path,
|
| + Delegate* delegate,
|
| + scoped_refptr<ExtensionSpecialStoragePolicy> extension_policy,
|
| + scoped_ptr<PrefService> prefs,
|
| + scoped_ptr<policy::UserCloudPolicyManager> manager);
|
| +
|
| virtual ~TestingProfile();
|
|
|
| // Creates the favicon service. Consequent calls would recreate the service.
|
| @@ -167,6 +223,8 @@ class TestingProfile : public Profile {
|
| // this by calling CreateRequestContext(). See the note at GetRequestContext
|
| // for more information.
|
| net::CookieMonster* GetCookieMonster();
|
| +
|
| + virtual policy::UserCloudPolicyManager* GetUserCloudPolicyManager() OVERRIDE;
|
| virtual policy::PolicyService* GetPolicyService() OVERRIDE;
|
| // Sets the profile's PrefService. If a pref service hasn't been explicitly
|
| // set GetPrefs creates one, so normally you need not invoke this. If you need
|
| @@ -242,6 +300,9 @@ class TestingProfile : public Profile {
|
| TestingPrefService* testing_prefs_;
|
|
|
| private:
|
| + // Creates a temporary directory for use by this profile.
|
| + void CreateTempProfileDir();
|
| +
|
| // Common initialization between the two constructors.
|
| void Init();
|
|
|
| @@ -289,6 +350,9 @@ class TestingProfile : public Profile {
|
| // The proxy prefs tracker.
|
| scoped_ptr<PrefProxyConfigTracker> pref_proxy_config_tracker_;
|
|
|
| + // UserCloudPolicyManager returned by GetUserCloudPolicyManager().
|
| + scoped_ptr<policy::UserCloudPolicyManager> user_cloud_policy_manager_;
|
| +
|
| // We use a temporary directory to store testing profile data. In a multi-
|
| // profile environment, this is invalid and the directory is managed by the
|
| // TestingProfileManager.
|
|
|