Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(188)

Side by Side Diff: chrome/browser/browser_process_impl.cc

Issue 11741003: Remove PrefServiceSimple, replacing it with PrefService and PrefRegistrySimple. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Respond to review comments. Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
43 #include "chrome/browser/metrics/variations/variations_service.h" 43 #include "chrome/browser/metrics/variations/variations_service.h"
44 #include "chrome/browser/net/chrome_net_log.h" 44 #include "chrome/browser/net/chrome_net_log.h"
45 #include "chrome/browser/net/crl_set_fetcher.h" 45 #include "chrome/browser/net/crl_set_fetcher.h"
46 #include "chrome/browser/net/sdch_dictionary_fetcher.h" 46 #include "chrome/browser/net/sdch_dictionary_fetcher.h"
47 #include "chrome/browser/notifications/notification_ui_manager.h" 47 #include "chrome/browser/notifications/notification_ui_manager.h"
48 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" 48 #include "chrome/browser/plugins/chrome_plugin_service_filter.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_registry_simple.h"
53 #include "chrome/browser/prefs/pref_service.h" 54 #include "chrome/browser/prefs/pref_service.h"
54 #include "chrome/browser/prerender/prerender_tracker.h" 55 #include "chrome/browser/prerender/prerender_tracker.h"
55 #include "chrome/browser/printing/background_printing_manager.h" 56 #include "chrome/browser/printing/background_printing_manager.h"
56 #include "chrome/browser/printing/print_job_manager.h" 57 #include "chrome/browser/printing/print_job_manager.h"
57 #include "chrome/browser/printing/print_preview_dialog_controller.h" 58 #include "chrome/browser/printing/print_preview_dialog_controller.h"
58 #include "chrome/browser/profiles/profile_manager.h" 59 #include "chrome/browser/profiles/profile_manager.h"
59 #include "chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate. h" 60 #include "chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate. h"
60 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 61 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
61 #include "chrome/browser/shell_integration.h" 62 #include "chrome/browser/shell_integration.h"
62 #include "chrome/browser/status_icons/status_tray.h" 63 #include "chrome/browser/status_icons/status_tray.h"
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 return watchdog_thread_.get(); 404 return watchdog_thread_.get();
404 } 405 }
405 406
406 ProfileManager* BrowserProcessImpl::profile_manager() { 407 ProfileManager* BrowserProcessImpl::profile_manager() {
407 DCHECK(CalledOnValidThread()); 408 DCHECK(CalledOnValidThread());
408 if (!created_profile_manager_) 409 if (!created_profile_manager_)
409 CreateProfileManager(); 410 CreateProfileManager();
410 return profile_manager_.get(); 411 return profile_manager_.get();
411 } 412 }
412 413
413 // TODO(joi): Switch to returning just PrefService, since those 414 PrefService* BrowserProcessImpl::local_state() {
414 // calling this function shouldn't be doing ad-hoc registration, that
415 // happens earlier in browser_prefs::RegisterLocalState.
416 PrefServiceSimple* BrowserProcessImpl::local_state() {
417 DCHECK(CalledOnValidThread()); 415 DCHECK(CalledOnValidThread());
418 if (!created_local_state_) 416 if (!created_local_state_)
419 CreateLocalState(); 417 CreateLocalState();
420 return local_state_.get(); 418 return local_state_.get();
421 } 419 }
422 420
423 net::URLRequestContextGetter* BrowserProcessImpl::system_request_context() { 421 net::URLRequestContextGetter* BrowserProcessImpl::system_request_context() {
424 DCHECK(CalledOnValidThread()); 422 DCHECK(CalledOnValidThread());
425 return io_thread()->system_url_request_context_getter(); 423 return io_thread()->system_url_request_context_getter();
426 } 424 }
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 media_file_system_registry_.reset(new chrome::MediaFileSystemRegistry()); 612 media_file_system_registry_.reset(new chrome::MediaFileSystemRegistry());
615 return media_file_system_registry_.get(); 613 return media_file_system_registry_.get();
616 } 614 }
617 615
618 #if !defined(OS_WIN) 616 #if !defined(OS_WIN)
619 void BrowserProcessImpl::PlatformSpecificCommandLineProcessing( 617 void BrowserProcessImpl::PlatformSpecificCommandLineProcessing(
620 const CommandLine& command_line) { 618 const CommandLine& command_line) {
621 } 619 }
622 #endif 620 #endif
623 621
622 // static
623 void BrowserProcessImpl::RegisterPrefs(PrefRegistrySimple* registry) {
624 registry->RegisterBooleanPref(prefs::kDefaultBrowserSettingEnabled,
625 false);
626 // This policy needs to be defined before the net subsystem is initialized,
627 // so we do it here.
628 registry->RegisterIntegerPref(prefs::kMaxConnectionsPerProxy,
629 net::kDefaultMaxSocketsPerProxyServer);
630
631 // This is observed by ChildProcessSecurityPolicy, which lives in content/
632 // though, so it can't register itself.
633 registry->RegisterListPref(prefs::kDisabledSchemes);
634
635 registry->RegisterBooleanPref(prefs::kAllowCrossOriginAuthPrompt, false);
636
637 #if defined(OS_WIN)
638 if (base::win::GetVersion() >= base::win::VERSION_WIN8)
639 registry->RegisterBooleanPref(prefs::kRestartSwitchMode, false);
640 #endif
641
642 // TODO(brettw,*): this comment about ResourceBundle was here since
643 // initial commit. This comment seems unrelated, bit-rotten and
644 // a candidate for removal.
645 // Initialize ResourceBundle which handles files loaded from external
646 // sources. This has to be done before uninstall code path and before prefs
647 // are registered.
648 registry->RegisterStringPref(prefs::kApplicationLocale, std::string());
649 #if defined(OS_CHROMEOS)
650 registry->RegisterStringPref(prefs::kOwnerLocale, std::string());
651 registry->RegisterStringPref(prefs::kHardwareKeyboardLayout,
652 std::string());
653 #endif // defined(OS_CHROMEOS)
654 #if !defined(OS_CHROMEOS)
655 registry->RegisterBooleanPref(
656 prefs::kMetricsReportingEnabled,
657 GoogleUpdateSettings::GetCollectStatsConsent());
658 #endif // !defined(OS_CHROMEOS)
659 }
660
624 DownloadRequestLimiter* BrowserProcessImpl::download_request_limiter() { 661 DownloadRequestLimiter* BrowserProcessImpl::download_request_limiter() {
625 DCHECK(CalledOnValidThread()); 662 DCHECK(CalledOnValidThread());
626 if (!download_request_limiter_) 663 if (!download_request_limiter_)
627 download_request_limiter_ = new DownloadRequestLimiter(); 664 download_request_limiter_ = new DownloadRequestLimiter();
628 return download_request_limiter_; 665 return download_request_limiter_;
629 } 666 }
630 667
631 BackgroundModeManager* BrowserProcessImpl::background_mode_manager() { 668 BackgroundModeManager* BrowserProcessImpl::background_mode_manager() {
632 DCHECK(CalledOnValidThread()); 669 DCHECK(CalledOnValidThread());
633 #if defined(ENABLE_BACKGROUND) 670 #if defined(ENABLE_BACKGROUND)
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); 787 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir);
751 profile_manager_.reset(new ProfileManager(user_data_dir)); 788 profile_manager_.reset(new ProfileManager(user_data_dir));
752 } 789 }
753 790
754 void BrowserProcessImpl::CreateLocalState() { 791 void BrowserProcessImpl::CreateLocalState() {
755 DCHECK(!created_local_state_ && local_state_.get() == NULL); 792 DCHECK(!created_local_state_ && local_state_.get() == NULL);
756 created_local_state_ = true; 793 created_local_state_ = true;
757 794
758 FilePath local_state_path; 795 FilePath local_state_path;
759 CHECK(PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path)); 796 CHECK(PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path));
797 scoped_refptr<PrefRegistrySimple> pref_registry = new PrefRegistrySimple;
760 local_state_.reset( 798 local_state_.reset(
761 chrome_prefs::CreateLocalState(local_state_path, 799 chrome_prefs::CreateLocalState(local_state_path,
762 local_state_task_runner_, 800 local_state_task_runner_,
763 policy_service(), 801 policy_service(),
764 NULL, false)); 802 NULL,
803 pref_registry,
804 false));
765 805
766 // Initialize the prefs of the local state. 806 // Initialize the prefs of the local state.
767 chrome::RegisterLocalState(local_state_.get()); 807 //
808 // TODO(joi): Once we clean up so none of the registration methods
809 // need the PrefService pointer, this should happen before the call
810 // to CreateLocalState.
811 chrome::RegisterLocalState(pref_registry, local_state_.get());
768 812
769 pref_change_registrar_.Init(local_state_.get()); 813 pref_change_registrar_.Init(local_state_.get());
770 814
771 // Initialize the notification for the default browser setting policy. 815 // Initialize the notification for the default browser setting policy.
772 local_state_->RegisterBooleanPref(prefs::kDefaultBrowserSettingEnabled,
773 false);
774 pref_change_registrar_.Add( 816 pref_change_registrar_.Add(
775 prefs::kDefaultBrowserSettingEnabled, 817 prefs::kDefaultBrowserSettingEnabled,
776 base::Bind(&BrowserProcessImpl::ApplyDefaultBrowserPolicy, 818 base::Bind(&BrowserProcessImpl::ApplyDefaultBrowserPolicy,
777 base::Unretained(this))); 819 base::Unretained(this)));
778 820
779 // This policy needs to be defined before the net subsystem is initialized,
780 // so we do it here.
781 local_state_->RegisterIntegerPref(prefs::kMaxConnectionsPerProxy,
782 net::kDefaultMaxSocketsPerProxyServer);
783 int max_per_proxy = local_state_->GetInteger(prefs::kMaxConnectionsPerProxy); 821 int max_per_proxy = local_state_->GetInteger(prefs::kMaxConnectionsPerProxy);
784 net::ClientSocketPoolManager::set_max_sockets_per_proxy_server( 822 net::ClientSocketPoolManager::set_max_sockets_per_proxy_server(
785 net::HttpNetworkSession::NORMAL_SOCKET_POOL, 823 net::HttpNetworkSession::NORMAL_SOCKET_POOL,
786 std::max(std::min(max_per_proxy, 99), 824 std::max(std::min(max_per_proxy, 99),
787 net::ClientSocketPoolManager::max_sockets_per_group( 825 net::ClientSocketPoolManager::max_sockets_per_group(
788 net::HttpNetworkSession::NORMAL_SOCKET_POOL))); 826 net::HttpNetworkSession::NORMAL_SOCKET_POOL)));
789 827
790 // This is observed by ChildProcessSecurityPolicy, which lives in content/
791 // though, so it can't register itself.
792 local_state_->RegisterListPref(prefs::kDisabledSchemes);
793 pref_change_registrar_.Add( 828 pref_change_registrar_.Add(
794 prefs::kDisabledSchemes, 829 prefs::kDisabledSchemes,
795 base::Bind(&BrowserProcessImpl::ApplyDisabledSchemesPolicy, 830 base::Bind(&BrowserProcessImpl::ApplyDisabledSchemesPolicy,
796 base::Unretained(this))); 831 base::Unretained(this)));
797 ApplyDisabledSchemesPolicy(); 832 ApplyDisabledSchemesPolicy();
798
799 local_state_->RegisterBooleanPref(prefs::kAllowCrossOriginAuthPrompt, false);
800
801 #if defined(OS_WIN)
802 if (base::win::GetVersion() >= base::win::VERSION_WIN8)
803 local_state_->RegisterBooleanPref(prefs::kRestartSwitchMode, false);
804 #endif
805 } 833 }
806 834
807 void BrowserProcessImpl::PreCreateThreads() { 835 void BrowserProcessImpl::PreCreateThreads() {
808 io_thread_.reset(new IOThread(local_state(), policy_service(), net_log_.get(), 836 io_thread_.reset(new IOThread(local_state(), policy_service(), net_log_.get(),
809 extension_event_router_forwarder_.get())); 837 extension_event_router_forwarder_.get()));
810 } 838 }
811 839
812 void BrowserProcessImpl::PreMainMessageLoopRun() { 840 void BrowserProcessImpl::PreMainMessageLoopRun() {
813 if (local_state_->IsManagedPreference(prefs::kDefaultBrowserSettingEnabled)) 841 if (local_state_->IsManagedPreference(prefs::kDefaultBrowserSettingEnabled))
814 ApplyDefaultBrowserPolicy(); 842 ApplyDefaultBrowserPolicy();
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
998 } 1026 }
999 1027
1000 void BrowserProcessImpl::OnAutoupdateTimer() { 1028 void BrowserProcessImpl::OnAutoupdateTimer() {
1001 if (CanAutorestartForUpdate()) { 1029 if (CanAutorestartForUpdate()) {
1002 DLOG(WARNING) << "Detected update. Restarting browser."; 1030 DLOG(WARNING) << "Detected update. Restarting browser.";
1003 RestartBackgroundInstance(); 1031 RestartBackgroundInstance();
1004 } 1032 }
1005 } 1033 }
1006 1034
1007 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) 1035 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698