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

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: Fix double registration in Chrome Frame test. 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
« no previous file with comments | « chrome/browser/browser_process_impl.h ('k') | chrome/browser/browser_shutdown.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
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/chrome_plugin_service_filter.h" 49 #include "chrome/browser/plugins/chrome_plugin_service_filter.h"
50 #include "chrome/browser/plugins/plugin_finder.h" 50 #include "chrome/browser/plugins/plugin_finder.h"
51 #include "chrome/browser/policy/policy_service.h" 51 #include "chrome/browser/policy/policy_service.h"
52 #include "chrome/browser/prefs/browser_prefs.h" 52 #include "chrome/browser/prefs/browser_prefs.h"
53 #include "chrome/browser/prefs/chrome_pref_service_factory.h" 53 #include "chrome/browser/prefs/chrome_pref_service_factory.h"
54 #include "chrome/browser/prefs/pref_registry_simple.h"
54 #include "chrome/browser/prefs/pref_service.h" 55 #include "chrome/browser/prefs/pref_service.h"
55 #include "chrome/browser/prerender/prerender_tracker.h" 56 #include "chrome/browser/prerender/prerender_tracker.h"
56 #include "chrome/browser/printing/background_printing_manager.h" 57 #include "chrome/browser/printing/background_printing_manager.h"
57 #include "chrome/browser/printing/print_job_manager.h" 58 #include "chrome/browser/printing/print_job_manager.h"
58 #include "chrome/browser/printing/print_preview_dialog_controller.h" 59 #include "chrome/browser/printing/print_preview_dialog_controller.h"
59 #include "chrome/browser/profiles/profile_manager.h" 60 #include "chrome/browser/profiles/profile_manager.h"
60 #include "chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate. h" 61 #include "chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate. h"
61 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 62 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
62 #include "chrome/browser/shell_integration.h" 63 #include "chrome/browser/shell_integration.h"
63 #include "chrome/browser/status_icons/status_tray.h" 64 #include "chrome/browser/status_icons/status_tray.h"
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 return watchdog_thread_.get(); 409 return watchdog_thread_.get();
409 } 410 }
410 411
411 ProfileManager* BrowserProcessImpl::profile_manager() { 412 ProfileManager* BrowserProcessImpl::profile_manager() {
412 DCHECK(CalledOnValidThread()); 413 DCHECK(CalledOnValidThread());
413 if (!created_profile_manager_) 414 if (!created_profile_manager_)
414 CreateProfileManager(); 415 CreateProfileManager();
415 return profile_manager_.get(); 416 return profile_manager_.get();
416 } 417 }
417 418
418 // TODO(joi): Switch to returning just PrefService, since those 419 PrefService* BrowserProcessImpl::local_state() {
419 // calling this function shouldn't be doing ad-hoc registration, that
420 // happens earlier in browser_prefs::RegisterLocalState.
421 PrefServiceSimple* BrowserProcessImpl::local_state() {
422 DCHECK(CalledOnValidThread()); 420 DCHECK(CalledOnValidThread());
423 if (!created_local_state_) 421 if (!created_local_state_)
424 CreateLocalState(); 422 CreateLocalState();
425 return local_state_.get(); 423 return local_state_.get();
426 } 424 }
427 425
428 net::URLRequestContextGetter* BrowserProcessImpl::system_request_context() { 426 net::URLRequestContextGetter* BrowserProcessImpl::system_request_context() {
429 DCHECK(CalledOnValidThread()); 427 DCHECK(CalledOnValidThread());
430 return io_thread()->system_url_request_context_getter(); 428 return io_thread()->system_url_request_context_getter();
431 } 429 }
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 media_file_system_registry_.reset(new chrome::MediaFileSystemRegistry()); 617 media_file_system_registry_.reset(new chrome::MediaFileSystemRegistry());
620 return media_file_system_registry_.get(); 618 return media_file_system_registry_.get();
621 } 619 }
622 620
623 #if !defined(OS_WIN) 621 #if !defined(OS_WIN)
624 void BrowserProcessImpl::PlatformSpecificCommandLineProcessing( 622 void BrowserProcessImpl::PlatformSpecificCommandLineProcessing(
625 const CommandLine& command_line) { 623 const CommandLine& command_line) {
626 } 624 }
627 #endif 625 #endif
628 626
627 // static
628 void BrowserProcessImpl::RegisterPrefs(PrefRegistrySimple* registry) {
629 registry->RegisterBooleanPref(prefs::kDefaultBrowserSettingEnabled,
630 false);
631 // This policy needs to be defined before the net subsystem is initialized,
632 // so we do it here.
633 registry->RegisterIntegerPref(prefs::kMaxConnectionsPerProxy,
634 net::kDefaultMaxSocketsPerProxyServer);
635
636 // This is observed by ChildProcessSecurityPolicy, which lives in content/
637 // though, so it can't register itself.
638 registry->RegisterListPref(prefs::kDisabledSchemes);
639
640 registry->RegisterBooleanPref(prefs::kAllowCrossOriginAuthPrompt, false);
641
642 #if defined(OS_WIN)
643 if (base::win::GetVersion() >= base::win::VERSION_WIN8)
644 registry->RegisterBooleanPref(prefs::kRestartSwitchMode, false);
645 #endif
646
647 // TODO(brettw,*): this comment about ResourceBundle was here since
648 // initial commit. This comment seems unrelated, bit-rotten and
649 // a candidate for removal.
650 // Initialize ResourceBundle which handles files loaded from external
651 // sources. This has to be done before uninstall code path and before prefs
652 // are registered.
653 registry->RegisterStringPref(prefs::kApplicationLocale, std::string());
654 #if defined(OS_CHROMEOS)
655 registry->RegisterStringPref(prefs::kOwnerLocale, std::string());
656 registry->RegisterStringPref(prefs::kHardwareKeyboardLayout,
657 std::string());
658 #endif // defined(OS_CHROMEOS)
659 #if !defined(OS_CHROMEOS)
660 registry->RegisterBooleanPref(
661 prefs::kMetricsReportingEnabled,
662 GoogleUpdateSettings::GetCollectStatsConsent());
663 #endif // !defined(OS_CHROMEOS)
664 }
665
629 DownloadRequestLimiter* BrowserProcessImpl::download_request_limiter() { 666 DownloadRequestLimiter* BrowserProcessImpl::download_request_limiter() {
630 DCHECK(CalledOnValidThread()); 667 DCHECK(CalledOnValidThread());
631 if (!download_request_limiter_) 668 if (!download_request_limiter_)
632 download_request_limiter_ = new DownloadRequestLimiter(); 669 download_request_limiter_ = new DownloadRequestLimiter();
633 return download_request_limiter_; 670 return download_request_limiter_;
634 } 671 }
635 672
636 BackgroundModeManager* BrowserProcessImpl::background_mode_manager() { 673 BackgroundModeManager* BrowserProcessImpl::background_mode_manager() {
637 DCHECK(CalledOnValidThread()); 674 DCHECK(CalledOnValidThread());
638 #if defined(ENABLE_BACKGROUND) 675 #if defined(ENABLE_BACKGROUND)
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); 792 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir);
756 profile_manager_.reset(new ProfileManager(user_data_dir)); 793 profile_manager_.reset(new ProfileManager(user_data_dir));
757 } 794 }
758 795
759 void BrowserProcessImpl::CreateLocalState() { 796 void BrowserProcessImpl::CreateLocalState() {
760 DCHECK(!created_local_state_ && local_state_.get() == NULL); 797 DCHECK(!created_local_state_ && local_state_.get() == NULL);
761 created_local_state_ = true; 798 created_local_state_ = true;
762 799
763 FilePath local_state_path; 800 FilePath local_state_path;
764 CHECK(PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path)); 801 CHECK(PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path));
802 scoped_refptr<PrefRegistrySimple> pref_registry = new PrefRegistrySimple;
765 local_state_.reset( 803 local_state_.reset(
766 chrome_prefs::CreateLocalState(local_state_path, 804 chrome_prefs::CreateLocalState(local_state_path,
767 local_state_task_runner_, 805 local_state_task_runner_,
768 policy_service(), 806 policy_service(),
769 NULL, false)); 807 NULL,
808 pref_registry,
809 false));
770 810
771 // Initialize the prefs of the local state. 811 // Initialize the prefs of the local state.
772 chrome::RegisterLocalState(local_state_.get()); 812 //
813 // TODO(joi): Once we clean up so none of the registration methods
814 // need the PrefService pointer, this should happen before the call
815 // to CreateLocalState.
816 chrome::RegisterLocalState(pref_registry, local_state_.get());
773 817
774 pref_change_registrar_.Init(local_state_.get()); 818 pref_change_registrar_.Init(local_state_.get());
775 819
776 // Initialize the notification for the default browser setting policy. 820 // Initialize the notification for the default browser setting policy.
777 local_state_->RegisterBooleanPref(prefs::kDefaultBrowserSettingEnabled,
778 false);
779 pref_change_registrar_.Add( 821 pref_change_registrar_.Add(
780 prefs::kDefaultBrowserSettingEnabled, 822 prefs::kDefaultBrowserSettingEnabled,
781 base::Bind(&BrowserProcessImpl::ApplyDefaultBrowserPolicy, 823 base::Bind(&BrowserProcessImpl::ApplyDefaultBrowserPolicy,
782 base::Unretained(this))); 824 base::Unretained(this)));
783 825
784 // This policy needs to be defined before the net subsystem is initialized,
785 // so we do it here.
786 local_state_->RegisterIntegerPref(prefs::kMaxConnectionsPerProxy,
787 net::kDefaultMaxSocketsPerProxyServer);
788 int max_per_proxy = local_state_->GetInteger(prefs::kMaxConnectionsPerProxy); 826 int max_per_proxy = local_state_->GetInteger(prefs::kMaxConnectionsPerProxy);
789 net::ClientSocketPoolManager::set_max_sockets_per_proxy_server( 827 net::ClientSocketPoolManager::set_max_sockets_per_proxy_server(
790 net::HttpNetworkSession::NORMAL_SOCKET_POOL, 828 net::HttpNetworkSession::NORMAL_SOCKET_POOL,
791 std::max(std::min(max_per_proxy, 99), 829 std::max(std::min(max_per_proxy, 99),
792 net::ClientSocketPoolManager::max_sockets_per_group( 830 net::ClientSocketPoolManager::max_sockets_per_group(
793 net::HttpNetworkSession::NORMAL_SOCKET_POOL))); 831 net::HttpNetworkSession::NORMAL_SOCKET_POOL)));
794 832
795 // This is observed by ChildProcessSecurityPolicy, which lives in content/
796 // though, so it can't register itself.
797 local_state_->RegisterListPref(prefs::kDisabledSchemes);
798 pref_change_registrar_.Add( 833 pref_change_registrar_.Add(
799 prefs::kDisabledSchemes, 834 prefs::kDisabledSchemes,
800 base::Bind(&BrowserProcessImpl::ApplyDisabledSchemesPolicy, 835 base::Bind(&BrowserProcessImpl::ApplyDisabledSchemesPolicy,
801 base::Unretained(this))); 836 base::Unretained(this)));
802 ApplyDisabledSchemesPolicy(); 837 ApplyDisabledSchemesPolicy();
803
804 local_state_->RegisterBooleanPref(prefs::kAllowCrossOriginAuthPrompt, false);
805
806 #if defined(OS_WIN)
807 if (base::win::GetVersion() >= base::win::VERSION_WIN8)
808 local_state_->RegisterBooleanPref(prefs::kRestartSwitchMode, false);
809 #endif
810 } 838 }
811 839
812 void BrowserProcessImpl::PreCreateThreads() { 840 void BrowserProcessImpl::PreCreateThreads() {
813 io_thread_.reset(new IOThread(local_state(), policy_service(), net_log_.get(), 841 io_thread_.reset(new IOThread(local_state(), policy_service(), net_log_.get(),
814 extension_event_router_forwarder_.get())); 842 extension_event_router_forwarder_.get()));
815 } 843 }
816 844
817 void BrowserProcessImpl::PreMainMessageLoopRun() { 845 void BrowserProcessImpl::PreMainMessageLoopRun() {
818 if (local_state_->IsManagedPreference(prefs::kDefaultBrowserSettingEnabled)) 846 if (local_state_->IsManagedPreference(prefs::kDefaultBrowserSettingEnabled))
819 ApplyDefaultBrowserPolicy(); 847 ApplyDefaultBrowserPolicy();
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
1003 } 1031 }
1004 1032
1005 void BrowserProcessImpl::OnAutoupdateTimer() { 1033 void BrowserProcessImpl::OnAutoupdateTimer() {
1006 if (CanAutorestartForUpdate()) { 1034 if (CanAutorestartForUpdate()) {
1007 DLOG(WARNING) << "Detected update. Restarting browser."; 1035 DLOG(WARNING) << "Detected update. Restarting browser.";
1008 RestartBackgroundInstance(); 1036 RestartBackgroundInstance();
1009 } 1037 }
1010 } 1038 }
1011 1039
1012 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) 1040 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS)
OLDNEW
« no previous file with comments | « chrome/browser/browser_process_impl.h ('k') | chrome/browser/browser_shutdown.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698