| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "chrome/browser/extensions/extension_process_manager.h" | 7 #include "chrome/browser/extensions/extension_process_manager.h" |
| 8 | 8 |
| 9 #include "chrome/browser/ui/browser_window.h" | 9 #include "chrome/browser/ui/browser_window.h" |
| 10 #include "content/browser/browsing_instance.h" | 10 #include "content/browser/browsing_instance.h" |
| 11 #include "chrome/browser/extensions/extension_event_router.h" |
| 11 #if defined(OS_MACOSX) | 12 #if defined(OS_MACOSX) |
| 12 #include "chrome/browser/extensions/extension_host_mac.h" | 13 #include "chrome/browser/extensions/extension_host_mac.h" |
| 13 #endif | 14 #endif |
| 14 #include "chrome/browser/extensions/extension_host.h" | 15 #include "chrome/browser/extensions/extension_host.h" |
| 15 #include "chrome/browser/extensions/extension_info_map.h" | 16 #include "chrome/browser/extensions/extension_info_map.h" |
| 16 #include "chrome/browser/extensions/extension_service.h" | 17 #include "chrome/browser/extensions/extension_service.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/browser/ui/browser.h" | 19 #include "chrome/browser/ui/browser.h" |
| 19 #include "chrome/common/chrome_notification_types.h" | 20 #include "chrome/common/chrome_notification_types.h" |
| 20 #include "chrome/common/chrome_switches.h" | 21 #include "chrome/common/chrome_switches.h" |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 SiteInstance* ExtensionProcessManager::GetSiteInstanceForURL(const GURL& url) { | 423 SiteInstance* ExtensionProcessManager::GetSiteInstanceForURL(const GURL& url) { |
| 423 return browsing_instance_->GetSiteInstanceForURL(url); | 424 return browsing_instance_->GetSiteInstanceForURL(url); |
| 424 } | 425 } |
| 425 | 426 |
| 426 bool ExtensionProcessManager::HasExtensionHost(ExtensionHost* host) const { | 427 bool ExtensionProcessManager::HasExtensionHost(ExtensionHost* host) const { |
| 427 return all_hosts_.find(host) != all_hosts_.end(); | 428 return all_hosts_.find(host) != all_hosts_.end(); |
| 428 } | 429 } |
| 429 | 430 |
| 430 void ExtensionProcessManager::OnExtensionIdle(const std::string& extension_id) { | 431 void ExtensionProcessManager::OnExtensionIdle(const std::string& extension_id) { |
| 431 ExtensionHost* host = GetBackgroundHostForExtension(extension_id); | 432 ExtensionHost* host = GetBackgroundHostForExtension(extension_id); |
| 432 if (host && !HasVisibleViews(extension_id)) | 433 if (host && !HasVisibleViews(extension_id)) { |
| 433 CloseBackgroundHost(host); | 434 Profile* profile = |
| 435 Profile::FromBrowserContext(browsing_instance_->browser_context()); |
| 436 if (!profile->GetExtensionEventRouter()->HasInFlightEvents(extension_id)) |
| 437 CloseBackgroundHost(host); |
| 438 } |
| 434 } | 439 } |
| 435 | 440 |
| 436 bool ExtensionProcessManager::HasVisibleViews(const std::string& extension_id) { | 441 bool ExtensionProcessManager::HasVisibleViews(const std::string& extension_id) { |
| 437 const std::set<RenderViewHost*>& views = | 442 const std::set<RenderViewHost*>& views = |
| 438 GetRenderViewHostsForExtension(extension_id); | 443 GetRenderViewHostsForExtension(extension_id); |
| 439 for (std::set<RenderViewHost*>::const_iterator it = views.begin(); | 444 for (std::set<RenderViewHost*>::const_iterator it = views.begin(); |
| 440 it != views.end(); ++it) { | 445 it != views.end(); ++it) { |
| 441 const RenderViewHost* host = *it; | 446 const RenderViewHost* host = *it; |
| 442 if (host->site_instance()->site().host() == extension_id && | 447 if (host->site_instance()->site().host() == extension_id && |
| 443 host->delegate()->GetRenderViewType() != | 448 host->delegate()->GetRenderViewType() != |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 670 if (service && service->is_ready()) | 675 if (service && service->is_ready()) |
| 671 CreateBackgroundHostsForProfileStartup(this, service->extensions()); | 676 CreateBackgroundHostsForProfileStartup(this, service->extensions()); |
| 672 } | 677 } |
| 673 break; | 678 break; |
| 674 } | 679 } |
| 675 default: | 680 default: |
| 676 ExtensionProcessManager::Observe(type, source, details); | 681 ExtensionProcessManager::Observe(type, source, details); |
| 677 break; | 682 break; |
| 678 } | 683 } |
| 679 } | 684 } |
| OLD | NEW |