OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <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" |
(...skipping 16 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" | |
38 #include "chrome/browser/net/proxy_service_factory.h" | |
37 #include "chrome/browser/net/sdch_dictionary_fetcher.h" | 39 #include "chrome/browser/net/sdch_dictionary_fetcher.h" |
38 #include "chrome/browser/notifications/notification_ui_manager.h" | 40 #include "chrome/browser/notifications/notification_ui_manager.h" |
39 #include "chrome/browser/plugin_data_remover.h" | 41 #include "chrome/browser/plugin_data_remover.h" |
40 #include "chrome/browser/plugin_service.h" | 42 #include "chrome/browser/plugin_service.h" |
41 #include "chrome/browser/plugin_updater.h" | 43 #include "chrome/browser/plugin_updater.h" |
42 #include "chrome/browser/policy/configuration_policy_provider_keeper.h" | 44 #include "chrome/browser/policy/configuration_policy_provider_keeper.h" |
43 #include "chrome/browser/prefs/pref_service.h" | 45 #include "chrome/browser/prefs/pref_service.h" |
44 #include "chrome/browser/printing/print_job_manager.h" | 46 #include "chrome/browser/printing/print_job_manager.h" |
45 #include "chrome/browser/printing/print_preview_tab_controller.h" | 47 #include "chrome/browser/printing/print_preview_tab_controller.h" |
46 #include "chrome/browser/profiles/profile_manager.h" | 48 #include "chrome/browser/profiles/profile_manager.h" |
47 #include "chrome/browser/renderer_host/render_process_host.h" | 49 #include "chrome/browser/renderer_host/render_process_host.h" |
48 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" | 50 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" |
49 #include "chrome/browser/safe_browsing/client_side_detection_service.h" | 51 #include "chrome/browser/safe_browsing/client_side_detection_service.h" |
50 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 52 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
51 #include "chrome/browser/shell_integration.h" | 53 #include "chrome/browser/shell_integration.h" |
52 #include "chrome/browser/sidebar/sidebar_manager.h" | 54 #include "chrome/browser/sidebar/sidebar_manager.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" |
62 #include "chrome/common/net/url_request_context_getter.h" | |
60 #include "chrome/common/notification_service.h" | 63 #include "chrome/common/notification_service.h" |
61 #include "chrome/common/pref_names.h" | 64 #include "chrome/common/pref_names.h" |
62 #include "chrome/common/url_constants.h" | 65 #include "chrome/common/url_constants.h" |
63 #include "chrome/common/switch_utils.h" | 66 #include "chrome/common/switch_utils.h" |
64 #include "chrome/installer/util/google_update_constants.h" | 67 #include "chrome/installer/util/google_update_constants.h" |
65 #include "ipc/ipc_logging.h" | 68 #include "ipc/ipc_logging.h" |
66 #include "ui/base/clipboard/clipboard.h" | 69 #include "ui/base/clipboard/clipboard.h" |
67 #include "ui/base/l10n/l10n_util.h" | 70 #include "ui/base/l10n/l10n_util.h" |
68 #include "webkit/database/database_tracker.h" | 71 #include "webkit/database/database_tracker.h" |
69 | 72 |
(...skipping 12 matching lines...) Expand all Loading... | |
82 static const int kUpdateCheckIntervalHours = 6; | 85 static const int kUpdateCheckIntervalHours = 6; |
83 #endif | 86 #endif |
84 | 87 |
85 #if defined(USE_X11) | 88 #if defined(USE_X11) |
86 // How long to wait for the File thread to complete during EndSession, on | 89 // How long to wait for the File thread to complete during EndSession, on |
87 // Linux. We have a timeout here because we're unable to run the UI messageloop | 90 // Linux. We have a timeout here because we're unable to run the UI messageloop |
88 // and there's some deadlock risk. Our only option is to exit anyway. | 91 // and there's some deadlock risk. Our only option is to exit anyway. |
89 static const int kEndSessionTimeoutSeconds = 10; | 92 static const int kEndSessionTimeoutSeconds = 10; |
90 #endif | 93 #endif |
91 | 94 |
95 #if defined(OS_CHROMEOS) | |
96 #include "chrome/browser/chromeos/proxy_config_service.h" | |
kuan
2011/02/18 16:29:31
any reason why u need this file instead of just pr
battre
2011/02/21 17:27:58
Done.
| |
97 #endif // defined(OS_CHROMEOS) | |
98 | |
92 BrowserProcessImpl::BrowserProcessImpl(const CommandLine& command_line) | 99 BrowserProcessImpl::BrowserProcessImpl(const CommandLine& command_line) |
93 : created_resource_dispatcher_host_(false), | 100 : created_resource_dispatcher_host_(false), |
94 created_metrics_service_(false), | 101 created_metrics_service_(false), |
95 created_io_thread_(false), | 102 created_io_thread_(false), |
96 created_file_thread_(false), | 103 created_file_thread_(false), |
97 created_db_thread_(false), | 104 created_db_thread_(false), |
98 created_process_launcher_thread_(false), | 105 created_process_launcher_thread_(false), |
99 created_cache_thread_(false), | 106 created_cache_thread_(false), |
100 created_profile_manager_(false), | 107 created_profile_manager_(false), |
101 created_local_state_(false), | 108 created_local_state_(false), |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
238 // former registers for notifications. | 245 // former registers for notifications. |
239 tab_closeable_state_watcher_.reset(); | 246 tab_closeable_state_watcher_.reset(); |
240 | 247 |
241 // Now OK to destroy NotificationService. | 248 // Now OK to destroy NotificationService. |
242 main_notification_service_.reset(); | 249 main_notification_service_.reset(); |
243 | 250 |
244 // Prior to clearing local state, we want to complete tasks pending | 251 // Prior to clearing local state, we want to complete tasks pending |
245 // on the db thread too. | 252 // on the db thread too. |
246 db_thread_.reset(); | 253 db_thread_.reset(); |
247 | 254 |
255 // Need to destroy PrefProxyConfigTracker before local state, since it | |
256 // caches a pointer to local state. | |
257 if (pref_proxy_config_tracker_) | |
258 pref_proxy_config_tracker_->DetachFromPrefService(); | |
259 pref_proxy_config_tracker_ = NULL; | |
260 | |
248 // At this point, no render process exist and the file, io, db, and | 261 // 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 | 262 // 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. | 263 // to access local state data such as cookies, database, or local storage. |
251 if (clear_local_state_on_exit) | 264 if (clear_local_state_on_exit) |
252 ClearLocalState(profile_path); | 265 ClearLocalState(profile_path); |
253 | 266 |
254 g_browser_process = NULL; | 267 g_browser_process = NULL; |
255 } | 268 } |
256 | 269 |
257 #if defined(OS_WIN) | 270 #if defined(OS_WIN) |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
416 if (!created_sidebar_manager_) | 429 if (!created_sidebar_manager_) |
417 CreateSidebarManager(); | 430 CreateSidebarManager(); |
418 return sidebar_manager_.get(); | 431 return sidebar_manager_.get(); |
419 } | 432 } |
420 | 433 |
421 ui::Clipboard* BrowserProcessImpl::clipboard() { | 434 ui::Clipboard* BrowserProcessImpl::clipboard() { |
422 DCHECK(CalledOnValidThread()); | 435 DCHECK(CalledOnValidThread()); |
423 return clipboard_.get(); | 436 return clipboard_.get(); |
424 } | 437 } |
425 | 438 |
439 PrefProxyConfigTracker* BrowserProcessImpl::pref_proxy_config_tracker() { | |
440 DCHECK(CalledOnValidThread()); | |
441 if (!created_pref_proxy_config_tracker_) | |
442 CreatePrefProxyConfigTracker(); | |
443 return pref_proxy_config_tracker_.get(); | |
444 } | |
445 | |
446 scoped_refptr<URLRequestContextGetter> | |
447 BrowserProcessImpl::system_request_context() { | |
448 DCHECK(CalledOnValidThread()); | |
449 if (!created_system_request_context_) | |
450 CreateSystemRequestContextGetter(); | |
451 return io_thread()->system_url_request_context_getter(); | |
452 } | |
453 | |
454 #if defined(OS_CHROMEOS) | |
455 chromeos::ProxyConfigServiceImpl* | |
456 BrowserProcessImpl::chromeos_proxy_config_service_impl() { | |
457 if (!chromeos_proxy_config_service_impl_) { | |
458 chromeos_proxy_config_service_impl_ = | |
459 new chromeos::ProxyConfigServiceImpl(); | |
460 } | |
461 return chromeos_proxy_config_service_impl_; | |
462 } | |
463 #endif // defined(OS_CHROMEOS) | |
464 | |
426 NotificationUIManager* BrowserProcessImpl::notification_ui_manager() { | 465 NotificationUIManager* BrowserProcessImpl::notification_ui_manager() { |
427 DCHECK(CalledOnValidThread()); | 466 DCHECK(CalledOnValidThread()); |
428 if (!created_notification_ui_manager_) | 467 if (!created_notification_ui_manager_) |
429 CreateNotificationUIManager(); | 468 CreateNotificationUIManager(); |
430 return notification_ui_manager_.get(); | 469 return notification_ui_manager_.get(); |
431 } | 470 } |
432 | 471 |
433 policy::ConfigurationPolicyProviderKeeper* | 472 policy::ConfigurationPolicyProviderKeeper* |
434 BrowserProcessImpl::configuration_policy_provider_keeper() { | 473 BrowserProcessImpl::configuration_policy_provider_keeper() { |
435 DCHECK(CalledOnValidThread()); | 474 DCHECK(CalledOnValidThread()); |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
826 if (IsSafeBrowsingDetectionServiceEnabled() && | 865 if (IsSafeBrowsingDetectionServiceEnabled() && |
827 PathService::Get(chrome::DIR_USER_DATA, &model_file_path) && | 866 PathService::Get(chrome::DIR_USER_DATA, &model_file_path) && |
828 profile && profile->GetRequestContext()) { | 867 profile && profile->GetRequestContext()) { |
829 safe_browsing_detection_service_.reset( | 868 safe_browsing_detection_service_.reset( |
830 safe_browsing::ClientSideDetectionService::Create( | 869 safe_browsing::ClientSideDetectionService::Create( |
831 model_file_path.Append(chrome::kSafeBrowsingPhishingModelFilename), | 870 model_file_path.Append(chrome::kSafeBrowsingPhishingModelFilename), |
832 profile->GetRequestContext())); | 871 profile->GetRequestContext())); |
833 } | 872 } |
834 } | 873 } |
835 | 874 |
875 void BrowserProcessImpl::CreatePrefProxyConfigTracker() { | |
brettw
2011/02/21 06:22:47
It's not clear to me why this code is in the Brows
battre
2011/02/21 17:27:58
Thanks for nagging. This simplified things signifi
| |
876 DCHECK(pref_proxy_config_tracker_.get() == NULL); | |
877 created_pref_proxy_config_tracker_ = true; | |
878 pref_proxy_config_tracker_ = new PrefProxyConfigTracker(local_state()); | |
879 } | |
880 | |
881 void BrowserProcessImpl::CreateSystemRequestContextGetter() { | |
882 DCHECK(!created_system_request_context_); | |
883 created_system_request_context_ = true; | |
884 | |
885 net::ProxyConfigService* proxy_config_service = | |
886 ProxyServiceFactory::CreateProxyConfigService( | |
887 pref_proxy_config_tracker()); | |
888 | |
889 // Takes ownership of config_service. | |
890 io_thread()->SetSystemProxyConfigService(proxy_config_service); | |
891 | |
892 // Initialize SystemUrlRequestContextGetter in |io_thread_|. | |
893 ignore_result(io_thread()->system_url_request_context_getter()); | |
894 } | |
895 | |
836 bool BrowserProcessImpl::IsSafeBrowsingDetectionServiceEnabled() { | 896 bool BrowserProcessImpl::IsSafeBrowsingDetectionServiceEnabled() { |
837 // The safe browsing client-side detection is enabled only if the switch is | 897 // The safe browsing client-side detection is enabled only if the switch is |
838 // enabled and when safe browsing related stats is allowed to be collected. | 898 // enabled and when safe browsing related stats is allowed to be collected. |
839 return CommandLine::ForCurrentProcess()->HasSwitch( | 899 return CommandLine::ForCurrentProcess()->HasSwitch( |
840 switches::kEnableClientSidePhishingDetection) && | 900 switches::kEnableClientSidePhishingDetection) && |
841 resource_dispatcher_host()->safe_browsing_service() && | 901 resource_dispatcher_host()->safe_browsing_service() && |
842 resource_dispatcher_host()->safe_browsing_service()->CanReportStats(); | 902 resource_dispatcher_host()->safe_browsing_service()->CanReportStats(); |
843 } | 903 } |
844 | 904 |
845 // The BrowserProcess object must outlive the file thread so we use traits | 905 // 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... | |
947 } | 1007 } |
948 | 1008 |
949 void BrowserProcessImpl::OnAutoupdateTimer() { | 1009 void BrowserProcessImpl::OnAutoupdateTimer() { |
950 if (CanAutorestartForUpdate()) { | 1010 if (CanAutorestartForUpdate()) { |
951 DLOG(WARNING) << "Detected update. Restarting browser."; | 1011 DLOG(WARNING) << "Detected update. Restarting browser."; |
952 RestartPersistentInstance(); | 1012 RestartPersistentInstance(); |
953 } | 1013 } |
954 } | 1014 } |
955 | 1015 |
956 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) | 1016 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) |
OLD | NEW |