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 "base/utf_string_conversions.h" | 17 #include "base/utf_string_conversions.h" |
18 #include "chrome/browser/autocomplete/autocomplete_classifier.h" | 18 #include "chrome/browser/autocomplete/autocomplete_classifier.h" |
19 #include "chrome/browser/autofill/personal_data_manager.h" | 19 #include "chrome/browser/autofill/personal_data_manager.h" |
20 #include "chrome/browser/background/background_contents_service_factory.h" | 20 #include "chrome/browser/background/background_contents_service_factory.h" |
21 #include "chrome/browser/background/background_mode_manager.h" | 21 #include "chrome/browser/background/background_mode_manager.h" |
22 #include "chrome/browser/bookmarks/bookmark_model.h" | 22 #include "chrome/browser/bookmarks/bookmark_model.h" |
23 #include "chrome/browser/browser_process.h" | 23 #include "chrome/browser/browser_process.h" |
24 #include "chrome/browser/browsing_data_remover.h" | 24 #include "chrome/browser/browsing_data_remover.h" |
25 #include "chrome/browser/chrome_plugin_service_filter.h" | 25 #include "chrome/browser/chrome_plugin_service_filter.h" |
26 #include "chrome/browser/content_settings/host_content_settings_map.h" | 26 #include "chrome/browser/content_settings/host_content_settings_map.h" |
27 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" | 27 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
28 #include "chrome/browser/defaults.h" | 28 #include "chrome/browser/defaults.h" |
29 #include "chrome/browser/download/chrome_download_manager_delegate.h" | 29 #include "chrome/browser/download/download_service.h" |
30 #include "chrome/browser/download/download_service_factory.h" | |
30 #include "chrome/browser/extensions/extension_devtools_manager.h" | 31 #include "chrome/browser/extensions/extension_devtools_manager.h" |
31 #include "chrome/browser/extensions/extension_error_reporter.h" | 32 #include "chrome/browser/extensions/extension_error_reporter.h" |
32 #include "chrome/browser/extensions/extension_event_router.h" | 33 #include "chrome/browser/extensions/extension_event_router.h" |
33 #include "chrome/browser/extensions/extension_info_map.h" | 34 #include "chrome/browser/extensions/extension_info_map.h" |
34 #include "chrome/browser/extensions/extension_message_service.h" | 35 #include "chrome/browser/extensions/extension_message_service.h" |
35 #include "chrome/browser/extensions/extension_navigation_observer.h" | 36 #include "chrome/browser/extensions/extension_navigation_observer.h" |
36 #include "chrome/browser/extensions/extension_pref_store.h" | 37 #include "chrome/browser/extensions/extension_pref_store.h" |
37 #include "chrome/browser/extensions/extension_process_manager.h" | 38 #include "chrome/browser/extensions/extension_process_manager.h" |
38 #include "chrome/browser/extensions/extension_service.h" | 39 #include "chrome/browser/extensions/extension_service.h" |
39 #include "chrome/browser/extensions/extension_settings_backend.h" | 40 #include "chrome/browser/extensions/extension_settings_backend.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
87 #include "chrome/common/chrome_paths_internal.h" | 88 #include "chrome/common/chrome_paths_internal.h" |
88 #include "chrome/common/chrome_switches.h" | 89 #include "chrome/common/chrome_switches.h" |
89 #include "chrome/common/extensions/extension_permission_set.h" | 90 #include "chrome/common/extensions/extension_permission_set.h" |
90 #include "chrome/common/json_pref_store.h" | 91 #include "chrome/common/json_pref_store.h" |
91 #include "chrome/common/pref_names.h" | 92 #include "chrome/common/pref_names.h" |
92 #include "chrome/common/render_messages.h" | 93 #include "chrome/common/render_messages.h" |
93 #include "chrome/common/spellcheck_messages.h" | 94 #include "chrome/common/spellcheck_messages.h" |
94 #include "content/browser/appcache/chrome_appcache_service.h" | 95 #include "content/browser/appcache/chrome_appcache_service.h" |
95 #include "content/browser/browser_thread.h" | 96 #include "content/browser/browser_thread.h" |
96 #include "content/browser/chrome_blob_storage_context.h" | 97 #include "content/browser/chrome_blob_storage_context.h" |
97 #include "content/browser/download/download_manager.h" | |
98 #include "content/browser/file_system/browser_file_system_helper.h" | 98 #include "content/browser/file_system/browser_file_system_helper.h" |
99 #include "content/browser/host_zoom_map.h" | 99 #include "content/browser/host_zoom_map.h" |
100 #include "content/browser/in_process_webkit/webkit_context.h" | 100 #include "content/browser/in_process_webkit/webkit_context.h" |
101 #include "content/browser/renderer_host/render_process_host.h" | 101 #include "content/browser/renderer_host/render_process_host.h" |
102 #include "content/browser/speech/speech_input_manager.h" | 102 #include "content/browser/speech/speech_input_manager.h" |
103 #include "content/browser/ssl/ssl_host_state.h" | 103 #include "content/browser/ssl/ssl_host_state.h" |
104 #include "content/browser/user_metrics.h" | 104 #include "content/browser/user_metrics.h" |
105 #include "content/common/notification_service.h" | 105 #include "content/common/notification_service.h" |
106 #include "grit/browser_resources.h" | 106 #include "grit/browser_resources.h" |
107 #include "grit/locale_settings.h" | 107 #include "grit/locale_settings.h" |
(...skipping 20 matching lines...) Expand all Loading... | |
128 #include "chrome/browser/password_manager/native_backend_kwallet_x.h" | 128 #include "chrome/browser/password_manager/native_backend_kwallet_x.h" |
129 #include "chrome/browser/password_manager/password_store_x.h" | 129 #include "chrome/browser/password_manager/password_store_x.h" |
130 #endif | 130 #endif |
131 | 131 |
132 #if defined(OS_CHROMEOS) | 132 #if defined(OS_CHROMEOS) |
133 #include "chrome/browser/chromeos/locale_change_guard.h" | 133 #include "chrome/browser/chromeos/locale_change_guard.h" |
134 #include "chrome/browser/chromeos/login/user_manager.h" | 134 #include "chrome/browser/chromeos/login/user_manager.h" |
135 #include "chrome/browser/chromeos/preferences.h" | 135 #include "chrome/browser/chromeos/preferences.h" |
136 #endif | 136 #endif |
137 | 137 |
138 class DownloadManager; | |
jam
2011/10/11 19:31:13
this isn't needed
Randy Smith (Not in Mondays)
2011/10/11 20:28:27
Done.
| |
139 | |
138 using base::Time; | 140 using base::Time; |
139 using base::TimeDelta; | 141 using base::TimeDelta; |
140 | 142 |
141 namespace { | 143 namespace { |
142 | 144 |
143 // Delay, in milliseconds, before we explicitly create the SessionService. | 145 // Delay, in milliseconds, before we explicitly create the SessionService. |
144 static const int kCreateSessionServiceDelayMS = 500; | 146 static const int kCreateSessionServiceDelayMS = 500; |
145 | 147 |
146 #if defined(OS_MACOSX) | 148 #if defined(OS_MACOSX) |
147 // Capacity for mock keychain used for testing. | 149 // Capacity for mock keychain used for testing. |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
321 : path_(path), | 323 : path_(path), |
322 visited_link_event_listener_(new VisitedLinkEventListener()), | 324 visited_link_event_listener_(new VisitedLinkEventListener()), |
323 extension_devtools_manager_(NULL), | 325 extension_devtools_manager_(NULL), |
324 ALLOW_THIS_IN_INITIALIZER_LIST(io_data_(this)), | 326 ALLOW_THIS_IN_INITIALIZER_LIST(io_data_(this)), |
325 host_content_settings_map_(NULL), | 327 host_content_settings_map_(NULL), |
326 host_zoom_map_(NULL), | 328 host_zoom_map_(NULL), |
327 history_service_created_(false), | 329 history_service_created_(false), |
328 favicon_service_created_(false), | 330 favicon_service_created_(false), |
329 created_web_data_service_(false), | 331 created_web_data_service_(false), |
330 created_password_store_(false), | 332 created_password_store_(false), |
331 created_download_manager_(false), | |
332 start_time_(Time::Now()), | 333 start_time_(Time::Now()), |
333 #if defined(OS_WIN) | 334 #if defined(OS_WIN) |
334 checked_instant_promo_(false), | 335 checked_instant_promo_(false), |
335 #endif | 336 #endif |
336 delegate_(delegate), | 337 delegate_(delegate), |
337 predictor_(NULL) { | 338 predictor_(NULL) { |
338 DCHECK(!path.empty()) << "Using an empty path will attempt to write " << | 339 DCHECK(!path.empty()) << "Using an empty path will attempt to write " << |
339 "profile files to the root directory!"; | 340 "profile files to the root directory!"; |
340 | 341 |
341 create_session_service_timer_.Start(FROM_HERE, | 342 create_session_service_timer_.Start(FROM_HERE, |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
720 ProfileDependencyManager::GetInstance()->DestroyProfileServices(this); | 721 ProfileDependencyManager::GetInstance()->DestroyProfileServices(this); |
721 | 722 |
722 if (db_tracker_) { | 723 if (db_tracker_) { |
723 BrowserThread::PostTask( | 724 BrowserThread::PostTask( |
724 BrowserThread::FILE, FROM_HERE, | 725 BrowserThread::FILE, FROM_HERE, |
725 NewRunnableMethod( | 726 NewRunnableMethod( |
726 db_tracker_.get(), | 727 db_tracker_.get(), |
727 &webkit_database::DatabaseTracker::Shutdown)); | 728 &webkit_database::DatabaseTracker::Shutdown)); |
728 } | 729 } |
729 | 730 |
730 // DownloadManager is lazily created, so check before accessing it. | |
731 if (download_manager_.get()) { | |
732 // The download manager queries the history system and should be shut down | |
733 // before the history is shut down so it can properly cancel all requests. | |
734 download_manager_->Shutdown(); | |
735 download_manager_ = NULL; | |
736 } | |
737 | |
738 // Password store uses WebDB, shut it down before the WebDB has been shutdown. | 731 // Password store uses WebDB, shut it down before the WebDB has been shutdown. |
739 if (password_store_.get()) | 732 if (password_store_.get()) |
740 password_store_->Shutdown(); | 733 password_store_->Shutdown(); |
741 | 734 |
742 // Both HistoryService and WebDataService maintain threads for background | 735 // Both HistoryService and WebDataService maintain threads for background |
743 // processing. Its possible each thread still has tasks on it that have | 736 // processing. Its possible each thread still has tasks on it that have |
744 // increased the ref count of the service. In such a situation, when we | 737 // increased the ref count of the service. In such a situation, when we |
745 // decrement the refcount, it won't be 0, and the threads/databases aren't | 738 // decrement the refcount, it won't be 0, and the threads/databases aren't |
746 // properly shut down. By explicitly calling Cleanup/Shutdown we ensure the | 739 // properly shut down. By explicitly calling Cleanup/Shutdown we ensure the |
747 // databases are properly closed. | 740 // databases are properly closed. |
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1294 delete login_db; | 1287 delete login_db; |
1295 | 1288 |
1296 if (!ps || !ps->Init()) { | 1289 if (!ps || !ps->Init()) { |
1297 NOTREACHED() << "Could not initialize password manager."; | 1290 NOTREACHED() << "Could not initialize password manager."; |
1298 return; | 1291 return; |
1299 } | 1292 } |
1300 password_store_.swap(ps); | 1293 password_store_.swap(ps); |
1301 } | 1294 } |
1302 | 1295 |
1303 DownloadManager* ProfileImpl::GetDownloadManager() { | 1296 DownloadManager* ProfileImpl::GetDownloadManager() { |
1304 if (!created_download_manager_) { | 1297 return DownloadServiceFactory::GetForProfile(this)->GetDownloadManager(); |
1305 // In case the delegate has already been set by SetDownloadManagerDelegate. | |
1306 if (!download_manager_delegate_.get()) | |
1307 download_manager_delegate_= new ChromeDownloadManagerDelegate(this); | |
1308 scoped_refptr<DownloadManager> dlm( | |
1309 new DownloadManager(download_manager_delegate_, | |
1310 g_browser_process->download_status_updater())); | |
1311 dlm->Init(this); | |
1312 download_manager_delegate_->SetDownloadManager(dlm); | |
1313 created_download_manager_ = true; | |
1314 download_manager_.swap(dlm); | |
1315 } | |
1316 return download_manager_.get(); | |
1317 } | |
1318 | |
1319 bool ProfileImpl::HasCreatedDownloadManager() const { | |
1320 return created_download_manager_; | |
1321 } | 1298 } |
1322 | 1299 |
1323 fileapi::FileSystemContext* ProfileImpl::GetFileSystemContext() { | 1300 fileapi::FileSystemContext* ProfileImpl::GetFileSystemContext() { |
1324 CreateQuotaManagerAndClients(); | 1301 CreateQuotaManagerAndClients(); |
1325 return file_system_context_.get(); | 1302 return file_system_context_.get(); |
1326 } | 1303 } |
1327 | 1304 |
1328 quota::QuotaManager* ProfileImpl::GetQuotaManager() { | 1305 quota::QuotaManager* ProfileImpl::GetQuotaManager() { |
1329 CreateQuotaManagerAndClients(); | 1306 CreateQuotaManagerAndClients(); |
1330 return quota_manager_.get(); | 1307 return quota_manager_.get(); |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1754 | 1731 |
1755 void ProfileImpl::DeleteTransportSecurityStateSince(base::Time time) { | 1732 void ProfileImpl::DeleteTransportSecurityStateSince(base::Time time) { |
1756 io_data_.DeleteTransportSecurityStateSince(time); | 1733 io_data_.DeleteTransportSecurityStateSince(time); |
1757 } | 1734 } |
1758 | 1735 |
1759 SpellCheckProfile* ProfileImpl::GetSpellCheckProfile() { | 1736 SpellCheckProfile* ProfileImpl::GetSpellCheckProfile() { |
1760 if (!spellcheck_profile_.get()) | 1737 if (!spellcheck_profile_.get()) |
1761 spellcheck_profile_.reset(new SpellCheckProfile()); | 1738 spellcheck_profile_.reset(new SpellCheckProfile()); |
1762 return spellcheck_profile_.get(); | 1739 return spellcheck_profile_.get(); |
1763 } | 1740 } |
1764 | |
1765 void ProfileImpl::SetDownloadManagerDelegate( | |
1766 ChromeDownloadManagerDelegate* delegate) { | |
1767 download_manager_delegate_ = delegate; | |
1768 } | |
OLD | NEW |