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/browser_process_impl.h" | 5 #include "chrome/browser/browser_process_impl.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <set> | 8 #include <set> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 30 matching lines...) Expand all Loading... |
41 #include "chrome/browser/notifications/notification_ui_manager.h" | 41 #include "chrome/browser/notifications/notification_ui_manager.h" |
42 #include "chrome/browser/policy/browser_policy_connector.h" | 42 #include "chrome/browser/policy/browser_policy_connector.h" |
43 #include "chrome/browser/prefs/browser_prefs.h" | 43 #include "chrome/browser/prefs/browser_prefs.h" |
44 #include "chrome/browser/prefs/pref_service.h" | 44 #include "chrome/browser/prefs/pref_service.h" |
45 #include "chrome/browser/prerender/prerender_tracker.h" | 45 #include "chrome/browser/prerender/prerender_tracker.h" |
46 #include "chrome/browser/printing/background_printing_manager.h" | 46 #include "chrome/browser/printing/background_printing_manager.h" |
47 #include "chrome/browser/printing/print_job_manager.h" | 47 #include "chrome/browser/printing/print_job_manager.h" |
48 #include "chrome/browser/printing/print_preview_tab_controller.h" | 48 #include "chrome/browser/printing/print_preview_tab_controller.h" |
49 #include "chrome/browser/profiles/profile_manager.h" | 49 #include "chrome/browser/profiles/profile_manager.h" |
50 #include "chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.
h" | 50 #include "chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.
h" |
51 #include "chrome/browser/safe_browsing/client_side_detection_service.h" | |
52 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 51 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
53 #include "chrome/browser/shell_integration.h" | 52 #include "chrome/browser/shell_integration.h" |
54 #include "chrome/browser/sidebar/sidebar_manager.h" | 53 #include "chrome/browser/sidebar/sidebar_manager.h" |
55 #include "chrome/browser/status_icons/status_tray.h" | 54 #include "chrome/browser/status_icons/status_tray.h" |
56 #include "chrome/browser/tab_closeable_state_watcher.h" | 55 #include "chrome/browser/tab_closeable_state_watcher.h" |
57 #include "chrome/browser/ui/browser_list.h" | 56 #include "chrome/browser/ui/browser_list.h" |
58 #include "chrome/browser/web_resource/gpu_blacklist_updater.h" | 57 #include "chrome/browser/web_resource/gpu_blacklist_updater.h" |
59 #include "chrome/common/chrome_constants.h" | 58 #include "chrome/common/chrome_constants.h" |
60 #include "chrome/common/chrome_notification_types.h" | 59 #include "chrome/common/chrome_notification_types.h" |
61 #include "chrome/common/chrome_paths.h" | 60 #include "chrome/common/chrome_paths.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 created_web_socket_proxy_thread_(false), | 127 created_web_socket_proxy_thread_(false), |
129 #endif | 128 #endif |
130 created_profile_manager_(false), | 129 created_profile_manager_(false), |
131 created_local_state_(false), | 130 created_local_state_(false), |
132 created_icon_manager_(false), | 131 created_icon_manager_(false), |
133 created_devtools_manager_(false), | 132 created_devtools_manager_(false), |
134 created_sidebar_manager_(false), | 133 created_sidebar_manager_(false), |
135 created_browser_policy_connector_(false), | 134 created_browser_policy_connector_(false), |
136 created_notification_ui_manager_(false), | 135 created_notification_ui_manager_(false), |
137 created_safe_browsing_service_(false), | 136 created_safe_browsing_service_(false), |
138 created_safe_browsing_detection_service_(false), | |
139 module_ref_count_(0), | 137 module_ref_count_(0), |
140 did_start_(false), | 138 did_start_(false), |
141 checked_for_new_frames_(false), | 139 checked_for_new_frames_(false), |
142 using_new_frames_(false) { | 140 using_new_frames_(false) { |
143 g_browser_process = this; | 141 g_browser_process = this; |
144 clipboard_.reset(new ui::Clipboard); | 142 clipboard_.reset(new ui::Clipboard); |
145 main_notification_service_.reset(new NotificationService); | 143 main_notification_service_.reset(new NotificationService); |
146 | 144 |
147 // Must be created after the NotificationService. | 145 // Must be created after the NotificationService. |
148 print_job_manager_.reset(new printing::PrintJobManager); | 146 print_job_manager_.reset(new printing::PrintJobManager); |
(...skipping 24 matching lines...) Expand all Loading... |
173 automation_provider_list_.reset(); | 171 automation_provider_list_.reset(); |
174 | 172 |
175 // We need to shutdown the SdchDictionaryFetcher as it regularly holds | 173 // We need to shutdown the SdchDictionaryFetcher as it regularly holds |
176 // a pointer to a URLFetcher, and that URLFetcher (upon destruction) will do | 174 // a pointer to a URLFetcher, and that URLFetcher (upon destruction) will do |
177 // a PostDelayedTask onto the IO thread. This shutdown call will both discard | 175 // a PostDelayedTask onto the IO thread. This shutdown call will both discard |
178 // any pending URLFetchers, and avoid creating any more. | 176 // any pending URLFetchers, and avoid creating any more. |
179 SdchDictionaryFetcher::Shutdown(); | 177 SdchDictionaryFetcher::Shutdown(); |
180 | 178 |
181 // We need to destroy the MetricsService, GoogleURLTracker, | 179 // We need to destroy the MetricsService, GoogleURLTracker, |
182 // IntranetRedirectDetector, and SafeBrowsing ClientSideDetectionService | 180 // IntranetRedirectDetector, and SafeBrowsing ClientSideDetectionService |
183 // before the io_thread_ gets destroyed, since their destructors can call the | 181 // (owned by the SafeBrowsingService) before the io_thread_ gets destroyed, |
184 // URLFetcher destructor, which does a PostDelayedTask operation on the IO | 182 // since their destructors can call the URLFetcher destructor, which does a |
185 // thread. (The IO thread will handle that URLFetcher operation before going | 183 // PostDelayedTask operation on the IO thread. |
186 // away.) | 184 // (The IO thread will handle that URLFetcher operation before going away.) |
187 metrics_service_.reset(); | 185 metrics_service_.reset(); |
188 google_url_tracker_.reset(); | 186 google_url_tracker_.reset(); |
189 intranet_redirect_detector_.reset(); | 187 intranet_redirect_detector_.reset(); |
190 safe_browsing_detection_service_.reset(); | 188 #if defined(ENABLE_SAFE_BROWSING) |
| 189 if (safe_browsing_service_.get()) { |
| 190 safe_browsing_service()->ShutDown(); |
| 191 } |
| 192 #endif |
191 | 193 |
192 // Need to clear the desktop notification balloons before the io_thread_ and | 194 // Need to clear the desktop notification balloons before the io_thread_ and |
193 // before the profiles, since if there are any still showing we will access | 195 // before the profiles, since if there are any still showing we will access |
194 // those things during teardown. | 196 // those things during teardown. |
195 notification_ui_manager_.reset(); | 197 notification_ui_manager_.reset(); |
196 | 198 |
197 // FIXME - We shouldn't need this, it's because of DefaultRequestContext! :( | 199 // FIXME - We shouldn't need this, it's because of DefaultRequestContext! :( |
198 // We need to kill off all URLFetchers using profile related | 200 // We need to kill off all URLFetchers using profile related |
199 // URLRequestContexts. Normally that'd be covered by deleting the Profiles, | 201 // URLRequestContexts. Normally that'd be covered by deleting the Profiles, |
200 // but we have some URLFetchers using the DefaultRequestContext, so they need | 202 // but we have some URLFetchers using the DefaultRequestContext, so they need |
201 // to be cancelled too. Remove this when DefaultRequestContext goes away. | 203 // to be cancelled too. Remove this when DefaultRequestContext goes away. |
202 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 204 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
203 NewRunnableFunction(&URLFetcher::CancelAll)); | 205 NewRunnableFunction(&URLFetcher::CancelAll)); |
204 | 206 |
205 // Need to clear profiles (download managers) before the io_thread_. | 207 // Need to clear profiles (download managers) before the io_thread_. |
206 profile_manager_.reset(); | 208 profile_manager_.reset(); |
207 | 209 |
208 // Debugger must be cleaned up before IO thread and NotificationService. | 210 // Debugger must be cleaned up before IO thread and NotificationService. |
209 remote_debugging_server_.reset(); | 211 remote_debugging_server_.reset(); |
210 | 212 |
211 if (devtools_legacy_handler_.get()) { | 213 if (devtools_legacy_handler_.get()) { |
212 devtools_legacy_handler_->Stop(); | 214 devtools_legacy_handler_->Stop(); |
213 devtools_legacy_handler_ = NULL; | 215 devtools_legacy_handler_ = NULL; |
214 } | 216 } |
215 | 217 |
216 #if defined(ENABLE_SAFE_BROWSING) | |
217 if (safe_browsing_service_.get()) | |
218 safe_browsing_service()->ShutDown(); | |
219 #endif | |
220 | |
221 if (resource_dispatcher_host_.get()) { | 218 if (resource_dispatcher_host_.get()) { |
222 // Cancel pending requests and prevent new requests. | 219 // Cancel pending requests and prevent new requests. |
223 resource_dispatcher_host()->Shutdown(); | 220 resource_dispatcher_host()->Shutdown(); |
224 } | 221 } |
225 | 222 |
226 ExtensionTabIdMap::GetInstance()->Shutdown(); | 223 ExtensionTabIdMap::GetInstance()->Shutdown(); |
227 | 224 |
228 // The policy providers managed by |browser_policy_connector_| need to shut | 225 // The policy providers managed by |browser_policy_connector_| need to shut |
229 // down while the IO and FILE threads are still alive. | 226 // down while the IO and FILE threads are still alive. |
230 browser_policy_connector_.reset(); | 227 browser_policy_connector_.reset(); |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
619 SafeBrowsingService* BrowserProcessImpl::safe_browsing_service() { | 616 SafeBrowsingService* BrowserProcessImpl::safe_browsing_service() { |
620 DCHECK(CalledOnValidThread()); | 617 DCHECK(CalledOnValidThread()); |
621 if (!created_safe_browsing_service_) | 618 if (!created_safe_browsing_service_) |
622 CreateSafeBrowsingService(); | 619 CreateSafeBrowsingService(); |
623 return safe_browsing_service_.get(); | 620 return safe_browsing_service_.get(); |
624 } | 621 } |
625 | 622 |
626 safe_browsing::ClientSideDetectionService* | 623 safe_browsing::ClientSideDetectionService* |
627 BrowserProcessImpl::safe_browsing_detection_service() { | 624 BrowserProcessImpl::safe_browsing_detection_service() { |
628 DCHECK(CalledOnValidThread()); | 625 DCHECK(CalledOnValidThread()); |
629 if (!created_safe_browsing_detection_service_) | 626 if (safe_browsing_service()) |
630 CreateSafeBrowsingDetectionService(); | 627 return safe_browsing_service()->safe_browsing_detection_service(); |
631 return safe_browsing_detection_service_.get(); | 628 return NULL; |
632 } | 629 } |
633 | 630 |
634 bool BrowserProcessImpl::plugin_finder_disabled() const { | 631 bool BrowserProcessImpl::plugin_finder_disabled() const { |
635 return *plugin_finder_disabled_pref_; | 632 return *plugin_finder_disabled_pref_; |
636 } | 633 } |
637 | 634 |
638 void BrowserProcessImpl::Observe(int type, | 635 void BrowserProcessImpl::Observe(int type, |
639 const NotificationSource& source, | 636 const NotificationSource& source, |
640 const NotificationDetails& details) { | 637 const NotificationDetails& details) { |
641 if (type == chrome::NOTIFICATION_PREF_CHANGED) { | 638 if (type == chrome::NOTIFICATION_PREF_CHANGED) { |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
981 DCHECK(safe_browsing_service_.get() == NULL); | 978 DCHECK(safe_browsing_service_.get() == NULL); |
982 // Set this flag to true so that we don't retry indefinitely to | 979 // Set this flag to true so that we don't retry indefinitely to |
983 // create the service class if there was an error. | 980 // create the service class if there was an error. |
984 created_safe_browsing_service_ = true; | 981 created_safe_browsing_service_ = true; |
985 #if defined(ENABLE_SAFE_BROWSING) | 982 #if defined(ENABLE_SAFE_BROWSING) |
986 safe_browsing_service_ = SafeBrowsingService::CreateSafeBrowsingService(); | 983 safe_browsing_service_ = SafeBrowsingService::CreateSafeBrowsingService(); |
987 safe_browsing_service_->Initialize(); | 984 safe_browsing_service_->Initialize(); |
988 #endif | 985 #endif |
989 } | 986 } |
990 | 987 |
991 void BrowserProcessImpl::CreateSafeBrowsingDetectionService() { | |
992 DCHECK(safe_browsing_detection_service_.get() == NULL); | |
993 // Set this flag to true so that we don't retry indefinitely to | |
994 // create the service class if there was an error. | |
995 created_safe_browsing_detection_service_ = true; | |
996 | |
997 #if defined(ENABLE_SAFE_BROWSING) | |
998 if (IsSafeBrowsingDetectionServiceEnabled()) { | |
999 safe_browsing_detection_service_.reset( | |
1000 safe_browsing::ClientSideDetectionService::Create( | |
1001 g_browser_process->system_request_context())); | |
1002 } | |
1003 #endif | |
1004 } | |
1005 | |
1006 bool BrowserProcessImpl::IsSafeBrowsingDetectionServiceEnabled() { | |
1007 // The safe browsing client-side detection is enabled only if the switch is | |
1008 // not disabled and when safe browsing related stats are allowed to be | |
1009 // collected. | |
1010 #if defined(ENABLE_SAFE_BROWSING) && !defined(OS_CHROMEOS) | |
1011 return !CommandLine::ForCurrentProcess()->HasSwitch( | |
1012 switches::kDisableClientSidePhishingDetection) && | |
1013 safe_browsing_service() && | |
1014 safe_browsing_service()->CanReportStats(); | |
1015 #else | |
1016 return false; | |
1017 #endif | |
1018 } | |
1019 | |
1020 void BrowserProcessImpl::ApplyDisabledSchemesPolicy() { | 988 void BrowserProcessImpl::ApplyDisabledSchemesPolicy() { |
1021 std::set<std::string> schemes; | 989 std::set<std::string> schemes; |
1022 const ListValue* scheme_list = local_state_->GetList(prefs::kDisabledSchemes); | 990 const ListValue* scheme_list = local_state_->GetList(prefs::kDisabledSchemes); |
1023 for (ListValue::const_iterator iter = scheme_list->begin(); | 991 for (ListValue::const_iterator iter = scheme_list->begin(); |
1024 iter != scheme_list->end(); ++iter) { | 992 iter != scheme_list->end(); ++iter) { |
1025 std::string scheme; | 993 std::string scheme; |
1026 if ((*iter)->GetAsString(&scheme)) | 994 if ((*iter)->GetAsString(&scheme)) |
1027 schemes.insert(scheme); | 995 schemes.insert(scheme); |
1028 } | 996 } |
1029 ChildProcessSecurityPolicy::GetInstance()->RegisterDisabledSchemes(schemes); | 997 ChildProcessSecurityPolicy::GetInstance()->RegisterDisabledSchemes(schemes); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1126 } | 1094 } |
1127 | 1095 |
1128 void BrowserProcessImpl::OnAutoupdateTimer() { | 1096 void BrowserProcessImpl::OnAutoupdateTimer() { |
1129 if (CanAutorestartForUpdate()) { | 1097 if (CanAutorestartForUpdate()) { |
1130 DLOG(WARNING) << "Detected update. Restarting browser."; | 1098 DLOG(WARNING) << "Detected update. Restarting browser."; |
1131 RestartPersistentInstance(); | 1099 RestartPersistentInstance(); |
1132 } | 1100 } |
1133 } | 1101 } |
1134 | 1102 |
1135 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) | 1103 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) |
OLD | NEW |