| 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 17 matching lines...) Expand all Loading... |
| 28 #include "chrome/browser/net/gaia/token_service.h" | 28 #include "chrome/browser/net/gaia/token_service.h" |
| 29 #include "chrome/browser/net/pref_proxy_config_service.h" | 29 #include "chrome/browser/net/pref_proxy_config_service.h" |
| 30 #include "chrome/browser/notifications/desktop_notification_service.h" | 30 #include "chrome/browser/notifications/desktop_notification_service.h" |
| 31 #include "chrome/browser/notifications/desktop_notification_service_factory.h" | 31 #include "chrome/browser/notifications/desktop_notification_service_factory.h" |
| 32 #include "chrome/browser/prefs/browser_prefs.h" | 32 #include "chrome/browser/prefs/browser_prefs.h" |
| 33 #include "chrome/browser/prefs/testing_pref_store.h" | 33 #include "chrome/browser/prefs/testing_pref_store.h" |
| 34 #include "chrome/browser/prerender/prerender_manager.h" | 34 #include "chrome/browser/prerender/prerender_manager.h" |
| 35 #include "chrome/browser/profiles/profile_dependency_manager.h" | 35 #include "chrome/browser/profiles/profile_dependency_manager.h" |
| 36 #include "chrome/browser/search_engines/template_url_fetcher.h" | 36 #include "chrome/browser/search_engines/template_url_fetcher.h" |
| 37 #include "chrome/browser/search_engines/template_url_model.h" | 37 #include "chrome/browser/search_engines/template_url_model.h" |
| 38 #include "chrome/browser/sessions/session_service.h" | 38 #include "chrome/browser/sessions/session_service_factory.h" |
| 39 #include "chrome/browser/sessions/tab_restore_service_factory.h" |
| 39 #include "chrome/browser/sync/profile_sync_service_mock.h" | 40 #include "chrome/browser/sync/profile_sync_service_mock.h" |
| 40 #include "chrome/browser/ui/find_bar/find_bar_state.h" | 41 #include "chrome/browser/ui/find_bar/find_bar_state.h" |
| 41 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 42 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
| 42 #include "chrome/browser/ui/webui/ntp_resource_cache.h" | 43 #include "chrome/browser/ui/webui/ntp_resource_cache.h" |
| 43 #include "chrome/common/chrome_constants.h" | 44 #include "chrome/common/chrome_constants.h" |
| 44 #include "chrome/common/url_constants.h" | 45 #include "chrome/common/url_constants.h" |
| 45 #include "chrome/test/test_url_request_context_getter.h" | 46 #include "chrome/test/test_url_request_context_getter.h" |
| 46 #include "chrome/test/testing_pref_service.h" | 47 #include "chrome/test/testing_pref_service.h" |
| 47 #include "chrome/test/ui_test_utils.h" | 48 #include "chrome/test/ui_test_utils.h" |
| 48 #include "content/browser/browser_thread.h" | 49 #include "content/browser/browser_thread.h" |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 } | 181 } |
| 181 } | 182 } |
| 182 | 183 |
| 183 // Install profile keyed service factory hooks for dummy/test services | 184 // Install profile keyed service factory hooks for dummy/test services |
| 184 BackgroundContentsServiceFactory::GetInstance()->ForceAssociationBetween( | 185 BackgroundContentsServiceFactory::GetInstance()->ForceAssociationBetween( |
| 185 this, NULL); | 186 this, NULL); |
| 186 DesktopNotificationServiceFactory::GetInstance()->set_test_factory( | 187 DesktopNotificationServiceFactory::GetInstance()->set_test_factory( |
| 187 &CreateTestDesktopNotificationService); | 188 &CreateTestDesktopNotificationService); |
| 188 DesktopNotificationServiceFactory::GetInstance()->ForceAssociationBetween( | 189 DesktopNotificationServiceFactory::GetInstance()->ForceAssociationBetween( |
| 189 this, NULL); | 190 this, NULL); |
| 191 SessionServiceFactory::GetInstance()->ForceAssociationBetween(this, NULL); |
| 192 TabRestoreServiceFactory::GetInstance()->ForceAssociationBetween(this, NULL); |
| 190 } | 193 } |
| 191 | 194 |
| 192 TestingProfile::~TestingProfile() { | 195 TestingProfile::~TestingProfile() { |
| 193 NotificationService::current()->Notify( | 196 NotificationService::current()->Notify( |
| 194 NotificationType::PROFILE_DESTROYED, | 197 NotificationType::PROFILE_DESTROYED, |
| 195 Source<Profile>(static_cast<Profile*>(this)), | 198 Source<Profile>(static_cast<Profile*>(this)), |
| 196 NotificationService::NoDetails()); | 199 NotificationService::NoDetails()); |
| 197 | 200 |
| 198 profile_dependency_manager_->DestroyProfileServices(this); | 201 profile_dependency_manager_->DestroyProfileServices(this); |
| 199 | 202 |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 630 geolocation_permission_context_ = | 633 geolocation_permission_context_ = |
| 631 new GeolocationPermissionContext(this); | 634 new GeolocationPermissionContext(this); |
| 632 } | 635 } |
| 633 return geolocation_permission_context_.get(); | 636 return geolocation_permission_context_.get(); |
| 634 } | 637 } |
| 635 | 638 |
| 636 HostZoomMap* TestingProfile::GetHostZoomMap() { | 639 HostZoomMap* TestingProfile::GetHostZoomMap() { |
| 637 return NULL; | 640 return NULL; |
| 638 } | 641 } |
| 639 | 642 |
| 640 SessionService* TestingProfile::GetSessionService() { | |
| 641 return session_service_.get(); | |
| 642 } | |
| 643 | |
| 644 bool TestingProfile::HasSessionService() const { | |
| 645 return (session_service_.get() != NULL); | |
| 646 } | |
| 647 | |
| 648 bool TestingProfile::HasProfileSyncService() const { | 643 bool TestingProfile::HasProfileSyncService() const { |
| 649 return (profile_sync_service_.get() != NULL); | 644 return (profile_sync_service_.get() != NULL); |
| 650 } | 645 } |
| 651 | 646 |
| 652 std::wstring TestingProfile::GetName() { | 647 std::wstring TestingProfile::GetName() { |
| 653 return std::wstring(); | 648 return std::wstring(); |
| 654 } | 649 } |
| 655 | 650 |
| 656 std::wstring TestingProfile::GetID() { | 651 std::wstring TestingProfile::GetID() { |
| 657 return id_; | 652 return id_; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 670 } | 665 } |
| 671 | 666 |
| 672 bool TestingProfile::IsSameProfile(Profile *p) { | 667 bool TestingProfile::IsSameProfile(Profile *p) { |
| 673 return this == p; | 668 return this == p; |
| 674 } | 669 } |
| 675 | 670 |
| 676 base::Time TestingProfile::GetStartTime() const { | 671 base::Time TestingProfile::GetStartTime() const { |
| 677 return start_time_; | 672 return start_time_; |
| 678 } | 673 } |
| 679 | 674 |
| 680 TabRestoreService* TestingProfile::GetTabRestoreService() { | |
| 681 return NULL; | |
| 682 } | |
| 683 | |
| 684 ProtocolHandlerRegistry* TestingProfile::GetProtocolHandlerRegistry() { | 675 ProtocolHandlerRegistry* TestingProfile::GetProtocolHandlerRegistry() { |
| 685 return protocol_handler_registry_.get(); | 676 return protocol_handler_registry_.get(); |
| 686 } | 677 } |
| 687 | 678 |
| 688 SpellCheckHost* TestingProfile::GetSpellCheckHost() { | 679 SpellCheckHost* TestingProfile::GetSpellCheckHost() { |
| 689 return NULL; | 680 return NULL; |
| 690 } | 681 } |
| 691 | 682 |
| 692 void TestingProfile::set_session_service(SessionService* session_service) { | |
| 693 session_service_.reset(session_service); | |
| 694 } | |
| 695 | |
| 696 WebKitContext* TestingProfile::GetWebKitContext() { | 683 WebKitContext* TestingProfile::GetWebKitContext() { |
| 697 if (webkit_context_ == NULL) { | 684 if (webkit_context_ == NULL) { |
| 698 webkit_context_ = new WebKitContext( | 685 webkit_context_ = new WebKitContext( |
| 699 IsOffTheRecord(), GetPath(), | 686 IsOffTheRecord(), GetPath(), |
| 700 GetExtensionSpecialStoragePolicy(), | 687 GetExtensionSpecialStoragePolicy(), |
| 701 false); | 688 false); |
| 702 } | 689 } |
| 703 return webkit_context_; | 690 return webkit_context_; |
| 704 } | 691 } |
| 705 | 692 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 814 } | 801 } |
| 815 | 802 |
| 816 DerivedTestingProfile::DerivedTestingProfile(Profile* profile) | 803 DerivedTestingProfile::DerivedTestingProfile(Profile* profile) |
| 817 : original_profile_(profile) {} | 804 : original_profile_(profile) {} |
| 818 | 805 |
| 819 DerivedTestingProfile::~DerivedTestingProfile() {} | 806 DerivedTestingProfile::~DerivedTestingProfile() {} |
| 820 | 807 |
| 821 ProfileId DerivedTestingProfile::GetRuntimeId() { | 808 ProfileId DerivedTestingProfile::GetRuntimeId() { |
| 822 return original_profile_->GetRuntimeId(); | 809 return original_profile_->GetRuntimeId(); |
| 823 } | 810 } |
| OLD | NEW |