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

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

Issue 10828263: Moving FaviconService to a ProfileKeyedService. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 4 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 | Annotate | Revision Log
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 "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"
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/message_loop_proxy.h" 12 #include "base/message_loop_proxy.h"
13 #include "base/path_service.h" 13 #include "base/path_service.h"
14 #include "base/run_loop.h" 14 #include "base/run_loop.h"
15 #include "base/string_number_conversions.h" 15 #include "base/string_number_conversions.h"
16 #include "chrome/browser/autocomplete/autocomplete_classifier.h" 16 #include "chrome/browser/autocomplete/autocomplete_classifier.h"
17 #include "chrome/browser/bookmarks/bookmark_model.h" 17 #include "chrome/browser/bookmarks/bookmark_model.h"
18 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 18 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
19 #include "chrome/browser/browser_process.h" 19 #include "chrome/browser/browser_process.h"
20 #include "chrome/browser/content_settings/host_content_settings_map.h" 20 #include "chrome/browser/content_settings/host_content_settings_map.h"
21 #include "chrome/browser/extensions/extension_service.h" 21 #include "chrome/browser/extensions/extension_service.h"
22 #include "chrome/browser/extensions/extension_special_storage_policy.h" 22 #include "chrome/browser/extensions/extension_special_storage_policy.h"
23 #include "chrome/browser/extensions/extension_system.h" 23 #include "chrome/browser/extensions/extension_system.h"
24 #include "chrome/browser/extensions/extension_system_factory.h" 24 #include "chrome/browser/extensions/extension_system_factory.h"
25 #include "chrome/browser/extensions/test_extension_system.h" 25 #include "chrome/browser/extensions/test_extension_system.h"
26 #include "chrome/browser/favicon/favicon_service.h" 26 #include "chrome/browser/favicon/favicon_service.h"
27 #include "chrome/browser/favicon/favicon_service_factory.h"
27 #include "chrome/browser/geolocation/chrome_geolocation_permission_context.h" 28 #include "chrome/browser/geolocation/chrome_geolocation_permission_context.h"
28 #include "chrome/browser/history/history.h" 29 #include "chrome/browser/history/history.h"
29 #include "chrome/browser/history/history_backend.h" 30 #include "chrome/browser/history/history_backend.h"
30 #include "chrome/browser/history/history_service_factory.h" 31 #include "chrome/browser/history/history_service_factory.h"
31 #include "chrome/browser/history/shortcuts_backend.h" 32 #include "chrome/browser/history/shortcuts_backend.h"
32 #include "chrome/browser/history/shortcuts_backend_factory.h" 33 #include "chrome/browser/history/shortcuts_backend_factory.h"
33 #include "chrome/browser/history/top_sites.h" 34 #include "chrome/browser/history/top_sites.h"
34 #include "chrome/browser/net/proxy_service_factory.h" 35 #include "chrome/browser/net/proxy_service_factory.h"
35 #include "chrome/browser/notifications/desktop_notification_service.h" 36 #include "chrome/browser/notifications/desktop_notification_service.h"
36 #include "chrome/browser/notifications/desktop_notification_service_factory.h" 37 #include "chrome/browser/notifications/desktop_notification_service_factory.h"
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 291
291 TestingProfile::~TestingProfile() { 292 TestingProfile::~TestingProfile() {
292 MaybeSendDestroyedNotification(); 293 MaybeSendDestroyedNotification();
293 294
294 profile_dependency_manager_->DestroyProfileServices(this); 295 profile_dependency_manager_->DestroyProfileServices(this);
295 296
296 if (host_content_settings_map_) 297 if (host_content_settings_map_)
297 host_content_settings_map_->ShutdownOnUIThread(); 298 host_content_settings_map_->ShutdownOnUIThread();
298 299
299 DestroyTopSites(); 300 DestroyTopSites();
300 DestroyFaviconService();
301 301
302 if (pref_proxy_config_tracker_.get()) 302 if (pref_proxy_config_tracker_.get())
303 pref_proxy_config_tracker_->DetachFromPrefService(); 303 pref_proxy_config_tracker_->DetachFromPrefService();
304 } 304 }
305 305
306 static ProfileKeyedService* BuildFaviconService(Profile* profile) {
307 return new FaviconService(profile);
308 }
309
306 void TestingProfile::CreateFaviconService() { 310 void TestingProfile::CreateFaviconService() {
307 favicon_service_.reset(new FaviconService(this)); 311 FaviconServiceFactory::GetInstance()->SetTestingFactory(
312 this, BuildFaviconService);
308 } 313 }
309 314
310 static scoped_refptr<RefcountedProfileKeyedService> BuildHistoryService( 315 static scoped_refptr<RefcountedProfileKeyedService> BuildHistoryService(
311 Profile* profile) { 316 Profile* profile) {
312 return new HistoryService(profile); 317 return new HistoryService(profile);
313 } 318 }
314 319
315 void TestingProfile::CreateHistoryService(bool delete_file, bool no_db) { 320 void TestingProfile::CreateHistoryService(bool delete_file, bool no_db) {
316 DestroyHistoryService(); 321 DestroyHistoryService();
317 if (delete_file) { 322 if (delete_file) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 top_sites_->Shutdown(); 370 top_sites_->Shutdown();
366 top_sites_ = NULL; 371 top_sites_ = NULL;
367 // TopSites::Shutdown schedules some tasks (from TopSitesBackend) that need 372 // TopSites::Shutdown schedules some tasks (from TopSitesBackend) that need
368 // to be run to properly shutdown. Run all pending tasks now. This is 373 // to be run to properly shutdown. Run all pending tasks now. This is
369 // normally handled by browser_process shutdown. 374 // normally handled by browser_process shutdown.
370 if (MessageLoop::current()) 375 if (MessageLoop::current())
371 MessageLoop::current()->RunAllPending(); 376 MessageLoop::current()->RunAllPending();
372 } 377 }
373 } 378 }
374 379
375 void TestingProfile::DestroyFaviconService() {
376 favicon_service_.reset();
377 }
378
379 static ProfileKeyedService* BuildBookmarkModel(Profile* profile) { 380 static ProfileKeyedService* BuildBookmarkModel(Profile* profile) {
380 BookmarkModel* bookmark_model = new BookmarkModel(profile); 381 BookmarkModel* bookmark_model = new BookmarkModel(profile);
381 bookmark_model->Load(); 382 bookmark_model->Load();
382 return bookmark_model; 383 return bookmark_model;
383 } 384 }
384 385
385 386
386 void TestingProfile::CreateBookmarkModel(bool delete_file) { 387 void TestingProfile::CreateBookmarkModel(bool delete_file) {
387 388
388 if (delete_file) { 389 if (delete_file) {
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 extension_special_storage_policy_ = extension_special_storage_policy; 514 extension_special_storage_policy_ = extension_special_storage_policy;
514 } 515 }
515 516
516 ExtensionSpecialStoragePolicy* 517 ExtensionSpecialStoragePolicy*
517 TestingProfile::GetExtensionSpecialStoragePolicy() { 518 TestingProfile::GetExtensionSpecialStoragePolicy() {
518 if (!extension_special_storage_policy_.get()) 519 if (!extension_special_storage_policy_.get())
519 extension_special_storage_policy_ = new ExtensionSpecialStoragePolicy(NULL); 520 extension_special_storage_policy_ = new ExtensionSpecialStoragePolicy(NULL);
520 return extension_special_storage_policy_.get(); 521 return extension_special_storage_policy_.get();
521 } 522 }
522 523
523 FaviconService* TestingProfile::GetFaviconService(ServiceAccessType access) {
524 return favicon_service_.get();
525 }
526
527 net::CookieMonster* TestingProfile::GetCookieMonster() { 524 net::CookieMonster* TestingProfile::GetCookieMonster() {
528 if (!GetRequestContext()) 525 if (!GetRequestContext())
529 return NULL; 526 return NULL;
530 return GetRequestContext()->GetURLRequestContext()->cookie_store()-> 527 return GetRequestContext()->GetURLRequestContext()->cookie_store()->
531 GetCookieMonster(); 528 GetCookieMonster();
532 } 529 }
533 530
534 policy::UserCloudPolicyManager* TestingProfile::GetUserCloudPolicyManager() { 531 policy::UserCloudPolicyManager* TestingProfile::GetUserCloudPolicyManager() {
535 return user_cloud_policy_manager_.get(); 532 return user_cloud_policy_manager_.get();
536 } 533 }
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 build_called_ = true; 802 build_called_ = true;
806 return scoped_ptr<TestingProfile>(new TestingProfile( 803 return scoped_ptr<TestingProfile>(new TestingProfile(
807 path_, 804 path_,
808 delegate_, 805 delegate_,
809 extension_policy_, 806 extension_policy_,
810 pref_service_.Pass(), 807 pref_service_.Pass(),
811 user_cloud_policy_manager_.Pass())); 808 user_cloud_policy_manager_.Pass()));
812 } 809 }
813 810
814 811
OLDNEW
« chrome/browser/favicon/favicon_service.h ('K') | « chrome/test/base/testing_profile.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698