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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 } | 158 } |
157 } | 159 } |
158 | 160 |
159 // Install profile keyed service factory hooks for dummy/test services | 161 // Install profile keyed service factory hooks for dummy/test services |
160 BackgroundContentsServiceFactory::GetInstance()->ForceAssociationBetween( | 162 BackgroundContentsServiceFactory::GetInstance()->ForceAssociationBetween( |
161 this, NULL); | 163 this, NULL); |
162 DesktopNotificationServiceFactory::GetInstance()->set_test_factory( | 164 DesktopNotificationServiceFactory::GetInstance()->set_test_factory( |
163 &CreateTestDesktopNotificationService); | 165 &CreateTestDesktopNotificationService); |
164 DesktopNotificationServiceFactory::GetInstance()->ForceAssociationBetween( | 166 DesktopNotificationServiceFactory::GetInstance()->ForceAssociationBetween( |
165 this, NULL); | 167 this, NULL); |
| 168 PrintPreviewDataServiceFactory::GetInstance()->ForceAssociationBetween(this, |
| 169 CreateTestPrintPreviewDataService()); |
166 SessionServiceFactory::GetInstance()->ForceAssociationBetween(this, NULL); | 170 SessionServiceFactory::GetInstance()->ForceAssociationBetween(this, NULL); |
167 TabRestoreServiceFactory::GetInstance()->ForceAssociationBetween(this, NULL); | 171 TabRestoreServiceFactory::GetInstance()->ForceAssociationBetween(this, NULL); |
168 } | 172 } |
169 | 173 |
170 TestingProfile::~TestingProfile() { | 174 TestingProfile::~TestingProfile() { |
171 NotificationService::current()->Notify( | 175 NotificationService::current()->Notify( |
172 NotificationType::PROFILE_DESTROYED, | 176 NotificationType::PROFILE_DESTROYED, |
173 Source<Profile>(static_cast<Profile*>(this)), | 177 Source<Profile>(static_cast<Profile*>(this)), |
174 NotificationService::NoDetails()); | 178 NotificationService::NoDetails()); |
175 | 179 |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 } | 485 } |
482 | 486 |
483 void TestingProfile::CreateTestingPrefService() { | 487 void TestingProfile::CreateTestingPrefService() { |
484 DCHECK(!prefs_.get()); | 488 DCHECK(!prefs_.get()); |
485 testing_prefs_ = new TestingPrefService(); | 489 testing_prefs_ = new TestingPrefService(); |
486 prefs_.reset(testing_prefs_); | 490 prefs_.reset(testing_prefs_); |
487 Profile::RegisterUserPrefs(prefs_.get()); | 491 Profile::RegisterUserPrefs(prefs_.get()); |
488 browser::RegisterUserPrefs(prefs_.get()); | 492 browser::RegisterUserPrefs(prefs_.get()); |
489 } | 493 } |
490 | 494 |
| 495 ProfileKeyedService* TestingProfile::CreateTestPrintPreviewDataService() { |
| 496 return new PrintPreviewDataService(); |
| 497 } |
| 498 |
491 PrefService* TestingProfile::GetPrefs() { | 499 PrefService* TestingProfile::GetPrefs() { |
492 if (!prefs_.get()) { | 500 if (!prefs_.get()) { |
493 CreateTestingPrefService(); | 501 CreateTestingPrefService(); |
494 } | 502 } |
495 return prefs_.get(); | 503 return prefs_.get(); |
496 } | 504 } |
497 | 505 |
498 TemplateURLModel* TestingProfile::GetTemplateURLModel() { | 506 TemplateURLModel* TestingProfile::GetTemplateURLModel() { |
499 return template_url_model_.get(); | 507 return template_url_model_.get(); |
500 } | 508 } |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
794 } | 802 } |
795 | 803 |
796 DerivedTestingProfile::DerivedTestingProfile(Profile* profile) | 804 DerivedTestingProfile::DerivedTestingProfile(Profile* profile) |
797 : original_profile_(profile) {} | 805 : original_profile_(profile) {} |
798 | 806 |
799 DerivedTestingProfile::~DerivedTestingProfile() {} | 807 DerivedTestingProfile::~DerivedTestingProfile() {} |
800 | 808 |
801 ProfileId DerivedTestingProfile::GetRuntimeId() { | 809 ProfileId DerivedTestingProfile::GetRuntimeId() { |
802 return original_profile_->GetRuntimeId(); | 810 return original_profile_->GetRuntimeId(); |
803 } | 811 } |
OLD | NEW |