OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "chrome/test/testing_profile.h" | 5 #include "chrome/test/testing_profile.h" |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 | 8 |
9 #include "base/base_paths.h" | 9 #include "base/base_paths.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 | 242 |
243 // Make sure we don't have any event pending that could disrupt the next | 243 // Make sure we don't have any event pending that could disrupt the next |
244 // test. | 244 // test. |
245 MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask); | 245 MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask); |
246 MessageLoop::current()->Run(); | 246 MessageLoop::current()->Run(); |
247 } | 247 } |
248 | 248 |
249 void TestingProfile::CreateTopSites() { | 249 void TestingProfile::CreateTopSites() { |
250 DestroyTopSites(); | 250 DestroyTopSites(); |
251 top_sites_ = new history::TopSites(this); | 251 top_sites_ = new history::TopSites(this); |
252 FilePath file_name = temp_dir_.path().Append(chrome::kTopSitesFilename); | 252 FilePath file_name = GetPath().Append(chrome::kTopSitesFilename); |
253 top_sites_->Init(file_name); | 253 top_sites_->Init(file_name); |
254 } | 254 } |
255 | 255 |
256 void TestingProfile::DestroyTopSites() { | 256 void TestingProfile::DestroyTopSites() { |
257 if (top_sites_.get()) { | 257 if (top_sites_.get()) { |
258 top_sites_->Shutdown(); | 258 top_sites_->Shutdown(); |
259 top_sites_ = NULL; | 259 top_sites_ = NULL; |
260 // TopSites::Shutdown schedules some tasks (from TopSitesBackend) that need | 260 // TopSites::Shutdown schedules some tasks (from TopSitesBackend) that need |
261 // to be run to properly shutdown. Run all pending tasks now. This is | 261 // to be run to properly shutdown. Run all pending tasks now. This is |
262 // normally handled by browser_process shutdown. | 262 // normally handled by browser_process shutdown. |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 | 340 |
341 void TestingProfile::UseThemeProvider(BrowserThemeProvider* theme_provider) { | 341 void TestingProfile::UseThemeProvider(BrowserThemeProvider* theme_provider) { |
342 theme_provider->Init(this); | 342 theme_provider->Init(this); |
343 created_theme_provider_ = true; | 343 created_theme_provider_ = true; |
344 theme_provider_.reset(theme_provider); | 344 theme_provider_.reset(theme_provider); |
345 } | 345 } |
346 | 346 |
347 scoped_refptr<ExtensionsService> TestingProfile::CreateExtensionsService( | 347 scoped_refptr<ExtensionsService> TestingProfile::CreateExtensionsService( |
348 const CommandLine* command_line, | 348 const CommandLine* command_line, |
349 const FilePath& install_directory) { | 349 const FilePath& install_directory) { |
| 350 extension_prefs_.reset(new ExtensionPrefs( |
| 351 this, |
| 352 GetPrefs(), |
| 353 install_directory)); |
350 extensions_service_ = new ExtensionsService(this, | 354 extensions_service_ = new ExtensionsService(this, |
351 command_line, | 355 command_line, |
352 install_directory, | 356 install_directory, |
| 357 extension_prefs_.get(), |
353 false); | 358 false); |
354 return extensions_service_; | 359 return extensions_service_; |
355 } | 360 } |
356 | 361 |
357 FilePath TestingProfile::GetPath() { | 362 FilePath TestingProfile::GetPath() { |
358 DCHECK(temp_dir_.IsValid()); // TODO(phajdan.jr): do it better. | 363 DCHECK(temp_dir_.IsValid()); // TODO(phajdan.jr): do it better. |
359 return temp_dir_.path(); | 364 return temp_dir_.path(); |
360 } | 365 } |
361 | 366 |
362 TestingPrefService* TestingProfile::GetTestingPrefService() { | 367 TestingPrefService* TestingProfile::GetTestingPrefService() { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 browser::RegisterAllPrefs(prefs_.get(), prefs_.get()); | 412 browser::RegisterAllPrefs(prefs_.get(), prefs_.get()); |
408 } | 413 } |
409 | 414 |
410 PrefService* TestingProfile::GetPrefs() { | 415 PrefService* TestingProfile::GetPrefs() { |
411 if (!prefs_.get()) { | 416 if (!prefs_.get()) { |
412 CreateTestingPrefService(); | 417 CreateTestingPrefService(); |
413 } | 418 } |
414 return prefs_.get(); | 419 return prefs_.get(); |
415 } | 420 } |
416 | 421 |
| 422 PrefStore* TestingProfile::GetExtensionPrefStore() { |
| 423 return ext_pref_store_; |
| 424 } |
| 425 |
| 426 void TestingProfile::SetExtensionPrefStore(PrefStore* ext_pref_store) { |
| 427 ext_pref_store_ = ext_pref_store; |
| 428 } |
| 429 |
417 history::TopSites* TestingProfile::GetTopSites() { | 430 history::TopSites* TestingProfile::GetTopSites() { |
418 return top_sites_.get(); | 431 return top_sites_.get(); |
419 } | 432 } |
420 | 433 |
421 URLRequestContextGetter* TestingProfile::GetRequestContext() { | 434 URLRequestContextGetter* TestingProfile::GetRequestContext() { |
422 return request_context_.get(); | 435 return request_context_.get(); |
423 } | 436 } |
424 | 437 |
425 void TestingProfile::CreateRequestContext() { | 438 void TestingProfile::CreateRequestContext() { |
426 if (!request_context_) | 439 if (!request_context_) |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
530 } | 543 } |
531 return profile_sync_service_.get(); | 544 return profile_sync_service_.get(); |
532 } | 545 } |
533 | 546 |
534 void TestingProfile::DestroyWebDataService() { | 547 void TestingProfile::DestroyWebDataService() { |
535 if (!web_data_service_.get()) | 548 if (!web_data_service_.get()) |
536 return; | 549 return; |
537 | 550 |
538 web_data_service_->Shutdown(); | 551 web_data_service_->Shutdown(); |
539 } | 552 } |
OLD | NEW |