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

Side by Side Diff: chrome/browser/browser_process_impl.cc

Issue 2479593006: Move enable extensions define to a build flag. (Closed)
Patch Set: Test updates Created 4 years, 1 month 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
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <map> 10 #include <map>
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 #include "content/public/browser/browser_thread.h" 110 #include "content/public/browser/browser_thread.h"
111 #include "content/public/browser/child_process_security_policy.h" 111 #include "content/public/browser/child_process_security_policy.h"
112 #include "content/public/browser/notification_details.h" 112 #include "content/public/browser/notification_details.h"
113 #include "content/public/browser/plugin_service.h" 113 #include "content/public/browser/plugin_service.h"
114 #include "content/public/browser/render_process_host.h" 114 #include "content/public/browser/render_process_host.h"
115 #include "content/public/browser/resource_dispatcher_host.h" 115 #include "content/public/browser/resource_dispatcher_host.h"
116 #include "content/public/browser/service_worker_context.h" 116 #include "content/public/browser/service_worker_context.h"
117 #include "content/public/browser/storage_partition.h" 117 #include "content/public/browser/storage_partition.h"
118 #include "content/public/common/content_switches.h" 118 #include "content/public/common/content_switches.h"
119 #include "extensions/common/constants.h" 119 #include "extensions/common/constants.h"
120 #include "extensions/features/features.h"
120 #include "net/socket/client_socket_pool_manager.h" 121 #include "net/socket/client_socket_pool_manager.h"
121 #include "net/url_request/url_request_context_getter.h" 122 #include "net/url_request/url_request_context_getter.h"
122 #include "printing/features/features.h" 123 #include "printing/features/features.h"
123 #include "ui/base/idle/idle.h" 124 #include "ui/base/idle/idle.h"
124 #include "ui/base/l10n/l10n_util.h" 125 #include "ui/base/l10n/l10n_util.h"
125 #include "ui/message_center/message_center.h" 126 #include "ui/message_center/message_center.h"
126 127
127 #if defined(OS_WIN) 128 #if defined(OS_WIN)
128 #include "base/win/windows_version.h" 129 #include "base/win/windows_version.h"
129 #include "ui/views/focus/view_storage.h" 130 #include "ui/views/focus/view_storage.h"
130 #elif defined(OS_MACOSX) 131 #elif defined(OS_MACOSX)
131 #include "chrome/browser/chrome_browser_main_mac.h" 132 #include "chrome/browser/chrome_browser_main_mac.h"
132 #endif 133 #endif
133 134
134 #if !defined(OS_ANDROID) 135 #if !defined(OS_ANDROID)
135 #include "chrome/browser/lifetime/keep_alive_registry.h" 136 #include "chrome/browser/lifetime/keep_alive_registry.h"
136 #include "chrome/browser/services/gcm/gcm_product_util.h" 137 #include "chrome/browser/services/gcm/gcm_product_util.h"
137 #include "chrome/browser/ui/user_manager.h" 138 #include "chrome/browser/ui/user_manager.h"
138 #include "components/gcm_driver/gcm_client_factory.h" 139 #include "components/gcm_driver/gcm_client_factory.h"
139 #include "components/gcm_driver/gcm_desktop_utils.h" 140 #include "components/gcm_driver/gcm_desktop_utils.h"
140 #endif 141 #endif
141 142
142 #if BUILDFLAG(ENABLE_BACKGROUND) 143 #if BUILDFLAG(ENABLE_BACKGROUND)
143 #include "chrome/browser/background/background_mode_manager.h" 144 #include "chrome/browser/background/background_mode_manager.h"
144 #endif 145 #endif
145 146
146 #if defined(ENABLE_EXTENSIONS) 147 #if BUILDFLAG(ENABLE_EXTENSIONS)
147 #include "chrome/browser/extensions/chrome_extensions_browser_client.h" 148 #include "chrome/browser/extensions/chrome_extensions_browser_client.h"
148 #include "chrome/browser/extensions/event_router_forwarder.h" 149 #include "chrome/browser/extensions/event_router_forwarder.h"
149 #include "chrome/browser/media_galleries/media_file_system_registry.h" 150 #include "chrome/browser/media_galleries/media_file_system_registry.h"
150 #include "chrome/browser/ui/apps/chrome_app_window_client.h" 151 #include "chrome/browser/ui/apps/chrome_app_window_client.h"
151 #include "components/storage_monitor/storage_monitor.h" 152 #include "components/storage_monitor/storage_monitor.h"
152 #include "extensions/common/extension_l10n_util.h" 153 #include "extensions/common/extension_l10n_util.h"
153 #endif 154 #endif
154 155
155 #if !defined(DISABLE_NACL) 156 #if !defined(DISABLE_NACL)
156 #include "chrome/browser/component_updater/pnacl_component_installer.h" 157 #include "chrome/browser/component_updater/pnacl_component_installer.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 230
230 ChildProcessSecurityPolicy::GetInstance()->RegisterWebSafeScheme( 231 ChildProcessSecurityPolicy::GetInstance()->RegisterWebSafeScheme(
231 chrome::kChromeSearchScheme); 232 chrome::kChromeSearchScheme);
232 233
233 #if defined(OS_MACOSX) 234 #if defined(OS_MACOSX)
234 ui::InitIdleMonitor(); 235 ui::InitIdleMonitor();
235 #endif 236 #endif
236 237
237 device_client_.reset(new ChromeDeviceClient); 238 device_client_.reset(new ChromeDeviceClient);
238 239
239 #if defined(ENABLE_EXTENSIONS) 240 #if BUILDFLAG(ENABLE_EXTENSIONS)
240 // Athena sets its own instance during Athena's init process. 241 // Athena sets its own instance during Athena's init process.
241 extensions::AppWindowClient::Set(ChromeAppWindowClient::GetInstance()); 242 extensions::AppWindowClient::Set(ChromeAppWindowClient::GetInstance());
242 243
243 extension_event_router_forwarder_ = new extensions::EventRouterForwarder; 244 extension_event_router_forwarder_ = new extensions::EventRouterForwarder;
244 245
245 extensions::ExtensionsClient::Set( 246 extensions::ExtensionsClient::Set(
246 extensions::ChromeExtensionsClient::GetInstance()); 247 extensions::ChromeExtensionsClient::GetInstance());
247 248
248 extensions_browser_client_.reset( 249 extensions_browser_client_.reset(
249 new extensions::ChromeExtensionsBrowserClient); 250 new extensions::ChromeExtensionsBrowserClient);
250 extensions::ExtensionsBrowserClient::Set(extensions_browser_client_.get()); 251 extensions::ExtensionsBrowserClient::Set(extensions_browser_client_.get());
251 #endif 252 #endif
252 253
253 message_center::MessageCenter::Initialize(); 254 message_center::MessageCenter::Initialize();
254 255
255 update_client::UpdateQueryParams::SetDelegate( 256 update_client::UpdateQueryParams::SetDelegate(
256 ChromeUpdateQueryParamsDelegate::GetInstance()); 257 ChromeUpdateQueryParamsDelegate::GetInstance());
257 258
258 #if !defined(OS_ANDROID) 259 #if !defined(OS_ANDROID)
259 KeepAliveRegistry::GetInstance()->AddObserver(this); 260 KeepAliveRegistry::GetInstance()->AddObserver(this);
260 #endif // !defined(OS_ANDROID) 261 #endif // !defined(OS_ANDROID)
261 } 262 }
262 263
263 BrowserProcessImpl::~BrowserProcessImpl() { 264 BrowserProcessImpl::~BrowserProcessImpl() {
264 #if defined(ENABLE_EXTENSIONS) 265 #if BUILDFLAG(ENABLE_EXTENSIONS)
265 extensions::ExtensionsBrowserClient::Set(nullptr); 266 extensions::ExtensionsBrowserClient::Set(nullptr);
266 #endif 267 #endif
267 268
268 #if !defined(OS_ANDROID) 269 #if !defined(OS_ANDROID)
269 KeepAliveRegistry::GetInstance()->RemoveObserver(this); 270 KeepAliveRegistry::GetInstance()->RemoveObserver(this);
270 #endif // !defined(OS_ANDROID) 271 #endif // !defined(OS_ANDROID)
271 272
272 tracked_objects::ThreadData::EnsureCleanupWasCalled(4); 273 tracked_objects::ThreadData::EnsureCleanupWasCalled(4);
273 274
274 g_browser_process = NULL; 275 g_browser_process = NULL;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 TRACE_EVENT0("shutdown", 317 TRACE_EVENT0("shutdown",
317 "BrowserProcessImpl::StartTearDown:ProfileManager"); 318 "BrowserProcessImpl::StartTearDown:ProfileManager");
318 // The desktop User Manager needs to be closed before the guest profile 319 // The desktop User Manager needs to be closed before the guest profile
319 // can be destroyed. 320 // can be destroyed.
320 UserManager::Hide(); 321 UserManager::Hide();
321 profile_manager_.reset(); 322 profile_manager_.reset();
322 } 323 }
323 324
324 child_process_watcher_.reset(); 325 child_process_watcher_.reset();
325 326
326 #if defined(ENABLE_EXTENSIONS) 327 #if BUILDFLAG(ENABLE_EXTENSIONS)
327 media_file_system_registry_.reset(); 328 media_file_system_registry_.reset();
328 // Remove the global instance of the Storage Monitor now. Otherwise the 329 // Remove the global instance of the Storage Monitor now. Otherwise the
329 // FILE thread would be gone when we try to release it in the dtor and 330 // FILE thread would be gone when we try to release it in the dtor and
330 // Valgrind would report a leak on almost every single browser_test. 331 // Valgrind would report a leak on almost every single browser_test.
331 // TODO(gbillock): Make this unnecessary. 332 // TODO(gbillock): Make this unnecessary.
332 storage_monitor::StorageMonitor::Destroy(); 333 storage_monitor::StorageMonitor::Destroy();
333 #endif 334 #endif
334 335
335 message_center::MessageCenter::Shutdown(); 336 message_center::MessageCenter::Shutdown();
336 337
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 DCHECK(CalledOnValidThread()); 565 DCHECK(CalledOnValidThread());
565 return GetMetricsServicesManager()->GetVariationsService(); 566 return GetMetricsServicesManager()->GetVariationsService();
566 } 567 }
567 568
568 BrowserProcessPlatformPart* BrowserProcessImpl::platform_part() { 569 BrowserProcessPlatformPart* BrowserProcessImpl::platform_part() {
569 return platform_part_.get(); 570 return platform_part_.get();
570 } 571 }
571 572
572 extensions::EventRouterForwarder* 573 extensions::EventRouterForwarder*
573 BrowserProcessImpl::extension_event_router_forwarder() { 574 BrowserProcessImpl::extension_event_router_forwarder() {
574 #if defined(ENABLE_EXTENSIONS) 575 #if BUILDFLAG(ENABLE_EXTENSIONS)
575 return extension_event_router_forwarder_.get(); 576 return extension_event_router_forwarder_.get();
576 #else 577 #else
577 return NULL; 578 return NULL;
578 #endif 579 #endif
579 } 580 }
580 581
581 NotificationUIManager* BrowserProcessImpl::notification_ui_manager() { 582 NotificationUIManager* BrowserProcessImpl::notification_ui_manager() {
582 DCHECK(CalledOnValidThread()); 583 DCHECK(CalledOnValidThread());
583 // TODO(miguelg) return NULL for MAC as well once native notifications 584 // TODO(miguelg) return NULL for MAC as well once native notifications
584 // are enabled by default. 585 // are enabled by default.
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 return intranet_redirect_detector_.get(); 710 return intranet_redirect_detector_.get();
710 } 711 }
711 712
712 const std::string& BrowserProcessImpl::GetApplicationLocale() { 713 const std::string& BrowserProcessImpl::GetApplicationLocale() {
713 DCHECK(!locale_.empty()); 714 DCHECK(!locale_.empty());
714 return locale_; 715 return locale_;
715 } 716 }
716 717
717 void BrowserProcessImpl::SetApplicationLocale(const std::string& locale) { 718 void BrowserProcessImpl::SetApplicationLocale(const std::string& locale) {
718 locale_ = locale; 719 locale_ = locale;
719 #if defined(ENABLE_EXTENSIONS) 720 #if BUILDFLAG(ENABLE_EXTENSIONS)
720 extension_l10n_util::SetProcessLocale(locale); 721 extension_l10n_util::SetProcessLocale(locale);
721 #endif 722 #endif
722 ChromeContentBrowserClient::SetApplicationLocale(locale); 723 ChromeContentBrowserClient::SetApplicationLocale(locale);
723 translate::TranslateDownloadManager::GetInstance()->set_application_locale( 724 translate::TranslateDownloadManager::GetInstance()->set_application_locale(
724 locale); 725 locale);
725 } 726 }
726 727
727 DownloadStatusUpdater* BrowserProcessImpl::download_status_updater() { 728 DownloadStatusUpdater* BrowserProcessImpl::download_status_updater() {
728 return download_status_updater_.get(); 729 return download_status_updater_.get();
729 } 730 }
730 731
731 MediaFileSystemRegistry* BrowserProcessImpl::media_file_system_registry() { 732 MediaFileSystemRegistry* BrowserProcessImpl::media_file_system_registry() {
732 #if defined(ENABLE_EXTENSIONS) 733 #if BUILDFLAG(ENABLE_EXTENSIONS)
733 if (!media_file_system_registry_) 734 if (!media_file_system_registry_)
734 media_file_system_registry_.reset(new MediaFileSystemRegistry()); 735 media_file_system_registry_.reset(new MediaFileSystemRegistry());
735 return media_file_system_registry_.get(); 736 return media_file_system_registry_.get();
736 #else 737 #else
737 return NULL; 738 return NULL;
738 #endif 739 #endif
739 } 740 }
740 741
741 bool BrowserProcessImpl::created_local_state() const { 742 bool BrowserProcessImpl::created_local_state() const {
742 return created_local_state_; 743 return created_local_state_;
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
1028 1029
1029 int max_per_proxy = local_state_->GetInteger(prefs::kMaxConnectionsPerProxy); 1030 int max_per_proxy = local_state_->GetInteger(prefs::kMaxConnectionsPerProxy);
1030 net::ClientSocketPoolManager::set_max_sockets_per_proxy_server( 1031 net::ClientSocketPoolManager::set_max_sockets_per_proxy_server(
1031 net::HttpNetworkSession::NORMAL_SOCKET_POOL, 1032 net::HttpNetworkSession::NORMAL_SOCKET_POOL,
1032 std::max(std::min(max_per_proxy, 99), 1033 std::max(std::min(max_per_proxy, 99),
1033 net::ClientSocketPoolManager::max_sockets_per_group( 1034 net::ClientSocketPoolManager::max_sockets_per_group(
1034 net::HttpNetworkSession::NORMAL_SOCKET_POOL))); 1035 net::HttpNetworkSession::NORMAL_SOCKET_POOL)));
1035 } 1036 }
1036 1037
1037 void BrowserProcessImpl::PreCreateThreads() { 1038 void BrowserProcessImpl::PreCreateThreads() {
1038 #if defined(ENABLE_EXTENSIONS) 1039 #if BUILDFLAG(ENABLE_EXTENSIONS)
1039 // Register the chrome-extension scheme to reflect the extension process 1040 // Register the chrome-extension scheme to reflect the extension process
1040 // model. Controlled by a field trial, so we can't do this earlier. 1041 // model. Controlled by a field trial, so we can't do this earlier.
1041 base::FieldTrialList::FindFullName("SiteIsolationExtensions"); 1042 base::FieldTrialList::FindFullName("SiteIsolationExtensions");
1042 if (extensions::IsIsolateExtensionsEnabled()) { 1043 if (extensions::IsIsolateExtensionsEnabled()) {
1043 // chrome-extension:// URLs are safe to request anywhere, but may only 1044 // chrome-extension:// URLs are safe to request anywhere, but may only
1044 // commit (including in iframes) in extension processes. 1045 // commit (including in iframes) in extension processes.
1045 ChildProcessSecurityPolicy::GetInstance()->RegisterWebSafeIsolatedScheme( 1046 ChildProcessSecurityPolicy::GetInstance()->RegisterWebSafeIsolatedScheme(
1046 extensions::kExtensionScheme, true); 1047 extensions::kExtensionScheme, true);
1047 // TODO(nick): Kill off kExtensionResourceScheme. 1048 // TODO(nick): Kill off kExtensionResourceScheme.
1048 ChildProcessSecurityPolicy::GetInstance()->RegisterWebSafeIsolatedScheme( 1049 ChildProcessSecurityPolicy::GetInstance()->RegisterWebSafeIsolatedScheme(
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
1398 } 1399 }
1399 1400
1400 void BrowserProcessImpl::OnAutoupdateTimer() { 1401 void BrowserProcessImpl::OnAutoupdateTimer() {
1401 if (CanAutorestartForUpdate()) { 1402 if (CanAutorestartForUpdate()) {
1402 DLOG(WARNING) << "Detected update. Restarting browser."; 1403 DLOG(WARNING) << "Detected update. Restarting browser.";
1403 RestartBackgroundInstance(); 1404 RestartBackgroundInstance();
1404 } 1405 }
1405 } 1406 }
1406 1407
1407 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) 1408 #endif // (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698