Chromium Code Reviews| 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 15 matching lines...) Expand all Loading... | |
| 26 #include "chrome/browser/history/history.h" | 26 #include "chrome/browser/history/history.h" |
| 27 #include "chrome/browser/history/history_backend.h" | 27 #include "chrome/browser/history/history_backend.h" |
| 28 #include "chrome/browser/history/top_sites.h" | 28 #include "chrome/browser/history/top_sites.h" |
| 29 #include "chrome/browser/net/gaia/token_service.h" | 29 #include "chrome/browser/net/gaia/token_service.h" |
| 30 #include "chrome/browser/net/pref_proxy_config_service.h" | 30 #include "chrome/browser/net/pref_proxy_config_service.h" |
| 31 #include "chrome/browser/notifications/desktop_notification_service.h" | 31 #include "chrome/browser/notifications/desktop_notification_service.h" |
| 32 #include "chrome/browser/notifications/desktop_notification_service_factory.h" | 32 #include "chrome/browser/notifications/desktop_notification_service_factory.h" |
| 33 #include "chrome/browser/prefs/browser_prefs.h" | 33 #include "chrome/browser/prefs/browser_prefs.h" |
| 34 #include "chrome/browser/prefs/testing_pref_store.h" | 34 #include "chrome/browser/prefs/testing_pref_store.h" |
| 35 #include "chrome/browser/prerender/prerender_manager.h" | 35 #include "chrome/browser/prerender/prerender_manager.h" |
| 36 #include "chrome/browser/printing/print_preview_data_service.h" | |
| 37 #include "chrome/browser/printing/print_preview_data_service_factory.h" | |
| 36 #include "chrome/browser/profiles/profile_dependency_manager.h" | 38 #include "chrome/browser/profiles/profile_dependency_manager.h" |
| 37 #include "chrome/browser/search_engines/template_url_fetcher.h" | 39 #include "chrome/browser/search_engines/template_url_fetcher.h" |
| 38 #include "chrome/browser/search_engines/template_url_model.h" | 40 #include "chrome/browser/search_engines/template_url_model.h" |
| 39 #include "chrome/browser/sessions/session_service_factory.h" | 41 #include "chrome/browser/sessions/session_service_factory.h" |
| 40 #include "chrome/browser/sessions/tab_restore_service_factory.h" | 42 #include "chrome/browser/sessions/tab_restore_service_factory.h" |
| 41 #include "chrome/browser/sync/profile_sync_service_mock.h" | 43 #include "chrome/browser/sync/profile_sync_service_mock.h" |
| 42 #include "chrome/browser/ui/find_bar/find_bar_state.h" | 44 #include "chrome/browser/ui/find_bar/find_bar_state.h" |
| 43 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 45 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
| 44 #include "chrome/browser/ui/webui/ntp/ntp_resource_cache.h" | 46 #include "chrome/browser/ui/webui/ntp/ntp_resource_cache.h" |
| 45 #include "chrome/common/chrome_constants.h" | 47 #include "chrome/common/chrome_constants.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 111 } | 113 } |
| 112 | 114 |
| 113 private: | 115 private: |
| 114 scoped_refptr<net::URLRequestContext> context_; | 116 scoped_refptr<net::URLRequestContext> context_; |
| 115 }; | 117 }; |
| 116 | 118 |
| 117 ProfileKeyedService* CreateTestDesktopNotificationService(Profile* profile) { | 119 ProfileKeyedService* CreateTestDesktopNotificationService(Profile* profile) { |
| 118 return new DesktopNotificationService(profile, NULL); | 120 return new DesktopNotificationService(profile, NULL); |
| 119 } | 121 } |
| 120 | 122 |
| 123 ProfileKeyedService* CreateTestPrintPreviewDataService(Profile* profile) { | |
| 124 return new PrintPreviewDataService(); | |
| 125 } | |
| 126 | |
| 121 } // namespace | 127 } // namespace |
| 122 | 128 |
| 123 TestingProfile::TestingProfile() | 129 TestingProfile::TestingProfile() |
| 124 : start_time_(Time::Now()), | 130 : start_time_(Time::Now()), |
| 125 testing_prefs_(NULL), | 131 testing_prefs_(NULL), |
| 126 incognito_(false), | 132 incognito_(false), |
| 127 last_session_exited_cleanly_(true), | 133 last_session_exited_cleanly_(true), |
| 128 profile_dependency_manager_(ProfileDependencyManager::GetInstance()) { | 134 profile_dependency_manager_(ProfileDependencyManager::GetInstance()) { |
| 129 if (!temp_dir_.CreateUniqueTempDir()) { | 135 if (!temp_dir_.CreateUniqueTempDir()) { |
| 130 LOG(ERROR) << "Failed to create unique temporary directory."; | 136 LOG(ERROR) << "Failed to create unique temporary directory."; |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 152 | 158 |
| 153 // Install profile keyed service factory hooks for dummy/test services | 159 // Install profile keyed service factory hooks for dummy/test services |
| 154 BackgroundContentsServiceFactory::GetInstance()->ForceAssociationBetween( | 160 BackgroundContentsServiceFactory::GetInstance()->ForceAssociationBetween( |
| 155 this, NULL); | 161 this, NULL); |
| 156 DesktopNotificationServiceFactory::GetInstance()->set_test_factory( | 162 DesktopNotificationServiceFactory::GetInstance()->set_test_factory( |
| 157 &CreateTestDesktopNotificationService); | 163 &CreateTestDesktopNotificationService); |
| 158 DesktopNotificationServiceFactory::GetInstance()->ForceAssociationBetween( | 164 DesktopNotificationServiceFactory::GetInstance()->ForceAssociationBetween( |
| 159 this, NULL); | 165 this, NULL); |
| 160 SessionServiceFactory::GetInstance()->ForceAssociationBetween(this, NULL); | 166 SessionServiceFactory::GetInstance()->ForceAssociationBetween(this, NULL); |
| 161 TabRestoreServiceFactory::GetInstance()->ForceAssociationBetween(this, NULL); | 167 TabRestoreServiceFactory::GetInstance()->ForceAssociationBetween(this, NULL); |
| 168 PrintPreviewDataServiceFactory::GetInstance()->set_test_factory( | |
|
Lei Zhang
2011/05/27 17:26:53
nit: keep it in alphabetical order?
kmadhusu
2011/05/27 23:44:42
Done.
| |
| 169 &CreateTestPrintPreviewDataService); | |
| 162 } | 170 } |
| 163 | 171 |
| 164 TestingProfile::~TestingProfile() { | 172 TestingProfile::~TestingProfile() { |
| 165 NotificationService::current()->Notify( | 173 NotificationService::current()->Notify( |
| 166 NotificationType::PROFILE_DESTROYED, | 174 NotificationType::PROFILE_DESTROYED, |
| 167 Source<Profile>(static_cast<Profile*>(this)), | 175 Source<Profile>(static_cast<Profile*>(this)), |
| 168 NotificationService::NoDetails()); | 176 NotificationService::NoDetails()); |
| 169 | 177 |
| 170 profile_dependency_manager_->DestroyProfileServices(this); | 178 profile_dependency_manager_->DestroyProfileServices(this); |
| 171 | 179 |
| (...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 776 } | 784 } |
| 777 | 785 |
| 778 DerivedTestingProfile::DerivedTestingProfile(Profile* profile) | 786 DerivedTestingProfile::DerivedTestingProfile(Profile* profile) |
| 779 : original_profile_(profile) {} | 787 : original_profile_(profile) {} |
| 780 | 788 |
| 781 DerivedTestingProfile::~DerivedTestingProfile() {} | 789 DerivedTestingProfile::~DerivedTestingProfile() {} |
| 782 | 790 |
| 783 ProfileId DerivedTestingProfile::GetRuntimeId() { | 791 ProfileId DerivedTestingProfile::GetRuntimeId() { |
| 784 return original_profile_->GetRuntimeId(); | 792 return original_profile_->GetRuntimeId(); |
| 785 } | 793 } |
| OLD | NEW |