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/browser/profiles/profile_impl.h" | 5 #include "chrome/browser/profiles/profile_impl.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/environment.h" | 9 #include "base/environment.h" |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
14 #include "base/path_service.h" | 14 #include "base/path_service.h" |
15 #include "base/string_number_conversions.h" | 15 #include "base/string_number_conversions.h" |
16 #include "base/string_util.h" | 16 #include "base/string_util.h" |
17 #include "chrome/browser/autocomplete/autocomplete_classifier.h" | 17 #include "chrome/browser/autocomplete/autocomplete_classifier.h" |
18 #include "chrome/browser/autofill/personal_data_manager.h" | 18 #include "chrome/browser/autofill/personal_data_manager.h" |
19 #include "chrome/browser/background/background_contents_service_factory.h" | 19 #include "chrome/browser/background/background_contents_service_factory.h" |
20 #include "chrome/browser/background/background_mode_manager.h" | 20 #include "chrome/browser/background/background_mode_manager.h" |
21 #include "chrome/browser/bookmarks/bookmark_model.h" | 21 #include "chrome/browser/bookmarks/bookmark_model.h" |
22 #include "chrome/browser/browser_process.h" | 22 #include "chrome/browser/browser_process.h" |
23 #include "chrome/browser/browsing_data_remover.h" | 23 #include "chrome/browser/browsing_data_remover.h" |
| 24 #include "chrome/browser/chrome_plugin_service_filter.h" |
24 #include "chrome/browser/content_settings/host_content_settings_map.h" | 25 #include "chrome/browser/content_settings/host_content_settings_map.h" |
25 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" | 26 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
26 #include "chrome/browser/defaults.h" | 27 #include "chrome/browser/defaults.h" |
27 #include "chrome/browser/download/chrome_download_manager_delegate.h" | 28 #include "chrome/browser/download/chrome_download_manager_delegate.h" |
28 #include "chrome/browser/extensions/extension_devtools_manager.h" | 29 #include "chrome/browser/extensions/extension_devtools_manager.h" |
29 #include "chrome/browser/extensions/extension_error_reporter.h" | 30 #include "chrome/browser/extensions/extension_error_reporter.h" |
30 #include "chrome/browser/extensions/extension_event_router.h" | 31 #include "chrome/browser/extensions/extension_event_router.h" |
31 #include "chrome/browser/extensions/extension_info_map.h" | 32 #include "chrome/browser/extensions/extension_info_map.h" |
32 #include "chrome/browser/extensions/extension_message_service.h" | 33 #include "chrome/browser/extensions/extension_message_service.h" |
33 #include "chrome/browser/extensions/extension_pref_store.h" | 34 #include "chrome/browser/extensions/extension_pref_store.h" |
34 #include "chrome/browser/extensions/extension_process_manager.h" | 35 #include "chrome/browser/extensions/extension_process_manager.h" |
35 #include "chrome/browser/extensions/extension_service.h" | 36 #include "chrome/browser/extensions/extension_service.h" |
36 #include "chrome/browser/extensions/extension_settings.h" | 37 #include "chrome/browser/extensions/extension_settings.h" |
37 #include "chrome/browser/extensions/extension_special_storage_policy.h" | 38 #include "chrome/browser/extensions/extension_special_storage_policy.h" |
38 #include "chrome/browser/extensions/user_script_master.h" | 39 #include "chrome/browser/extensions/user_script_master.h" |
39 #include "chrome/browser/favicon/favicon_service.h" | 40 #include "chrome/browser/favicon/favicon_service.h" |
40 #include "chrome/browser/geolocation/chrome_geolocation_permission_context.h" | 41 #include "chrome/browser/geolocation/chrome_geolocation_permission_context.h" |
41 #include "chrome/browser/history/history.h" | 42 #include "chrome/browser/history/history.h" |
42 #include "chrome/browser/history/shortcuts_backend.h" | 43 #include "chrome/browser/history/shortcuts_backend.h" |
43 #include "chrome/browser/history/top_sites.h" | 44 #include "chrome/browser/history/top_sites.h" |
44 #include "chrome/browser/instant/instant_controller.h" | 45 #include "chrome/browser/instant/instant_controller.h" |
45 #include "chrome/browser/metrics/metrics_service.h" | 46 #include "chrome/browser/metrics/metrics_service.h" |
46 #include "chrome/browser/net/chrome_url_request_context.h" | 47 #include "chrome/browser/net/chrome_url_request_context.h" |
47 #include "chrome/browser/net/gaia/token_service.h" | 48 #include "chrome/browser/net/gaia/token_service.h" |
48 #include "chrome/browser/net/net_pref_observer.h" | 49 #include "chrome/browser/net/net_pref_observer.h" |
49 #include "chrome/browser/net/pref_proxy_config_service.h" | 50 #include "chrome/browser/net/pref_proxy_config_service.h" |
50 #include "chrome/browser/net/ssl_config_service_manager.h" | 51 #include "chrome/browser/net/ssl_config_service_manager.h" |
51 #include "chrome/browser/password_manager/password_store_default.h" | 52 #include "chrome/browser/password_manager/password_store_default.h" |
| 53 #include "chrome/browser/plugin_prefs.h" |
52 #include "chrome/browser/policy/configuration_policy_pref_store.h" | 54 #include "chrome/browser/policy/configuration_policy_pref_store.h" |
53 #include "chrome/browser/prefs/browser_prefs.h" | 55 #include "chrome/browser/prefs/browser_prefs.h" |
54 #include "chrome/browser/prefs/pref_value_store.h" | 56 #include "chrome/browser/prefs/pref_value_store.h" |
55 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 57 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
56 #include "chrome/browser/prerender/prerender_manager.h" | 58 #include "chrome/browser/prerender/prerender_manager.h" |
57 #include "chrome/browser/profiles/profile_dependency_manager.h" | 59 #include "chrome/browser/profiles/profile_dependency_manager.h" |
58 #include "chrome/browser/profiles/profile_manager.h" | 60 #include "chrome/browser/profiles/profile_manager.h" |
59 #include "chrome/browser/search_engines/template_url_fetcher.h" | 61 #include "chrome/browser/search_engines/template_url_fetcher.h" |
60 #include "chrome/browser/search_engines/template_url_service.h" | 62 #include "chrome/browser/search_engines/template_url_service.h" |
61 #include "chrome/browser/sessions/session_service_factory.h" | 63 #include "chrome/browser/sessions/session_service_factory.h" |
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 } | 654 } |
653 | 655 |
654 FilePath ProfileImpl::last_selected_directory() { | 656 FilePath ProfileImpl::last_selected_directory() { |
655 return GetPrefs()->GetFilePath(prefs::kSelectFileLastDirectory); | 657 return GetPrefs()->GetFilePath(prefs::kSelectFileLastDirectory); |
656 } | 658 } |
657 | 659 |
658 void ProfileImpl::set_last_selected_directory(const FilePath& path) { | 660 void ProfileImpl::set_last_selected_directory(const FilePath& path) { |
659 GetPrefs()->SetFilePath(prefs::kSelectFileLastDirectory, path); | 661 GetPrefs()->SetFilePath(prefs::kSelectFileLastDirectory, path); |
660 } | 662 } |
661 | 663 |
| 664 ProfileImpl::ProfileImpl() : ALLOW_THIS_IN_INITIALIZER_LIST(io_data_(this)) { |
| 665 ChromePluginServiceFilter::GetInstance()->RegisterResourceContext( |
| 666 PluginPrefs::GetForProfile(this), &GetResourceContext()); |
| 667 } |
| 668 |
662 ProfileImpl::~ProfileImpl() { | 669 ProfileImpl::~ProfileImpl() { |
663 NotificationService::current()->Notify( | 670 NotificationService::current()->Notify( |
664 chrome::NOTIFICATION_PROFILE_DESTROYED, | 671 chrome::NOTIFICATION_PROFILE_DESTROYED, |
665 Source<Profile>(this), | 672 Source<Profile>(this), |
666 NotificationService::NoDetails()); | 673 NotificationService::NoDetails()); |
667 | 674 |
668 if (appcache_service_ && clear_local_state_on_exit_) { | 675 if (appcache_service_ && clear_local_state_on_exit_) { |
669 BrowserThread::PostTask( | 676 BrowserThread::PostTask( |
670 BrowserThread::IO, FROM_HERE, | 677 BrowserThread::IO, FROM_HERE, |
671 NewRunnableMethod( | 678 NewRunnableMethod( |
672 appcache_service_.get(), | 679 appcache_service_.get(), |
673 &appcache::AppCacheService::set_clear_local_state_on_exit, | 680 &appcache::AppCacheService::set_clear_local_state_on_exit, |
674 true)); | 681 true)); |
675 } | 682 } |
676 | 683 |
677 if (webkit_context_.get()) | 684 if (webkit_context_.get()) |
678 webkit_context_->DeleteSessionOnlyData(); | 685 webkit_context_->DeleteSessionOnlyData(); |
679 | 686 |
680 StopCreateSessionServiceTimer(); | 687 StopCreateSessionServiceTimer(); |
681 | 688 |
682 // Remove pref observers | 689 // Remove pref observers |
683 pref_change_registrar_.RemoveAll(); | 690 pref_change_registrar_.RemoveAll(); |
684 | 691 |
685 // The sync service needs to be deleted before the services it calls. | 692 // The sync service needs to be deleted before the services it calls. |
686 // TODO(stevet): Make ProfileSyncService into a PKS and let the PDM take care | 693 // TODO(stevet): Make ProfileSyncService into a PKS and let the PDM take care |
687 // of the cleanup below. | 694 // of the cleanup below. |
688 sync_service_.reset(); | 695 sync_service_.reset(); |
689 | 696 |
| 697 ChromePluginServiceFilter::GetInstance()->UnregisterResourceContext( |
| 698 &GetResourceContext()); |
| 699 |
690 ProfileDependencyManager::GetInstance()->DestroyProfileServices(this); | 700 ProfileDependencyManager::GetInstance()->DestroyProfileServices(this); |
691 | 701 |
692 if (db_tracker_) { | 702 if (db_tracker_) { |
693 BrowserThread::PostTask( | 703 BrowserThread::PostTask( |
694 BrowserThread::FILE, FROM_HERE, | 704 BrowserThread::FILE, FROM_HERE, |
695 NewRunnableMethod( | 705 NewRunnableMethod( |
696 db_tracker_.get(), | 706 db_tracker_.get(), |
697 &webkit_database::DatabaseTracker::Shutdown)); | 707 &webkit_database::DatabaseTracker::Shutdown)); |
698 } | 708 } |
699 | 709 |
(...skipping 1028 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1728 #endif | 1738 #endif |
1729 } | 1739 } |
1730 return prerender_manager_.get(); | 1740 return prerender_manager_.get(); |
1731 } | 1741 } |
1732 | 1742 |
1733 SpellCheckProfile* ProfileImpl::GetSpellCheckProfile() { | 1743 SpellCheckProfile* ProfileImpl::GetSpellCheckProfile() { |
1734 if (!spellcheck_profile_.get()) | 1744 if (!spellcheck_profile_.get()) |
1735 spellcheck_profile_.reset(new SpellCheckProfile()); | 1745 spellcheck_profile_.reset(new SpellCheckProfile()); |
1736 return spellcheck_profile_.get(); | 1746 return spellcheck_profile_.get(); |
1737 } | 1747 } |
OLD | NEW |