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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 void BlockUntilTopSitesLoaded(); | 167 void BlockUntilTopSitesLoaded(); |
168 | 168 |
169 TestingPrefServiceSyncable* GetTestingPrefService(); | 169 TestingPrefServiceSyncable* GetTestingPrefService(); |
170 | 170 |
171 // content::BrowserContext | 171 // content::BrowserContext |
172 virtual base::FilePath GetPath() const OVERRIDE; | 172 virtual base::FilePath GetPath() const OVERRIDE; |
173 virtual scoped_refptr<base::SequencedTaskRunner> GetIOTaskRunner() OVERRIDE; | 173 virtual scoped_refptr<base::SequencedTaskRunner> GetIOTaskRunner() OVERRIDE; |
174 virtual bool IsOffTheRecord() const OVERRIDE; | 174 virtual bool IsOffTheRecord() const OVERRIDE; |
175 virtual content::DownloadManagerDelegate* | 175 virtual content::DownloadManagerDelegate* |
176 GetDownloadManagerDelegate() OVERRIDE; | 176 GetDownloadManagerDelegate() OVERRIDE; |
177 // Returns a testing ContextGetter (if one has been created via | |
178 // CreateRequestContext) or NULL. This is not done on-demand for two reasons: | |
179 // (1) Some tests depend on GetRequestContext() returning NULL. (2) Because | |
180 // of the special memory management considerations for the | |
181 // TestURLRequestContextGetter class, many tests would find themseleves | |
182 // leaking if they called this method without the necessary IO thread. This | |
183 // getter is currently only capable of returning a Context that helps test | |
184 // the CookieMonster. See implementation comments for more details. | |
185 virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE; | 177 virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE; |
186 virtual net::URLRequestContextGetter* CreateRequestContext( | 178 virtual net::URLRequestContextGetter* CreateRequestContext( |
187 content::ProtocolHandlerMap* protocol_handlers) OVERRIDE; | 179 content::ProtocolHandlerMap* protocol_handlers) OVERRIDE; |
188 virtual net::URLRequestContextGetter* GetRequestContextForRenderProcess( | 180 virtual net::URLRequestContextGetter* GetRequestContextForRenderProcess( |
189 int renderer_child_id) OVERRIDE; | 181 int renderer_child_id) OVERRIDE; |
190 virtual content::ResourceContext* GetResourceContext() OVERRIDE; | 182 virtual content::ResourceContext* GetResourceContext() OVERRIDE; |
191 virtual content::GeolocationPermissionContext* | 183 virtual content::GeolocationPermissionContext* |
192 GetGeolocationPermissionContext() OVERRIDE; | 184 GetGeolocationPermissionContext() OVERRIDE; |
193 virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE; | 185 virtual quota::SpecialStoragePolicy* GetSpecialStoragePolicy() OVERRIDE; |
194 | 186 |
195 virtual TestingProfile* AsTestingProfile() OVERRIDE; | 187 virtual TestingProfile* AsTestingProfile() OVERRIDE; |
196 virtual std::string GetProfileName() OVERRIDE; | 188 virtual std::string GetProfileName() OVERRIDE; |
197 void set_incognito(bool incognito) { incognito_ = incognito; } | 189 void set_incognito(bool incognito) { incognito_ = incognito; } |
198 // Assumes ownership. | 190 // Assumes ownership. |
199 virtual void SetOffTheRecordProfile(Profile* profile); | 191 virtual void SetOffTheRecordProfile(Profile* profile); |
200 virtual void SetOriginalProfile(Profile* profile); | 192 virtual void SetOriginalProfile(Profile* profile); |
201 virtual Profile* GetOffTheRecordProfile() OVERRIDE; | 193 virtual Profile* GetOffTheRecordProfile() OVERRIDE; |
202 virtual void DestroyOffTheRecordProfile() OVERRIDE {} | 194 virtual void DestroyOffTheRecordProfile() OVERRIDE {} |
203 virtual bool HasOffTheRecordProfile() OVERRIDE; | 195 virtual bool HasOffTheRecordProfile() OVERRIDE; |
204 virtual Profile* GetOriginalProfile() OVERRIDE; | 196 virtual Profile* GetOriginalProfile() OVERRIDE; |
205 virtual ExtensionService* GetExtensionService() OVERRIDE; | 197 virtual ExtensionService* GetExtensionService() OVERRIDE; |
206 void SetExtensionSpecialStoragePolicy( | 198 void SetExtensionSpecialStoragePolicy( |
207 ExtensionSpecialStoragePolicy* extension_special_storage_policy); | 199 ExtensionSpecialStoragePolicy* extension_special_storage_policy); |
208 virtual ExtensionSpecialStoragePolicy* | 200 virtual ExtensionSpecialStoragePolicy* |
209 GetExtensionSpecialStoragePolicy() OVERRIDE; | 201 GetExtensionSpecialStoragePolicy() OVERRIDE; |
210 // The CookieMonster will only be returned if a Context has been created. Do | 202 // TODO(ajwong): Remove this API in favor of directly retrieving the |
211 // this by calling CreateRequestContext(). See the note at GetRequestContext | 203 // CookieStore from the StoragePartition after ExtensionURLRequestContext |
212 // for more information. | 204 // has been removed. |
213 net::CookieMonster* GetCookieMonster(); | 205 net::CookieMonster* GetCookieMonster(); |
214 | 206 |
215 virtual PrefService* GetPrefs() OVERRIDE; | 207 virtual PrefService* GetPrefs() OVERRIDE; |
216 | 208 |
217 virtual history::TopSites* GetTopSites() OVERRIDE; | 209 virtual history::TopSites* GetTopSites() OVERRIDE; |
218 virtual history::TopSites* GetTopSitesWithoutCreating() OVERRIDE; | 210 virtual history::TopSites* GetTopSitesWithoutCreating() OVERRIDE; |
219 | 211 |
220 void CreateRequestContext(); | |
221 // Clears out the created request context (which must be done before shutting | |
222 // down the IO thread to avoid leaks). | |
223 void ResetRequestContext(); | |
224 | |
225 virtual net::URLRequestContextGetter* GetMediaRequestContext() OVERRIDE; | 212 virtual net::URLRequestContextGetter* GetMediaRequestContext() OVERRIDE; |
226 virtual net::URLRequestContextGetter* GetMediaRequestContextForRenderProcess( | 213 virtual net::URLRequestContextGetter* GetMediaRequestContextForRenderProcess( |
227 int renderer_child_id) OVERRIDE; | 214 int renderer_child_id) OVERRIDE; |
228 virtual net::URLRequestContextGetter* | 215 virtual net::URLRequestContextGetter* |
229 GetRequestContextForExtensions() OVERRIDE; | 216 GetRequestContextForExtensions() OVERRIDE; |
230 virtual net::URLRequestContextGetter* | 217 virtual net::URLRequestContextGetter* |
231 GetMediaRequestContextForStoragePartition( | 218 GetMediaRequestContextForStoragePartition( |
232 const base::FilePath& partition_path, | 219 const base::FilePath& partition_path, |
233 bool in_memory) OVERRIDE; | 220 bool in_memory) OVERRIDE; |
234 virtual void RequestMIDISysExPermission( | 221 virtual void RequestMIDISysExPermission( |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 | 293 |
307 // Creates a TestingPrefService and associates it with the TestingProfile. | 294 // Creates a TestingPrefService and associates it with the TestingProfile. |
308 void CreateTestingPrefService(); | 295 void CreateTestingPrefService(); |
309 | 296 |
310 // Creates a ProfilePolicyConnector that the ProfilePolicyConnectorFactory | 297 // Creates a ProfilePolicyConnector that the ProfilePolicyConnectorFactory |
311 // maps to this profile. | 298 // maps to this profile. |
312 void CreateProfilePolicyConnector(); | 299 void CreateProfilePolicyConnector(); |
313 | 300 |
314 // Internally, this is a TestURLRequestContextGetter that creates a dummy | 301 // Internally, this is a TestURLRequestContextGetter that creates a dummy |
315 // request context. Currently, only the CookieMonster is hooked up. | 302 // request context. Currently, only the CookieMonster is hooked up. |
316 scoped_refptr<net::URLRequestContextGetter> request_context_; | |
317 scoped_refptr<net::URLRequestContextGetter> extensions_request_context_; | 303 scoped_refptr<net::URLRequestContextGetter> extensions_request_context_; |
318 | 304 |
319 std::wstring id_; | 305 std::wstring id_; |
320 | 306 |
321 bool incognito_; | 307 bool incognito_; |
322 scoped_ptr<Profile> incognito_profile_; | 308 scoped_ptr<Profile> incognito_profile_; |
323 Profile* original_profile_; | 309 Profile* original_profile_; |
324 | 310 |
325 // Did the last session exit cleanly? Default is true. | 311 // Did the last session exit cleanly? Default is true. |
326 bool last_session_exited_cleanly_; | 312 bool last_session_exited_cleanly_; |
(...skipping 15 matching lines...) Expand all Loading... |
342 base::ScopedTempDir temp_dir_; | 328 base::ScopedTempDir temp_dir_; |
343 // The path to this profile. This will be valid in either of the two above | 329 // The path to this profile. This will be valid in either of the two above |
344 // cases. | 330 // cases. |
345 base::FilePath profile_path_; | 331 base::FilePath profile_path_; |
346 | 332 |
347 // We keep a weak pointer to the dependency manager we want to notify on our | 333 // We keep a weak pointer to the dependency manager we want to notify on our |
348 // death. Defaults to the Singleton implementation but overridable for | 334 // death. Defaults to the Singleton implementation but overridable for |
349 // testing. | 335 // testing. |
350 BrowserContextDependencyManager* browser_context_dependency_manager_; | 336 BrowserContextDependencyManager* browser_context_dependency_manager_; |
351 | 337 |
352 scoped_ptr<content::MockResourceContext> resource_context_; | 338 // Owned, but must be deleted on the IO thread so not placing in a |
| 339 // scoped_ptr<>. |
| 340 content::MockResourceContext* resource_context_; |
353 | 341 |
354 scoped_ptr<policy::ProfilePolicyConnector> profile_policy_connector_; | 342 scoped_ptr<policy::ProfilePolicyConnector> profile_policy_connector_; |
355 | 343 |
356 // Weak pointer to a delegate for indicating that a profile was created. | 344 // Weak pointer to a delegate for indicating that a profile was created. |
357 Delegate* delegate_; | 345 Delegate* delegate_; |
358 }; | 346 }; |
359 | 347 |
360 #endif // CHROME_TEST_BASE_TESTING_PROFILE_H_ | 348 #endif // CHROME_TEST_BASE_TESTING_PROFILE_H_ |
OLD | NEW |