OLD | NEW |
---|---|
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 <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/atomic_ref_count.h" | 11 #include "base/atomic_ref_count.h" |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
15 #include "base/debug/alias.h" | 15 #include "base/debug/alias.h" |
16 #include "base/debug/leak_annotations.h" | 16 #include "base/debug/leak_annotations.h" |
17 #include "base/files/file_path.h" | 17 #include "base/files/file_path.h" |
18 #include "base/metrics/field_trial.h" | 18 #include "base/metrics/field_trial.h" |
19 #include "base/path_service.h" | 19 #include "base/path_service.h" |
20 #include "base/prefs/json_pref_store.h" | 20 #include "base/prefs/json_pref_store.h" |
21 #include "base/prefs/pref_registry_simple.h" | 21 #include "base/prefs/pref_registry_simple.h" |
22 #include "base/prefs/pref_service.h" | 22 #include "base/prefs/pref_service.h" |
23 #include "base/synchronization/waitable_event.h" | 23 #include "base/synchronization/waitable_event.h" |
24 #include "base/threading/thread.h" | 24 #include "base/threading/thread.h" |
25 #include "base/threading/thread_restrictions.h" | 25 #include "base/threading/thread_restrictions.h" |
26 #include "base/time/default_tick_clock.h" | 26 #include "base/time/default_tick_clock.h" |
27 #include "chrome/browser/background/background_mode_manager.h" | |
28 #include "chrome/browser/chrome_browser_main.h" | 27 #include "chrome/browser/chrome_browser_main.h" |
29 #include "chrome/browser/chrome_content_browser_client.h" | 28 #include "chrome/browser/chrome_content_browser_client.h" |
30 #include "chrome/browser/chrome_notification_types.h" | 29 #include "chrome/browser/chrome_notification_types.h" |
31 #include "chrome/browser/component_updater/chrome_component_updater_configurator .h" | 30 #include "chrome/browser/component_updater/chrome_component_updater_configurator .h" |
32 #include "chrome/browser/defaults.h" | 31 #include "chrome/browser/defaults.h" |
33 #include "chrome/browser/devtools/remote_debugging_server.h" | 32 #include "chrome/browser/devtools/remote_debugging_server.h" |
34 #include "chrome/browser/download/download_request_limiter.h" | 33 #include "chrome/browser/download/download_request_limiter.h" |
35 #include "chrome/browser/download/download_status_updater.h" | 34 #include "chrome/browser/download/download_status_updater.h" |
36 #include "chrome/browser/first_run/upgrade_util.h" | 35 #include "chrome/browser/first_run/upgrade_util.h" |
37 #include "chrome/browser/gpu/gl_string_manager.h" | 36 #include "chrome/browser/gpu/gl_string_manager.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
84 #include "components/translate/core/browser/translate_download_manager.h" | 83 #include "components/translate/core/browser/translate_download_manager.h" |
85 #include "content/public/browser/browser_thread.h" | 84 #include "content/public/browser/browser_thread.h" |
86 #include "content/public/browser/child_process_security_policy.h" | 85 #include "content/public/browser/child_process_security_policy.h" |
87 #include "content/public/browser/notification_details.h" | 86 #include "content/public/browser/notification_details.h" |
88 #include "content/public/browser/plugin_service.h" | 87 #include "content/public/browser/plugin_service.h" |
89 #include "content/public/browser/render_process_host.h" | 88 #include "content/public/browser/render_process_host.h" |
90 #include "content/public/browser/resource_dispatcher_host.h" | 89 #include "content/public/browser/resource_dispatcher_host.h" |
91 #include "content/public/browser/service_worker_context.h" | 90 #include "content/public/browser/service_worker_context.h" |
92 #include "content/public/browser/storage_partition.h" | 91 #include "content/public/browser/storage_partition.h" |
93 #include "extensions/common/constants.h" | 92 #include "extensions/common/constants.h" |
94 #include "extensions/common/extension_l10n_util.h" | |
95 #include "net/socket/client_socket_pool_manager.h" | 93 #include "net/socket/client_socket_pool_manager.h" |
96 #include "net/url_request/url_request_context_getter.h" | 94 #include "net/url_request/url_request_context_getter.h" |
97 #include "ui/base/l10n/l10n_util.h" | 95 #include "ui/base/l10n/l10n_util.h" |
98 #include "ui/message_center/message_center.h" | 96 #include "ui/message_center/message_center.h" |
99 | 97 |
100 #if defined(OS_WIN) | 98 #if defined(OS_WIN) |
101 #include "base/win/windows_version.h" | 99 #include "base/win/windows_version.h" |
102 #include "ui/views/focus/view_storage.h" | 100 #include "ui/views/focus/view_storage.h" |
103 #elif defined(OS_MACOSX) | 101 #elif defined(OS_MACOSX) |
104 #include "chrome/browser/chrome_browser_main_mac.h" | 102 #include "chrome/browser/chrome_browser_main_mac.h" |
105 #endif | 103 #endif |
106 | 104 |
107 #if defined(OS_ANDROID) | 105 #if defined(OS_ANDROID) |
108 #include "components/gcm_driver/gcm_driver_android.h" | 106 #include "components/gcm_driver/gcm_driver_android.h" |
109 #else | 107 #else |
110 #include "chrome/browser/chrome_device_client.h" | 108 #include "chrome/browser/chrome_device_client.h" |
111 #include "chrome/browser/services/gcm/gcm_desktop_utils.h" | 109 #include "chrome/browser/services/gcm/gcm_desktop_utils.h" |
112 #include "components/gcm_driver/gcm_client_factory.h" | 110 #include "components/gcm_driver/gcm_client_factory.h" |
113 #endif | 111 #endif |
114 | 112 |
115 #if defined(USE_AURA) | 113 #if defined(USE_AURA) |
116 #include "ui/aura/env.h" | 114 #include "ui/aura/env.h" |
117 #endif | 115 #endif |
118 | 116 |
117 #if defined(ENABLE_BACKGROUND) | |
118 #include "chrome/browser/background/background_mode_manager.h" | |
119 #endif | |
120 | |
119 #if defined(ENABLE_CONFIGURATION_POLICY) | 121 #if defined(ENABLE_CONFIGURATION_POLICY) |
120 #include "components/policy/core/browser/browser_policy_connector.h" | 122 #include "components/policy/core/browser/browser_policy_connector.h" |
121 #else | 123 #else |
122 #include "components/policy/core/common/policy_service_stub.h" | 124 #include "components/policy/core/common/policy_service_stub.h" |
123 #endif // defined(ENABLE_CONFIGURATION_POLICY) | 125 #endif // defined(ENABLE_CONFIGURATION_POLICY) |
124 | 126 |
125 #if defined(ENABLE_EXTENSIONS) | 127 #if defined(ENABLE_EXTENSIONS) |
126 #include "chrome/browser/extensions/chrome_extensions_browser_client.h" | 128 #include "chrome/browser/extensions/chrome_extensions_browser_client.h" |
127 #include "chrome/browser/extensions/event_router_forwarder.h" | 129 #include "chrome/browser/extensions/event_router_forwarder.h" |
128 #include "chrome/browser/extensions/extension_renderer_state.h" | 130 #include "chrome/browser/extensions/extension_renderer_state.h" |
129 #include "chrome/browser/media_galleries/media_file_system_registry.h" | 131 #include "chrome/browser/media_galleries/media_file_system_registry.h" |
130 #include "components/storage_monitor/storage_monitor.h" | 132 #include "components/storage_monitor/storage_monitor.h" |
133 #include "extensions/common/extension_l10n_util.h" | |
131 #endif | 134 #endif |
132 | 135 |
133 #if !defined(DISABLE_NACL) | 136 #if !defined(DISABLE_NACL) |
134 #include "chrome/browser/component_updater/pnacl/pnacl_component_installer.h" | 137 #include "chrome/browser/component_updater/pnacl/pnacl_component_installer.h" |
135 #endif | 138 #endif |
136 | 139 |
137 #if defined(ENABLE_PLUGIN_INSTALLATION) | 140 #if defined(ENABLE_PLUGIN_INSTALLATION) |
138 #include "chrome/browser/plugins/plugins_resource_service.h" | 141 #include "chrome/browser/plugins/plugins_resource_service.h" |
139 #endif | 142 #endif |
140 | 143 |
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
720 return intranet_redirect_detector_.get(); | 723 return intranet_redirect_detector_.get(); |
721 } | 724 } |
722 | 725 |
723 const std::string& BrowserProcessImpl::GetApplicationLocale() { | 726 const std::string& BrowserProcessImpl::GetApplicationLocale() { |
724 DCHECK(!locale_.empty()); | 727 DCHECK(!locale_.empty()); |
725 return locale_; | 728 return locale_; |
726 } | 729 } |
727 | 730 |
728 void BrowserProcessImpl::SetApplicationLocale(const std::string& locale) { | 731 void BrowserProcessImpl::SetApplicationLocale(const std::string& locale) { |
729 locale_ = locale; | 732 locale_ = locale; |
733 #if defined(ENABLE_EXTENSIONS) | |
730 extension_l10n_util::SetProcessLocale(locale); | 734 extension_l10n_util::SetProcessLocale(locale); |
735 #endif | |
731 chrome::ChromeContentBrowserClient::SetApplicationLocale(locale); | 736 chrome::ChromeContentBrowserClient::SetApplicationLocale(locale); |
732 translate::TranslateDownloadManager::GetInstance()->set_application_locale( | 737 translate::TranslateDownloadManager::GetInstance()->set_application_locale( |
733 locale); | 738 locale); |
734 } | 739 } |
735 | 740 |
736 DownloadStatusUpdater* BrowserProcessImpl::download_status_updater() { | 741 DownloadStatusUpdater* BrowserProcessImpl::download_status_updater() { |
737 return download_status_updater_.get(); | 742 return download_status_updater_.get(); |
738 } | 743 } |
739 | 744 |
740 MediaFileSystemRegistry* BrowserProcessImpl::media_file_system_registry() { | 745 MediaFileSystemRegistry* BrowserProcessImpl::media_file_system_registry() { |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
834 CreateBackgroundModeManager(); | 839 CreateBackgroundModeManager(); |
835 return background_mode_manager_.get(); | 840 return background_mode_manager_.get(); |
836 #else | 841 #else |
837 NOTIMPLEMENTED(); | 842 NOTIMPLEMENTED(); |
838 return NULL; | 843 return NULL; |
839 #endif | 844 #endif |
840 } | 845 } |
841 | 846 |
842 void BrowserProcessImpl::set_background_mode_manager_for_test( | 847 void BrowserProcessImpl::set_background_mode_manager_for_test( |
843 scoped_ptr<BackgroundModeManager> manager) { | 848 scoped_ptr<BackgroundModeManager> manager) { |
849 #if defined(ENABLE_BACKGROUND) | |
844 background_mode_manager_ = manager.Pass(); | 850 background_mode_manager_ = manager.Pass(); |
851 #endif | |
845 } | 852 } |
846 | 853 |
847 StatusTray* BrowserProcessImpl::status_tray() { | 854 StatusTray* BrowserProcessImpl::status_tray() { |
848 DCHECK(CalledOnValidThread()); | 855 DCHECK(CalledOnValidThread()); |
849 if (!status_tray_.get()) | 856 if (!status_tray_.get()) |
850 CreateStatusTray(); | 857 CreateStatusTray(); |
851 return status_tray_.get(); | 858 return status_tray_.get(); |
852 } | 859 } |
853 | 860 |
854 | 861 |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1077 } | 1084 } |
1078 | 1085 |
1079 void BrowserProcessImpl::CreateNotificationUIManager() { | 1086 void BrowserProcessImpl::CreateNotificationUIManager() { |
1080 #if defined(ENABLE_NOTIFICATIONS) | 1087 #if defined(ENABLE_NOTIFICATIONS) |
1081 DCHECK(notification_ui_manager_.get() == NULL); | 1088 DCHECK(notification_ui_manager_.get() == NULL); |
1082 notification_ui_manager_.reset(NotificationUIManager::Create(local_state())); | 1089 notification_ui_manager_.reset(NotificationUIManager::Create(local_state())); |
1083 created_notification_ui_manager_ = true; | 1090 created_notification_ui_manager_ = true; |
1084 #endif | 1091 #endif |
1085 } | 1092 } |
1086 | 1093 |
1087 void BrowserProcessImpl::CreateBackgroundModeManager() { | 1094 void BrowserProcessImpl::CreateBackgroundModeManager() { |
Andrew T Wilson (Slow)
2014/10/20 14:23:02
Why isn't this entire API inside ENABLE_BACKGROUND
Lei Zhang
2014/10/20 18:38:20
I'm being consistent with the all the other #ifdef
| |
1095 #if defined(ENABLE_BACKGROUND) | |
1088 DCHECK(background_mode_manager_.get() == NULL); | 1096 DCHECK(background_mode_manager_.get() == NULL); |
1089 background_mode_manager_.reset( | 1097 background_mode_manager_.reset( |
1090 new BackgroundModeManager(CommandLine::ForCurrentProcess(), | 1098 new BackgroundModeManager(CommandLine::ForCurrentProcess(), |
1091 &profile_manager()->GetProfileInfoCache())); | 1099 &profile_manager()->GetProfileInfoCache())); |
1100 #endif | |
1092 } | 1101 } |
1093 | 1102 |
1094 void BrowserProcessImpl::CreateStatusTray() { | 1103 void BrowserProcessImpl::CreateStatusTray() { |
1095 DCHECK(status_tray_.get() == NULL); | 1104 DCHECK(status_tray_.get() == NULL); |
1096 status_tray_.reset(StatusTray::Create()); | 1105 status_tray_.reset(StatusTray::Create()); |
1097 } | 1106 } |
1098 | 1107 |
1099 void BrowserProcessImpl::CreatePrintPreviewDialogController() { | 1108 void BrowserProcessImpl::CreatePrintPreviewDialogController() { |
1100 #if defined(ENABLE_FULL_PRINTING) | 1109 #if defined(ENABLE_FULL_PRINTING) |
1101 DCHECK(print_preview_dialog_controller_.get() == NULL); | 1110 DCHECK(print_preview_dialog_controller_.get() == NULL); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1220 } | 1229 } |
1221 | 1230 |
1222 void BrowserProcessImpl::OnAutoupdateTimer() { | 1231 void BrowserProcessImpl::OnAutoupdateTimer() { |
1223 if (CanAutorestartForUpdate()) { | 1232 if (CanAutorestartForUpdate()) { |
1224 DLOG(WARNING) << "Detected update. Restarting browser."; | 1233 DLOG(WARNING) << "Detected update. Restarting browser."; |
1225 RestartBackgroundInstance(); | 1234 RestartBackgroundInstance(); |
1226 } | 1235 } |
1227 } | 1236 } |
1228 | 1237 |
1229 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) | 1238 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) |
OLD | NEW |