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

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: resyncing with library after revert Created 8 years, 3 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
« no previous file with comments | « chrome/test/base/testing_profile.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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(
308 HistoryServiceFactory::GetForProfileWithoutCreating(profile));
309 }
310
306 void TestingProfile::CreateFaviconService() { 311 void TestingProfile::CreateFaviconService() {
307 favicon_service_.reset(new FaviconService(this)); 312 // It is up to the caller to create the history service if one is needed.
313 FaviconServiceFactory::GetInstance()->SetTestingFactory(
314 this, BuildFaviconService);
308 } 315 }
309 316
310 static scoped_refptr<RefcountedProfileKeyedService> BuildHistoryService( 317 static scoped_refptr<RefcountedProfileKeyedService> BuildHistoryService(
311 Profile* profile) { 318 Profile* profile) {
312 return new HistoryService(profile); 319 return new HistoryService(profile);
313 } 320 }
314 321
315 void TestingProfile::CreateHistoryService(bool delete_file, bool no_db) { 322 void TestingProfile::CreateHistoryService(bool delete_file, bool no_db) {
316 DestroyHistoryService(); 323 DestroyHistoryService();
317 if (delete_file) { 324 if (delete_file) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 top_sites_->Shutdown(); 372 top_sites_->Shutdown();
366 top_sites_ = NULL; 373 top_sites_ = NULL;
367 // TopSites::Shutdown schedules some tasks (from TopSitesBackend) that need 374 // TopSites::Shutdown schedules some tasks (from TopSitesBackend) that need
368 // to be run to properly shutdown. Run all pending tasks now. This is 375 // to be run to properly shutdown. Run all pending tasks now. This is
369 // normally handled by browser_process shutdown. 376 // normally handled by browser_process shutdown.
370 if (MessageLoop::current()) 377 if (MessageLoop::current())
371 MessageLoop::current()->RunAllPending(); 378 MessageLoop::current()->RunAllPending();
372 } 379 }
373 } 380 }
374 381
375 void TestingProfile::DestroyFaviconService() {
376 favicon_service_.reset();
377 }
378
379 static ProfileKeyedService* BuildBookmarkModel(Profile* profile) { 382 static ProfileKeyedService* BuildBookmarkModel(Profile* profile) {
380 BookmarkModel* bookmark_model = new BookmarkModel(profile); 383 BookmarkModel* bookmark_model = new BookmarkModel(profile);
381 bookmark_model->Load(); 384 bookmark_model->Load();
382 return bookmark_model; 385 return bookmark_model;
383 } 386 }
384 387
385 388
386 void TestingProfile::CreateBookmarkModel(bool delete_file) { 389 void TestingProfile::CreateBookmarkModel(bool delete_file) {
387 390
388 if (delete_file) { 391 if (delete_file) {
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 extension_special_storage_policy_ = extension_special_storage_policy; 516 extension_special_storage_policy_ = extension_special_storage_policy;
514 } 517 }
515 518
516 ExtensionSpecialStoragePolicy* 519 ExtensionSpecialStoragePolicy*
517 TestingProfile::GetExtensionSpecialStoragePolicy() { 520 TestingProfile::GetExtensionSpecialStoragePolicy() {
518 if (!extension_special_storage_policy_.get()) 521 if (!extension_special_storage_policy_.get())
519 extension_special_storage_policy_ = new ExtensionSpecialStoragePolicy(NULL); 522 extension_special_storage_policy_ = new ExtensionSpecialStoragePolicy(NULL);
520 return extension_special_storage_policy_.get(); 523 return extension_special_storage_policy_.get();
521 } 524 }
522 525
523 FaviconService* TestingProfile::GetFaviconService(ServiceAccessType access) {
524 return favicon_service_.get();
525 }
526
527 net::CookieMonster* TestingProfile::GetCookieMonster() { 526 net::CookieMonster* TestingProfile::GetCookieMonster() {
528 if (!GetRequestContext()) 527 if (!GetRequestContext())
529 return NULL; 528 return NULL;
530 return GetRequestContext()->GetURLRequestContext()->cookie_store()-> 529 return GetRequestContext()->GetURLRequestContext()->cookie_store()->
531 GetCookieMonster(); 530 GetCookieMonster();
532 } 531 }
533 532
534 policy::UserCloudPolicyManager* TestingProfile::GetUserCloudPolicyManager() { 533 policy::UserCloudPolicyManager* TestingProfile::GetUserCloudPolicyManager() {
535 return user_cloud_policy_manager_.get(); 534 return user_cloud_policy_manager_.get();
536 } 535 }
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 build_called_ = true; 810 build_called_ = true;
812 return scoped_ptr<TestingProfile>(new TestingProfile( 811 return scoped_ptr<TestingProfile>(new TestingProfile(
813 path_, 812 path_,
814 delegate_, 813 delegate_,
815 extension_policy_, 814 extension_policy_,
816 pref_service_.Pass(), 815 pref_service_.Pass(),
817 user_cloud_policy_manager_.Pass())); 816 user_cloud_policy_manager_.Pass()));
818 } 817 }
819 818
820 819
OLDNEW
« no previous file with comments | « chrome/test/base/testing_profile.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698