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/download/download_manager.h" |
Miranda Callahan
2011/10/06 20:07:32
This could just be a forward declaration of Downlo
Randy Smith (Not in Mondays)
2011/10/08 23:46:54
Done.
| |
98 #include "content/browser/file_system/browser_file_system_helper.h" | 99 #include "content/browser/file_system/browser_file_system_helper.h" |
99 #include "content/browser/host_zoom_map.h" | 100 #include "content/browser/host_zoom_map.h" |
100 #include "content/browser/in_process_webkit/webkit_context.h" | 101 #include "content/browser/in_process_webkit/webkit_context.h" |
101 #include "content/browser/renderer_host/render_process_host.h" | 102 #include "content/browser/renderer_host/render_process_host.h" |
102 #include "content/browser/speech/speech_input_manager.h" | 103 #include "content/browser/speech/speech_input_manager.h" |
103 #include "content/browser/ssl/ssl_host_state.h" | 104 #include "content/browser/ssl/ssl_host_state.h" |
104 #include "content/browser/user_metrics.h" | 105 #include "content/browser/user_metrics.h" |
105 #include "content/common/notification_service.h" | 106 #include "content/common/notification_service.h" |
106 #include "grit/browser_resources.h" | 107 #include "grit/browser_resources.h" |
107 #include "grit/locale_settings.h" | 108 #include "grit/locale_settings.h" |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
323 : path_(path), | 324 : path_(path), |
324 visited_link_event_listener_(new VisitedLinkEventListener()), | 325 visited_link_event_listener_(new VisitedLinkEventListener()), |
325 extension_devtools_manager_(NULL), | 326 extension_devtools_manager_(NULL), |
326 ALLOW_THIS_IN_INITIALIZER_LIST(io_data_(this)), | 327 ALLOW_THIS_IN_INITIALIZER_LIST(io_data_(this)), |
327 host_content_settings_map_(NULL), | 328 host_content_settings_map_(NULL), |
328 host_zoom_map_(NULL), | 329 host_zoom_map_(NULL), |
329 history_service_created_(false), | 330 history_service_created_(false), |
330 favicon_service_created_(false), | 331 favicon_service_created_(false), |
331 created_web_data_service_(false), | 332 created_web_data_service_(false), |
332 created_password_store_(false), | 333 created_password_store_(false), |
333 created_download_manager_(false), | |
334 start_time_(Time::Now()), | 334 start_time_(Time::Now()), |
335 #if defined(OS_WIN) | 335 #if defined(OS_WIN) |
336 checked_instant_promo_(false), | 336 checked_instant_promo_(false), |
337 #endif | 337 #endif |
338 delegate_(delegate), | 338 delegate_(delegate), |
339 predictor_(NULL) { | 339 predictor_(NULL) { |
340 DCHECK(!path.empty()) << "Using an empty path will attempt to write " << | 340 DCHECK(!path.empty()) << "Using an empty path will attempt to write " << |
341 "profile files to the root directory!"; | 341 "profile files to the root directory!"; |
342 | 342 |
343 create_session_service_timer_.Start(FROM_HERE, | 343 create_session_service_timer_.Start(FROM_HERE, |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
722 ProfileDependencyManager::GetInstance()->DestroyProfileServices(this); | 722 ProfileDependencyManager::GetInstance()->DestroyProfileServices(this); |
723 | 723 |
724 if (db_tracker_) { | 724 if (db_tracker_) { |
725 BrowserThread::PostTask( | 725 BrowserThread::PostTask( |
726 BrowserThread::FILE, FROM_HERE, | 726 BrowserThread::FILE, FROM_HERE, |
727 NewRunnableMethod( | 727 NewRunnableMethod( |
728 db_tracker_.get(), | 728 db_tracker_.get(), |
729 &webkit_database::DatabaseTracker::Shutdown)); | 729 &webkit_database::DatabaseTracker::Shutdown)); |
730 } | 730 } |
731 | 731 |
732 // DownloadManager is lazily created, so check before accessing it. | |
733 if (download_manager_.get()) { | |
734 // The download manager queries the history system and should be shut down | |
735 // before the history is shut down so it can properly cancel all requests. | |
736 download_manager_->Shutdown(); | |
737 download_manager_ = NULL; | |
738 } | |
739 | |
740 // Password store uses WebDB, shut it down before the WebDB has been shutdown. | 732 // Password store uses WebDB, shut it down before the WebDB has been shutdown. |
741 if (password_store_.get()) | 733 if (password_store_.get()) |
742 password_store_->Shutdown(); | 734 password_store_->Shutdown(); |
743 | 735 |
744 // Both HistoryService and WebDataService maintain threads for background | 736 // Both HistoryService and WebDataService maintain threads for background |
745 // processing. Its possible each thread still has tasks on it that have | 737 // processing. Its possible each thread still has tasks on it that have |
746 // increased the ref count of the service. In such a situation, when we | 738 // increased the ref count of the service. In such a situation, when we |
747 // decrement the refcount, it won't be 0, and the threads/databases aren't | 739 // decrement the refcount, it won't be 0, and the threads/databases aren't |
748 // properly shut down. By explicitly calling Cleanup/Shutdown we ensure the | 740 // properly shut down. By explicitly calling Cleanup/Shutdown we ensure the |
749 // databases are properly closed. | 741 // databases are properly closed. |
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1294 delete login_db; | 1286 delete login_db; |
1295 | 1287 |
1296 if (!ps || !ps->Init()) { | 1288 if (!ps || !ps->Init()) { |
1297 NOTREACHED() << "Could not initialize password manager."; | 1289 NOTREACHED() << "Could not initialize password manager."; |
1298 return; | 1290 return; |
1299 } | 1291 } |
1300 password_store_.swap(ps); | 1292 password_store_.swap(ps); |
1301 } | 1293 } |
1302 | 1294 |
1303 DownloadManager* ProfileImpl::GetDownloadManager() { | 1295 DownloadManager* ProfileImpl::GetDownloadManager() { |
1304 if (!created_download_manager_) { | 1296 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 } | 1297 } |
1322 | 1298 |
1323 fileapi::FileSystemContext* ProfileImpl::GetFileSystemContext() { | 1299 fileapi::FileSystemContext* ProfileImpl::GetFileSystemContext() { |
1324 CreateQuotaManagerAndClients(); | 1300 CreateQuotaManagerAndClients(); |
1325 return file_system_context_.get(); | 1301 return file_system_context_.get(); |
1326 } | 1302 } |
1327 | 1303 |
1328 quota::QuotaManager* ProfileImpl::GetQuotaManager() { | 1304 quota::QuotaManager* ProfileImpl::GetQuotaManager() { |
1329 CreateQuotaManagerAndClients(); | 1305 CreateQuotaManagerAndClients(); |
1330 return quota_manager_.get(); | 1306 return quota_manager_.get(); |
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1772 void ProfileImpl::DeleteTransportSecurityStateSince(base::Time time) { | 1748 void ProfileImpl::DeleteTransportSecurityStateSince(base::Time time) { |
1773 io_data_.DeleteTransportSecurityStateSince(time); | 1749 io_data_.DeleteTransportSecurityStateSince(time); |
1774 } | 1750 } |
1775 | 1751 |
1776 SpellCheckProfile* ProfileImpl::GetSpellCheckProfile() { | 1752 SpellCheckProfile* ProfileImpl::GetSpellCheckProfile() { |
1777 if (!spellcheck_profile_.get()) | 1753 if (!spellcheck_profile_.get()) |
1778 spellcheck_profile_.reset(new SpellCheckProfile()); | 1754 spellcheck_profile_.reset(new SpellCheckProfile()); |
1779 return spellcheck_profile_.get(); | 1755 return spellcheck_profile_.get(); |
1780 } | 1756 } |
1781 | 1757 |
1782 void ProfileImpl::SetDownloadManagerDelegate( | |
1783 ChromeDownloadManagerDelegate* delegate) { | |
1784 download_manager_delegate_ = delegate; | |
1785 } | |
OLD | NEW |