| 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 #include "chrome/common/chrome_switches.h" | 62 #include "chrome/common/chrome_switches.h" |
| 63 #include "chrome/common/extensions/extension_l10n_util.h" | 63 #include "chrome/common/extensions/extension_l10n_util.h" |
| 64 #include "chrome/common/extensions/extension_resource.h" | 64 #include "chrome/common/extensions/extension_resource.h" |
| 65 #include "chrome/common/json_pref_store.h" | 65 #include "chrome/common/json_pref_store.h" |
| 66 #include "chrome/common/pref_names.h" | 66 #include "chrome/common/pref_names.h" |
| 67 #include "chrome/common/switch_utils.h" | 67 #include "chrome/common/switch_utils.h" |
| 68 #include "chrome/common/url_constants.h" | 68 #include "chrome/common/url_constants.h" |
| 69 #include "chrome/installer/util/google_update_constants.h" | 69 #include "chrome/installer/util/google_update_constants.h" |
| 70 #include "content/browser/browser_child_process_host.h" | 70 #include "content/browser/browser_child_process_host.h" |
| 71 #include "content/browser/child_process_security_policy.h" | 71 #include "content/browser/child_process_security_policy.h" |
| 72 #include "content/browser/download/download_file_manager.h" | |
| 73 #include "content/browser/download/download_status_updater.h" | 72 #include "content/browser/download/download_status_updater.h" |
| 74 #include "content/browser/download/mhtml_generation_manager.h" | 73 #include "content/browser/download/mhtml_generation_manager.h" |
| 75 #include "content/browser/download/save_file_manager.h" | |
| 76 #include "content/browser/gpu/gpu_process_host_ui_shim.h" | 74 #include "content/browser/gpu/gpu_process_host_ui_shim.h" |
| 77 #include "content/browser/net/browser_online_state_observer.h" | 75 #include "content/browser/net/browser_online_state_observer.h" |
| 78 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 76 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
| 79 #include "content/public/browser/browser_thread.h" | 77 #include "content/public/browser/browser_thread.h" |
| 80 #include "content/public/browser/notification_details.h" | 78 #include "content/public/browser/notification_details.h" |
| 81 #include "content/public/browser/plugin_service.h" | 79 #include "content/public/browser/plugin_service.h" |
| 82 #include "content/public/browser/render_process_host.h" | 80 #include "content/public/browser/render_process_host.h" |
| 83 #include "content/public/common/url_fetcher.h" | 81 #include "content/public/common/url_fetcher.h" |
| 84 #include "media/audio/audio_manager.h" | 82 #include "media/audio/audio_manager.h" |
| 85 #include "net/socket/client_socket_pool_manager.h" | 83 #include "net/socket/client_socket_pool_manager.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 116 // How long to wait for the File thread to complete during EndSession, on | 114 // How long to wait for the File thread to complete during EndSession, on |
| 117 // Linux. We have a timeout here because we're unable to run the UI messageloop | 115 // Linux. We have a timeout here because we're unable to run the UI messageloop |
| 118 // and there's some deadlock risk. Our only option is to exit anyway. | 116 // and there's some deadlock risk. Our only option is to exit anyway. |
| 119 static const int kEndSessionTimeoutSeconds = 10; | 117 static const int kEndSessionTimeoutSeconds = 10; |
| 120 #endif | 118 #endif |
| 121 | 119 |
| 122 using content::BrowserThread; | 120 using content::BrowserThread; |
| 123 using content::PluginService; | 121 using content::PluginService; |
| 124 | 122 |
| 125 BrowserProcessImpl::BrowserProcessImpl(const CommandLine& command_line) | 123 BrowserProcessImpl::BrowserProcessImpl(const CommandLine& command_line) |
| 126 : created_resource_dispatcher_host_(false), | 124 : created_metrics_service_(false), |
| 127 created_metrics_service_(false), | |
| 128 created_watchdog_thread_(false), | 125 created_watchdog_thread_(false), |
| 129 created_profile_manager_(false), | 126 created_profile_manager_(false), |
| 130 created_local_state_(false), | 127 created_local_state_(false), |
| 131 created_icon_manager_(false), | 128 created_icon_manager_(false), |
| 132 created_sidebar_manager_(false), | 129 created_sidebar_manager_(false), |
| 133 created_browser_policy_connector_(false), | 130 created_browser_policy_connector_(false), |
| 134 created_notification_ui_manager_(false), | 131 created_notification_ui_manager_(false), |
| 135 created_safe_browsing_service_(false), | 132 created_safe_browsing_service_(false), |
| 136 module_ref_count_(0), | 133 module_ref_count_(0), |
| 137 did_start_(false), | 134 did_start_(false), |
| (...skipping 13 matching lines...) Expand all Loading... |
| 151 chrome::kExtensionScheme); | 148 chrome::kExtensionScheme); |
| 152 | 149 |
| 153 extension_event_router_forwarder_ = new ExtensionEventRouterForwarder; | 150 extension_event_router_forwarder_ = new ExtensionEventRouterForwarder; |
| 154 | 151 |
| 155 ExtensionTabIdMap::GetInstance()->Init(); | 152 ExtensionTabIdMap::GetInstance()->Init(); |
| 156 | 153 |
| 157 online_state_observer_.reset(new BrowserOnlineStateObserver); | 154 online_state_observer_.reset(new BrowserOnlineStateObserver); |
| 158 } | 155 } |
| 159 | 156 |
| 160 BrowserProcessImpl::~BrowserProcessImpl() { | 157 BrowserProcessImpl::~BrowserProcessImpl() { |
| 161 // See StartTearDown and PreStopThread functions below, this is where | |
| 162 // most destruction happens so that it can be interleaved with threads | |
| 163 // going away. | |
| 164 | |
| 165 // Wait for the pending print jobs to finish. | 158 // Wait for the pending print jobs to finish. |
| 166 print_job_manager_->OnQuit(); | 159 print_job_manager_->OnQuit(); |
| 167 print_job_manager_.reset(); | 160 print_job_manager_.reset(); |
| 168 | 161 |
| 169 tracked_objects::ThreadData::EnsureCleanupWasCalled(4); | 162 tracked_objects::ThreadData::EnsureCleanupWasCalled(4); |
| 170 | 163 |
| 164 #if defined(OS_CHROMEOS) |
| 165 chromeos::WebSocketProxyController::Shutdown(); |
| 166 #endif |
| 167 |
| 171 g_browser_process = NULL; | 168 g_browser_process = NULL; |
| 172 } | 169 } |
| 173 | 170 |
| 174 void BrowserProcessImpl::StartTearDown() { | 171 void BrowserProcessImpl::StartTearDown() { |
| 175 // Delete the AutomationProviderList before NotificationService, | 172 // Delete the AutomationProviderList before NotificationService, |
| 176 // since it may try to unregister notifications | 173 // since it may try to unregister notifications |
| 177 // Both NotificationService and AutomationProvider are singleton instances in | 174 // Both NotificationService and AutomationProvider are singleton instances in |
| 178 // the BrowserProcess. Since AutomationProvider may have some active | 175 // the BrowserProcess. Since AutomationProvider may have some active |
| 179 // notification observers, it is essential that it gets destroyed before the | 176 // notification observers, it is essential that it gets destroyed before the |
| 180 // NotificationService. NotificationService won't be destroyed until after | 177 // NotificationService. NotificationService won't be destroyed until after |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 // to be cancelled too. Remove this when DefaultRequestContext goes away. | 212 // to be cancelled too. Remove this when DefaultRequestContext goes away. |
| 216 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 213 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
| 217 base::Bind(&content::URLFetcher::CancelAll)); | 214 base::Bind(&content::URLFetcher::CancelAll)); |
| 218 | 215 |
| 219 // Need to clear profiles (download managers) before the io_thread_. | 216 // Need to clear profiles (download managers) before the io_thread_. |
| 220 profile_manager_.reset(); | 217 profile_manager_.reset(); |
| 221 | 218 |
| 222 // Debugger must be cleaned up before IO thread and NotificationService. | 219 // Debugger must be cleaned up before IO thread and NotificationService. |
| 223 remote_debugging_server_.reset(); | 220 remote_debugging_server_.reset(); |
| 224 | 221 |
| 225 if (resource_dispatcher_host_.get()) { | |
| 226 // Cancel pending requests and prevent new requests. | |
| 227 resource_dispatcher_host()->Shutdown(); | |
| 228 } | |
| 229 | |
| 230 ExtensionTabIdMap::GetInstance()->Shutdown(); | 222 ExtensionTabIdMap::GetInstance()->Shutdown(); |
| 231 | 223 |
| 232 // The policy providers managed by |browser_policy_connector_| need to shut | 224 // The policy providers managed by |browser_policy_connector_| need to shut |
| 233 // down while the IO and FILE threads are still alive. | 225 // down while the IO and FILE threads are still alive. |
| 234 browser_policy_connector_.reset(); | 226 browser_policy_connector_.reset(); |
| 235 | 227 |
| 236 // Destroying the GpuProcessHostUIShims on the UI thread posts a task to | 228 // Destroying the GpuProcessHostUIShims on the UI thread posts a task to |
| 237 // delete related objects on the GPU thread. This must be done before | 229 // delete related objects on the GPU thread. This must be done before |
| 238 // stopping the GPU thread. The GPU thread will close IPC channels to renderer | 230 // stopping the GPU thread. The GPU thread will close IPC channels to renderer |
| 239 // processes so this has to happen before stopping the IO thread. | 231 // processes so this has to happen before stopping the IO thread. |
| 240 GpuProcessHostUIShim::DestroyAll(); | 232 GpuProcessHostUIShim::DestroyAll(); |
| 241 | 233 |
| 242 // Stop the watchdog thread before stopping other threads. | 234 // Stop the watchdog thread before stopping other threads. |
| 243 watchdog_thread_.reset(); | 235 watchdog_thread_.reset(); |
| 244 } | 236 } |
| 245 | 237 |
| 246 void BrowserProcessImpl::PreStartThread(BrowserThread::ID thread_id) { | 238 void BrowserProcessImpl::PostDestroyThreads() { |
| 247 switch (thread_id) { | 239 // With the file_thread_ flushed, we can release any icon resources. |
| 248 case BrowserThread::IO: | 240 icon_manager_.reset(); |
| 249 CreateIOThreadState(); | |
| 250 break; | |
| 251 | 241 |
| 252 default: | 242 // Reset associated state right after actual thread is stopped, |
| 253 break; | 243 // as io_thread_.global_ cleanup happens in CleanUp on the IO |
| 254 } | 244 // thread, i.e. as the thread exits its message loop. |
| 255 } | 245 // |
| 256 | 246 // This is important also because in various places, the |
| 257 void BrowserProcessImpl::PostStartThread(BrowserThread::ID thread_id) { | 247 // IOThread object being NULL is considered synonymous with the |
| 258 } | 248 // IO thread having stopped. |
| 259 | 249 io_thread_.reset(); |
| 260 void BrowserProcessImpl::PreStopThread(BrowserThread::ID thread_id) { | |
| 261 switch (thread_id) { | |
| 262 #if defined(OS_CHROMEOS) | |
| 263 case BrowserThread::WEB_SOCKET_PROXY: | |
| 264 chromeos::WebSocketProxyController::Shutdown(); | |
| 265 break; | |
| 266 #endif | |
| 267 case BrowserThread::FILE: | |
| 268 // Clean up state that lives on or uses the file_thread_ before | |
| 269 // it goes away. | |
| 270 if (resource_dispatcher_host_.get()) { | |
| 271 resource_dispatcher_host()->download_file_manager()->Shutdown(); | |
| 272 resource_dispatcher_host()->save_file_manager()->Shutdown(); | |
| 273 } | |
| 274 break; | |
| 275 case BrowserThread::WEBKIT_DEPRECATED: | |
| 276 // Need to destroy ResourceDispatcherHost before PluginService | |
| 277 // and SafeBrowsingService, since it caches a pointer to | |
| 278 // it. | |
| 279 resource_dispatcher_host_.reset(); | |
| 280 break; | |
| 281 default: | |
| 282 break; | |
| 283 } | |
| 284 } | |
| 285 | |
| 286 void BrowserProcessImpl::PostStopThread(BrowserThread::ID thread_id) { | |
| 287 switch (thread_id) { | |
| 288 case BrowserThread::FILE: | |
| 289 // With the file_thread_ flushed, we can release any icon resources. | |
| 290 icon_manager_.reset(); | |
| 291 break; | |
| 292 case BrowserThread::IO: | |
| 293 // Reset associated state right after actual thread is stopped, | |
| 294 // as io_thread_.global_ cleanup happens in CleanUp on the IO | |
| 295 // thread, i.e. as the thread exits its message loop. | |
| 296 // | |
| 297 // This is important also because in various places, the | |
| 298 // IOThread object being NULL is considered synonymous with the | |
| 299 // IO thread having stopped. | |
| 300 io_thread_.reset(); | |
| 301 break; | |
| 302 default: | |
| 303 break; | |
| 304 } | |
| 305 } | 250 } |
| 306 | 251 |
| 307 #if defined(OS_WIN) | 252 #if defined(OS_WIN) |
| 308 // Send a QuitTask to the given MessageLoop when the (file) thread has processed | 253 // Send a QuitTask to the given MessageLoop when the (file) thread has processed |
| 309 // our (other) recent requests (to save preferences). | 254 // our (other) recent requests (to save preferences). |
| 310 // Change the boolean so that the receiving thread will know that we did indeed | 255 // Change the boolean so that the receiving thread will know that we did indeed |
| 311 // send the QuitTask that terminated the message loop. | 256 // send the QuitTask that terminated the message loop. |
| 312 static void PostQuit(MessageLoop* message_loop) { | 257 static void PostQuit(MessageLoop* message_loop) { |
| 313 g_end_session_file_thread_has_completed = true; | 258 g_end_session_file_thread_has_completed = true; |
| 314 message_loop->PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 259 message_loop->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 ++quits_received; | 338 ++quits_received; |
| 394 } while (!g_end_session_file_thread_has_completed); | 339 } while (!g_end_session_file_thread_has_completed); |
| 395 // If we did get extra quits, then we should re-post them to the message loop. | 340 // If we did get extra quits, then we should re-post them to the message loop. |
| 396 while (--quits_received > 0) | 341 while (--quits_received > 0) |
| 397 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 342 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
| 398 #else | 343 #else |
| 399 NOTIMPLEMENTED(); | 344 NOTIMPLEMENTED(); |
| 400 #endif | 345 #endif |
| 401 } | 346 } |
| 402 | 347 |
| 403 ResourceDispatcherHost* BrowserProcessImpl::resource_dispatcher_host() { | |
| 404 DCHECK(CalledOnValidThread()); | |
| 405 if (!created_resource_dispatcher_host_) | |
| 406 CreateResourceDispatcherHost(); | |
| 407 return resource_dispatcher_host_.get(); | |
| 408 } | |
| 409 | |
| 410 MetricsService* BrowserProcessImpl::metrics_service() { | 348 MetricsService* BrowserProcessImpl::metrics_service() { |
| 411 DCHECK(CalledOnValidThread()); | 349 DCHECK(CalledOnValidThread()); |
| 412 if (!created_metrics_service_) | 350 if (!created_metrics_service_) |
| 413 CreateMetricsService(); | 351 CreateMetricsService(); |
| 414 return metrics_service_.get(); | 352 return metrics_service_.get(); |
| 415 } | 353 } |
| 416 | 354 |
| 417 IOThread* BrowserProcessImpl::io_thread() { | 355 IOThread* BrowserProcessImpl::io_thread() { |
| 418 DCHECK(CalledOnValidThread()); | 356 DCHECK(CalledOnValidThread()); |
| 419 DCHECK(io_thread_.get()); | 357 DCHECK(io_thread_.get()); |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 705 } | 643 } |
| 706 | 644 |
| 707 AudioManager* BrowserProcessImpl::audio_manager() { | 645 AudioManager* BrowserProcessImpl::audio_manager() { |
| 708 DCHECK(CalledOnValidThread()); | 646 DCHECK(CalledOnValidThread()); |
| 709 if (!audio_manager_) | 647 if (!audio_manager_) |
| 710 audio_manager_ = AudioManager::Create(); | 648 audio_manager_ = AudioManager::Create(); |
| 711 | 649 |
| 712 return audio_manager_; | 650 return audio_manager_; |
| 713 } | 651 } |
| 714 | 652 |
| 715 void BrowserProcessImpl::CreateResourceDispatcherHost() { | 653 void BrowserProcessImpl::ResourceDispatcherHostCreated() { |
| 716 DCHECK(!created_resource_dispatcher_host_ && | |
| 717 resource_dispatcher_host_.get() == NULL); | |
| 718 created_resource_dispatcher_host_ = true; | |
| 719 | |
| 720 // UserScriptListener and NetworkDelayListener will delete themselves. | 654 // UserScriptListener and NetworkDelayListener will delete themselves. |
| 721 ResourceQueue::DelegateSet resource_queue_delegates; | 655 ResourceDispatcherHost* rdh = ResourceDispatcherHost::Get(); |
| 722 resource_queue_delegates.insert(new UserScriptListener()); | 656 rdh->AddResourceQueueDelegate(new UserScriptListener()); |
| 723 resource_queue_delegates.insert(new NetworkDelayListener()); | 657 rdh->AddResourceQueueDelegate(new NetworkDelayListener()); |
| 724 | |
| 725 resource_dispatcher_host_.reset( | |
| 726 new ResourceDispatcherHost(resource_queue_delegates)); | |
| 727 resource_dispatcher_host_->Initialize(); | |
| 728 | 658 |
| 729 resource_dispatcher_host_delegate_.reset( | 659 resource_dispatcher_host_delegate_.reset( |
| 730 new ChromeResourceDispatcherHostDelegate(resource_dispatcher_host_.get(), | 660 new ChromeResourceDispatcherHostDelegate(rdh, prerender_tracker())); |
| 731 prerender_tracker())); | 661 rdh->set_delegate(resource_dispatcher_host_delegate_.get()); |
| 732 resource_dispatcher_host_->set_delegate( | |
| 733 resource_dispatcher_host_delegate_.get()); | |
| 734 | 662 |
| 735 pref_change_registrar_.Add(prefs::kAllowCrossOriginAuthPrompt, this); | 663 pref_change_registrar_.Add(prefs::kAllowCrossOriginAuthPrompt, this); |
| 736 ApplyAllowCrossOriginAuthPromptPolicy(); | 664 ApplyAllowCrossOriginAuthPromptPolicy(); |
| 737 } | 665 } |
| 738 | 666 |
| 739 void BrowserProcessImpl::CreateMetricsService() { | 667 void BrowserProcessImpl::CreateMetricsService() { |
| 740 DCHECK(!created_metrics_service_ && metrics_service_.get() == NULL); | 668 DCHECK(!created_metrics_service_ && metrics_service_.get() == NULL); |
| 741 created_metrics_service_ = true; | 669 created_metrics_service_ = true; |
| 742 | 670 |
| 743 metrics_service_.reset(new MetricsService); | 671 metrics_service_.reset(new MetricsService); |
| 744 } | 672 } |
| 745 | 673 |
| 746 void BrowserProcessImpl::CreateIOThreadState() { | |
| 747 // Prior to any processing happening on the io thread, we create the | |
| 748 // plugin service as it is predominantly used from the io thread, | |
| 749 // but must be created on the main thread. The service ctor is | |
| 750 // inexpensive and does not invoke the io_thread() accessor. | |
| 751 PluginService* plugin_service = PluginService::GetInstance(); | |
| 752 plugin_service->Init(); | |
| 753 plugin_service->SetFilter(ChromePluginServiceFilter::GetInstance()); | |
| 754 plugin_service->StartWatchingPlugins(); | |
| 755 | |
| 756 // Register the internal Flash if available. | |
| 757 FilePath path; | |
| 758 if (!CommandLine::ForCurrentProcess()->HasSwitch( | |
| 759 switches::kDisableInternalFlash) && | |
| 760 PathService::Get(chrome::FILE_FLASH_PLUGIN, &path)) { | |
| 761 plugin_service->AddExtraPluginPath(path); | |
| 762 } | |
| 763 | |
| 764 #if defined(OS_POSIX) | |
| 765 // Also find plugins in a user-specific plugins dir, | |
| 766 // e.g. ~/.config/chromium/Plugins. | |
| 767 FilePath user_data_dir; | |
| 768 if (PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) { | |
| 769 plugin_service->AddExtraPluginPath(user_data_dir.Append("Plugins")); | |
| 770 } | |
| 771 #endif | |
| 772 | |
| 773 scoped_ptr<IOThread> thread(new IOThread( | |
| 774 local_state(), net_log_.get(), extension_event_router_forwarder_.get())); | |
| 775 io_thread_.swap(thread); | |
| 776 } | |
| 777 | |
| 778 void BrowserProcessImpl::CreateWatchdogThread() { | 674 void BrowserProcessImpl::CreateWatchdogThread() { |
| 779 DCHECK(!created_watchdog_thread_ && watchdog_thread_.get() == NULL); | 675 DCHECK(!created_watchdog_thread_ && watchdog_thread_.get() == NULL); |
| 780 created_watchdog_thread_ = true; | 676 created_watchdog_thread_ = true; |
| 781 | 677 |
| 782 scoped_ptr<WatchDogThread> thread(new WatchDogThread()); | 678 scoped_ptr<WatchDogThread> thread(new WatchDogThread()); |
| 783 if (!thread->Start()) | 679 if (!thread->Start()) |
| 784 return; | 680 return; |
| 785 watchdog_thread_.swap(thread); | 681 watchdog_thread_.swap(thread); |
| 786 } | 682 } |
| 787 | 683 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 834 | 730 |
| 835 // This is observed by ChildProcessSecurityPolicy, which lives in content/ | 731 // This is observed by ChildProcessSecurityPolicy, which lives in content/ |
| 836 // though, so it can't register itself. | 732 // though, so it can't register itself. |
| 837 local_state_->RegisterListPref(prefs::kDisabledSchemes); | 733 local_state_->RegisterListPref(prefs::kDisabledSchemes); |
| 838 pref_change_registrar_.Add(prefs::kDisabledSchemes, this); | 734 pref_change_registrar_.Add(prefs::kDisabledSchemes, this); |
| 839 ApplyDisabledSchemesPolicy(); | 735 ApplyDisabledSchemesPolicy(); |
| 840 | 736 |
| 841 local_state_->RegisterBooleanPref(prefs::kAllowCrossOriginAuthPrompt, false); | 737 local_state_->RegisterBooleanPref(prefs::kAllowCrossOriginAuthPrompt, false); |
| 842 } | 738 } |
| 843 | 739 |
| 740 void BrowserProcessImpl::PreCreateThreads() { |
| 741 io_thread_.reset(new IOThread( |
| 742 local_state(), net_log_.get(), extension_event_router_forwarder_.get())); |
| 743 } |
| 744 |
| 844 void BrowserProcessImpl::PreMainMessageLoopRun() { | 745 void BrowserProcessImpl::PreMainMessageLoopRun() { |
| 746 PluginService* plugin_service = PluginService::GetInstance(); |
| 747 plugin_service->SetFilter(ChromePluginServiceFilter::GetInstance()); |
| 748 plugin_service->StartWatchingPlugins(); |
| 749 |
| 750 // Register the internal Flash if available. |
| 751 FilePath path; |
| 752 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
| 753 switches::kDisableInternalFlash) && |
| 754 PathService::Get(chrome::FILE_FLASH_PLUGIN, &path)) { |
| 755 plugin_service->AddExtraPluginPath(path); |
| 756 } |
| 757 |
| 758 #if defined(OS_POSIX) |
| 759 // Also find plugins in a user-specific plugins dir, |
| 760 // e.g. ~/.config/chromium/Plugins. |
| 761 FilePath user_data_dir; |
| 762 if (PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) { |
| 763 plugin_service->AddExtraPluginPath(user_data_dir.Append("Plugins")); |
| 764 } |
| 765 #endif |
| 766 |
| 845 if (local_state_->IsManagedPreference(prefs::kDefaultBrowserSettingEnabled)) | 767 if (local_state_->IsManagedPreference(prefs::kDefaultBrowserSettingEnabled)) |
| 846 ApplyDefaultBrowserPolicy(); | 768 ApplyDefaultBrowserPolicy(); |
| 847 } | 769 } |
| 848 | 770 |
| 849 void BrowserProcessImpl::CreateIconManager() { | 771 void BrowserProcessImpl::CreateIconManager() { |
| 850 DCHECK(!created_icon_manager_ && icon_manager_.get() == NULL); | 772 DCHECK(!created_icon_manager_ && icon_manager_.get() == NULL); |
| 851 created_icon_manager_ = true; | 773 created_icon_manager_ = true; |
| 852 icon_manager_.reset(new IconManager); | 774 icon_manager_.reset(new IconManager); |
| 853 } | 775 } |
| 854 | 776 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 930 void BrowserProcessImpl::ApplyDefaultBrowserPolicy() { | 852 void BrowserProcessImpl::ApplyDefaultBrowserPolicy() { |
| 931 if (local_state_->GetBoolean(prefs::kDefaultBrowserSettingEnabled)) { | 853 if (local_state_->GetBoolean(prefs::kDefaultBrowserSettingEnabled)) { |
| 932 scoped_refptr<ShellIntegration::DefaultWebClientWorker> | 854 scoped_refptr<ShellIntegration::DefaultWebClientWorker> |
| 933 set_browser_worker = new ShellIntegration::DefaultBrowserWorker(NULL); | 855 set_browser_worker = new ShellIntegration::DefaultBrowserWorker(NULL); |
| 934 set_browser_worker->StartSetAsDefault(); | 856 set_browser_worker->StartSetAsDefault(); |
| 935 } | 857 } |
| 936 } | 858 } |
| 937 | 859 |
| 938 void BrowserProcessImpl::ApplyAllowCrossOriginAuthPromptPolicy() { | 860 void BrowserProcessImpl::ApplyAllowCrossOriginAuthPromptPolicy() { |
| 939 bool value = local_state()->GetBoolean(prefs::kAllowCrossOriginAuthPrompt); | 861 bool value = local_state()->GetBoolean(prefs::kAllowCrossOriginAuthPrompt); |
| 940 resource_dispatcher_host()->set_allow_cross_origin_auth_prompt(value); | 862 ResourceDispatcherHost::Get()->set_allow_cross_origin_auth_prompt(value); |
| 941 } | 863 } |
| 942 | 864 |
| 943 // Mac is currently not supported. | 865 // Mac is currently not supported. |
| 944 #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) | 866 #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) |
| 945 | 867 |
| 946 bool BrowserProcessImpl::CanAutorestartForUpdate() const { | 868 bool BrowserProcessImpl::CanAutorestartForUpdate() const { |
| 947 // Check if browser is in the background and if it needs to be restarted to | 869 // Check if browser is in the background and if it needs to be restarted to |
| 948 // apply a pending update. | 870 // apply a pending update. |
| 949 return BrowserList::size() == 0 && BrowserList::WillKeepAlive() && | 871 return BrowserList::size() == 0 && BrowserList::WillKeepAlive() && |
| 950 upgrade_util::IsUpdatePendingRestart(); | 872 upgrade_util::IsUpdatePendingRestart(); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 990 } | 912 } |
| 991 | 913 |
| 992 void BrowserProcessImpl::OnAutoupdateTimer() { | 914 void BrowserProcessImpl::OnAutoupdateTimer() { |
| 993 if (CanAutorestartForUpdate()) { | 915 if (CanAutorestartForUpdate()) { |
| 994 DLOG(WARNING) << "Detected update. Restarting browser."; | 916 DLOG(WARNING) << "Detected update. Restarting browser."; |
| 995 RestartBackgroundInstance(); | 917 RestartBackgroundInstance(); |
| 996 } | 918 } |
| 997 } | 919 } |
| 998 | 920 |
| 999 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) | 921 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) |
| OLD | NEW |