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 "base/base_paths.h" | 7 #include "base/base_paths.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/message_loop/message_loop_proxy.h" | 10 #include "base/message_loop/message_loop_proxy.h" |
11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
12 #include "base/prefs/testing_pref_store.h" | 12 #include "base/prefs/testing_pref_store.h" |
13 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
15 #include "chrome/browser/autocomplete/autocomplete_classifier.h" | 15 #include "chrome/browser/autocomplete/autocomplete_classifier.h" |
16 #include "chrome/browser/autocomplete/in_memory_url_index.h" | 16 #include "chrome/browser/autocomplete/in_memory_url_index.h" |
17 #include "chrome/browser/autocomplete/in_memory_url_index_factory.h" | 17 #include "chrome/browser/autocomplete/in_memory_url_index_factory.h" |
18 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 18 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
19 #include "chrome/browser/bookmarks/chrome_bookmark_client.h" | 19 #include "chrome/browser/bookmarks/chrome_bookmark_client.h" |
20 #include "chrome/browser/bookmarks/chrome_bookmark_client_factory.h" | 20 #include "chrome/browser/bookmarks/chrome_bookmark_client_factory.h" |
21 #include "chrome/browser/browser_process.h" | 21 #include "chrome/browser/browser_process.h" |
22 #include "chrome/browser/chrome_notification_types.h" | 22 #include "chrome/browser/chrome_notification_types.h" |
| 23 #include "chrome/browser/favicon/chrome_fallback_icon_client_factory.h" |
23 #include "chrome/browser/favicon/chrome_favicon_client_factory.h" | 24 #include "chrome/browser/favicon/chrome_favicon_client_factory.h" |
| 25 #include "chrome/browser/favicon/fallback_icon_service_factory.h" |
24 #include "chrome/browser/favicon/favicon_service_factory.h" | 26 #include "chrome/browser/favicon/favicon_service_factory.h" |
25 #include "chrome/browser/history/chrome_history_client.h" | 27 #include "chrome/browser/history/chrome_history_client.h" |
26 #include "chrome/browser/history/chrome_history_client_factory.h" | 28 #include "chrome/browser/history/chrome_history_client_factory.h" |
27 #include "chrome/browser/history/history_service_factory.h" | 29 #include "chrome/browser/history/history_service_factory.h" |
28 #include "chrome/browser/history/top_sites_factory.h" | 30 #include "chrome/browser/history/top_sites_factory.h" |
29 #include "chrome/browser/history/top_sites_impl.h" | 31 #include "chrome/browser/history/top_sites_impl.h" |
30 #include "chrome/browser/history/web_history_service_factory.h" | 32 #include "chrome/browser/history/web_history_service_factory.h" |
31 #include "chrome/browser/net/pref_proxy_config_tracker.h" | 33 #include "chrome/browser/net/pref_proxy_config_tracker.h" |
32 #include "chrome/browser/net/proxy_service_factory.h" | 34 #include "chrome/browser/net/proxy_service_factory.h" |
33 #include "chrome/browser/notifications/desktop_notification_service.h" | 35 #include "chrome/browser/notifications/desktop_notification_service.h" |
(...skipping 13 matching lines...) Expand all Loading... |
47 #include "chrome/common/chrome_constants.h" | 49 #include "chrome/common/chrome_constants.h" |
48 #include "chrome/common/chrome_switches.h" | 50 #include "chrome/common/chrome_switches.h" |
49 #include "chrome/common/pref_names.h" | 51 #include "chrome/common/pref_names.h" |
50 #include "chrome/common/url_constants.h" | 52 #include "chrome/common/url_constants.h" |
51 #include "chrome/test/base/history_index_restore_observer.h" | 53 #include "chrome/test/base/history_index_restore_observer.h" |
52 #include "chrome/test/base/testing_pref_service_syncable.h" | 54 #include "chrome/test/base/testing_pref_service_syncable.h" |
53 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" | 55 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" |
54 #include "components/bookmarks/browser/bookmark_model.h" | 56 #include "components/bookmarks/browser/bookmark_model.h" |
55 #include "components/bookmarks/common/bookmark_constants.h" | 57 #include "components/bookmarks/common/bookmark_constants.h" |
56 #include "components/content_settings/core/browser/host_content_settings_map.h" | 58 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 59 #include "components/favicon/core/fallback_icon_service.h" |
57 #include "components/favicon/core/favicon_service.h" | 60 #include "components/favicon/core/favicon_service.h" |
58 #include "components/history/content/browser/content_visit_delegate.h" | 61 #include "components/history/content/browser/content_visit_delegate.h" |
59 #include "components/history/content/browser/history_database_helper.h" | 62 #include "components/history/content/browser/history_database_helper.h" |
60 #include "components/history/core/browser/history_backend.h" | 63 #include "components/history/core/browser/history_backend.h" |
61 #include "components/history/core/browser/history_constants.h" | 64 #include "components/history/core/browser/history_constants.h" |
62 #include "components/history/core/browser/history_database_params.h" | 65 #include "components/history/core/browser/history_database_params.h" |
63 #include "components/history/core/browser/history_db_task.h" | 66 #include "components/history/core/browser/history_db_task.h" |
64 #include "components/history/core/browser/history_service.h" | 67 #include "components/history/core/browser/history_service.h" |
65 #include "components/history/core/browser/top_sites.h" | 68 #include "components/history/core/browser/top_sites.h" |
66 #include "components/history/core/browser/top_sites_observer.h" | 69 #include "components/history/core/browser/top_sites_observer.h" |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 scoped_ptr<net::URLRequestContext> context_; | 209 scoped_ptr<net::URLRequestContext> context_; |
207 }; | 210 }; |
208 | 211 |
209 #if defined(ENABLE_NOTIFICATIONS) | 212 #if defined(ENABLE_NOTIFICATIONS) |
210 KeyedService* CreateTestDesktopNotificationService( | 213 KeyedService* CreateTestDesktopNotificationService( |
211 content::BrowserContext* profile) { | 214 content::BrowserContext* profile) { |
212 return new DesktopNotificationService(static_cast<Profile*>(profile)); | 215 return new DesktopNotificationService(static_cast<Profile*>(profile)); |
213 } | 216 } |
214 #endif | 217 #endif |
215 | 218 |
| 219 KeyedService* BuildFallbackIconService(content::BrowserContext* context) { |
| 220 Profile* profile = Profile::FromBrowserContext(context); |
| 221 return new FallbackIconService( |
| 222 ChromeFallbackIconClientFactory::GetForProfile(profile)); |
| 223 } |
| 224 |
216 KeyedService* BuildFaviconService(content::BrowserContext* context) { | 225 KeyedService* BuildFaviconService(content::BrowserContext* context) { |
217 Profile* profile = Profile::FromBrowserContext(context); | 226 Profile* profile = Profile::FromBrowserContext(context); |
218 return new FaviconService(ChromeFaviconClientFactory::GetForProfile(profile), | 227 return new FaviconService(ChromeFaviconClientFactory::GetForProfile(profile), |
219 HistoryServiceFactory::GetForProfile( | 228 HistoryServiceFactory::GetForProfile( |
220 profile, ServiceAccessType::EXPLICIT_ACCESS)); | 229 profile, ServiceAccessType::EXPLICIT_ACCESS)); |
221 } | 230 } |
222 | 231 |
223 KeyedService* BuildHistoryService(content::BrowserContext* context) { | 232 KeyedService* BuildHistoryService(content::BrowserContext* context) { |
224 Profile* profile = Profile::FromBrowserContext(context); | 233 Profile* profile = Profile::FromBrowserContext(context); |
225 history::HistoryService* history_service = new history::HistoryService( | 234 history::HistoryService* history_service = new history::HistoryService( |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 // Failing a post == leaks == heapcheck failure. Make that an immediate test | 572 // Failing a post == leaks == heapcheck failure. Make that an immediate test |
564 // failure. | 573 // failure. |
565 if (resource_context_) { | 574 if (resource_context_) { |
566 CHECK(BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, | 575 CHECK(BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, |
567 resource_context_)); | 576 resource_context_)); |
568 resource_context_ = NULL; | 577 resource_context_ = NULL; |
569 content::RunAllPendingInMessageLoop(BrowserThread::IO); | 578 content::RunAllPendingInMessageLoop(BrowserThread::IO); |
570 } | 579 } |
571 } | 580 } |
572 | 581 |
| 582 void TestingProfile::CreateFallbackIconService() { |
| 583 FaviconServiceFactory::GetInstance()->SetTestingFactory( |
| 584 this, BuildFallbackIconService); |
| 585 } |
| 586 |
573 void TestingProfile::CreateFaviconService() { | 587 void TestingProfile::CreateFaviconService() { |
574 // It is up to the caller to create the history service if one is needed. | 588 // It is up to the caller to create the history service if one is needed. |
575 FaviconServiceFactory::GetInstance()->SetTestingFactory( | 589 FaviconServiceFactory::GetInstance()->SetTestingFactory( |
576 this, BuildFaviconService); | 590 this, BuildFaviconService); |
577 } | 591 } |
578 | 592 |
579 bool TestingProfile::CreateHistoryService(bool delete_file, bool no_db) { | 593 bool TestingProfile::CreateHistoryService(bool delete_file, bool no_db) { |
580 DestroyHistoryService(); | 594 DestroyHistoryService(); |
581 if (delete_file) { | 595 if (delete_file) { |
582 base::FilePath path = GetPath(); | 596 base::FilePath path = GetPath(); |
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1123 #if defined(ENABLE_EXTENSIONS) | 1137 #if defined(ENABLE_EXTENSIONS) |
1124 extension_policy_, | 1138 extension_policy_, |
1125 #endif | 1139 #endif |
1126 pref_service_.Pass(), | 1140 pref_service_.Pass(), |
1127 original_profile, | 1141 original_profile, |
1128 guest_session_, | 1142 guest_session_, |
1129 supervised_user_id_, | 1143 supervised_user_id_, |
1130 policy_service_.Pass(), | 1144 policy_service_.Pass(), |
1131 testing_factories_); | 1145 testing_factories_); |
1132 } | 1146 } |
OLD | NEW |