| 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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 } | 120 } |
| 121 | 121 |
| 122 private: | 122 private: |
| 123 scoped_refptr<net::URLRequestContext> context_; | 123 scoped_refptr<net::URLRequestContext> context_; |
| 124 }; | 124 }; |
| 125 | 125 |
| 126 ProfileKeyedBase* CreateTestDesktopNotificationService(Profile* profile) { | 126 ProfileKeyedBase* CreateTestDesktopNotificationService(Profile* profile) { |
| 127 return new DesktopNotificationService(profile, NULL); | 127 return new DesktopNotificationService(profile, NULL); |
| 128 } | 128 } |
| 129 | 129 |
| 130 fileapi::FileSystemOptions CreateTestingFileSystemOptions(bool is_incognito) { | |
| 131 return fileapi::FileSystemOptions( | |
| 132 is_incognito | |
| 133 ? fileapi::FileSystemOptions::PROFILE_MODE_INCOGNITO | |
| 134 : fileapi::FileSystemOptions::PROFILE_MODE_NORMAL, | |
| 135 std::vector<std::string>()); | |
| 136 } | |
| 137 | |
| 138 } // namespace | 130 } // namespace |
| 139 | 131 |
| 140 TestingProfile::TestingProfile() | 132 TestingProfile::TestingProfile() |
| 141 : start_time_(Time::Now()), | 133 : start_time_(Time::Now()), |
| 142 testing_prefs_(NULL), | 134 testing_prefs_(NULL), |
| 143 incognito_(false), | 135 incognito_(false), |
| 144 last_session_exited_cleanly_(true), | 136 last_session_exited_cleanly_(true), |
| 145 profile_dependency_manager_(ProfileDependencyManager::GetInstance()), | 137 profile_dependency_manager_(ProfileDependencyManager::GetInstance()), |
| 146 delegate_(NULL) { | 138 delegate_(NULL) { |
| 147 if (!temp_dir_.CreateUniqueTempDir()) { | 139 if (!temp_dir_.CreateUniqueTempDir()) { |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 host_content_settings_map_->ShutdownOnUIThread(); | 229 host_content_settings_map_->ShutdownOnUIThread(); |
| 238 | 230 |
| 239 DestroyTopSites(); | 231 DestroyTopSites(); |
| 240 DestroyHistoryService(); | 232 DestroyHistoryService(); |
| 241 // FaviconService depends on HistoryServce so destroying it later. | 233 // FaviconService depends on HistoryServce so destroying it later. |
| 242 DestroyFaviconService(); | 234 DestroyFaviconService(); |
| 243 DestroyWebDataService(); | 235 DestroyWebDataService(); |
| 244 | 236 |
| 245 if (pref_proxy_config_tracker_.get()) | 237 if (pref_proxy_config_tracker_.get()) |
| 246 pref_proxy_config_tracker_->DetachFromPrefService(); | 238 pref_proxy_config_tracker_->DetachFromPrefService(); |
| 247 | |
| 248 // Close the handles so that proper cleanup can be done. | |
| 249 db_tracker_ = NULL; | |
| 250 } | 239 } |
| 251 | 240 |
| 252 void TestingProfile::CreateFaviconService() { | 241 void TestingProfile::CreateFaviconService() { |
| 253 favicon_service_.reset(new FaviconService(this)); | 242 favicon_service_.reset(new FaviconService(this)); |
| 254 } | 243 } |
| 255 | 244 |
| 256 void TestingProfile::CreateHistoryService(bool delete_file, bool no_db) { | 245 void TestingProfile::CreateHistoryService(bool delete_file, bool no_db) { |
| 257 DestroyHistoryService(); | 246 DestroyHistoryService(); |
| 258 if (delete_file) { | 247 if (delete_file) { |
| 259 FilePath path = GetPath(); | 248 FilePath path = GetPath(); |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 } | 456 } |
| 468 | 457 |
| 469 bool TestingProfile::HasOffTheRecordProfile() { | 458 bool TestingProfile::HasOffTheRecordProfile() { |
| 470 return incognito_profile_.get() != NULL; | 459 return incognito_profile_.get() != NULL; |
| 471 } | 460 } |
| 472 | 461 |
| 473 Profile* TestingProfile::GetOriginalProfile() { | 462 Profile* TestingProfile::GetOriginalProfile() { |
| 474 return this; | 463 return this; |
| 475 } | 464 } |
| 476 | 465 |
| 477 void TestingProfile::SetAppCacheService( | |
| 478 ChromeAppCacheService* appcache_service) { | |
| 479 appcache_service_ = appcache_service; | |
| 480 } | |
| 481 | |
| 482 ChromeAppCacheService* TestingProfile::GetAppCacheService() { | |
| 483 return appcache_service_.get(); | |
| 484 } | |
| 485 | |
| 486 webkit_database::DatabaseTracker* TestingProfile::GetDatabaseTracker() { | |
| 487 if (!db_tracker_) { | |
| 488 db_tracker_ = new webkit_database::DatabaseTracker( | |
| 489 GetPath(), false, false, GetExtensionSpecialStoragePolicy(), | |
| 490 NULL, NULL); | |
| 491 } | |
| 492 return db_tracker_; | |
| 493 } | |
| 494 | |
| 495 VisitedLinkMaster* TestingProfile::GetVisitedLinkMaster() { | 466 VisitedLinkMaster* TestingProfile::GetVisitedLinkMaster() { |
| 496 return NULL; | 467 return NULL; |
| 497 } | 468 } |
| 498 | 469 |
| 499 ExtensionService* TestingProfile::GetExtensionService() { | 470 ExtensionService* TestingProfile::GetExtensionService() { |
| 500 return extension_service_.get(); | 471 return extension_service_.get(); |
| 501 } | 472 } |
| 502 | 473 |
| 503 UserScriptMaster* TestingProfile::GetUserScriptMaster() { | 474 UserScriptMaster* TestingProfile::GetUserScriptMaster() { |
| 504 return NULL; | 475 return NULL; |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 } | 570 } |
| 600 | 571 |
| 601 history::TopSites* TestingProfile::GetTopSitesWithoutCreating() { | 572 history::TopSites* TestingProfile::GetTopSitesWithoutCreating() { |
| 602 return top_sites_.get(); | 573 return top_sites_.get(); |
| 603 } | 574 } |
| 604 | 575 |
| 605 DownloadManager* TestingProfile::GetDownloadManager() { | 576 DownloadManager* TestingProfile::GetDownloadManager() { |
| 606 return NULL; | 577 return NULL; |
| 607 } | 578 } |
| 608 | 579 |
| 609 fileapi::FileSystemContext* TestingProfile::GetFileSystemContext() { | |
| 610 if (!file_system_context_) { | |
| 611 file_system_context_ = new fileapi::FileSystemContext( | |
| 612 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), | |
| 613 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), | |
| 614 GetExtensionSpecialStoragePolicy(), | |
| 615 NULL, | |
| 616 GetPath(), | |
| 617 CreateTestingFileSystemOptions(IsOffTheRecord())); | |
| 618 } | |
| 619 return file_system_context_.get(); | |
| 620 } | |
| 621 | |
| 622 void TestingProfile::SetQuotaManager(quota::QuotaManager* manager) { | |
| 623 quota_manager_ = manager; | |
| 624 } | |
| 625 | |
| 626 quota::QuotaManager* TestingProfile::GetQuotaManager() { | |
| 627 return quota_manager_.get(); | |
| 628 } | |
| 629 | |
| 630 net::URLRequestContextGetter* TestingProfile::GetRequestContext() { | 580 net::URLRequestContextGetter* TestingProfile::GetRequestContext() { |
| 631 return request_context_.get(); | 581 return request_context_.get(); |
| 632 } | 582 } |
| 633 | 583 |
| 634 net::URLRequestContextGetter* TestingProfile::GetRequestContextForRenderProcess( | 584 net::URLRequestContextGetter* TestingProfile::GetRequestContextForRenderProcess( |
| 635 int renderer_child_id) { | 585 int renderer_child_id) { |
| 636 if (extension_service_.get()) { | 586 if (extension_service_.get()) { |
| 637 const Extension* installed_app = extension_service_-> | 587 const Extension* installed_app = extension_service_-> |
| 638 GetInstalledAppForRenderer(renderer_child_id); | 588 GetInstalledAppForRenderer(renderer_child_id); |
| 639 if (installed_app != NULL && installed_app->is_storage_isolated()) | 589 if (installed_app != NULL && installed_app->is_storage_isolated()) |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 733 } | 683 } |
| 734 | 684 |
| 735 base::Time TestingProfile::GetStartTime() const { | 685 base::Time TestingProfile::GetStartTime() const { |
| 736 return start_time_; | 686 return start_time_; |
| 737 } | 687 } |
| 738 | 688 |
| 739 ProtocolHandlerRegistry* TestingProfile::GetProtocolHandlerRegistry() { | 689 ProtocolHandlerRegistry* TestingProfile::GetProtocolHandlerRegistry() { |
| 740 return protocol_handler_registry_.get(); | 690 return protocol_handler_registry_.get(); |
| 741 } | 691 } |
| 742 | 692 |
| 743 WebKitContext* TestingProfile::GetWebKitContext() { | |
| 744 if (webkit_context_ == NULL) { | |
| 745 webkit_context_ = new WebKitContext( | |
| 746 IsOffTheRecord(), GetPath(), | |
| 747 GetExtensionSpecialStoragePolicy(), | |
| 748 false, NULL, NULL); | |
| 749 } | |
| 750 return webkit_context_; | |
| 751 } | |
| 752 | |
| 753 WebKitContext* TestingProfile::GetOffTheRecordWebKitContext() { | 693 WebKitContext* TestingProfile::GetOffTheRecordWebKitContext() { |
| 754 return NULL; | 694 return NULL; |
| 755 } | 695 } |
| 756 | 696 |
| 757 FilePath TestingProfile::last_selected_directory() { | 697 FilePath TestingProfile::last_selected_directory() { |
| 758 return last_selected_directory_; | 698 return last_selected_directory_; |
| 759 } | 699 } |
| 760 | 700 |
| 761 void TestingProfile::set_last_selected_directory(const FilePath& path) { | 701 void TestingProfile::set_last_selected_directory(const FilePath& path) { |
| 762 last_selected_directory_ = path; | 702 last_selected_directory_ = path; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 779 MessageLoop::current()->Run(); | 719 MessageLoop::current()->Run(); |
| 780 } | 720 } |
| 781 | 721 |
| 782 TokenService* TestingProfile::GetTokenService() { | 722 TokenService* TestingProfile::GetTokenService() { |
| 783 if (!token_service_.get()) { | 723 if (!token_service_.get()) { |
| 784 token_service_.reset(new TokenService()); | 724 token_service_.reset(new TokenService()); |
| 785 } | 725 } |
| 786 return token_service_.get(); | 726 return token_service_.get(); |
| 787 } | 727 } |
| 788 | 728 |
| 789 ChromeBlobStorageContext* TestingProfile::GetBlobStorageContext() { | |
| 790 return NULL; | |
| 791 } | |
| 792 | |
| 793 ExtensionInfoMap* TestingProfile::GetExtensionInfoMap() { | 729 ExtensionInfoMap* TestingProfile::GetExtensionInfoMap() { |
| 794 return NULL; | 730 return NULL; |
| 795 } | 731 } |
| 796 | 732 |
| 797 PromoCounter* TestingProfile::GetInstantPromoCounter() { | 733 PromoCounter* TestingProfile::GetInstantPromoCounter() { |
| 798 return NULL; | 734 return NULL; |
| 799 } | 735 } |
| 800 | 736 |
| 801 ChromeURLDataManager* TestingProfile::GetChromeURLDataManager() { | 737 ChromeURLDataManager* TestingProfile::GetChromeURLDataManager() { |
| 802 if (!chrome_url_data_manager_.get()) | 738 if (!chrome_url_data_manager_.get()) |
| (...skipping 22 matching lines...) Expand all Loading... |
| 825 quota::SpecialStoragePolicy* TestingProfile::GetSpecialStoragePolicy() { | 761 quota::SpecialStoragePolicy* TestingProfile::GetSpecialStoragePolicy() { |
| 826 return GetExtensionSpecialStoragePolicy(); | 762 return GetExtensionSpecialStoragePolicy(); |
| 827 } | 763 } |
| 828 | 764 |
| 829 void TestingProfile::DestroyWebDataService() { | 765 void TestingProfile::DestroyWebDataService() { |
| 830 if (!web_data_service_.get()) | 766 if (!web_data_service_.get()) |
| 831 return; | 767 return; |
| 832 | 768 |
| 833 web_data_service_->Shutdown(); | 769 web_data_service_->Shutdown(); |
| 834 } | 770 } |
| OLD | NEW |