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 #include "chrome/test/base/testing_profile.h" | 5 #include "chrome/test/base/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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 base::Unretained(this))); | 199 base::Unretained(this))); |
200 } else { | 200 } else { |
201 FinishInit(); | 201 FinishInit(); |
202 } | 202 } |
203 } | 203 } |
204 | 204 |
205 TestingProfile::TestingProfile( | 205 TestingProfile::TestingProfile( |
206 const FilePath& path, | 206 const FilePath& path, |
207 Delegate* delegate, | 207 Delegate* delegate, |
208 scoped_refptr<ExtensionSpecialStoragePolicy> extension_policy, | 208 scoped_refptr<ExtensionSpecialStoragePolicy> extension_policy, |
209 scoped_ptr<PrefService> prefs) | 209 scoped_ptr<PrefServiceSyncable> prefs) |
210 : start_time_(Time::Now()), | 210 : start_time_(Time::Now()), |
211 prefs_(prefs.release()), | 211 prefs_(prefs.release()), |
212 testing_prefs_(NULL), | 212 testing_prefs_(NULL), |
213 incognito_(false), | 213 incognito_(false), |
214 last_session_exited_cleanly_(true), | 214 last_session_exited_cleanly_(true), |
215 extension_special_storage_policy_(extension_policy), | 215 extension_special_storage_policy_(extension_policy), |
216 profile_path_(path), | 216 profile_path_(path), |
217 profile_dependency_manager_(ProfileDependencyManager::GetInstance()), | 217 profile_dependency_manager_(ProfileDependencyManager::GetInstance()), |
218 delegate_(delegate) { | 218 delegate_(delegate) { |
219 | 219 |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 } | 467 } |
468 | 468 |
469 FilePath TestingProfile::GetPath() { | 469 FilePath TestingProfile::GetPath() { |
470 return profile_path_; | 470 return profile_path_; |
471 } | 471 } |
472 | 472 |
473 scoped_refptr<base::SequencedTaskRunner> TestingProfile::GetIOTaskRunner() { | 473 scoped_refptr<base::SequencedTaskRunner> TestingProfile::GetIOTaskRunner() { |
474 return MessageLoop::current()->message_loop_proxy(); | 474 return MessageLoop::current()->message_loop_proxy(); |
475 } | 475 } |
476 | 476 |
477 TestingPrefService* TestingProfile::GetTestingPrefService() { | 477 TestingPrefServiceSyncable* TestingProfile::GetTestingPrefService() { |
478 if (!prefs_.get()) | 478 if (!prefs_.get()) |
479 CreateTestingPrefService(); | 479 CreateTestingPrefService(); |
480 DCHECK(testing_prefs_); | 480 DCHECK(testing_prefs_); |
481 return testing_prefs_; | 481 return testing_prefs_; |
482 } | 482 } |
483 | 483 |
484 TestingProfile* TestingProfile::AsTestingProfile() { | 484 TestingProfile* TestingProfile::AsTestingProfile() { |
485 return this; | 485 return this; |
486 } | 486 } |
487 | 487 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
546 #if defined(ENABLE_CONFIGURATION_POLICY) | 546 #if defined(ENABLE_CONFIGURATION_POLICY) |
547 policy::PolicyServiceImpl::Providers providers; | 547 policy::PolicyServiceImpl::Providers providers; |
548 policy_service_.reset(new policy::PolicyServiceImpl(providers)); | 548 policy_service_.reset(new policy::PolicyServiceImpl(providers)); |
549 #else | 549 #else |
550 policy_service_.reset(new policy::PolicyServiceStub()); | 550 policy_service_.reset(new policy::PolicyServiceStub()); |
551 #endif | 551 #endif |
552 } | 552 } |
553 return policy_service_.get(); | 553 return policy_service_.get(); |
554 } | 554 } |
555 | 555 |
556 void TestingProfile::SetPrefService(PrefService* prefs) { | 556 void TestingProfile::SetPrefService(PrefServiceSyncable* prefs) { |
557 prefs_.reset(prefs); | 557 prefs_.reset(prefs); |
558 } | 558 } |
559 | 559 |
560 void TestingProfile::CreateTestingPrefService() { | 560 void TestingProfile::CreateTestingPrefService() { |
561 DCHECK(!prefs_.get()); | 561 DCHECK(!prefs_.get()); |
562 testing_prefs_ = new TestingPrefService(); | 562 testing_prefs_ = new TestingPrefServiceSyncable(); |
563 prefs_.reset(testing_prefs_); | 563 prefs_.reset(testing_prefs_); |
564 Profile::RegisterUserPrefs(prefs_.get()); | 564 Profile::RegisterUserPrefs(prefs_.get()); |
565 chrome::RegisterUserPrefs(prefs_.get()); | 565 chrome::RegisterUserPrefs(prefs_.get()); |
566 } | 566 } |
567 | 567 |
568 PrefService* TestingProfile::GetPrefs() { | 568 PrefServiceSyncable* TestingProfile::GetPrefs() { |
569 if (!prefs_.get()) { | 569 if (!prefs_.get()) { |
570 CreateTestingPrefService(); | 570 CreateTestingPrefService(); |
571 } | 571 } |
572 return prefs_.get(); | 572 return prefs_.get(); |
573 } | 573 } |
574 | 574 |
575 history::TopSites* TestingProfile::GetTopSites() { | 575 history::TopSites* TestingProfile::GetTopSites() { |
576 return top_sites_.get(); | 576 return top_sites_.get(); |
577 } | 577 } |
578 | 578 |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
744 const base::Closure& completion) { | 744 const base::Closure& completion) { |
745 if (!completion.is_null()) { | 745 if (!completion.is_null()) { |
746 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, completion); | 746 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, completion); |
747 } | 747 } |
748 } | 748 } |
749 | 749 |
750 GURL TestingProfile::GetHomePage() { | 750 GURL TestingProfile::GetHomePage() { |
751 return GURL(chrome::kChromeUINewTabURL); | 751 return GURL(chrome::kChromeUINewTabURL); |
752 } | 752 } |
753 | 753 |
754 PrefService* TestingProfile::GetOffTheRecordPrefs() { | 754 PrefServiceSyncable* TestingProfile::GetOffTheRecordPrefs() { |
755 return NULL; | 755 return NULL; |
756 } | 756 } |
757 | 757 |
758 quota::SpecialStoragePolicy* TestingProfile::GetSpecialStoragePolicy() { | 758 quota::SpecialStoragePolicy* TestingProfile::GetSpecialStoragePolicy() { |
759 return GetExtensionSpecialStoragePolicy(); | 759 return GetExtensionSpecialStoragePolicy(); |
760 } | 760 } |
761 | 761 |
762 bool TestingProfile::WasCreatedByVersionOrLater(const std::string& version) { | 762 bool TestingProfile::WasCreatedByVersionOrLater(const std::string& version) { |
763 return true; | 763 return true; |
764 } | 764 } |
(...skipping 21 matching lines...) Expand all Loading... |
786 | 786 |
787 void TestingProfile::Builder::SetDelegate(Delegate* delegate) { | 787 void TestingProfile::Builder::SetDelegate(Delegate* delegate) { |
788 delegate_ = delegate; | 788 delegate_ = delegate; |
789 } | 789 } |
790 | 790 |
791 void TestingProfile::Builder::SetExtensionSpecialStoragePolicy( | 791 void TestingProfile::Builder::SetExtensionSpecialStoragePolicy( |
792 scoped_refptr<ExtensionSpecialStoragePolicy> policy) { | 792 scoped_refptr<ExtensionSpecialStoragePolicy> policy) { |
793 extension_policy_ = policy; | 793 extension_policy_ = policy; |
794 } | 794 } |
795 | 795 |
796 void TestingProfile::Builder::SetPrefService(scoped_ptr<PrefService> prefs) { | 796 void TestingProfile::Builder::SetPrefService( |
| 797 scoped_ptr<PrefServiceSyncable> prefs) { |
797 pref_service_ = prefs.Pass(); | 798 pref_service_ = prefs.Pass(); |
798 } | 799 } |
799 | 800 |
800 scoped_ptr<TestingProfile> TestingProfile::Builder::Build() { | 801 scoped_ptr<TestingProfile> TestingProfile::Builder::Build() { |
801 DCHECK(!build_called_); | 802 DCHECK(!build_called_); |
802 build_called_ = true; | 803 build_called_ = true; |
803 return scoped_ptr<TestingProfile>(new TestingProfile( | 804 return scoped_ptr<TestingProfile>(new TestingProfile( |
804 path_, | 805 path_, |
805 delegate_, | 806 delegate_, |
806 extension_policy_, | 807 extension_policy_, |
807 pref_service_.Pass())); | 808 pref_service_.Pass())); |
808 } | 809 } |
OLD | NEW |