| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 return theme_provider_.get(); | 487 return theme_provider_.get(); |
| 488 } | 488 } |
| 489 | 489 |
| 490 void TestingProfile::SetPrefService(PrefService* prefs) { | 490 void TestingProfile::SetPrefService(PrefService* prefs) { |
| 491 DCHECK(!prefs_.get()); | 491 DCHECK(!prefs_.get()); |
| 492 prefs_.reset(prefs); | 492 prefs_.reset(prefs); |
| 493 } | 493 } |
| 494 | 494 |
| 495 void TestingProfile::CreateTestingPrefService() { | 495 void TestingProfile::CreateTestingPrefService() { |
| 496 DCHECK(!prefs_.get()); | 496 DCHECK(!prefs_.get()); |
| 497 testing_prefs_ = new TestingPrefService(); | 497 if (!prefs_.get()) { |
| 498 prefs_.reset(testing_prefs_); | 498 testing_prefs_ = new TestingPrefService(); |
| 499 prefs_.reset(testing_prefs_); |
| 500 } |
| 499 Profile::RegisterUserPrefs(prefs_.get()); | 501 Profile::RegisterUserPrefs(prefs_.get()); |
| 500 browser::RegisterAllPrefs(prefs_.get(), prefs_.get()); | 502 if (!local_state_.get()) |
| 503 local_state_.reset(new TestingPrefService()); |
| 504 browser::RegisterAllPrefs(prefs_.get(), local_state_.get()); |
| 501 } | 505 } |
| 502 | 506 |
| 503 PrefService* TestingProfile::GetPrefs() { | 507 PrefService* TestingProfile::GetPrefs() { |
| 504 if (!prefs_.get()) { | 508 if (!prefs_.get()) { |
| 505 CreateTestingPrefService(); | 509 CreateTestingPrefService(); |
| 506 } | 510 } |
| 507 return prefs_.get(); | 511 return prefs_.get(); |
| 508 } | 512 } |
| 509 | 513 |
| 514 PrefService* TestingProfile::GetLocalState() { |
| 515 if (!local_state_.get()) { |
| 516 CreateTestingPrefService(); |
| 517 } |
| 518 return local_state_.get(); |
| 519 } |
| 520 |
| 521 void TestingProfile::SetLocalState(PrefService* local_state) { |
| 522 DCHECK(!local_state_.get()); |
| 523 local_state_.reset(local_state); |
| 524 } |
| 525 |
| 510 TemplateURLModel* TestingProfile::GetTemplateURLModel() { | 526 TemplateURLModel* TestingProfile::GetTemplateURLModel() { |
| 511 return template_url_model_.get(); | 527 return template_url_model_.get(); |
| 512 } | 528 } |
| 513 | 529 |
| 514 TemplateURLFetcher* TestingProfile::GetTemplateURLFetcher() { | 530 TemplateURLFetcher* TestingProfile::GetTemplateURLFetcher() { |
| 515 return template_url_fetcher_.get(); | 531 return template_url_fetcher_.get(); |
| 516 } | 532 } |
| 517 | 533 |
| 518 history::TopSites* TestingProfile::GetTopSites() { | 534 history::TopSites* TestingProfile::GetTopSites() { |
| 519 return top_sites_.get(); | 535 return top_sites_.get(); |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 783 } | 799 } |
| 784 | 800 |
| 785 DerivedTestingProfile::DerivedTestingProfile(Profile* profile) | 801 DerivedTestingProfile::DerivedTestingProfile(Profile* profile) |
| 786 : original_profile_(profile) {} | 802 : original_profile_(profile) {} |
| 787 | 803 |
| 788 DerivedTestingProfile::~DerivedTestingProfile() {} | 804 DerivedTestingProfile::~DerivedTestingProfile() {} |
| 789 | 805 |
| 790 ProfileId DerivedTestingProfile::GetRuntimeId() { | 806 ProfileId DerivedTestingProfile::GetRuntimeId() { |
| 791 return original_profile_->GetRuntimeId(); | 807 return original_profile_->GetRuntimeId(); |
| 792 } | 808 } |
| OLD | NEW |