| 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<PrefServiceSyncable> prefs); | 85 void SetPrefService(scoped_ptr<PrefServiceSyncable> prefs); |
| 86 | 86 |
| 87 // Sets the TestingProfile to be off-the-record by default. |
| 88 void SetOffTheRecord(); |
| 89 |
| 87 // Creates the TestingProfile using previously-set settings. | 90 // Creates the TestingProfile using previously-set settings. |
| 88 scoped_ptr<TestingProfile> Build(); | 91 scoped_ptr<TestingProfile> Build(); |
| 89 | 92 |
| 90 private: | 93 private: |
| 91 // If true, Build() has already been called. | 94 // If true, Build() has already been called. |
| 92 bool build_called_; | 95 bool build_called_; |
| 93 | 96 |
| 94 // Various staging variables where values are held until Build() is invoked. | 97 // Various staging variables where values are held until Build() is invoked. |
| 95 scoped_ptr<PrefServiceSyncable> pref_service_; | 98 scoped_ptr<PrefServiceSyncable> pref_service_; |
| 96 scoped_refptr<ExtensionSpecialStoragePolicy> extension_policy_; | 99 scoped_refptr<ExtensionSpecialStoragePolicy> extension_policy_; |
| 97 FilePath path_; | 100 FilePath path_; |
| 98 Delegate* delegate_; | 101 Delegate* delegate_; |
| 102 bool off_the_record_; |
| 99 | 103 |
| 100 DISALLOW_COPY_AND_ASSIGN(Builder); | 104 DISALLOW_COPY_AND_ASSIGN(Builder); |
| 101 }; | 105 }; |
| 102 | 106 |
| 103 // Multi-profile aware constructor that takes the path to a directory managed | 107 // Multi-profile aware constructor that takes the path to a directory managed |
| 104 // for this profile. This constructor is meant to be used by | 108 // for this profile. This constructor is meant to be used by |
| 105 // TestingProfileManager::CreateTestingProfile. If you need to create multi- | 109 // TestingProfileManager::CreateTestingProfile. If you need to create multi- |
| 106 // profile profiles, use that factory method instead of this directly. | 110 // profile profiles, use that factory method instead of this directly. |
| 107 // Exception: if you need to create multi-profile profiles for testing the | 111 // Exception: if you need to create multi-profile profiles for testing the |
| 108 // ProfileManager, then use the constructor below instead. | 112 // ProfileManager, then use the constructor below instead. |
| 109 explicit TestingProfile(const FilePath& path); | 113 explicit TestingProfile(const FilePath& path); |
| 110 | 114 |
| 111 // Multi-profile aware constructor that takes the path to a directory managed | 115 // Multi-profile aware constructor that takes the path to a directory managed |
| 112 // for this profile and a delegate. This constructor is meant to be used | 116 // for this profile and a delegate. This constructor is meant to be used |
| 113 // for unittesting the ProfileManager. | 117 // for unittesting the ProfileManager. |
| 114 TestingProfile(const FilePath& path, Delegate* delegate); | 118 TestingProfile(const FilePath& path, Delegate* delegate); |
| 115 | 119 |
| 116 // Full constructor allowing the setting of all possible instance data. | 120 // Full constructor allowing the setting of all possible instance data. |
| 117 // Callers should use Builder::Build() instead of invoking this constructor. | 121 // Callers should use Builder::Build() instead of invoking this constructor. |
| 118 TestingProfile(const FilePath& path, | 122 TestingProfile(const FilePath& path, |
| 119 Delegate* delegate, | 123 Delegate* delegate, |
| 120 scoped_refptr<ExtensionSpecialStoragePolicy> extension_policy, | 124 scoped_refptr<ExtensionSpecialStoragePolicy> extension_policy, |
| 121 scoped_ptr<PrefServiceSyncable> prefs); | 125 scoped_ptr<PrefServiceSyncable> prefs, |
| 126 bool off_the_record); |
| 122 | 127 |
| 123 virtual ~TestingProfile(); | 128 virtual ~TestingProfile(); |
| 124 | 129 |
| 125 // Creates the favicon service. Consequent calls would recreate the service. | 130 // Creates the favicon service. Consequent calls would recreate the service. |
| 126 void CreateFaviconService(); | 131 void CreateFaviconService(); |
| 127 | 132 |
| 128 // Creates the history service. If |delete_file| is true, the history file is | 133 // Creates the history service. If |delete_file| is true, the history file is |
| 129 // deleted first, then the HistoryService is created. As TestingProfile | 134 // deleted first, then the HistoryService is created. As TestingProfile |
| 130 // deletes the directory containing the files used by HistoryService, this | 135 // deletes the directory containing the files used by HistoryService, this |
| 131 // only matters if you're recreating the HistoryService. If |no_db| is true, | 136 // only matters if you're recreating the HistoryService. If |no_db| is true, |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 // testing. | 355 // testing. |
| 351 ProfileDependencyManager* profile_dependency_manager_; | 356 ProfileDependencyManager* profile_dependency_manager_; |
| 352 | 357 |
| 353 scoped_ptr<content::MockResourceContext> resource_context_; | 358 scoped_ptr<content::MockResourceContext> resource_context_; |
| 354 | 359 |
| 355 // Weak pointer to a delegate for indicating that a profile was created. | 360 // Weak pointer to a delegate for indicating that a profile was created. |
| 356 Delegate* delegate_; | 361 Delegate* delegate_; |
| 357 }; | 362 }; |
| 358 | 363 |
| 359 #endif // CHROME_TEST_BASE_TESTING_PROFILE_H_ | 364 #endif // CHROME_TEST_BASE_TESTING_PROFILE_H_ |
| OLD | NEW |