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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 : path_(path), | 321 : path_(path), |
322 visited_link_event_listener_(new VisitedLinkEventListener()), | 322 visited_link_event_listener_(new VisitedLinkEventListener()), |
323 extension_devtools_manager_(NULL), | 323 extension_devtools_manager_(NULL), |
324 ALLOW_THIS_IN_INITIALIZER_LIST(io_data_(this)), | 324 ALLOW_THIS_IN_INITIALIZER_LIST(io_data_(this)), |
325 host_content_settings_map_(NULL), | 325 host_content_settings_map_(NULL), |
326 host_zoom_map_(NULL), | 326 host_zoom_map_(NULL), |
327 history_service_created_(false), | 327 history_service_created_(false), |
328 favicon_service_created_(false), | 328 favicon_service_created_(false), |
329 created_web_data_service_(false), | 329 created_web_data_service_(false), |
330 created_password_store_(false), | 330 created_password_store_(false), |
331 created_download_manager_(false), | |
332 start_time_(Time::Now()), | 331 start_time_(Time::Now()), |
333 #if defined(OS_WIN) | 332 #if defined(OS_WIN) |
334 checked_instant_promo_(false), | 333 checked_instant_promo_(false), |
335 #endif | 334 #endif |
336 delegate_(delegate), | 335 delegate_(delegate), |
337 predictor_(NULL) { | 336 predictor_(NULL) { |
338 DCHECK(!path.empty()) << "Using an empty path will attempt to write " << | 337 DCHECK(!path.empty()) << "Using an empty path will attempt to write " << |
339 "profile files to the root directory!"; | 338 "profile files to the root directory!"; |
340 | 339 |
341 create_session_service_timer_.Start(FROM_HERE, | 340 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); | 719 ProfileDependencyManager::GetInstance()->DestroyProfileServices(this); |
721 | 720 |
722 if (db_tracker_) { | 721 if (db_tracker_) { |
723 BrowserThread::PostTask( | 722 BrowserThread::PostTask( |
724 BrowserThread::FILE, FROM_HERE, | 723 BrowserThread::FILE, FROM_HERE, |
725 NewRunnableMethod( | 724 NewRunnableMethod( |
726 db_tracker_.get(), | 725 db_tracker_.get(), |
727 &webkit_database::DatabaseTracker::Shutdown)); | 726 &webkit_database::DatabaseTracker::Shutdown)); |
728 } | 727 } |
729 | 728 |
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. | 729 // Password store uses WebDB, shut it down before the WebDB has been shutdown. |
739 if (password_store_.get()) | 730 if (password_store_.get()) |
740 password_store_->Shutdown(); | 731 password_store_->Shutdown(); |
741 | 732 |
742 // Both HistoryService and WebDataService maintain threads for background | 733 // Both HistoryService and WebDataService maintain threads for background |
743 // processing. Its possible each thread still has tasks on it that have | 734 // 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 | 735 // 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 | 736 // 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 | 737 // properly shut down. By explicitly calling Cleanup/Shutdown we ensure the |
747 // databases are properly closed. | 738 // databases are properly closed. |
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1294 delete login_db; | 1285 delete login_db; |
1295 | 1286 |
1296 if (!ps || !ps->Init()) { | 1287 if (!ps || !ps->Init()) { |
1297 NOTREACHED() << "Could not initialize password manager."; | 1288 NOTREACHED() << "Could not initialize password manager."; |
1298 return; | 1289 return; |
1299 } | 1290 } |
1300 password_store_.swap(ps); | 1291 password_store_.swap(ps); |
1301 } | 1292 } |
1302 | 1293 |
1303 DownloadManager* ProfileImpl::GetDownloadManager() { | 1294 DownloadManager* ProfileImpl::GetDownloadManager() { |
1304 if (!created_download_manager_) { | 1295 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 } | 1296 } |
1322 | 1297 |
1323 fileapi::FileSystemContext* ProfileImpl::GetFileSystemContext() { | 1298 fileapi::FileSystemContext* ProfileImpl::GetFileSystemContext() { |
1324 CreateQuotaManagerAndClients(); | 1299 CreateQuotaManagerAndClients(); |
1325 return file_system_context_.get(); | 1300 return file_system_context_.get(); |
1326 } | 1301 } |
1327 | 1302 |
1328 quota::QuotaManager* ProfileImpl::GetQuotaManager() { | 1303 quota::QuotaManager* ProfileImpl::GetQuotaManager() { |
1329 CreateQuotaManagerAndClients(); | 1304 CreateQuotaManagerAndClients(); |
1330 return quota_manager_.get(); | 1305 return quota_manager_.get(); |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1754 | 1729 |
1755 void ProfileImpl::DeleteTransportSecurityStateSince(base::Time time) { | 1730 void ProfileImpl::DeleteTransportSecurityStateSince(base::Time time) { |
1756 io_data_.DeleteTransportSecurityStateSince(time); | 1731 io_data_.DeleteTransportSecurityStateSince(time); |
1757 } | 1732 } |
1758 | 1733 |
1759 SpellCheckProfile* ProfileImpl::GetSpellCheckProfile() { | 1734 SpellCheckProfile* ProfileImpl::GetSpellCheckProfile() { |
1760 if (!spellcheck_profile_.get()) | 1735 if (!spellcheck_profile_.get()) |
1761 spellcheck_profile_.reset(new SpellCheckProfile()); | 1736 spellcheck_profile_.reset(new SpellCheckProfile()); |
1762 return spellcheck_profile_.get(); | 1737 return spellcheck_profile_.get(); |
1763 } | 1738 } |
1764 | |
1765 void ProfileImpl::SetDownloadManagerDelegate( | |
1766 ChromeDownloadManagerDelegate* delegate) { | |
1767 download_manager_delegate_ = delegate; | |
1768 } | |
OLD | NEW |