OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "extensions/browser/process_manager.h" | 5 #include "extensions/browser/process_manager.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 iter != all_extension_views_.end(); ++iter) { | 241 iter != all_extension_views_.end(); ++iter) { |
242 result.insert(iter->first); | 242 result.insert(iter->first); |
243 } | 243 } |
244 return result; | 244 return result; |
245 } | 245 } |
246 | 246 |
247 ExtensionHost* ProcessManager::CreateBackgroundHost(const Extension* extension, | 247 ExtensionHost* ProcessManager::CreateBackgroundHost(const Extension* extension, |
248 const GURL& url) { | 248 const GURL& url) { |
249 // Hosted apps are taken care of from BackgroundContentsService. Ignore them | 249 // Hosted apps are taken care of from BackgroundContentsService. Ignore them |
250 // here. | 250 // here. |
251 if (extension->is_hosted_app()) | 251 if (extension->is_hosted_app() || |
| 252 !ExtensionsBrowserClient::Get()-> |
| 253 IsBackgroundPageAllowed(GetBrowserContext())) { |
252 return NULL; | 254 return NULL; |
| 255 } |
253 | 256 |
254 // Don't create multiple background hosts for an extension. | 257 // Don't create multiple background hosts for an extension. |
255 if (ExtensionHost* host = GetBackgroundHostForExtension(extension->id())) | 258 if (ExtensionHost* host = GetBackgroundHostForExtension(extension->id())) |
256 return host; // TODO(kalman): return NULL here? It might break things... | 259 return host; // TODO(kalman): return NULL here? It might break things... |
257 | 260 |
258 ExtensionHost* host = | 261 ExtensionHost* host = |
259 new ExtensionHost(extension, GetSiteInstanceForURL(url), url, | 262 new ExtensionHost(extension, GetSiteInstanceForURL(url), url, |
260 VIEW_TYPE_EXTENSION_BACKGROUND_PAGE); | 263 VIEW_TYPE_EXTENSION_BACKGROUND_PAGE); |
261 host->CreateRenderViewSoon(); | 264 host->CreateRenderViewSoon(); |
262 OnBackgroundHostCreated(host); | 265 OnBackgroundHostCreated(host); |
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
702 if (attached) { | 705 if (attached) { |
703 // Keep the lazy background page alive while it's being inspected. | 706 // Keep the lazy background page alive while it's being inspected. |
704 CancelSuspend(extension); | 707 CancelSuspend(extension); |
705 IncrementLazyKeepaliveCount(extension); | 708 IncrementLazyKeepaliveCount(extension); |
706 } else { | 709 } else { |
707 DecrementLazyKeepaliveCount(extension); | 710 DecrementLazyKeepaliveCount(extension); |
708 } | 711 } |
709 } | 712 } |
710 | 713 |
711 void ProcessManager::CreateBackgroundHostsForProfileStartup() { | 714 void ProcessManager::CreateBackgroundHostsForProfileStartup() { |
712 if (startup_background_hosts_created_) | 715 if (startup_background_hosts_created_ || |
| 716 !ExtensionsBrowserClient::Get()-> |
| 717 IsBackgroundPageAllowed(GetBrowserContext())) { |
713 return; | 718 return; |
| 719 } |
714 | 720 |
715 ExtensionService* service = ExtensionSystem::GetForBrowserContext( | 721 ExtensionService* service = ExtensionSystem::GetForBrowserContext( |
716 GetBrowserContext())->extension_service(); | 722 GetBrowserContext())->extension_service(); |
717 DCHECK(service); | 723 DCHECK(service); |
718 for (ExtensionSet::const_iterator extension = service->extensions()->begin(); | 724 for (ExtensionSet::const_iterator extension = service->extensions()->begin(); |
719 extension != service->extensions()->end(); ++extension) { | 725 extension != service->extensions()->end(); ++extension) { |
720 CreateBackgroundHostForExtensionLoad(this, extension->get()); | 726 CreateBackgroundHostForExtensionLoad(this, extension->get()); |
721 | 727 |
722 RuntimeEventRouter::DispatchOnStartupEvent(GetBrowserContext(), | 728 RuntimeEventRouter::DispatchOnStartupEvent(GetBrowserContext(), |
723 (*extension)->id()); | 729 (*extension)->id()); |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
864 } | 870 } |
865 | 871 |
866 bool IncognitoProcessManager::IsIncognitoEnabled(const Extension* extension) { | 872 bool IncognitoProcessManager::IsIncognitoEnabled(const Extension* extension) { |
867 // Keep in sync with duplicate in extension_info_map.cc. | 873 // Keep in sync with duplicate in extension_info_map.cc. |
868 ExtensionService* service = ExtensionSystem::GetForBrowserContext( | 874 ExtensionService* service = ExtensionSystem::GetForBrowserContext( |
869 GetBrowserContext())->extension_service(); | 875 GetBrowserContext())->extension_service(); |
870 return extension_util::IsIncognitoEnabled(extension->id(), service); | 876 return extension_util::IsIncognitoEnabled(extension->id(), service); |
871 } | 877 } |
872 | 878 |
873 } // namespace extensions | 879 } // namespace extensions |
OLD | NEW |