| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 #include "chrome/browser/metrics/thread_watcher.h" | 43 #include "chrome/browser/metrics/thread_watcher.h" |
| 44 #include "chrome/browser/metrics/variations/variations_service.h" | 44 #include "chrome/browser/metrics/variations/variations_service.h" |
| 45 #include "chrome/browser/net/chrome_net_log.h" | 45 #include "chrome/browser/net/chrome_net_log.h" |
| 46 #include "chrome/browser/net/crl_set_fetcher.h" | 46 #include "chrome/browser/net/crl_set_fetcher.h" |
| 47 #include "chrome/browser/net/sdch_dictionary_fetcher.h" | 47 #include "chrome/browser/net/sdch_dictionary_fetcher.h" |
| 48 #include "chrome/browser/notifications/notification_ui_manager.h" | 48 #include "chrome/browser/notifications/notification_ui_manager.h" |
| 49 #include "chrome/browser/plugins/plugin_finder.h" | 49 #include "chrome/browser/plugins/plugin_finder.h" |
| 50 #include "chrome/browser/policy/policy_service.h" | 50 #include "chrome/browser/policy/policy_service.h" |
| 51 #include "chrome/browser/prefs/browser_prefs.h" | 51 #include "chrome/browser/prefs/browser_prefs.h" |
| 52 #include "chrome/browser/prefs/chrome_pref_service_factory.h" | 52 #include "chrome/browser/prefs/chrome_pref_service_factory.h" |
| 53 #include "chrome/browser/prefs/pref_registrar_simple.h" |
| 54 #include "chrome/browser/prefs/pref_registrar_simple.h" |
| 53 #include "chrome/browser/prefs/pref_service.h" | 55 #include "chrome/browser/prefs/pref_service.h" |
| 54 #include "chrome/browser/prerender/prerender_tracker.h" | 56 #include "chrome/browser/prerender/prerender_tracker.h" |
| 55 #include "chrome/browser/printing/background_printing_manager.h" | 57 #include "chrome/browser/printing/background_printing_manager.h" |
| 56 #include "chrome/browser/printing/print_job_manager.h" | 58 #include "chrome/browser/printing/print_job_manager.h" |
| 57 #include "chrome/browser/printing/print_preview_dialog_controller.h" | 59 #include "chrome/browser/printing/print_preview_dialog_controller.h" |
| 58 #include "chrome/browser/profiles/profile_manager.h" | 60 #include "chrome/browser/profiles/profile_manager.h" |
| 59 #include "chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.
h" | 61 #include "chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.
h" |
| 60 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 62 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 61 #include "chrome/browser/shell_integration.h" | 63 #include "chrome/browser/shell_integration.h" |
| 62 #include "chrome/browser/status_icons/status_tray.h" | 64 #include "chrome/browser/status_icons/status_tray.h" |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 return watchdog_thread_.get(); | 393 return watchdog_thread_.get(); |
| 392 } | 394 } |
| 393 | 395 |
| 394 ProfileManager* BrowserProcessImpl::profile_manager() { | 396 ProfileManager* BrowserProcessImpl::profile_manager() { |
| 395 DCHECK(CalledOnValidThread()); | 397 DCHECK(CalledOnValidThread()); |
| 396 if (!created_profile_manager_) | 398 if (!created_profile_manager_) |
| 397 CreateProfileManager(); | 399 CreateProfileManager(); |
| 398 return profile_manager_.get(); | 400 return profile_manager_.get(); |
| 399 } | 401 } |
| 400 | 402 |
| 401 // TODO(joi): Switch to returning just PrefService, since those | 403 PrefService* BrowserProcessImpl::local_state() { |
| 402 // calling this function shouldn't be doing ad-hoc registration, that | |
| 403 // happens earlier in browser_prefs::RegisterLocalState. | |
| 404 PrefServiceSimple* BrowserProcessImpl::local_state() { | |
| 405 DCHECK(CalledOnValidThread()); | 404 DCHECK(CalledOnValidThread()); |
| 406 if (!created_local_state_) | 405 if (!created_local_state_) |
| 407 CreateLocalState(); | 406 CreateLocalState(); |
| 408 return local_state_.get(); | 407 return local_state_.get(); |
| 409 } | 408 } |
| 410 | 409 |
| 411 net::URLRequestContextGetter* BrowserProcessImpl::system_request_context() { | 410 net::URLRequestContextGetter* BrowserProcessImpl::system_request_context() { |
| 412 DCHECK(CalledOnValidThread()); | 411 DCHECK(CalledOnValidThread()); |
| 413 return io_thread()->system_url_request_context_getter(); | 412 return io_thread()->system_url_request_context_getter(); |
| 414 } | 413 } |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 media_file_system_registry_.reset(new chrome::MediaFileSystemRegistry()); | 590 media_file_system_registry_.reset(new chrome::MediaFileSystemRegistry()); |
| 592 return media_file_system_registry_.get(); | 591 return media_file_system_registry_.get(); |
| 593 } | 592 } |
| 594 | 593 |
| 595 #if !defined(OS_WIN) | 594 #if !defined(OS_WIN) |
| 596 void BrowserProcessImpl::PlatformSpecificCommandLineProcessing( | 595 void BrowserProcessImpl::PlatformSpecificCommandLineProcessing( |
| 597 const CommandLine& command_line) { | 596 const CommandLine& command_line) { |
| 598 } | 597 } |
| 599 #endif | 598 #endif |
| 600 | 599 |
| 600 // static |
| 601 void BrowserProcessImpl::RegisterPrefs(PrefRegistrarSimple* registrar) { |
| 602 registrar->RegisterBooleanPref(prefs::kDefaultBrowserSettingEnabled, |
| 603 false); |
| 604 // This policy needs to be defined before the net subsystem is initialized, |
| 605 // so we do it here. |
| 606 registrar->RegisterIntegerPref(prefs::kMaxConnectionsPerProxy, |
| 607 net::kDefaultMaxSocketsPerProxyServer); |
| 608 |
| 609 // This is observed by ChildProcessSecurityPolicy, which lives in content/ |
| 610 // though, so it can't register itself. |
| 611 registrar->RegisterListPref(prefs::kDisabledSchemes); |
| 612 |
| 613 registrar->RegisterBooleanPref(prefs::kAllowCrossOriginAuthPrompt, false); |
| 614 |
| 615 #if defined(OS_WIN) |
| 616 if (base::win::GetVersion() >= base::win::VERSION_WIN8) |
| 617 registrar->RegisterBooleanPref(prefs::kRestartSwitchMode, false); |
| 618 #endif |
| 619 |
| 620 // TODO(brettw,*): this comment about ResourceBundle was here since |
| 621 // initial commit. This comment seems unrelated, bit-rotten and |
| 622 // a candidate for removal. |
| 623 // Initialize ResourceBundle which handles files loaded from external |
| 624 // sources. This has to be done before uninstall code path and before prefs |
| 625 // are registered. |
| 626 registrar->RegisterStringPref(prefs::kApplicationLocale, std::string()); |
| 627 #if defined(OS_CHROMEOS) |
| 628 registrar->RegisterStringPref(prefs::kOwnerLocale, std::string()); |
| 629 registrar->RegisterStringPref(prefs::kHardwareKeyboardLayout, |
| 630 std::string()); |
| 631 #endif // defined(OS_CHROMEOS) |
| 632 #if !defined(OS_CHROMEOS) |
| 633 registrar->RegisterBooleanPref( |
| 634 prefs::kMetricsReportingEnabled, |
| 635 GoogleUpdateSettings::GetCollectStatsConsent()); |
| 636 #endif // !defined(OS_CHROMEOS) |
| 637 } |
| 638 |
| 601 DownloadRequestLimiter* BrowserProcessImpl::download_request_limiter() { | 639 DownloadRequestLimiter* BrowserProcessImpl::download_request_limiter() { |
| 602 DCHECK(CalledOnValidThread()); | 640 DCHECK(CalledOnValidThread()); |
| 603 if (!download_request_limiter_) | 641 if (!download_request_limiter_) |
| 604 download_request_limiter_ = new DownloadRequestLimiter(); | 642 download_request_limiter_ = new DownloadRequestLimiter(); |
| 605 return download_request_limiter_; | 643 return download_request_limiter_; |
| 606 } | 644 } |
| 607 | 645 |
| 608 BackgroundModeManager* BrowserProcessImpl::background_mode_manager() { | 646 BackgroundModeManager* BrowserProcessImpl::background_mode_manager() { |
| 609 DCHECK(CalledOnValidThread()); | 647 DCHECK(CalledOnValidThread()); |
| 610 #if defined(ENABLE_BACKGROUND) | 648 #if defined(ENABLE_BACKGROUND) |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 740 local_state_task_runner_, | 778 local_state_task_runner_, |
| 741 policy_service(), | 779 policy_service(), |
| 742 NULL, false)); | 780 NULL, false)); |
| 743 | 781 |
| 744 // Initialize the prefs of the local state. | 782 // Initialize the prefs of the local state. |
| 745 chrome::RegisterLocalState(local_state_.get()); | 783 chrome::RegisterLocalState(local_state_.get()); |
| 746 | 784 |
| 747 pref_change_registrar_.Init(local_state_.get()); | 785 pref_change_registrar_.Init(local_state_.get()); |
| 748 | 786 |
| 749 // Initialize the notification for the default browser setting policy. | 787 // Initialize the notification for the default browser setting policy. |
| 750 local_state_->RegisterBooleanPref(prefs::kDefaultBrowserSettingEnabled, | |
| 751 false); | |
| 752 pref_change_registrar_.Add( | 788 pref_change_registrar_.Add( |
| 753 prefs::kDefaultBrowserSettingEnabled, | 789 prefs::kDefaultBrowserSettingEnabled, |
| 754 base::Bind(&BrowserProcessImpl::ApplyDefaultBrowserPolicy, | 790 base::Bind(&BrowserProcessImpl::ApplyDefaultBrowserPolicy, |
| 755 base::Unretained(this))); | 791 base::Unretained(this))); |
| 756 | 792 |
| 757 // This policy needs to be defined before the net subsystem is initialized, | |
| 758 // so we do it here. | |
| 759 local_state_->RegisterIntegerPref(prefs::kMaxConnectionsPerProxy, | |
| 760 net::kDefaultMaxSocketsPerProxyServer); | |
| 761 int max_per_proxy = local_state_->GetInteger(prefs::kMaxConnectionsPerProxy); | 793 int max_per_proxy = local_state_->GetInteger(prefs::kMaxConnectionsPerProxy); |
| 762 net::ClientSocketPoolManager::set_max_sockets_per_proxy_server( | 794 net::ClientSocketPoolManager::set_max_sockets_per_proxy_server( |
| 763 net::HttpNetworkSession::NORMAL_SOCKET_POOL, | 795 net::HttpNetworkSession::NORMAL_SOCKET_POOL, |
| 764 std::max(std::min(max_per_proxy, 99), | 796 std::max(std::min(max_per_proxy, 99), |
| 765 net::ClientSocketPoolManager::max_sockets_per_group( | 797 net::ClientSocketPoolManager::max_sockets_per_group( |
| 766 net::HttpNetworkSession::NORMAL_SOCKET_POOL))); | 798 net::HttpNetworkSession::NORMAL_SOCKET_POOL))); |
| 767 | 799 |
| 768 // This is observed by ChildProcessSecurityPolicy, which lives in content/ | |
| 769 // though, so it can't register itself. | |
| 770 local_state_->RegisterListPref(prefs::kDisabledSchemes); | |
| 771 pref_change_registrar_.Add( | 800 pref_change_registrar_.Add( |
| 772 prefs::kDisabledSchemes, | 801 prefs::kDisabledSchemes, |
| 773 base::Bind(&BrowserProcessImpl::ApplyDisabledSchemesPolicy, | 802 base::Bind(&BrowserProcessImpl::ApplyDisabledSchemesPolicy, |
| 774 base::Unretained(this))); | 803 base::Unretained(this))); |
| 775 ApplyDisabledSchemesPolicy(); | 804 ApplyDisabledSchemesPolicy(); |
| 776 | |
| 777 local_state_->RegisterBooleanPref(prefs::kAllowCrossOriginAuthPrompt, false); | |
| 778 | |
| 779 #if defined(OS_WIN) | |
| 780 if (base::win::GetVersion() >= base::win::VERSION_WIN8) | |
| 781 local_state_->RegisterBooleanPref(prefs::kRestartSwitchMode, false); | |
| 782 #endif | |
| 783 } | 805 } |
| 784 | 806 |
| 785 void BrowserProcessImpl::PreCreateThreads() { | 807 void BrowserProcessImpl::PreCreateThreads() { |
| 786 io_thread_.reset(new IOThread(local_state(), policy_service(), net_log_.get(), | 808 io_thread_.reset(new IOThread(local_state(), policy_service(), net_log_.get(), |
| 787 extension_event_router_forwarder_.get())); | 809 extension_event_router_forwarder_.get())); |
| 788 } | 810 } |
| 789 | 811 |
| 790 void BrowserProcessImpl::PreMainMessageLoopRun() { | 812 void BrowserProcessImpl::PreMainMessageLoopRun() { |
| 791 #if defined(ENABLE_PLUGINS) | 813 #if defined(ENABLE_PLUGINS) |
| 792 PluginService* plugin_service = PluginService::GetInstance(); | 814 PluginService* plugin_service = PluginService::GetInstance(); |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 962 } | 984 } |
| 963 | 985 |
| 964 void BrowserProcessImpl::OnAutoupdateTimer() { | 986 void BrowserProcessImpl::OnAutoupdateTimer() { |
| 965 if (CanAutorestartForUpdate()) { | 987 if (CanAutorestartForUpdate()) { |
| 966 DLOG(WARNING) << "Detected update. Restarting browser."; | 988 DLOG(WARNING) << "Detected update. Restarting browser."; |
| 967 RestartBackgroundInstance(); | 989 RestartBackgroundInstance(); |
| 968 } | 990 } |
| 969 } | 991 } |
| 970 | 992 |
| 971 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) | 993 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) |
| OLD | NEW |