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 19 matching lines...) Expand all Loading... |
30 #include "chrome/browser/google/google_url_tracker.h" | 30 #include "chrome/browser/google/google_url_tracker.h" |
31 #include "chrome/browser/icon_manager.h" | 31 #include "chrome/browser/icon_manager.h" |
32 #include "chrome/browser/intranet_redirect_detector.h" | 32 #include "chrome/browser/intranet_redirect_detector.h" |
33 #include "chrome/browser/io_thread.h" | 33 #include "chrome/browser/io_thread.h" |
34 #include "chrome/browser/metrics/metrics_service.h" | 34 #include "chrome/browser/metrics/metrics_service.h" |
35 #include "chrome/browser/metrics/thread_watcher.h" | 35 #include "chrome/browser/metrics/thread_watcher.h" |
36 #include "chrome/browser/net/chrome_net_log.h" | 36 #include "chrome/browser/net/chrome_net_log.h" |
37 #include "chrome/browser/net/predictor_api.h" | 37 #include "chrome/browser/net/predictor_api.h" |
38 #include "chrome/browser/net/sdch_dictionary_fetcher.h" | 38 #include "chrome/browser/net/sdch_dictionary_fetcher.h" |
39 #include "chrome/browser/notifications/notification_ui_manager.h" | 39 #include "chrome/browser/notifications/notification_ui_manager.h" |
40 #include "chrome/browser/plugin_data_remover.h" | |
41 #include "chrome/browser/policy/browser_policy_connector.h" | 40 #include "chrome/browser/policy/browser_policy_connector.h" |
42 #include "chrome/browser/prefs/browser_prefs.h" | 41 #include "chrome/browser/prefs/browser_prefs.h" |
43 #include "chrome/browser/prefs/pref_service.h" | 42 #include "chrome/browser/prefs/pref_service.h" |
44 #include "chrome/browser/prerender/prerender_tracker.h" | 43 #include "chrome/browser/prerender/prerender_tracker.h" |
45 #include "chrome/browser/printing/background_printing_manager.h" | 44 #include "chrome/browser/printing/background_printing_manager.h" |
46 #include "chrome/browser/printing/print_job_manager.h" | 45 #include "chrome/browser/printing/print_job_manager.h" |
47 #include "chrome/browser/printing/print_preview_tab_controller.h" | 46 #include "chrome/browser/printing/print_preview_tab_controller.h" |
48 #include "chrome/browser/profiles/profile_manager.h" | 47 #include "chrome/browser/profiles/profile_manager.h" |
49 #include "chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.
h" | 48 #include "chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.
h" |
50 #include "chrome/browser/safe_browsing/client_side_detection_service.h" | 49 #include "chrome/browser/safe_browsing/client_side_detection_service.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 created_safe_browsing_service_(false), | 131 created_safe_browsing_service_(false), |
133 created_safe_browsing_detection_service_(false), | 132 created_safe_browsing_detection_service_(false), |
134 module_ref_count_(0), | 133 module_ref_count_(0), |
135 did_start_(false), | 134 did_start_(false), |
136 checked_for_new_frames_(false), | 135 checked_for_new_frames_(false), |
137 using_new_frames_(false) { | 136 using_new_frames_(false) { |
138 g_browser_process = this; | 137 g_browser_process = this; |
139 clipboard_.reset(new ui::Clipboard); | 138 clipboard_.reset(new ui::Clipboard); |
140 main_notification_service_.reset(new NotificationService); | 139 main_notification_service_.reset(new NotificationService); |
141 | 140 |
142 notification_registrar_.Add(this, | |
143 NotificationType::APP_TERMINATING, | |
144 NotificationService::AllSources()); | |
145 | |
146 // Must be created after the NotificationService. | 141 // Must be created after the NotificationService. |
147 print_job_manager_.reset(new printing::PrintJobManager); | 142 print_job_manager_.reset(new printing::PrintJobManager); |
148 | 143 |
149 net_log_.reset(new ChromeNetLog); | 144 net_log_.reset(new ChromeNetLog); |
150 | 145 |
151 extension_event_router_forwarder_ = new ExtensionEventRouterForwarder; | 146 extension_event_router_forwarder_ = new ExtensionEventRouterForwarder; |
152 | 147 |
153 ExtensionTabIdMap::GetInstance()->Init(); | 148 ExtensionTabIdMap::GetInstance()->Init(); |
154 } | 149 } |
155 | 150 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 // Cancel pending requests and prevent new requests. | 212 // Cancel pending requests and prevent new requests. |
218 resource_dispatcher_host()->Shutdown(); | 213 resource_dispatcher_host()->Shutdown(); |
219 } | 214 } |
220 | 215 |
221 ExtensionTabIdMap::GetInstance()->Shutdown(); | 216 ExtensionTabIdMap::GetInstance()->Shutdown(); |
222 | 217 |
223 // The policy providers managed by |browser_policy_connector_| need to shut | 218 // The policy providers managed by |browser_policy_connector_| need to shut |
224 // down while the IO and FILE threads are still alive. | 219 // down while the IO and FILE threads are still alive. |
225 browser_policy_connector_.reset(); | 220 browser_policy_connector_.reset(); |
226 | 221 |
227 // Wait for removing plugin data to finish before shutting down the IO thread. | |
228 WaitForPluginDataRemoverToFinish(); | |
229 | |
230 // Destroying the GpuProcessHostUIShims on the UI thread posts a task to | 222 // Destroying the GpuProcessHostUIShims on the UI thread posts a task to |
231 // delete related objects on the GPU thread. This must be done before | 223 // delete related objects on the GPU thread. This must be done before |
232 // stopping the GPU thread. The GPU thread will close IPC channels to renderer | 224 // stopping the GPU thread. The GPU thread will close IPC channels to renderer |
233 // processes so this has to happen before stopping the IO thread. | 225 // processes so this has to happen before stopping the IO thread. |
234 GpuProcessHostUIShim::DestroyAll(); | 226 GpuProcessHostUIShim::DestroyAll(); |
235 | 227 |
236 // Need to stop io_thread_ before resource_dispatcher_host_, since | 228 // Need to stop io_thread_ before resource_dispatcher_host_, since |
237 // io_thread_ may still deref ResourceDispatcherHost and handle resource | 229 // io_thread_ may still deref ResourceDispatcherHost and handle resource |
238 // request before going away. | 230 // request before going away. |
239 io_thread_.reset(); | 231 io_thread_.reset(); |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 return safe_browsing_detection_service_.get(); | 624 return safe_browsing_detection_service_.get(); |
633 } | 625 } |
634 | 626 |
635 bool BrowserProcessImpl::plugin_finder_disabled() const { | 627 bool BrowserProcessImpl::plugin_finder_disabled() const { |
636 return *plugin_finder_disabled_pref_; | 628 return *plugin_finder_disabled_pref_; |
637 } | 629 } |
638 | 630 |
639 void BrowserProcessImpl::Observe(NotificationType type, | 631 void BrowserProcessImpl::Observe(NotificationType type, |
640 const NotificationSource& source, | 632 const NotificationSource& source, |
641 const NotificationDetails& details) { | 633 const NotificationDetails& details) { |
642 if (type == NotificationType::APP_TERMINATING) { | 634 if (type == NotificationType::PREF_CHANGED) { |
643 Profile* profile = ProfileManager::GetDefaultProfile(); | |
644 if (profile) { | |
645 PrefService* prefs = profile->GetPrefs(); | |
646 if (prefs->GetBoolean(prefs::kClearSiteDataOnExit) && | |
647 local_state()->GetBoolean(prefs::kClearPluginLSODataEnabled)) { | |
648 plugin_data_remover_ = new PluginDataRemover(); | |
649 if (!plugin_data_remover_mime_type().empty()) | |
650 plugin_data_remover_->set_mime_type(plugin_data_remover_mime_type()); | |
651 plugin_data_remover_->StartRemoving(base::Time()); | |
652 } | |
653 } | |
654 } else if (type == NotificationType::PREF_CHANGED) { | |
655 std::string* pref = Details<std::string>(details).ptr(); | 635 std::string* pref = Details<std::string>(details).ptr(); |
656 if (*pref == prefs::kDefaultBrowserSettingEnabled) { | 636 if (*pref == prefs::kDefaultBrowserSettingEnabled) { |
657 if (local_state_->GetBoolean(prefs::kDefaultBrowserSettingEnabled)) | 637 if (local_state_->GetBoolean(prefs::kDefaultBrowserSettingEnabled)) |
658 ShellIntegration::SetAsDefaultBrowser(); | 638 ShellIntegration::SetAsDefaultBrowser(); |
659 } else if (*pref == prefs::kDisabledSchemes) { | 639 } else if (*pref == prefs::kDisabledSchemes) { |
660 ApplyDisabledSchemesPolicy(); | 640 ApplyDisabledSchemesPolicy(); |
661 } else if (*pref == prefs::kAllowCrossOriginAuthPrompt) { | 641 } else if (*pref == prefs::kAllowCrossOriginAuthPrompt) { |
662 ApplyAllowCrossOriginAuthPromptPolicy(); | 642 ApplyAllowCrossOriginAuthPromptPolicy(); |
663 } | 643 } |
664 } else { | 644 } else { |
665 NOTREACHED(); | 645 NOTREACHED(); |
666 } | 646 } |
667 } | 647 } |
668 | 648 |
669 void BrowserProcessImpl::WaitForPluginDataRemoverToFinish() { | |
670 if (plugin_data_remover_.get()) | |
671 plugin_data_remover_->Wait(); | |
672 } | |
673 | |
674 #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) | 649 #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) |
675 void BrowserProcessImpl::StartAutoupdateTimer() { | 650 void BrowserProcessImpl::StartAutoupdateTimer() { |
676 autoupdate_timer_.Start( | 651 autoupdate_timer_.Start( |
677 base::TimeDelta::FromHours(kUpdateCheckIntervalHours), | 652 base::TimeDelta::FromHours(kUpdateCheckIntervalHours), |
678 this, | 653 this, |
679 &BrowserProcessImpl::OnAutoupdateTimer); | 654 &BrowserProcessImpl::OnAutoupdateTimer); |
680 } | 655 } |
681 #endif | 656 #endif |
682 | 657 |
683 ChromeNetLog* BrowserProcessImpl::net_log() { | 658 ChromeNetLog* BrowserProcessImpl::net_log() { |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1133 } | 1108 } |
1134 | 1109 |
1135 void BrowserProcessImpl::OnAutoupdateTimer() { | 1110 void BrowserProcessImpl::OnAutoupdateTimer() { |
1136 if (CanAutorestartForUpdate()) { | 1111 if (CanAutorestartForUpdate()) { |
1137 DLOG(WARNING) << "Detected update. Restarting browser."; | 1112 DLOG(WARNING) << "Detected update. Restarting browser."; |
1138 RestartPersistentInstance(); | 1113 RestartPersistentInstance(); |
1139 } | 1114 } |
1140 } | 1115 } |
1141 | 1116 |
1142 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) | 1117 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) |
OLD | NEW |