| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 |
| 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 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| 11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 27 #include "chrome/browser/download/download_file_manager.h" | 27 #include "chrome/browser/download/download_file_manager.h" |
| 28 #include "chrome/browser/download/save_file_manager.h" | 28 #include "chrome/browser/download/save_file_manager.h" |
| 29 #include "chrome/browser/first_run/first_run.h" | 29 #include "chrome/browser/first_run/first_run.h" |
| 30 #include "chrome/browser/google/google_url_tracker.h" | 30 #include "chrome/browser/google/google_url_tracker.h" |
| 31 #include "chrome/browser/icon_manager.h" | 31 #include "chrome/browser/icon_manager.h" |
| 32 #include "chrome/browser/intranet_redirect_detector.h" | 32 #include "chrome/browser/intranet_redirect_detector.h" |
| 33 #include "chrome/browser/io_thread.h" | 33 #include "chrome/browser/io_thread.h" |
| 34 #include "chrome/browser/metrics/metrics_service.h" | 34 #include "chrome/browser/metrics/metrics_service.h" |
| 35 #include "chrome/browser/net/chrome_net_log.h" | 35 #include "chrome/browser/net/chrome_net_log.h" |
| 36 #include "chrome/browser/net/predictor_api.h" | 36 #include "chrome/browser/net/predictor_api.h" |
| 37 #include "chrome/browser/net/pref_proxy_config_service.h" |
| 37 #include "chrome/browser/net/sdch_dictionary_fetcher.h" | 38 #include "chrome/browser/net/sdch_dictionary_fetcher.h" |
| 38 #include "chrome/browser/notifications/notification_ui_manager.h" | 39 #include "chrome/browser/notifications/notification_ui_manager.h" |
| 39 #include "chrome/browser/plugin_data_remover.h" | 40 #include "chrome/browser/plugin_data_remover.h" |
| 40 #include "chrome/browser/plugin_service.h" | 41 #include "chrome/browser/plugin_service.h" |
| 41 #include "chrome/browser/plugin_updater.h" | 42 #include "chrome/browser/plugin_updater.h" |
| 42 #include "chrome/browser/policy/configuration_policy_provider_keeper.h" | 43 #include "chrome/browser/policy/configuration_policy_provider_keeper.h" |
| 43 #include "chrome/browser/prefs/pref_service.h" | 44 #include "chrome/browser/prefs/pref_service.h" |
| 44 #include "chrome/browser/printing/print_job_manager.h" | 45 #include "chrome/browser/printing/print_job_manager.h" |
| 45 #include "chrome/browser/printing/print_preview_tab_controller.h" | 46 #include "chrome/browser/printing/print_preview_tab_controller.h" |
| 46 #include "chrome/browser/profiles/profile_manager.h" | 47 #include "chrome/browser/profiles/profile_manager.h" |
| 47 #include "chrome/browser/renderer_host/render_process_host.h" | 48 #include "chrome/browser/renderer_host/render_process_host.h" |
| 48 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" | 49 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" |
| 49 #include "chrome/browser/safe_browsing/client_side_detection_service.h" | 50 #include "chrome/browser/safe_browsing/client_side_detection_service.h" |
| 50 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 51 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 51 #include "chrome/browser/shell_integration.h" | 52 #include "chrome/browser/shell_integration.h" |
| 52 #include "chrome/browser/sidebar/sidebar_manager.h" | 53 #include "chrome/browser/sidebar/sidebar_manager.h" |
| 54 #include "chrome/browser/system_url_request_context_getter.h" |
| 53 #include "chrome/browser/tab_closeable_state_watcher.h" | 55 #include "chrome/browser/tab_closeable_state_watcher.h" |
| 54 #include "chrome/common/chrome_constants.h" | 56 #include "chrome/common/chrome_constants.h" |
| 55 #include "chrome/common/chrome_paths.h" | 57 #include "chrome/common/chrome_paths.h" |
| 56 #include "chrome/common/chrome_switches.h" | 58 #include "chrome/common/chrome_switches.h" |
| 57 #include "chrome/common/extensions/extension_resource.h" | 59 #include "chrome/common/extensions/extension_resource.h" |
| 58 #include "chrome/common/extensions/extension_l10n_util.h" | 60 #include "chrome/common/extensions/extension_l10n_util.h" |
| 59 #include "chrome/common/json_pref_store.h" | 61 #include "chrome/common/json_pref_store.h" |
| 60 #include "chrome/common/notification_service.h" | 62 #include "chrome/common/notification_service.h" |
| 61 #include "chrome/common/pref_names.h" | 63 #include "chrome/common/pref_names.h" |
| 62 #include "chrome/common/url_constants.h" | 64 #include "chrome/common/url_constants.h" |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 // former registers for notifications. | 240 // former registers for notifications. |
| 239 tab_closeable_state_watcher_.reset(); | 241 tab_closeable_state_watcher_.reset(); |
| 240 | 242 |
| 241 // Now OK to destroy NotificationService. | 243 // Now OK to destroy NotificationService. |
| 242 main_notification_service_.reset(); | 244 main_notification_service_.reset(); |
| 243 | 245 |
| 244 // Prior to clearing local state, we want to complete tasks pending | 246 // Prior to clearing local state, we want to complete tasks pending |
| 245 // on the db thread too. | 247 // on the db thread too. |
| 246 db_thread_.reset(); | 248 db_thread_.reset(); |
| 247 | 249 |
| 250 // Need to destroy PrefProxyConfigTracker before local state, since it |
| 251 // caches a pointer to it. |
| 252 pref_proxy_config_tracker_->DetachFromPrefService(); |
| 253 pref_proxy_config_tracker_ = NULL; |
| 254 |
| 248 // At this point, no render process exist and the file, io, db, and | 255 // At this point, no render process exist and the file, io, db, and |
| 249 // webkit threads in this process have all terminated, so it's safe | 256 // webkit threads in this process have all terminated, so it's safe |
| 250 // to access local state data such as cookies, database, or local storage. | 257 // to access local state data such as cookies, database, or local storage. |
| 251 if (clear_local_state_on_exit) | 258 if (clear_local_state_on_exit) |
| 252 ClearLocalState(profile_path); | 259 ClearLocalState(profile_path); |
| 253 | 260 |
| 254 g_browser_process = NULL; | 261 g_browser_process = NULL; |
| 255 } | 262 } |
| 256 | 263 |
| 257 #if defined(OS_WIN) | 264 #if defined(OS_WIN) |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 if (!created_sidebar_manager_) | 423 if (!created_sidebar_manager_) |
| 417 CreateSidebarManager(); | 424 CreateSidebarManager(); |
| 418 return sidebar_manager_.get(); | 425 return sidebar_manager_.get(); |
| 419 } | 426 } |
| 420 | 427 |
| 421 ui::Clipboard* BrowserProcessImpl::clipboard() { | 428 ui::Clipboard* BrowserProcessImpl::clipboard() { |
| 422 DCHECK(CalledOnValidThread()); | 429 DCHECK(CalledOnValidThread()); |
| 423 return clipboard_.get(); | 430 return clipboard_.get(); |
| 424 } | 431 } |
| 425 | 432 |
| 433 PrefProxyConfigTracker* BrowserProcessImpl::pref_proxy_config_tracker() { |
| 434 DCHECK(CalledOnValidThread()); |
| 435 if (!created_pref_proxy_config_tracker_) |
| 436 CreatePrefProxyConfigTracker(); |
| 437 return pref_proxy_config_tracker_.get(); |
| 438 } |
| 439 |
| 440 URLRequestContextGetter* BrowserProcessImpl::system_request_context() { |
| 441 DCHECK(CalledOnValidThread()); |
| 442 if (!system_request_context_) |
| 443 CreateSystemRequestContextGetter(); |
| 444 return system_request_context_.get(); |
| 445 } |
| 446 |
| 426 NotificationUIManager* BrowserProcessImpl::notification_ui_manager() { | 447 NotificationUIManager* BrowserProcessImpl::notification_ui_manager() { |
| 427 DCHECK(CalledOnValidThread()); | 448 DCHECK(CalledOnValidThread()); |
| 428 if (!created_notification_ui_manager_) | 449 if (!created_notification_ui_manager_) |
| 429 CreateNotificationUIManager(); | 450 CreateNotificationUIManager(); |
| 430 return notification_ui_manager_.get(); | 451 return notification_ui_manager_.get(); |
| 431 } | 452 } |
| 432 | 453 |
| 433 policy::ConfigurationPolicyProviderKeeper* | 454 policy::ConfigurationPolicyProviderKeeper* |
| 434 BrowserProcessImpl::configuration_policy_provider_keeper() { | 455 BrowserProcessImpl::configuration_policy_provider_keeper() { |
| 435 DCHECK(CalledOnValidThread()); | 456 DCHECK(CalledOnValidThread()); |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 822 if (IsSafeBrowsingDetectionServiceEnabled() && | 843 if (IsSafeBrowsingDetectionServiceEnabled() && |
| 823 PathService::Get(chrome::DIR_USER_DATA, &model_file_path) && | 844 PathService::Get(chrome::DIR_USER_DATA, &model_file_path) && |
| 824 profile && profile->GetRequestContext()) { | 845 profile && profile->GetRequestContext()) { |
| 825 safe_browsing_detection_service_.reset( | 846 safe_browsing_detection_service_.reset( |
| 826 safe_browsing::ClientSideDetectionService::Create( | 847 safe_browsing::ClientSideDetectionService::Create( |
| 827 model_file_path.Append(chrome::kSafeBrowsingPhishingModelFilename), | 848 model_file_path.Append(chrome::kSafeBrowsingPhishingModelFilename), |
| 828 profile->GetRequestContext())); | 849 profile->GetRequestContext())); |
| 829 } | 850 } |
| 830 } | 851 } |
| 831 | 852 |
| 853 void BrowserProcessImpl::CreatePrefProxyConfigTracker() { |
| 854 DCHECK(pref_proxy_config_tracker_.get() == NULL); |
| 855 created_pref_proxy_config_tracker_ = true; |
| 856 pref_proxy_config_tracker_ = new PrefProxyConfigTracker(local_state()); |
| 857 } |
| 858 |
| 859 void BrowserProcessImpl::CreateSystemRequestContextGetter() { |
| 860 DCHECK(system_request_context_.get() == NULL); |
| 861 created_system_request_context_ = true; |
| 862 system_request_context_ = new SystemURLRequestContextGetter(io_thread()); |
| 863 } |
| 864 |
| 832 bool BrowserProcessImpl::IsSafeBrowsingDetectionServiceEnabled() { | 865 bool BrowserProcessImpl::IsSafeBrowsingDetectionServiceEnabled() { |
| 833 // The safe browsing client-side detection is enabled only if the switch is | 866 // The safe browsing client-side detection is enabled only if the switch is |
| 834 // enabled and when safe browsing related stats is allowed to be collected. | 867 // enabled and when safe browsing related stats is allowed to be collected. |
| 835 return CommandLine::ForCurrentProcess()->HasSwitch( | 868 return CommandLine::ForCurrentProcess()->HasSwitch( |
| 836 switches::kEnableClientSidePhishingDetection) && | 869 switches::kEnableClientSidePhishingDetection) && |
| 837 resource_dispatcher_host()->safe_browsing_service() && | 870 resource_dispatcher_host()->safe_browsing_service() && |
| 838 resource_dispatcher_host()->safe_browsing_service()->CanReportStats(); | 871 resource_dispatcher_host()->safe_browsing_service()->CanReportStats(); |
| 839 } | 872 } |
| 840 | 873 |
| 841 // The BrowserProcess object must outlive the file thread so we use traits | 874 // The BrowserProcess object must outlive the file thread so we use traits |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 943 } | 976 } |
| 944 | 977 |
| 945 void BrowserProcessImpl::OnAutoupdateTimer() { | 978 void BrowserProcessImpl::OnAutoupdateTimer() { |
| 946 if (CanAutorestartForUpdate()) { | 979 if (CanAutorestartForUpdate()) { |
| 947 DLOG(WARNING) << "Detected update. Restarting browser."; | 980 DLOG(WARNING) << "Detected update. Restarting browser."; |
| 948 RestartPersistentInstance(); | 981 RestartPersistentInstance(); |
| 949 } | 982 } |
| 950 } | 983 } |
| 951 | 984 |
| 952 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) | 985 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) |
| 986 |
| 987 void BrowserProcessImpl::InitSystemRequestContext() { |
| 988 // The linux gconf-based proxy settings getter relies on being initialized |
| 989 // from the UI thread. |
| 990 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 991 |
| 992 // Create a baseline service that provides proxy configuration in case nothing |
| 993 // is configured through prefs (Note: prefs include command line and |
| 994 // configuration policy). |
| 995 net::ProxyConfigService* base_service = NULL; |
| 996 |
| 997 // TODO(port): the IO and FILE message loops are only used by Linux. Can |
| 998 // that code be moved to chrome/browser instead of being in net, so that it |
| 999 // can use BrowserThread instead of raw MessageLoop pointers? See bug 25354. |
| 1000 #if defined(OS_CHROMEOS) |
| 1001 base_service = new chromeos::ProxyConfigService( |
| 1002 new chromeos::ProxyConfigServiceImpl()); |
| 1003 #else |
| 1004 base_service = net::ProxyService::CreateSystemProxyConfigService( |
| 1005 io_thread()->message_loop(), file_thread()->message_loop()); |
| 1006 #endif // defined(OS_CHROMEOS) |
| 1007 |
| 1008 net::ProxyConfigService* config_service = |
| 1009 new PrefProxyConfigService(pref_proxy_config_tracker(), |
| 1010 base_service); |
| 1011 |
| 1012 // Takes ownership of config_service. |
| 1013 io_thread()->InitSystemRequestContext(config_service); |
| 1014 } |
| OLD | NEW |