Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(365)

Side by Side Diff: chrome/test/base/testing_profile.cc

Issue 996253002: [Fallback Icons] Refactor FallbackIconService to be a BrowserContext-level singleton (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Making FallbackIconSource take FallbackIconService directly. Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/bookmarks/bookmark_model_factory.h" 16 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
17 #include "chrome/browser/bookmarks/chrome_bookmark_client.h" 17 #include "chrome/browser/bookmarks/chrome_bookmark_client.h"
18 #include "chrome/browser/bookmarks/chrome_bookmark_client_factory.h" 18 #include "chrome/browser/bookmarks/chrome_bookmark_client_factory.h"
19 #include "chrome/browser/browser_process.h" 19 #include "chrome/browser/browser_process.h"
20 #include "chrome/browser/chrome_notification_types.h" 20 #include "chrome/browser/chrome_notification_types.h"
21 #include "chrome/browser/favicon/chrome_favicon_client_factory.h" 21 #include "chrome/browser/favicon/chrome_favicon_client_factory.h"
22 #include "chrome/browser/favicon/fallback_icon_service.h"
23 #include "chrome/browser/favicon/fallback_icon_service_factory.h"
22 #include "chrome/browser/favicon/favicon_service.h" 24 #include "chrome/browser/favicon/favicon_service.h"
23 #include "chrome/browser/favicon/favicon_service_factory.h" 25 #include "chrome/browser/favicon/favicon_service_factory.h"
24 #include "chrome/browser/history/chrome_history_client.h" 26 #include "chrome/browser/history/chrome_history_client.h"
25 #include "chrome/browser/history/chrome_history_client_factory.h" 27 #include "chrome/browser/history/chrome_history_client_factory.h"
26 #include "chrome/browser/history/content_visit_delegate.h" 28 #include "chrome/browser/history/content_visit_delegate.h"
27 #include "chrome/browser/history/history_backend.h" 29 #include "chrome/browser/history/history_backend.h"
28 #include "chrome/browser/history/history_service.h" 30 #include "chrome/browser/history/history_service.h"
29 #include "chrome/browser/history/history_service_factory.h" 31 #include "chrome/browser/history/history_service_factory.h"
30 #include "chrome/browser/history/top_sites_factory.h" 32 #include "chrome/browser/history/top_sites_factory.h"
31 #include "chrome/browser/history/top_sites_impl.h" 33 #include "chrome/browser/history/top_sites_impl.h"
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 scoped_ptr<net::URLRequestContext> context_; 206 scoped_ptr<net::URLRequestContext> context_;
205 }; 207 };
206 208
207 #if defined(ENABLE_NOTIFICATIONS) 209 #if defined(ENABLE_NOTIFICATIONS)
208 KeyedService* CreateTestDesktopNotificationService( 210 KeyedService* CreateTestDesktopNotificationService(
209 content::BrowserContext* profile) { 211 content::BrowserContext* profile) {
210 return new DesktopNotificationService(static_cast<Profile*>(profile)); 212 return new DesktopNotificationService(static_cast<Profile*>(profile));
211 } 213 }
212 #endif 214 #endif
213 215
216 KeyedService* BuildFallbackIconService(content::BrowserContext* profile) {
217 FallbackIconClient* fallback_icon_client =
218 ChromeFallbackIconClientFactory::GetForProfile(
219 static_cast<Profile*>(profile));
sdefresne 2015/03/17 09:41:52 nit: Profile::FromBrowserContext(profile)
huangs 2015/03/23 03:28:35 Done.
220 return new FallbackIconService(fallback_icon_client);
221 }
222
214 KeyedService* BuildFaviconService(content::BrowserContext* profile) { 223 KeyedService* BuildFaviconService(content::BrowserContext* profile) {
215 FaviconClient* favicon_client = 224 FaviconClient* favicon_client =
216 ChromeFaviconClientFactory::GetForProfile(static_cast<Profile*>(profile)); 225 ChromeFaviconClientFactory::GetForProfile(static_cast<Profile*>(profile));
217 return new FaviconService(static_cast<Profile*>(profile), favicon_client); 226 return new FaviconService(static_cast<Profile*>(profile), favicon_client);
218 } 227 }
219 228
220 KeyedService* BuildHistoryService(content::BrowserContext* context) { 229 KeyedService* BuildHistoryService(content::BrowserContext* context) {
221 Profile* profile = Profile::FromBrowserContext(context); 230 Profile* profile = Profile::FromBrowserContext(context);
222 HistoryService* history_service = new HistoryService( 231 HistoryService* history_service = new HistoryService(
223 ChromeHistoryClientFactory::GetForProfile(profile), 232 ChromeHistoryClientFactory::GetForProfile(profile),
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 // Failing a post == leaks == heapcheck failure. Make that an immediate test 556 // Failing a post == leaks == heapcheck failure. Make that an immediate test
548 // failure. 557 // failure.
549 if (resource_context_) { 558 if (resource_context_) {
550 CHECK(BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, 559 CHECK(BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE,
551 resource_context_)); 560 resource_context_));
552 resource_context_ = NULL; 561 resource_context_ = NULL;
553 content::RunAllPendingInMessageLoop(BrowserThread::IO); 562 content::RunAllPendingInMessageLoop(BrowserThread::IO);
554 } 563 }
555 } 564 }
556 565
566 void TestingProfile::CreateFallbackIconService() {
567 FaviconServiceFactory::GetInstance()->SetTestingFactory(
568 this, BuildFallbackIconService);
569 }
570
557 void TestingProfile::CreateFaviconService() { 571 void TestingProfile::CreateFaviconService() {
558 // It is up to the caller to create the history service if one is needed. 572 // It is up to the caller to create the history service if one is needed.
559 FaviconServiceFactory::GetInstance()->SetTestingFactory( 573 FaviconServiceFactory::GetInstance()->SetTestingFactory(
560 this, BuildFaviconService); 574 this, BuildFaviconService);
561 } 575 }
562 576
563 bool TestingProfile::CreateHistoryService(bool delete_file, bool no_db) { 577 bool TestingProfile::CreateHistoryService(bool delete_file, bool no_db) {
564 DestroyHistoryService(); 578 DestroyHistoryService();
565 if (delete_file) { 579 if (delete_file) {
566 base::FilePath path = GetPath(); 580 base::FilePath path = GetPath();
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
1101 #if defined(ENABLE_EXTENSIONS) 1115 #if defined(ENABLE_EXTENSIONS)
1102 extension_policy_, 1116 extension_policy_,
1103 #endif 1117 #endif
1104 pref_service_.Pass(), 1118 pref_service_.Pass(),
1105 original_profile, 1119 original_profile,
1106 guest_session_, 1120 guest_session_,
1107 supervised_user_id_, 1121 supervised_user_id_,
1108 policy_service_.Pass(), 1122 policy_service_.Pass(),
1109 testing_factories_); 1123 testing_factories_);
1110 } 1124 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698