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

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: Switch to desired interfaces. Created 7 years, 11 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 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 return watchdog_thread_.get(); 393 return watchdog_thread_.get();
393 } 394 }
394 395
395 ProfileManager* BrowserProcessImpl::profile_manager() { 396 ProfileManager* BrowserProcessImpl::profile_manager() {
396 DCHECK(CalledOnValidThread()); 397 DCHECK(CalledOnValidThread());
397 if (!created_profile_manager_) 398 if (!created_profile_manager_)
398 CreateProfileManager(); 399 CreateProfileManager();
399 return profile_manager_.get(); 400 return profile_manager_.get();
400 } 401 }
401 402
402 // TODO(joi): Switch to returning just PrefService, since those 403 PrefService* BrowserProcessImpl::local_state() {
403 // calling this function shouldn't be doing ad-hoc registration, that
404 // happens earlier in browser_prefs::RegisterLocalState.
405 PrefServiceSimple* BrowserProcessImpl::local_state() {
406 DCHECK(CalledOnValidThread()); 404 DCHECK(CalledOnValidThread());
407 if (!created_local_state_) 405 if (!created_local_state_)
408 CreateLocalState(); 406 CreateLocalState();
409 return local_state_.get(); 407 return local_state_.get();
410 } 408 }
411 409
412 net::URLRequestContextGetter* BrowserProcessImpl::system_request_context() { 410 net::URLRequestContextGetter* BrowserProcessImpl::system_request_context() {
413 DCHECK(CalledOnValidThread()); 411 DCHECK(CalledOnValidThread());
414 return io_thread()->system_url_request_context_getter(); 412 return io_thread()->system_url_request_context_getter();
415 } 413 }
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 media_file_system_registry_.reset(new chrome::MediaFileSystemRegistry()); 588 media_file_system_registry_.reset(new chrome::MediaFileSystemRegistry());
591 return media_file_system_registry_.get(); 589 return media_file_system_registry_.get();
592 } 590 }
593 591
594 #if !defined(OS_WIN) 592 #if !defined(OS_WIN)
595 void BrowserProcessImpl::PlatformSpecificCommandLineProcessing( 593 void BrowserProcessImpl::PlatformSpecificCommandLineProcessing(
596 const CommandLine& command_line) { 594 const CommandLine& command_line) {
597 } 595 }
598 #endif 596 #endif
599 597
598 // static
599 void BrowserProcessImpl::RegisterPrefs(PrefRegistrySimple* registry) {
600 registry->RegisterBooleanPref(prefs::kDefaultBrowserSettingEnabled,
601 false);
602 // This policy needs to be defined before the net subsystem is initialized,
603 // so we do it here.
604 registry->RegisterIntegerPref(prefs::kMaxConnectionsPerProxy,
605 net::kDefaultMaxSocketsPerProxyServer);
606
607 // This is observed by ChildProcessSecurityPolicy, which lives in content/
608 // though, so it can't register itself.
609 registry->RegisterListPref(prefs::kDisabledSchemes);
610
611 registry->RegisterBooleanPref(prefs::kAllowCrossOriginAuthPrompt, false);
612
613 #if defined(OS_WIN)
614 if (base::win::GetVersion() >= base::win::VERSION_WIN8)
615 registry->RegisterBooleanPref(prefs::kRestartSwitchMode, false);
616 #endif
617
618 // TODO(brettw,*): this comment about ResourceBundle was here since
619 // initial commit. This comment seems unrelated, bit-rotten and
620 // a candidate for removal.
621 // Initialize ResourceBundle which handles files loaded from external
622 // sources. This has to be done before uninstall code path and before prefs
623 // are registered.
624 registry->RegisterStringPref(prefs::kApplicationLocale, std::string());
625 #if defined(OS_CHROMEOS)
626 registry->RegisterStringPref(prefs::kOwnerLocale, std::string());
627 registry->RegisterStringPref(prefs::kHardwareKeyboardLayout,
628 std::string());
629 #endif // defined(OS_CHROMEOS)
630 #if !defined(OS_CHROMEOS)
631 registry->RegisterBooleanPref(
632 prefs::kMetricsReportingEnabled,
633 GoogleUpdateSettings::GetCollectStatsConsent());
634 #endif // !defined(OS_CHROMEOS)
635 }
636
600 DownloadRequestLimiter* BrowserProcessImpl::download_request_limiter() { 637 DownloadRequestLimiter* BrowserProcessImpl::download_request_limiter() {
601 DCHECK(CalledOnValidThread()); 638 DCHECK(CalledOnValidThread());
602 if (!download_request_limiter_) 639 if (!download_request_limiter_)
603 download_request_limiter_ = new DownloadRequestLimiter(); 640 download_request_limiter_ = new DownloadRequestLimiter();
604 return download_request_limiter_; 641 return download_request_limiter_;
605 } 642 }
606 643
607 BackgroundModeManager* BrowserProcessImpl::background_mode_manager() { 644 BackgroundModeManager* BrowserProcessImpl::background_mode_manager() {
608 DCHECK(CalledOnValidThread()); 645 DCHECK(CalledOnValidThread());
609 #if defined(ENABLE_BACKGROUND) 646 #if defined(ENABLE_BACKGROUND)
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir); 763 PathService::Get(chrome::DIR_USER_DATA, &user_data_dir);
727 profile_manager_.reset(new ProfileManager(user_data_dir)); 764 profile_manager_.reset(new ProfileManager(user_data_dir));
728 } 765 }
729 766
730 void BrowserProcessImpl::CreateLocalState() { 767 void BrowserProcessImpl::CreateLocalState() {
731 DCHECK(!created_local_state_ && local_state_.get() == NULL); 768 DCHECK(!created_local_state_ && local_state_.get() == NULL);
732 created_local_state_ = true; 769 created_local_state_ = true;
733 770
734 FilePath local_state_path; 771 FilePath local_state_path;
735 CHECK(PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path)); 772 CHECK(PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path));
773 PrefRegistrySimple* pref_registry = new PrefRegistrySimple();
736 local_state_.reset( 774 local_state_.reset(
737 chrome_prefs::CreateLocalState(local_state_path, 775 chrome_prefs::CreateLocalState(local_state_path,
738 local_state_task_runner_, 776 local_state_task_runner_,
739 policy_service(), 777 policy_service(),
740 NULL, false)); 778 NULL,
779 scoped_ptr<PrefRegistry>(pref_registry),
780 false));
741 781
742 // Initialize the prefs of the local state. 782 // Initialize the prefs of the local state.
743 chrome::RegisterLocalState(local_state_.get()); 783 //
784 // TODO(joi): Once we clean up so none of the registration methods
785 // need the PrefService pointer, this should happen before the call
786 // to CreateLocalState.
787 chrome::RegisterLocalState(pref_registry, local_state_.get());
744 788
745 pref_change_registrar_.Init(local_state_.get()); 789 pref_change_registrar_.Init(local_state_.get());
746 790
747 // Initialize the notification for the default browser setting policy. 791 // Initialize the notification for the default browser setting policy.
748 local_state_->RegisterBooleanPref(prefs::kDefaultBrowserSettingEnabled,
749 false);
750 pref_change_registrar_.Add( 792 pref_change_registrar_.Add(
751 prefs::kDefaultBrowserSettingEnabled, 793 prefs::kDefaultBrowserSettingEnabled,
752 base::Bind(&BrowserProcessImpl::ApplyDefaultBrowserPolicy, 794 base::Bind(&BrowserProcessImpl::ApplyDefaultBrowserPolicy,
753 base::Unretained(this))); 795 base::Unretained(this)));
754 796
755 // This policy needs to be defined before the net subsystem is initialized,
756 // so we do it here.
757 local_state_->RegisterIntegerPref(prefs::kMaxConnectionsPerProxy,
758 net::kDefaultMaxSocketsPerProxyServer);
759 int max_per_proxy = local_state_->GetInteger(prefs::kMaxConnectionsPerProxy); 797 int max_per_proxy = local_state_->GetInteger(prefs::kMaxConnectionsPerProxy);
760 net::ClientSocketPoolManager::set_max_sockets_per_proxy_server( 798 net::ClientSocketPoolManager::set_max_sockets_per_proxy_server(
761 net::HttpNetworkSession::NORMAL_SOCKET_POOL, 799 net::HttpNetworkSession::NORMAL_SOCKET_POOL,
762 std::max(std::min(max_per_proxy, 99), 800 std::max(std::min(max_per_proxy, 99),
763 net::ClientSocketPoolManager::max_sockets_per_group( 801 net::ClientSocketPoolManager::max_sockets_per_group(
764 net::HttpNetworkSession::NORMAL_SOCKET_POOL))); 802 net::HttpNetworkSession::NORMAL_SOCKET_POOL)));
765 803
766 // This is observed by ChildProcessSecurityPolicy, which lives in content/
767 // though, so it can't register itself.
768 local_state_->RegisterListPref(prefs::kDisabledSchemes);
769 pref_change_registrar_.Add( 804 pref_change_registrar_.Add(
770 prefs::kDisabledSchemes, 805 prefs::kDisabledSchemes,
771 base::Bind(&BrowserProcessImpl::ApplyDisabledSchemesPolicy, 806 base::Bind(&BrowserProcessImpl::ApplyDisabledSchemesPolicy,
772 base::Unretained(this))); 807 base::Unretained(this)));
773 ApplyDisabledSchemesPolicy(); 808 ApplyDisabledSchemesPolicy();
774
775 local_state_->RegisterBooleanPref(prefs::kAllowCrossOriginAuthPrompt, false);
776
777 #if defined(OS_WIN)
778 if (base::win::GetVersion() >= base::win::VERSION_WIN8)
779 local_state_->RegisterBooleanPref(prefs::kRestartSwitchMode, false);
780 #endif
781 } 809 }
782 810
783 void BrowserProcessImpl::PreCreateThreads() { 811 void BrowserProcessImpl::PreCreateThreads() {
784 io_thread_.reset(new IOThread(local_state(), policy_service(), net_log_.get(), 812 io_thread_.reset(new IOThread(local_state(), policy_service(), net_log_.get(),
785 extension_event_router_forwarder_.get())); 813 extension_event_router_forwarder_.get()));
786 } 814 }
787 815
788 void BrowserProcessImpl::PreMainMessageLoopRun() { 816 void BrowserProcessImpl::PreMainMessageLoopRun() {
789 if (local_state_->IsManagedPreference(prefs::kDefaultBrowserSettingEnabled)) 817 if (local_state_->IsManagedPreference(prefs::kDefaultBrowserSettingEnabled))
790 ApplyDefaultBrowserPolicy(); 818 ApplyDefaultBrowserPolicy();
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
966 } 994 }
967 995
968 void BrowserProcessImpl::OnAutoupdateTimer() { 996 void BrowserProcessImpl::OnAutoupdateTimer() {
969 if (CanAutorestartForUpdate()) { 997 if (CanAutorestartForUpdate()) {
970 DLOG(WARNING) << "Detected update. Restarting browser."; 998 DLOG(WARNING) << "Detected update. Restarting browser.";
971 RestartBackgroundInstance(); 999 RestartBackgroundInstance();
972 } 1000 }
973 } 1001 }
974 1002
975 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) 1003 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698