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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 #if defined(ENABLE_EXTENSIONS) | 154 #if defined(ENABLE_EXTENSIONS) |
155 scoped_refptr<ExtensionSpecialStoragePolicy> extension_policy, | 155 scoped_refptr<ExtensionSpecialStoragePolicy> extension_policy, |
156 #endif | 156 #endif |
157 scoped_ptr<PrefServiceSyncable> prefs, | 157 scoped_ptr<PrefServiceSyncable> prefs, |
158 TestingProfile* parent, | 158 TestingProfile* parent, |
159 bool guest_session, | 159 bool guest_session, |
160 const std::string& supervised_user_id, | 160 const std::string& supervised_user_id, |
161 scoped_ptr<policy::PolicyService> policy_service, | 161 scoped_ptr<policy::PolicyService> policy_service, |
162 const TestingFactories& factories); | 162 const TestingFactories& factories); |
163 | 163 |
164 virtual ~TestingProfile(); | 164 ~TestingProfile() override; |
165 | 165 |
166 // Creates the favicon service. Consequent calls would recreate the service. | 166 // Creates the favicon service. Consequent calls would recreate the service. |
167 void CreateFaviconService(); | 167 void CreateFaviconService(); |
168 | 168 |
169 // Creates the history service. If |delete_file| is true, the history file is | 169 // Creates the history service. If |delete_file| is true, the history file is |
170 // deleted first, then the HistoryService is created. As TestingProfile | 170 // deleted first, then the HistoryService is created. As TestingProfile |
171 // deletes the directory containing the files used by HistoryService, this | 171 // deletes the directory containing the files used by HistoryService, this |
172 // only matters if you're recreating the HistoryService. If |no_db| is true, | 172 // only matters if you're recreating the HistoryService. If |no_db| is true, |
173 // the history backend will fail to initialize its database; this is useful | 173 // the history backend will fail to initialize its database; this is useful |
174 // for testing error conditions. Returns true on success. | 174 // for testing error conditions. Returns true on success. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 void SetGuestSession(bool guest); | 209 void SetGuestSession(bool guest); |
210 | 210 |
211 TestingPrefServiceSyncable* GetTestingPrefService(); | 211 TestingPrefServiceSyncable* GetTestingPrefService(); |
212 | 212 |
213 // Called on the parent of an incognito |profile|. Usually called from the | 213 // Called on the parent of an incognito |profile|. Usually called from the |
214 // constructor of an incognito TestingProfile, but can also be used by tests | 214 // constructor of an incognito TestingProfile, but can also be used by tests |
215 // to provide an OffTheRecordProfileImpl instance. | 215 // to provide an OffTheRecordProfileImpl instance. |
216 void SetOffTheRecordProfile(scoped_ptr<Profile> profile); | 216 void SetOffTheRecordProfile(scoped_ptr<Profile> profile); |
217 | 217 |
218 // content::BrowserContext | 218 // content::BrowserContext |
219 virtual base::FilePath GetPath() const override; | 219 base::FilePath GetPath() const override; |
220 virtual scoped_refptr<base::SequencedTaskRunner> GetIOTaskRunner() override; | 220 scoped_refptr<base::SequencedTaskRunner> GetIOTaskRunner() override; |
221 virtual bool IsOffTheRecord() const override; | 221 bool IsOffTheRecord() const override; |
222 virtual content::DownloadManagerDelegate* | 222 content::DownloadManagerDelegate* GetDownloadManagerDelegate() override; |
223 GetDownloadManagerDelegate() override; | 223 net::URLRequestContextGetter* GetRequestContext() override; |
224 virtual net::URLRequestContextGetter* GetRequestContext() override; | 224 net::URLRequestContextGetter* CreateRequestContext( |
225 virtual net::URLRequestContextGetter* CreateRequestContext( | |
226 content::ProtocolHandlerMap* protocol_handlers, | 225 content::ProtocolHandlerMap* protocol_handlers, |
227 content::URLRequestInterceptorScopedVector request_interceptors) override; | 226 content::URLRequestInterceptorScopedVector request_interceptors) override; |
228 virtual net::URLRequestContextGetter* GetRequestContextForRenderProcess( | 227 net::URLRequestContextGetter* GetRequestContextForRenderProcess( |
229 int renderer_child_id) override; | 228 int renderer_child_id) override; |
230 virtual content::ResourceContext* GetResourceContext() override; | 229 content::ResourceContext* GetResourceContext() override; |
231 virtual content::BrowserPluginGuestManager* GetGuestManager() override; | 230 content::BrowserPluginGuestManager* GetGuestManager() override; |
232 virtual storage::SpecialStoragePolicy* GetSpecialStoragePolicy() override; | 231 storage::SpecialStoragePolicy* GetSpecialStoragePolicy() override; |
233 virtual content::PushMessagingService* GetPushMessagingService() override; | 232 content::PushMessagingService* GetPushMessagingService() override; |
234 virtual content::SSLHostStateDelegate* GetSSLHostStateDelegate() override; | 233 content::SSLHostStateDelegate* GetSSLHostStateDelegate() override; |
235 | 234 |
236 virtual TestingProfile* AsTestingProfile() override; | 235 TestingProfile* AsTestingProfile() override; |
237 | 236 |
238 // Profile | 237 // Profile |
239 virtual std::string GetProfileName() override; | 238 std::string GetProfileName() override; |
240 virtual ProfileType GetProfileType() const override; | 239 ProfileType GetProfileType() const override; |
241 | 240 |
242 // DEPRECATED, because it's fragile to change a profile from non-incognito | 241 // DEPRECATED, because it's fragile to change a profile from non-incognito |
243 // to incognito after the ProfileKeyedServices have been created (some | 242 // to incognito after the ProfileKeyedServices have been created (some |
244 // ProfileKeyedServices either should not exist in incognito mode, or will | 243 // ProfileKeyedServices either should not exist in incognito mode, or will |
245 // crash when they try to get references to other services they depend on, | 244 // crash when they try to get references to other services they depend on, |
246 // but do not exist in incognito mode). | 245 // but do not exist in incognito mode). |
247 // TODO(atwilson): Remove this API (http://crbug.com/277296). | 246 // TODO(atwilson): Remove this API (http://crbug.com/277296). |
248 // | 247 // |
249 // Changes a profile's to/from incognito mode temporarily - profile will be | 248 // Changes a profile's to/from incognito mode temporarily - profile will be |
250 // returned to non-incognito before destruction to allow services to | 249 // returned to non-incognito before destruction to allow services to |
251 // properly shutdown. This is only supported for legacy tests - new tests | 250 // properly shutdown. This is only supported for legacy tests - new tests |
252 // should create a true incognito profile using Builder::SetIncognito() or | 251 // should create a true incognito profile using Builder::SetIncognito() or |
253 // by using the TestingProfile constructor that allows setting the incognito | 252 // by using the TestingProfile constructor that allows setting the incognito |
254 // flag. | 253 // flag. |
255 void ForceIncognito(bool force_incognito) { | 254 void ForceIncognito(bool force_incognito) { |
256 force_incognito_ = force_incognito; | 255 force_incognito_ = force_incognito; |
257 } | 256 } |
258 | 257 |
259 virtual Profile* GetOffTheRecordProfile() override; | 258 Profile* GetOffTheRecordProfile() override; |
260 virtual void DestroyOffTheRecordProfile() override {} | 259 void DestroyOffTheRecordProfile() override {} |
261 virtual bool HasOffTheRecordProfile() override; | 260 bool HasOffTheRecordProfile() override; |
262 virtual Profile* GetOriginalProfile() override; | 261 Profile* GetOriginalProfile() override; |
263 virtual bool IsSupervised() override; | 262 bool IsSupervised() override; |
264 #if defined(ENABLE_EXTENSIONS) | 263 #if defined(ENABLE_EXTENSIONS) |
265 void SetExtensionSpecialStoragePolicy( | 264 void SetExtensionSpecialStoragePolicy( |
266 ExtensionSpecialStoragePolicy* extension_special_storage_policy); | 265 ExtensionSpecialStoragePolicy* extension_special_storage_policy); |
267 #endif | 266 #endif |
268 virtual ExtensionSpecialStoragePolicy* | 267 ExtensionSpecialStoragePolicy* GetExtensionSpecialStoragePolicy() override; |
269 GetExtensionSpecialStoragePolicy() override; | |
270 // TODO(ajwong): Remove this API in favor of directly retrieving the | 268 // TODO(ajwong): Remove this API in favor of directly retrieving the |
271 // CookieStore from the StoragePartition after ExtensionURLRequestContext | 269 // CookieStore from the StoragePartition after ExtensionURLRequestContext |
272 // has been removed. | 270 // has been removed. |
273 net::CookieMonster* GetCookieMonster(); | 271 net::CookieMonster* GetCookieMonster(); |
274 | 272 |
275 virtual PrefService* GetPrefs() override; | 273 PrefService* GetPrefs() override; |
276 | 274 |
277 virtual history::TopSites* GetTopSites() override; | 275 history::TopSites* GetTopSites() override; |
278 virtual history::TopSites* GetTopSitesWithoutCreating() override; | 276 history::TopSites* GetTopSitesWithoutCreating() override; |
279 | 277 |
280 virtual net::URLRequestContextGetter* GetMediaRequestContext() override; | 278 net::URLRequestContextGetter* GetMediaRequestContext() override; |
281 virtual net::URLRequestContextGetter* GetMediaRequestContextForRenderProcess( | 279 net::URLRequestContextGetter* GetMediaRequestContextForRenderProcess( |
282 int renderer_child_id) override; | 280 int renderer_child_id) override; |
283 virtual net::URLRequestContextGetter* | 281 net::URLRequestContextGetter* GetRequestContextForExtensions() override; |
284 GetRequestContextForExtensions() override; | 282 net::URLRequestContextGetter* GetMediaRequestContextForStoragePartition( |
285 virtual net::URLRequestContextGetter* | 283 const base::FilePath& partition_path, |
286 GetMediaRequestContextForStoragePartition( | 284 bool in_memory) override; |
287 const base::FilePath& partition_path, | 285 net::URLRequestContextGetter* CreateRequestContextForStoragePartition( |
288 bool in_memory) override; | |
289 virtual net::URLRequestContextGetter* CreateRequestContextForStoragePartition( | |
290 const base::FilePath& partition_path, | 286 const base::FilePath& partition_path, |
291 bool in_memory, | 287 bool in_memory, |
292 content::ProtocolHandlerMap* protocol_handlers, | 288 content::ProtocolHandlerMap* protocol_handlers, |
293 content::URLRequestInterceptorScopedVector request_interceptors) override; | 289 content::URLRequestInterceptorScopedVector request_interceptors) override; |
294 virtual net::SSLConfigService* GetSSLConfigService() override; | 290 net::SSLConfigService* GetSSLConfigService() override; |
295 virtual HostContentSettingsMap* GetHostContentSettingsMap() override; | 291 HostContentSettingsMap* GetHostContentSettingsMap() override; |
296 void set_last_session_exited_cleanly(bool value) { | 292 void set_last_session_exited_cleanly(bool value) { |
297 last_session_exited_cleanly_ = value; | 293 last_session_exited_cleanly_ = value; |
298 } | 294 } |
299 virtual bool IsSameProfile(Profile *p) override; | 295 bool IsSameProfile(Profile* p) override; |
300 virtual base::Time GetStartTime() const override; | 296 base::Time GetStartTime() const override; |
301 virtual base::FilePath last_selected_directory() override; | 297 base::FilePath last_selected_directory() override; |
302 virtual void set_last_selected_directory(const base::FilePath& path) override; | 298 void set_last_selected_directory(const base::FilePath& path) override; |
303 virtual bool WasCreatedByVersionOrLater(const std::string& version) override; | 299 bool WasCreatedByVersionOrLater(const std::string& version) override; |
304 virtual bool IsGuestSession() const override; | 300 bool IsGuestSession() const override; |
305 virtual void SetExitType(ExitType exit_type) override {} | 301 void SetExitType(ExitType exit_type) override {} |
306 virtual ExitType GetLastSessionExitType() override; | 302 ExitType GetLastSessionExitType() override; |
307 #if defined(OS_CHROMEOS) | 303 #if defined(OS_CHROMEOS) |
308 virtual void ChangeAppLocale(const std::string&, | 304 virtual void ChangeAppLocale(const std::string&, |
309 AppLocaleChangedVia) override { | 305 AppLocaleChangedVia) override { |
310 } | 306 } |
311 virtual void OnLogin() override { | 307 virtual void OnLogin() override { |
312 } | 308 } |
313 virtual void InitChromeOSPreferences() override { | 309 virtual void InitChromeOSPreferences() override { |
314 } | 310 } |
315 #endif // defined(OS_CHROMEOS) | 311 #endif // defined(OS_CHROMEOS) |
316 | 312 |
317 virtual PrefProxyConfigTracker* GetProxyConfigTracker() override; | 313 PrefProxyConfigTracker* GetProxyConfigTracker() override; |
318 | 314 |
319 // Schedules a task on the history backend and runs a nested loop until the | 315 // Schedules a task on the history backend and runs a nested loop until the |
320 // task is processed. This has the effect of blocking the caller until the | 316 // task is processed. This has the effect of blocking the caller until the |
321 // history service processes all pending requests. | 317 // history service processes all pending requests. |
322 void BlockUntilHistoryProcessesPendingRequests(); | 318 void BlockUntilHistoryProcessesPendingRequests(); |
323 | 319 |
324 virtual chrome_browser_net::Predictor* GetNetworkPredictor() override; | 320 chrome_browser_net::Predictor* GetNetworkPredictor() override; |
325 virtual DevToolsNetworkController* GetDevToolsNetworkController() override; | 321 DevToolsNetworkController* GetDevToolsNetworkController() override; |
326 virtual void ClearNetworkingHistorySince( | 322 void ClearNetworkingHistorySince(base::Time time, |
327 base::Time time, | 323 const base::Closure& completion) override; |
328 const base::Closure& completion) override; | 324 GURL GetHomePage() override; |
329 virtual GURL GetHomePage() override; | |
330 | 325 |
331 virtual PrefService* GetOffTheRecordPrefs() override; | 326 PrefService* GetOffTheRecordPrefs() override; |
332 | 327 |
333 void set_profile_name(const std::string& profile_name) { | 328 void set_profile_name(const std::string& profile_name) { |
334 profile_name_ = profile_name; | 329 profile_name_ = profile_name; |
335 } | 330 } |
336 | 331 |
337 protected: | 332 protected: |
338 base::Time start_time_; | 333 base::Time start_time_; |
339 scoped_ptr<PrefServiceSyncable> prefs_; | 334 scoped_ptr<PrefServiceSyncable> prefs_; |
340 // ref only for right type, lifecycle is managed by prefs_ | 335 // ref only for right type, lifecycle is managed by prefs_ |
341 TestingPrefServiceSyncable* testing_prefs_; | 336 TestingPrefServiceSyncable* testing_prefs_; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 | 408 |
414 // Weak pointer to a delegate for indicating that a profile was created. | 409 // Weak pointer to a delegate for indicating that a profile was created. |
415 Delegate* delegate_; | 410 Delegate* delegate_; |
416 | 411 |
417 std::string profile_name_; | 412 std::string profile_name_; |
418 | 413 |
419 scoped_ptr<policy::PolicyService> policy_service_; | 414 scoped_ptr<policy::PolicyService> policy_service_; |
420 }; | 415 }; |
421 | 416 |
422 #endif // CHROME_TEST_BASE_TESTING_PROFILE_H_ | 417 #endif // CHROME_TEST_BASE_TESTING_PROFILE_H_ |
OLD | NEW |